List of usage examples for com.vaadin.ui Label getDescription
@Override
public String getDescription()
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/*from w ww. ja va 2s .com*/ 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.ContextView.java
License:Open Source License
private void handleLayoutListeners() { if (contextController.canUpdateContext()) { headerLayout.addListener(new LayoutClickListener() { @Override/*from ww w . j a v a 2s . co m*/ public void layoutClick(final LayoutClickEvent event) { 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.RESOURCE_NAME_CONTEXT)) { reSwapComponents(); oldComponent = event.getClickedComponent(); swapComponent = editName(child.getValue().toString() .replace(ViewConstants.RESOURCE_NAME_CONTEXT, ""), ViewConstants.RESOURCE_NAME_CONTEXT); headerLayout.replaceComponent(oldComponent, swapComponent); } } } else { reSwapComponents(); } } private Component editName(String name, String description) { final TextField txtType = new TextField(); txtType.setInvalidAllowed(false); txtType.setValue(name); txtType.setDescription(description); return txtType; } }); vlLeft.addListener(new LayoutClickListener() { private static final long serialVersionUID = 1L; @Override public void layoutClick(final LayoutClickEvent event) { 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.CONTEXT_TYPE)) { reSwapComponents(); oldComponent = event.getClickedComponent(); swapComponent = editType( child.getValue().toString().replace(ViewConstants.CONTEXT_TYPE, ""), ViewConstants.CONTEXT_TYPE); vlLeft.replaceComponent(oldComponent, swapComponent); } else if ((child.getDescription() == ViewConstants.DESC_STATUS) && (!child.getValue() .equals(resourceProxy.getType().getLabel() + " is closed"))) { reSwapComponents(); oldComponent = event.getClickedComponent(); swapComponent = editStatus(child.getValue().toString() .replace(resourceProxy.getType().getLabel() + " is ", "")); vlLeft.replaceComponent(oldComponent, swapComponent); } } } else { reSwapComponents(); } } private ComboBox cmbStatus; private Component editStatus(final String lockStatus) { cmbStatus = new ComboBox(); cmbStatus.setNullSelectionAllowed(false); if (lockStatus.contains(CREATED)) { cmbStatus.addItem(PublicStatus.OPENED.toString().toLowerCase()); } else { cmbStatus.addItem(PublicStatus.CLOSED.toString().toLowerCase()); } cmbStatus.select(Integer.valueOf(1)); return cmbStatus; } }); } }
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 ww . ja v a 2 s . co 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.OrgUnitView.java
License:Open Source License
private void handleLayoutListeners() { if (orgUnitController.hasAccess()) { vlLeft.addListener(new LayoutClickListener() { private static final long serialVersionUID = 1L; @Override/*from w ww. ja v a 2s . co 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)) { reSwapComponents(); oldComponent = event.getClickedComponent(); swapComponent = editStatus(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(); } } 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(PublicStatus.CREATED.toString())) { cmbStatus.setNullSelectionItemId(PublicStatus.CREATED.toString().toUpperCase()); cmbStatus.addItem(PublicStatus.OPENED.toString().toUpperCase()); } else if (publicStatus.equals(PublicStatus.OPENED.toString())) { cmbStatus.setNullSelectionItemId(PublicStatus.OPENED.toString().toUpperCase()); cmbStatus.addItem(PublicStatus.CLOSED.toString().toUpperCase()); } else if (publicStatus.equals(PublicStatus.CLOSED.toString())) { cmbStatus.setNullSelectionItemId(PublicStatus.WITHDRAWN.toString().toUpperCase()); } else { cmbStatus.addItem(PublicStatus.valueOf(pubStatus)); } cmbStatus.select(1); return cmbStatus; } /** * 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().toString().toUpperCase()); if (((ComboBox) swapComponent).getValue().toString().toUpperCase() .equals(PublicStatus.OPENED.toString())) { orgUnitController.openOU(); } if (((ComboBox) swapComponent).getValue().toString().toUpperCase() .equals(PublicStatus.WITHDRAWN.toString())) { orgUnitController.withdrawOU(); } else if (((ComboBox) swapComponent).getValue().toString().toUpperCase() .equals(PublicStatus.CLOSED.toString())) { orgUnitController.closeOU(); } } vlLeft.replaceComponent(swapComponent, oldComponent); swapComponent = null; } } }); } }
From source file:org.escidoc.browser.ui.view.helpers.ItemPropertiesVH.java
License:Open Source License
private void handleLayoutListeners() { if (controller.canUpdateItem()) { vlPropertiesLeft.addListener(new LayoutClickListener() { @Override//www . ja va 2 s. co 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().equals("com.vaadin.ui.Label")) { final Label child = (Label) event.getChildComponent(); if ((child.getDescription() == ViewConstants.DESC_STATUS2) && (!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 { 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 { updateItem(""); } } 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(Integer.valueOf(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")) { lblStatus.setValue("withdrawn"); } else { cmbStatus.addItem(PublicStatus.valueOf(pubStatus)); } cmbStatus.select(Integer.valueOf(1)); return cmbStatus; } private boolean hasAccessDelResource() { try { return repositories.pdp().forCurrentUser().isAction(ActionIdConstants.DELETE_CONTAINER) .forResource(resourceProxy.getId()).permitted(); } catch (final UnsupportedOperationException e) { mainWindow.showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); return false; } catch (final EscidocClientException e) { mainWindow.showNotification(e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); e.printStackTrace(); return false; } catch (final 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 final 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."); final HorizontalLayout hl = new HorizontalLayout(); final Button close = new Button("Update", new Button.ClickListener() { private static final long serialVersionUID = 1424933077274899865L; // inline click-listener @Override public void buttonClick(final ClickEvent event) { // close the window by removing it from the // parent window updateItem(editor.getValue().toString()); (subwindow.getParent()).removeWindow(subwindow); } }); final Button cancel = new Button("Cancel", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); hl.addComponent(close); hl.addComponent(cancel); subwindow.addComponent(editor); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); } private void updatePublicStatus(final Item item, final String comment) { Preconditions.checkNotNull(item, "Item is null"); Preconditions.checkNotNull(comment, "Comment is null"); // 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(item, repositories.item(), mainWindow); } try { repositories.item().changePublicStatus(item, 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(final Item item, final String comment) { if (!resourceProxy.getLockStatus() .equals(lblLockstatus.getValue().toString().replace(lockStatus, ""))) { String lockStatusTxt = lblLockstatus.getValue().toString().replace(lockStatus, "") .toUpperCase(); try { if (lockStatusTxt.contains("LOCKED")) { repositories.item().lockResource(item, comment); mainWindow.showNotification(new Window.Notification(ViewConstants.LOCKED, Notification.TYPE_TRAY_NOTIFICATION)); } else { repositories.item().unlockResource(item, 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 updateItem(final String comment) { Item item; try { item = repositories.item().findItemById(resourceProxy.getId()); if (resourceProxy.getLockStatus().equals("unlocked")) { updatePublicStatus(item, comment); // retrive the container to get the last // modifiaction date. item = repositories.item().findItemById(resourceProxy.getId()); updateLockStatus(item, comment); } else { updateLockStatus(item, comment); updatePublicStatus(item, comment); } } catch (final EscidocClientException e) { LOG.debug("Infrastructure Exception " + e.getLocalizedMessage()); } } }); } }