List of usage examples for com.vaadin.ui Window Window
public Window(String caption)
From source file:org.escidoc.browser.ui.listeners.RelationsClickListener.java
License:Open Source License
@Override public void buttonClick(final ClickEvent event) { final Window subwindow = new Window("Relations"); subwindow.setWidth("600px"); subwindow.setModal(true);/*ww w . j av a 2 s .c o m*/ String id = ""; if (event.getButton().getCaption().equals("Container Content Relations")) { id = containerProxy.getId(); } else if (event.getButton().getCaption().equals("Item Content Relations")) { id = itemProxy.getId(); } else { throw new RuntimeException("Bug: unexpected event button: " + event.getButton()); } try { content = getRelations(itemOrContainerRepository, id, subwindow); } catch (final EscidocClientException e) { content = new HorizontalLayout(); content.addComponent(new Label("No information available")); } subwindow.addComponent(content); if (subwindow.getParent() != null) { mainWindow.showNotification("Window is already open"); } else { mainWindow.addWindow(subwindow); } }
From source file:org.escidoc.browser.ui.listeners.ResourceDeleteConfirmation.java
License:Open Source License
private void delete(final Container container, final ContainerRepository containerRepository, final Window mainWindow) { final Window subwindow = new Window(ViewConstants.DELETE_RESOURCE_WINDOW_NAME); subwindow.setModal(true);/*from w w w . j a v a 2 s. c o m*/ final Label message = new Label(ViewConstants.QUESTION_DELETE_RESOURCE); subwindow.addComponent(message); @SuppressWarnings("serial") final Button okConfirmed = new Button("Yes", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); try { containerRepository.finalDelete(container); mainWindow.showNotification( new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION)); } catch (final EscidocClientException e) { mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); } } }); @SuppressWarnings("serial") final Button cancel = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); final HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(okConfirmed); hl.addComponent(cancel); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }
From source file:org.escidoc.browser.ui.listeners.ResourceDeleteConfirmation.java
License:Open Source License
private void delete(final Item item, final ItemRepository itemRepository, final Window mainWindow) throws EscidocClientException { final Window subwindow = new Window(ViewConstants.DELETE_RESOURCE_WINDOW_NAME); subwindow.setModal(true);// w w w. j ava 2s .c o m Label message = new Label(ViewConstants.QUESTION_DELETE_RESOURCE); subwindow.addComponent(message); @SuppressWarnings("serial") Button okConfirmed = new Button("Yes", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); try { itemRepository.finalDelete(item); mainWindow.showNotification( new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION)); } catch (EscidocClientException e) { mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); } } }); @SuppressWarnings("serial") Button cancel = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(okConfirmed); hl.addComponent(cancel); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }
From source file:org.escidoc.browser.ui.listeners.VersionHistoryClickListener.java
License:Open Source License
@Override public void buttonClick(final ClickEvent event) { final Window subwindow = new Window("Version History"); subwindow.setWidth("600px"); subwindow.setModal(true);//from w w w . j a va 2 s . c o m // if (event.getButton().getCaption().equals("Container Version History") // || event.getButton().getCaption().equals(" Has previous version")) { // id = containerProxy.getId(); // } // else if (event.getButton().getCaption().equals("Item Version History") // || event.getButton().getCaption().equals(" Has previous versions")) { // id = itemProxy.getId(); // } // else { // throw new RuntimeException("Bug: unexpected event button: " + event.getButton()); // } try { wndContent = getVersionHistory(repository, id); } catch (final EscidocClientException e) { wndContent = "No information ?" + e.getMessage(); } final Label msgWindow = new Label(wndContent, Label.CONTENT_RAW); subwindow.addComponent(msgWindow); if (subwindow.getParent() != null) { mainWindow.showNotification("Window is already open"); } else { mainWindow.addWindow(subwindow); } }
From source file:org.escidoc.browser.ui.maincontent.ContainerMetadataRecordsView.java
License:Open Source License
@SuppressWarnings("serial") private Panel lblAddtionalResources() { final Panel pnl = new Panel(); pnl.setSizeFull();//from ww w. j a v a2 s . com VerticalLayout hl = new VerticalLayout(); hl.setSizeFull(); final Button btnVersionHistoryContainer = new Button("Container Version History", new VersionHistoryClickListener(resourceProxy, mainWindow, repositories)); btnVersionHistoryContainer.setStyleName(BaseTheme.BUTTON_LINK); btnVersionHistoryContainer.setDescription("Show Version history in a Pop-up"); final CssLayout cssLayout = new CssLayout(); buildPanelHeader(cssLayout, "Additional Resources"); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); final Button addResourceButton = new Button(); addResourceButton.setStyleName(BaseTheme.BUTTON_LINK); addResourceButton.addStyleName("floatright paddingtop3"); addResourceButton.setWidth("20px"); addResourceButton.setIcon(ICON); addResourceButton.addListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Window subwindow = new Window("A modal subwindow"); subwindow.setModal(true); subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); subwindow.addComponent(new Label("Not yet implemented")); Button close = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); router.getMainWindow().addWindow(subwindow); } }); cssLayout.addComponent(addResourceButton); hl.addComponent(cssLayout); hl.addComponent(btnVersionHistoryContainer); pnl.setContent(hl); return pnl; }
From source file:org.escidoc.browser.ui.maincontent.ContainerView.java
License:Open Source License
private void handleLayoutListeners() { if (hasAccess()) { vlPropertiesLeft.addListener(new LayoutClickListener() { private static final long serialVersionUID = 1L; @Override/*ww w. j av a 2 s .c o m*/ public void layoutClick(final LayoutClickEvent event) { // Get the child component which was clicked if (event.getChildComponent() != null) { // Is Label? if (event.getChildComponent().getClass().getCanonicalName() == "com.vaadin.ui.Label") { final Label child = (Label) event.getChildComponent(); if ((child.getDescription() == ViewConstants.DESC_STATUS) && (!lblStatus.getValue().equals(status + "withdrawn"))) { reSwapComponents(); oldComponent = event.getClickedComponent(); swapComponent = editStatus(child.getValue().toString().replace(status, "")); vlPropertiesLeft.replaceComponent(oldComponent, swapComponent); } else if (child.getDescription() == ViewConstants.DESC_LOCKSTATUS) { reSwapComponents(); oldComponent = event.getClickedComponent(); swapComponent = editLockStatus(child.getValue().toString().replace(status, "")); vlPropertiesLeft.replaceComponent(oldComponent, swapComponent); } } // else { // // getWindow().showNotification( // // "The click was over a " + // event.getChildComponent().getClass().getCanonicalName() // // + event.getChildComponent().getStyleName()); // } } else { reSwapComponents(); } } /** * Switch the component back to the original component (Label) after inline editing */ private void reSwapComponents() { if (swapComponent != null) { if (swapComponent instanceof Label) { ((Label) oldComponent).setValue(((TextArea) swapComponent).getValue()); } else if ((swapComponent instanceof ComboBox) && ((ComboBox) swapComponent).getValue() != null) { ((Label) oldComponent).setValue(status + ((ComboBox) swapComponent).getValue()); // Because there should be no comment-window on // Delete Operation if (!(((ComboBox) swapComponent).getValue().equals("delete"))) { addCommentWindow(); } else { updateContainer(""); } } vlPropertiesLeft.replaceComponent(swapComponent, oldComponent); swapComponent = null; } } private Component editLockStatus(final String lockStatus) { final ComboBox cmbLockStatus = new ComboBox(); cmbLockStatus.setNullSelectionAllowed(false); if (lockStatus.contains("unlocked")) { cmbLockStatus.addItem(LockStatus.LOCKED.toString().toLowerCase()); } else { cmbLockStatus.addItem(LockStatus.UNLOCKED.toString().toLowerCase()); } cmbLockStatus.select(1); return cmbLockStatus; } private Component editStatus(final String publicStatus) { final ComboBox cmbStatus = new ComboBox(); cmbStatus.setInvalidAllowed(false); cmbStatus.setNullSelectionAllowed(false); final String pubStatus = publicStatus.toUpperCase(); if (publicStatus.equals("pending")) { cmbStatus.addItem(PublicStatus.PENDING.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.SUBMITTED.toString().toLowerCase()); cmbStatus.setNullSelectionItemId(PublicStatus.PENDING.toString().toLowerCase()); if (hasAccessDelResource()) { cmbStatus.addItem("delete"); } } else if (publicStatus.equals("submitted")) { cmbStatus.setNullSelectionItemId(PublicStatus.SUBMITTED.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.SUBMITTED.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.IN_REVISION.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.RELEASED.toString().toLowerCase()); } else if (publicStatus.equals("in_revision")) { cmbStatus.setNullSelectionItemId(PublicStatus.IN_REVISION.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.IN_REVISION.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.SUBMITTED.toString().toLowerCase()); } else if (publicStatus.equals("released")) { cmbStatus.setNullSelectionItemId(PublicStatus.RELEASED.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.RELEASED.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.WITHDRAWN.toString().toLowerCase()); } else if (publicStatus.equals("withdrawn")) { // do nothing } else { cmbStatus.addItem(PublicStatus.valueOf(pubStatus)); } cmbStatus.select(1); return cmbStatus; } private boolean hasAccessDelResource() { try { return repositories.pdp().forCurrentUser().isAction(ActionIdConstants.DELETE_CONTAINER) .forResource(resourceProxy.getId()).permitted(); } catch (UnsupportedOperationException e) { mainWindow.showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); return false; } catch (EscidocClientException e) { mainWindow.showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); return false; } catch (URISyntaxException e) { mainWindow.showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); return false; } } public void addCommentWindow() { subwindow = new Window(ViewConstants.SUBWINDOW_EDIT); subwindow.setModal(true); // Configure the windws layout; by default a VerticalLayout VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeUndefined(); final TextArea editor = new TextArea("Your Comment"); editor.setRequired(true); editor.setRequiredError("The Field may not be empty."); HorizontalLayout hl = new HorizontalLayout(); Button close = new Button("Update", new Button.ClickListener() { // inline click-listener @Override public void buttonClick(ClickEvent event) { // close the window by removing it from the // parent window updateContainer(editor.getValue().toString()); (subwindow.getParent()).removeWindow(subwindow); } }); Button cancel = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); hl.addComponent(close); hl.addComponent(cancel); subwindow.addComponent(editor); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); } private void updatePublicStatus(Container container, String comment) { // Update PublicStatus if there is a change if (!resourceProxy.getVersionStatus() .equals(lblCurrentVersionStatus.getValue().toString().replace(status, ""))) { String publicStatusTxt = lblCurrentVersionStatus.getValue().toString().replace(status, "") .toUpperCase(); if (publicStatusTxt.equals("DELETE")) { new ResourceDeleteConfirmation(container, repositories.container(), mainWindow); } try { repositories.container().changePublicStatus(container, lblCurrentVersionStatus.getValue().toString().replace(status, "").toUpperCase(), comment); if (publicStatusTxt.equals("SUBMITTED")) { mainWindow.showNotification(new Window.Notification(ViewConstants.SUBMITTED, Notification.TYPE_TRAY_NOTIFICATION)); } else if (publicStatusTxt.equals("IN_REVISION")) { mainWindow.showNotification(new Window.Notification(ViewConstants.IN_REVISION, Notification.TYPE_TRAY_NOTIFICATION)); } else if (publicStatusTxt.equals("RELEASED")) { mainWindow.showNotification(new Window.Notification(ViewConstants.RELEASED, Notification.TYPE_TRAY_NOTIFICATION)); } else if (publicStatusTxt.equals("WITHDRAWN")) { mainWindow.showNotification(new Window.Notification(ViewConstants.WITHDRAWN, Notification.TYPE_TRAY_NOTIFICATION)); } } catch (EscidocClientException e) { mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); } } } private void updateLockStatus(Container container, String comment) { // Update LockStatus if there is a change if (!resourceProxy.getLockStatus() .equals(lblLockstatus.getValue().toString().replace(lockStatus, ""))) { String lockStatusTxt = lblLockstatus.getValue().toString().replace(lockStatus, "") .toUpperCase(); try { if (lockStatusTxt.contains("LOCKED")) { repositories.container().unlockResource(container, comment); mainWindow.showNotification(new Window.Notification(ViewConstants.LOCKED, Notification.TYPE_TRAY_NOTIFICATION)); } else { repositories.container().lockResource(container, comment); mainWindow.showNotification(new Window.Notification(ViewConstants.UNLOCKED, Notification.TYPE_TRAY_NOTIFICATION)); } } catch (EscidocClientException e) { mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); } } } private void updateContainer(String comment) { LOG.debug("Called the updateContainer"); Container container; try { container = repositories.container().findContainerById(resourceProxy.getId()); if (resourceProxy.getLockStatus().contains("unlocked")) { updatePublicStatus(container, comment); // retrive the container to get the last // modifiaction date. container = repositories.container().findContainerById(resourceProxy.getId()); updateLockStatus(container, comment); } else { updateLockStatus(container, comment); updatePublicStatus(container, comment); } } catch (final EscidocClientException e) { LOG.debug("Infrastructure Exception " + e.getLocalizedMessage()); } } }); } }
From source file:org.escidoc.browser.ui.maincontent.ContextRightPanel.java
License:Open Source License
@SuppressWarnings("serial") private Panel buildOrganizationUnit() { final Panel pnlOrgUnit = new Panel(); pnlOrgUnit.setSizeFull();/*www . j av a 2 s.c o m*/ VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); final CssLayout cssLayout = new CssLayout(); buildPanelHeader(cssLayout, ViewConstants.ORGANIZATIONAL_UNIT); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); if (contextController.canAddOUs()) { final Button addResourceButton = new Button(); addResourceButton.setStyleName(BaseTheme.BUTTON_LINK); addResourceButton.addStyleName("floatright paddingtop3"); addResourceButton.setWidth("20px"); addResourceButton.setIcon(ICON); addResourceButton.addListener(new ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) { final Window subwindow = new Window("A modal subwindow"); subwindow.setModal(true); subwindow.setWidth("650px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); try { subwindow.addComponent(new AddOrgUnitstoContext(router, resourceProxy, contextController, resourceProxy.getOrganizationalUnit())); } catch (EscidocClientException e) { contextController.showError(e); } Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") ClickEvent event) { subwindow.getParent().removeWindow(subwindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); router.getMainWindow().addWindow(subwindow); } }); cssLayout.addComponent(addResourceButton); } vl.addComponent(cssLayout); OrganizationalUnitsTableVH orgUnitTable = new OrganizationalUnitsTableVH(contextController, resourceProxy.getOrganizationalUnit(), router, resourceProxy); orgUnitTable.buildTable(); vl.addComponent(orgUnitTable); vl.setComponentAlignment(orgUnitTable, Alignment.TOP_LEFT); vl.setExpandRatio(orgUnitTable, 9f); pnlOrgUnit.setContent(vl); return pnlOrgUnit; }
From source file:org.escidoc.browser.ui.maincontent.ContextView.java
License:Open Source License
/** * Called in the reSwapComponents()//from w ww. j av a 2 s. co m * * @return String */ public void addCommentWindow(final String status) { final Window subwindow = new Window(ViewConstants.SUBWINDOW_EDIT); subwindow.setModal(true); // Configure the windws layout; by default a VerticalLayout VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeUndefined(); final TextArea editor = new TextArea("Your Comment"); editor.setRequired(true); editor.setRequiredError("The Field may not be empty."); HorizontalLayout hl = new HorizontalLayout(); Button close = new Button("Update", new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") com.vaadin.ui.Button.ClickEvent event) { // close the window by removing it from the parent window String comment = editor.getValue().toString(); try { contextController.updatePublicStatus(status, resourceProxy.getId(), comment); mainWindow.showNotification("Context Status updated successfully", Notification.TYPE_TRAY_NOTIFICATION); } catch (EscidocClientException e) { mainWindow.showNotification( "Could not update Context Type, an error occurred" + e.getLocalizedMessage(), Notification.TYPE_ERROR_MESSAGE); } (subwindow.getParent()).removeWindow(subwindow); } }); Button cancel = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") com.vaadin.ui.Button.ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); hl.addComponent(close); hl.addComponent(cancel); subwindow.addComponent(editor); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }
From source file:org.escidoc.browser.ui.maincontent.FolderView.java
License:Open Source License
private void handleLayoutListeners() { if (folderController.hasAccess()) { vlLeft.addListener(new LayoutClickListener() { private static final long serialVersionUID = 1L; private Window subwindow; @Override/* w w w .j a va2 s . c o m*/ public void layoutClick(final LayoutClickEvent event) { // Get the child component which was clicked if (event.getChildComponent() != null) { // Is Label? if (event.getChildComponent().getClass().getCanonicalName() == "com.vaadin.ui.Label") { final Label child = (Label) event.getChildComponent(); if ((child.getDescription() == ViewConstants.DESC_STATUS) && (!lblStatus.getValue().equals(status + "withdrawn"))) { reSwapComponents(); oldComponent = event.getClickedComponent(); swapComponent = editStatus(child.getValue().toString().replace(status, "")); vlLeft.replaceComponent(oldComponent, swapComponent); } else if (child.getDescription() == ViewConstants.DESC_LOCKSTATUS) { reSwapComponents(); oldComponent = event.getClickedComponent(); swapComponent = editLockStatus(child.getValue().toString().replace(status, "")); vlLeft.replaceComponent(oldComponent, swapComponent); } } // else { // // getWindow().showNotification( // // "The click was over a " + // event.getChildComponent().getClass().getCanonicalName() // // + event.getChildComponent().getStyleName()); // } } else { reSwapComponents(); } } /** * Switch the component back to the original component (Label) after inline editing */ private void reSwapComponents() { if (swapComponent != null) { if (swapComponent instanceof Label) { ((Label) oldComponent).setValue(((TextArea) swapComponent).getValue()); } else if ((swapComponent instanceof ComboBox) && ((ComboBox) swapComponent).getValue() != null) { ((Label) oldComponent).setValue(status + ((ComboBox) swapComponent).getValue()); // Because there should be no comment-window on // Delete Operation if (!(((ComboBox) swapComponent).getValue().equals("delete"))) { addCommentWindow(); } else { updateContainer(""); } } vlLeft.replaceComponent(swapComponent, oldComponent); swapComponent = null; } } private Component editLockStatus(final String lockStatus) { final ComboBox cmbLockStatus = new ComboBox(); cmbLockStatus.setNullSelectionAllowed(false); if (lockStatus.contains("unlocked")) { cmbLockStatus.addItem(LockStatus.LOCKED.toString().toLowerCase()); } else { cmbLockStatus.addItem(LockStatus.UNLOCKED.toString().toLowerCase()); } cmbLockStatus.select(1); return cmbLockStatus; } private Component editStatus(final String publicStatus) { final ComboBox cmbStatus = new ComboBox(); cmbStatus.setInvalidAllowed(false); cmbStatus.setNullSelectionAllowed(false); final String pubStatus = publicStatus.toUpperCase(); if (publicStatus.equals("pending")) { cmbStatus.addItem(PublicStatus.PENDING.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.SUBMITTED.toString().toLowerCase()); cmbStatus.setNullSelectionItemId(PublicStatus.PENDING.toString().toLowerCase()); if (hasAccessDelResource()) { cmbStatus.addItem("delete"); } } else if (publicStatus.equals("submitted")) { cmbStatus.setNullSelectionItemId(PublicStatus.SUBMITTED.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.SUBMITTED.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.IN_REVISION.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.RELEASED.toString().toLowerCase()); } else if (publicStatus.equals("in_revision")) { cmbStatus.setNullSelectionItemId(PublicStatus.IN_REVISION.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.IN_REVISION.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.SUBMITTED.toString().toLowerCase()); } else if (publicStatus.equals("released")) { cmbStatus.setNullSelectionItemId(PublicStatus.RELEASED.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.RELEASED.toString().toLowerCase()); cmbStatus.addItem(PublicStatus.WITHDRAWN.toString().toLowerCase()); } else if (publicStatus.equals("withdrawn")) { // do nothing } else { cmbStatus.addItem(PublicStatus.valueOf(pubStatus)); } cmbStatus.select(1); return cmbStatus; } private boolean hasAccessDelResource() { try { return repositories.pdp().forCurrentUser().isAction(ActionIdConstants.DELETE_CONTAINER) .forResource(resourceProxy.getId()).permitted(); } catch (UnsupportedOperationException e) { router.getMainWindow().showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); return false; } catch (EscidocClientException e) { router.getMainWindow().showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); return false; } catch (URISyntaxException e) { router.getMainWindow().showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); return false; } } public void addCommentWindow() { subwindow = new Window(ViewConstants.SUBWINDOW_EDIT); subwindow.setModal(true); // Configure the windws layout; by default a VerticalLayout VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeUndefined(); final TextArea editor = new TextArea("Your Comment"); editor.setRequired(true); editor.setRequiredError("The Field may not be empty."); HorizontalLayout hl = new HorizontalLayout(); Button close = new Button("Update", new Button.ClickListener() { // inline click-listener @Override public void buttonClick(ClickEvent event) { // close the window by removing it from the // parent window updateContainer(editor.getValue().toString()); (subwindow.getParent()).removeWindow(subwindow); } }); Button cancel = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); hl.addComponent(close); hl.addComponent(cancel); subwindow.addComponent(editor); subwindow.addComponent(hl); router.getMainWindow().addWindow(subwindow); } private void updatePublicStatus(Container container, String comment) { // Update PublicStatus if there is a change if (!resourceProxy.getVersionStatus() .equals(lblCurrentVersionStatus.getValue().toString().replace(status, ""))) { String publicStatusTxt = lblCurrentVersionStatus.getValue().toString().replace(status, "") .toUpperCase(); if (publicStatusTxt.equals("DELETE")) { new ResourceDeleteConfirmation(container, repositories.container(), router.getMainWindow()); } try { repositories.container().changePublicStatus(container, lblCurrentVersionStatus.getValue().toString().replace(status, "").toUpperCase(), comment); if (publicStatusTxt.equals("SUBMITTED")) { router.getMainWindow().showNotification(new Window.Notification( ViewConstants.SUBMITTED, Notification.TYPE_TRAY_NOTIFICATION)); } else if (publicStatusTxt.equals("IN_REVISION")) { router.getMainWindow().showNotification(new Window.Notification( ViewConstants.IN_REVISION, Notification.TYPE_TRAY_NOTIFICATION)); } else if (publicStatusTxt.equals("RELEASED")) { router.getMainWindow().showNotification(new Window.Notification( ViewConstants.RELEASED, Notification.TYPE_TRAY_NOTIFICATION)); } else if (publicStatusTxt.equals("WITHDRAWN")) { router.getMainWindow().showNotification(new Window.Notification( ViewConstants.WITHDRAWN, Notification.TYPE_TRAY_NOTIFICATION)); } } catch (EscidocClientException e) { router.getMainWindow().showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); } } } private void updateContainer(String comment) { LOG.debug("Called the updateContainer"); Container container; try { container = repositories.container().findContainerById(resourceProxy.getId()); if (resourceProxy.getLockStatus().contains("unlocked")) { container = repositories.container().findContainerById(resourceProxy.getId()); updatePublicStatus(container, comment); } else { updatePublicStatus(container, comment); } } catch (final EscidocClientException e) { LOG.debug("Infrastructure Exception " + e.getLocalizedMessage()); } } }); } }
From source file:org.escidoc.browser.ui.maincontent.ItemContent.java
License:Open Source License
private void initView() { final CssLayout cssLayout = new CssLayout(); cssLayout.setHeight("20px"); buildPanelHeader(cssLayout, ViewConstants.COMPONENTS); ThemeResource ICON = new ThemeResource("images/assets/plus.png"); if (true) {/*from w w w .j a va 2 s . c o m*/ final Button btnAddNew = new Button(); btnAddNew.addListener(new Button.ClickListener() { @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { Window modalWindow = new Window("Select a file to add."); modalWindow.setWidth("25%"); modalWindow.setHeight("20%"); modalWindow.setModal(true); modalWindow.addComponent(new ComponentUploadView(repositories, controller, itemProxy, ItemContent.this, mainWindow)); mainWindow.addWindow(modalWindow); } }); btnAddNew.setStyleName(BaseTheme.BUTTON_LINK); btnAddNew.addStyleName("floatright paddingtop3"); btnAddNew.setWidth("20px"); btnAddNew.setIcon(ICON); cssLayout.addComponent(btnAddNew); } verticalLayout.addComponent(cssLayout); wrap(verticalLayout); if (controller.hasComponents()) { verticalLayout.addComponent(buildTable()); } else { final Label lblNoComponents = new Label( "No components in this Item. You can drag n'drop some file from your computer to this box to add new components!"); lblNoComponents.setWidth("90%"); lblNoComponents.setStyleName("skybluetext"); verticalLayout.addComponent(lblNoComponents); } }