List of usage examples for com.vaadin.ui Window Window
public Window(String caption)
From source file:org.escidoc.browser.ui.view.helpers.DeleteContainerShowLogsHelper.java
License:Open Source License
public void showWindow() { final Window subwindow = new Window("Change Category Type"); subwindow.setModal(true);/*from w w w . j a va 2 s.c om*/ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); Table tblDeleted = new Table("Successfully deleted resources"); tblDeleted.setWidth("90%"); tblDeleted.addContainerProperty("Id", String.class, null); tblDeleted.addContainerProperty("Resource ", String.class, null); for (Map.Entry<String, String> entry : listDeleted.entrySet()) { tblDeleted.addItem(new Object[] { entry.getKey(), entry.getValue() }, entry.getKey()); } layout.addComponent(tblDeleted); Table tblNotDeleted = new Table("Resources that could not be deleted"); tblNotDeleted.setWidth("90%"); tblNotDeleted.addContainerProperty("Resource Id", String.class, null); tblNotDeleted.addContainerProperty("Resource & Error", String.class, null); for (Map.Entry<String, String> entry : listNotDeleted.entrySet()) { tblNotDeleted.addItem(new Object[] { entry.getKey(), entry.getValue() }, entry.getKey()); } layout.addComponent(tblNotDeleted); Button close = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); layout.addComponent(close); subwindow.setWidth("600px"); subwindow.addComponent(layout); router.getMainWindow().addWindow(subwindow); }
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//from w w w.ja va 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().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()); } } }); } }
From source file:org.escidoc.browser.ui.view.helpers.OrganizationalUnitsTableVH.java
License:Open Source License
@Override protected void addActionLists() { // if (contextController.canUpdateContext()) { table.addActionHandler(new Action.Handler() { @Override//from w w w . j a v a2 s .co m public Action[] getActions(Object target, Object sender) { return ACTIONS_LIST; } @Override public void handleAction(Action action, Object sender, Object target) { if ((ACTION_DELETE == action) && (target != null)) { confirmActionWindow(target); } else { openViewAddRemoveOUs(); } } private void openViewAddRemoveOUs() { 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, controller, resourceProxy.getOrganizationalUnit())); } catch (EscidocClientException e) { controller.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); } }); // } }
From source file:org.escidoc.browser.ui.view.helpers.OUParentTableVH.java
License:Open Source License
@Override protected void addActionLists() { table.addActionHandler(new Action.Handler() { @Override/*from w ww . java 2 s .c om*/ public Action[] getActions(Object target, Object sender) { return ACTIONS_LIST; } @Override public void handleAction(Action action, Object sender, Object target) { if ((ACTION_DELETE == action) && (target != null)) { confirmActionWindow(target); } else { openViewAddRemoveOUs(); } } private void openViewAddRemoveOUs() { 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 OrgUnitParentEditView(orgUnitProxy, orgUnitProxy.getParentList(), router, controller)); } catch (EscidocClientException e) { controller.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); } }); }
From source file:org.escidoc.browser.ui.view.helpers.TableContainerVH.java
License:Open Source License
public void confirmActionWindow(final Object target) { final Window subwindow = new Window(ViewConstants.DELETE_RESOURCE_WINDOW_NAME); subwindow.setModal(true);/* w ww .java 2s .co m*/ subwindow.setWidth("500px"); VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); Label message = new Label(ViewConstants.QUESTION_DELETE_RESOURCE); subwindow.addComponent(message); Button okBtn = new Button("Yes Remove", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { removeAction(target); table.refreshRowCache(); (subwindow.getParent()).removeWindow(subwindow); } }); Button cancelBtn = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(okBtn); hl.addComponent(cancelBtn); layout.addComponent(hl); this.getApplication().getMainWindow().addWindow(subwindow); }
From source file:org.esn.esobase.view.MainView.java
private void openSearchInCatalogs() { if (searchInCatalogsTabContent == null) { searchInCatalogsTabContent = new SearchInCatalogsTab(service, dictionaryService); }/* w ww. j a v a 2 s .com*/ Window subWindow = new Window(searchInCatalogsMenuItem.getText()); subWindow.setModal(true); subWindow.center(); this.getUI().addWindow(subWindow); subWindow.setResizable(false); subWindow.setSizeFull(); subWindow.setContent(searchInCatalogsTabContent); searchInCatalogsTabContent.setWidth(); }
From source file:org.esn.esobase.view.MainView.java
private void openSearchInRaw() { if (searchInRawStringsTabContent == null) { searchInRawStringsTabContent = new SearchInRawStringsTab(service); }//www . jav a2 s . c o m Window subWindow = new Window(searchInRawStringsMenuItem.getText()); subWindow.setModal(true); subWindow.center(); this.getUI().addWindow(subWindow); subWindow.setResizable(false); subWindow.setSizeFull(); subWindow.setContent(searchInRawStringsTabContent); searchInRawStringsTabContent.setWidth(); }
From source file:org.exampledriven.vaadinexample.MyVaadinApplication.java
License:Apache License
@Override public void init() { window = new Window("My Vaadin Application"); MainForm mainForm = new MainForm(); window.setContent(mainForm);/*from www. jav a 2 s . c om*/ mainForm.setSizeFull(); setMainWindow(window); }
From source file:org.fossa.rolp.RolpApplication.java
License:Open Source License
@Override public void init() { setMainWindow(new Window("Rolp")); setTheme("rolp"); String appSeverity = Config.getAppSeverity(); if (appSeverity.equals("prod")) { authorizer.checkAuthorization(); } else if (appSeverity.equals("demo")) { demoWelcome();//from w w w .j a v a 2 s .com } }
From source file:org.geant.sat.ui.EntityListViewer.java
License:BSD License
/** * Creates a subwindow for editing survey details of entity. * /*from w ww . j a va 2 s. c o m*/ * @param details * entity */ private void editSurveys(EntityDetails details) { Window subWindowNewEntity = new Window(getString("lang.window.newentity.editsids.title")); subWindowNewEntity.setModal(true); VerticalLayout subContent = new VerticalLayout(); TwinColSelect<String> selectSids = new TwinColSelect<>(getString("lang.window.newentity.editsids.sids")); selectSids.setData(details); ListAllSurveysResponse resp = getMainUI().getSatApiClient().getSurveys(); if (!verifySuccess(resp)) { return; } List<SurveyDetails> surveyDetails = resp.getSurveys(); // parse active sids List<String> activeSurveyDetails = new ArrayList<String>(); for (SurveyDetails surveyDetail : surveyDetails) { if (surveyDetail.getActive()) { activeSurveyDetails.add(surveyDetail.getSid()); } } selectSids.setItems(activeSurveyDetails); // set current sids as selection selectSids.updateSelection(details.getSids(), new HashSet<String>()); subContent.addComponent(selectSids, 0); Button editButton = new Button(getString("lang.window.newentity.buttonModify")); subContent.addComponent(editButton, 1); editButton.addClickListener(this::editedSurveys); Button cancelButton = new Button(getString("lang.window.newentity.buttonCancel")); subContent.addComponent(cancelButton, 2); cancelButton.addClickListener(this::canceledEditSurveys); subWindowNewEntity.setContent(subContent); getMainUI().addWindow(subWindowNewEntity); }