List of usage examples for com.vaadin.ui Window close
public void close()
From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java
License:Apache License
private void createTestCaseMenu(ContextMenu menu) { MenuItem create = menu.addItem(TRANSLATOR.translate("create.step"), VaadinIcons.PLUS, (MenuItem selectedItem) -> { TestCase tc = (TestCase) tree.getValue(); Step s = new Step(); s.setStepSequence(tc.getStepList().size() + 1); s.setTestCase(tc);/* www . j a v a 2 s. com*/ displayStep(s, true); }); create.setEnabled(checkRight("requirement.modify")); MenuItem edit = menu.addItem(TRANSLATOR.translate("edit.test.case"), EDIT_ICON, (MenuItem selectedItem) -> { displayTestCase((TestCase) tree.getValue(), true); }); edit.setEnabled(checkRight("testcase.modify")); MenuItem importSteps = menu.addItem(TRANSLATOR.translate("import.step"), IMPORT_ICON, (MenuItem selectedItem) -> { // Create a sub-window and set the content Window subWindow = new VMWindow(TRANSLATOR.translate("import.test.case.step")); VerticalLayout subContent = new VerticalLayout(); subWindow.setContent(subContent); //Add a checkbox to know if file has headers or not CheckBox cb = new CheckBox(TRANSLATOR.translate("file.has.header")); FileUploader receiver = new FileUploader(); Upload upload = new Upload(TRANSLATOR.translate("upload.excel"), receiver); upload.addSucceededListener((Upload.SucceededEvent event1) -> { try { subWindow.close(); //TODO: Display the excel file (partially), map columns and import //Process the file TestCase tc = (TestCase) tree.getValue(); StepImporter importer = new StepImporter(receiver.getFile(), tc); importer.importFile(cb.getValue()); importer.processImport(); SortedMap<Integer, Step> map = new TreeMap<>(); tc.getStepList().forEach((s) -> { map.put(s.getStepSequence(), s); }); //Now update the sequence numbers int count = 0; for (Entry<Integer, Step> entry : map.entrySet()) { entry.getValue().setStepSequence(++count); try { new StepJpaController(DataBaseManager.getEntityManagerFactory()) .edit(entry.getValue()); } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); } } buildProjectTree(new TestCaseServer(tc.getTestCasePK()).getEntity()); updateScreen(); } catch (TestCaseImportException ex) { LOG.log(Level.SEVERE, TRANSLATOR.translate("import.error"), ex); Notification.show(TRANSLATOR.translate("import.unsuccessful"), Notification.Type.ERROR_MESSAGE); } }); upload.addFailedListener((Upload.FailedEvent event1) -> { LOG.log(Level.SEVERE, "Upload unsuccessful!\n{0}", event1.getReason()); Notification.show(TRANSLATOR.translate("upload.unsuccessful"), Notification.Type.ERROR_MESSAGE); subWindow.close(); }); subContent.addComponent(cb); subContent.addComponent(upload); // Open it in the UI addWindow(subWindow); }); importSteps.setEnabled(checkRight("requirement.modify")); MenuItem export = menu.addItem(TRANSLATOR.translate("general.export"), VaadinIcons.DOWNLOAD, (MenuItem selectedItem) -> { TestCase tc = (TestCase) tree.getValue(); UI.getCurrent().addWindow(TestCaseExporter.getTestCaseExporter(Arrays.asList(tc))); }); export.setEnabled(checkRight("testcase.view")); addExecutionDashboard(menu); }
From source file:org.azrul.langkuik.framework.customtype.attachment.AttachmentCustomTypeUICreator.java
@Override public Component createUIForForm(final C currentBean, final Class<? extends CustomType> attachmentClass, final String pojoFieldName, final BeanView beanView, final DataAccessObject<C> conatainerClassDao, final DataAccessObject<? extends CustomType> customTypeDao, final RelationManagerFactory relationManagerFactory, final Configuration config, final ComponentState componentState, final Window window) { final FormLayout form = new FormLayout(); final DataAccessObject<AttachmentCustomType> attachmentDao = ((DataAccessObject<AttachmentCustomType>) customTypeDao); final Collection<AttachmentCustomType> attachments = attachmentDao.find(currentBean, pojoFieldName, null, true, 0, Integer.parseInt(config.get("uploadCountLimit"))); final WebEntityItemContainer attachmentIC = new WebEntityItemContainer(attachmentClass); if (!attachments.isEmpty()) { attachmentIC.addAll(attachments); }/*w w w. j a va 2 s . c o m*/ final ListSelect attachmentList = new ListSelect("", attachmentIC); createAtachmentList(attachmentList, attachments, config, beanView, form); final String relativePath = currentBean.getClass().getCanonicalName() + File.separator + conatainerClassDao.getIdentifierValue(currentBean); final String fullPath = config.get("attachmentRepository") + File.separator + relativePath; MyUploadHandler<C> uploadFinishHandler = new MyUploadHandler<>(currentBean, Integer.parseInt(config.get("uploadCountLimit").trim()), pojoFieldName, fullPath, relativePath, attachmentList, attachmentIC, customTypeDao, attachmentClass, relationManagerFactory); //File upload/download/delete buttons HorizontalLayout attachmentButtons = new HorizontalLayout(); attachmentButtons.setSpacing(true); UploadStateWindow uploadStateWindow = new UploadStateWindow(); MultiFileUpload fileUpload = new MultiFileUpload(uploadFinishHandler, uploadStateWindow); uploadFinishHandler.setFileUpload(fileUpload); fileUpload.getSmartUpload().setEnabled(true); fileUpload.getSmartUpload().setMaxFileSize(Integer.parseInt(config.get("uploadSizeLimit").trim())); fileUpload.getSmartUpload().setUploadButtonCaptions("Upload files", "Upload files"); fileUpload.getSmartUpload().setId("Upload files"); fileUpload.setId("Upload files2"); Button deleteAttachmentBtn = new Button("Delete file", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList .getValue(); if (!attachments.isEmpty()) { customTypeDao.unlinkAndDelete(attachments, currentBean, pojoFieldName, relationManagerFactory.create(currentBean.getClass(), attachmentClass)); Collection<AttachmentCustomType> a = attachmentDao.find(currentBean, pojoFieldName, null, true, 0, Integer.parseInt(config.get("uploadCountLimit"))); attachmentIC.removeAllItems(); attachmentIC.addAll(a); attachmentIC.refreshItems(); } } }); deleteAttachmentBtn.setId(deleteAttachmentBtn.getCaption()); Button downloadAttachmentBtn = new Button("Download file", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList .getValue(); if (!attachments.isEmpty()) { AttachmentCustomType attachment = attachments.iterator().next(); final String fullPath = config.get("attachmentRepository") + File.separator + attachment.getRelativeLocation() + File.separator + attachment.getFileName(); FileResource res = new FileResource(new File(fullPath)); beanView.setViewResource("DOWNLOAD", res); ResourceReference rr = ResourceReference.create(res, beanView, "DOWNLOAD"); Page.getCurrent().open(rr.getURL(), null); } } }); downloadAttachmentBtn.setId(downloadAttachmentBtn.getCaption()); Button closeWindowBtn = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { window.close(); } }); closeWindowBtn.setId(closeWindowBtn.getCaption()); if (componentState.equals(ComponentState.EDITABLE)) { attachmentButtons.addComponent(fileUpload); attachmentButtons.addComponent(deleteAttachmentBtn); } if (componentState.equals(ComponentState.EDITABLE) || componentState.equals(ComponentState.READ_ONLY)) { attachmentButtons.addComponent(downloadAttachmentBtn); } attachmentButtons.addComponent(closeWindowBtn); form.addComponent(attachmentButtons); form.setMargin(true); //beanView.addComponent(form); return form; }
From source file:org.azrul.langkuik.framework.webgui.EditorTableView.java
public void enter(final ViewChangeListener.ViewChangeEvent vcevent) { setCurrentView(vcevent.getViewName()); this.removeAllComponents(); //get user roles UserDetails userDetails = null;//from w w w . j a v a2 s .c o m Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (!(auth instanceof AnonymousAuthenticationToken)) { userDetails = (UserDetails) auth.getPrincipal(); } else { return; } Set<String> currentUserRoles = new HashSet<>(); for (GrantedAuthority grantedAuth : userDetails.getAuthorities()) { currentUserRoles.add(grantedAuth.getAuthority()); } //determine entity rights EntityRight entityRight = null; EntityUserMap[] entityUserMaps = classOfBean.getAnnotation(WebEntity.class).userMap(); for (EntityUserMap e : entityUserMaps) { if (currentUserRoles.contains(e.role()) || ("*").equals(e.role())) { entityRight = e.right(); break; } } if (entityRight == null) { //if entityRight=EntityRight.NONE, still allow to go through because field level might be accessible //Not accessible return; } //create bean utils BeanUtils beanUtils = new BeanUtils(); //creat bread crumb BreadCrumbBuilder.buildBreadCrumb(vcevent.getNavigator(), pageParameter.getBreadcrumb(), pageParameter.getHistory()); //create form FormLayout form = new FormLayout(); FindAnyEntityParameter<C> searchQuery = new FindAnyEntityParameter<>(classOfBean); FindEntityCollectionParameter<P, C> entityCollectionQuery = new FindEntityCollectionParameter<>(parentBean, parentToBeanField, pageParameter.getRelationManagerFactory().create((Class<P>) parentBean.getClass(), classOfBean)); final SearchDataTableLayout<C> allDataTableLayout = new SearchDataTableLayout<>(searchQuery, classOfBean, dao, noBeansPerPage, pageParameter.getCustomTypeDaos(), pageParameter.getConfig(), currentUserRoles, entityRight); final CollectionDataTableLayout<P, C> beanTableLayout = new CollectionDataTableLayout<>( entityCollectionQuery, classOfBean, dao, noBeansPerPage, pageParameter.getCustomTypeDaos(), pageParameter.getConfig(), currentUserRoles, entityRight); //handle associate existing data final Window window = new Window("Associate"); window.setId(window.getCaption()); window.setContent(allDataTableLayout); window.setModal(true); HorizontalLayout popupButtonLayout = new HorizontalLayout(); Button associateToCurrentBtn = new Button("Associate to current", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<C> allDataList = allDataTableLayout.getTableValues(); beanTableLayout.associateEntities(allDataList, choiceType); window.close(); } }); associateToCurrentBtn.setId(associateToCurrentBtn.getCaption()); popupButtonLayout.addComponent(associateToCurrentBtn); Button closeBtn = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { window.close(); } }); popupButtonLayout.addComponent(closeBtn); closeBtn.setId(closeBtn.getCaption()); popupButtonLayout.setSpacing(true); MarginInfo marginInfo = new MarginInfo(true); allDataTableLayout.setMargin(marginInfo); allDataTableLayout.addComponent(popupButtonLayout); if (parentToBeanFieldState.equals(ComponentState.EDITABLE)) { Button associateExistingBtn = new Button("Associate existing", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { EditorTableView.this.getUI().addWindow(window); } }); form.addComponent(associateExistingBtn); associateExistingBtn.setId(associateExistingBtn.getCaption()); } form.addComponent(beanTableLayout); //Navigation and actions HorizontalLayout buttonLayout = new HorizontalLayout(); if (beanUtils.isCreatable(classOfBean, currentUserRoles) && parentToBeanFieldState.equals(ComponentState.EDITABLE)) { Button addNewBtn = new Button("Add new", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { C currentBean = dao.createNew(true);//dao.createAndSave(parentBean, parentToBeanField, pageParameter.getRelationManagerFactory().create((Class<P>) parentBean.getClass(), classOfBean)); BeanView<P, C> beanView = new BeanView<P, C>(currentBean, parentBean, parentToBeanField, pageParameter); String targetView = "CHOOSE_ONE_TABLE_VIEW_" + UUID.randomUUID().toString(); WebEntity myObject = (WebEntity) currentBean.getClass().getAnnotation(WebEntity.class); History his = new History(targetView, "Add new " + myObject.name()); pageParameter.getHistory().push(his); vcevent.getNavigator().addView(targetView, beanView); vcevent.getNavigator().navigateTo(targetView); } }); buttonLayout.addComponent(addNewBtn); addNewBtn.setId(addNewBtn.getCaption()); } if (beanUtils.isEditable(classOfBean, currentUserRoles) || beanUtils.isViewable(classOfBean, currentUserRoles)) { Button manageBtn = new Button("Manage", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { C currentBean = beanTableLayout.getTableValues().iterator().next(); if (currentBean != null) { BeanView<P, C> beanView = new BeanView<P, C>(currentBean, parentBean, parentToBeanField, pageParameter); String targetView = "CHOOSE_ONE_TABLE_VIEW_" + UUID.randomUUID().toString(); WebEntity myObject = (WebEntity) currentBean.getClass().getAnnotation(WebEntity.class); History his = new History(targetView, "Manage " + myObject.name()); pageParameter.getHistory().push(his); vcevent.getNavigator().addView(targetView, beanView); vcevent.getNavigator().navigateTo(targetView); } } }); buttonLayout.addComponent(manageBtn); manageBtn.setId(manageBtn.getCaption()); } if (parentToBeanFieldState.equals(ComponentState.EDITABLE)) { if (beanUtils.isCreatable(classOfBean, currentUserRoles) && parentToBeanFieldState.equals(ComponentState.EDITABLE)) { Button deleteBtn = new Button("Delete", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { final Collection<C> currentBeans = (Collection<C>) beanTableLayout.getTableValues(); if (!currentBeans.isEmpty()) { ConfirmDialog.show(EditorTableView.this.getUI(), "Please Confirm:", "Are you really sure you want to delete these entries?", "I am", "Not quite", new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { EditorTableView.this.parentBean = beanTableLayout .deleteData(currentBeans); } } }); } } }); buttonLayout.addComponent(deleteBtn); deleteBtn.setId(deleteBtn.getCaption()); } } Button saveAndBackBtn = new Button("Save and back", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //parentDao.save(parentBean); if (!pageParameter.getHistory().isEmpty()) { String currentView = pageParameter.getHistory().pop().getViewHandle(); String lastView = pageParameter.getHistory().peek().getViewHandle(); vcevent.getNavigator().removeView(currentView); vcevent.getNavigator().navigateTo(lastView); } } }); buttonLayout.addComponent(saveAndBackBtn); saveAndBackBtn.setId(saveAndBackBtn.getCaption()); buttonLayout.setSpacing(true); form.addComponent(buttonLayout); this.addComponent(form); }
From source file:org.opencms.ui.A_CmsUI.java
License:Open Source License
/** * Closes all opened dialog windows.<p> *///from w w w . ja v a 2s . c o m public void closeWindows() { for (Window window : getWindows()) { window.close(); } }
From source file:org.opencms.ui.CmsVaadinUtils.java
License:Open Source License
/** * Shows an alert box to the user with the given information, which will perform the given action after the user clicks on OK.<p> * * @param title the title/* w ww . jav a2 s . c om*/ * @param message the message * * @param callback the callback to execute after clicking OK */ public static void showAlert(String title, String message, final Runnable callback) { final Window window = new Window(); window.setModal(true); Panel panel = new Panel(); panel.setCaption(title); panel.setWidth("500px"); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); panel.setContent(layout); layout.addComponent(new Label(message)); Button okButton = new Button(); okButton.addClickListener(new ClickListener() { /** The serial version id. */ private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { window.close(); if (callback != null) { callback.run(); } } }); layout.addComponent(okButton); layout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); okButton.setCaption(org.opencms.workplace.Messages.get().getBundle(A_CmsUI.get().getLocale()) .key(org.opencms.workplace.Messages.GUI_DIALOG_BUTTON_OK_0)); window.setContent(panel); window.setClosable(false); window.setResizable(false); A_CmsUI.get().addWindow(window); }
From source file:org.opencms.ui.components.CmsConfirmationDialog.java
License:Open Source License
/** * Shows the confirmation dialog in a window.<p> * * @param title the window title/*from w ww .j a va2 s . c o m*/ * @param message the message to display in the dialog * @param okAction the action to execute when the user clicks OK * @param cancelAction the action for the cancel case */ public static void show(String title, String message, final Runnable okAction, final Runnable cancelAction) { final Window window = CmsBasicDialog.prepareWindow(); window.setCaption(title); CmsConfirmationDialog dialog = new CmsConfirmationDialog(message, new Runnable() { public void run() { window.close(); okAction.run(); } }, new Runnable() { public void run() { if (cancelAction != null) { cancelAction.run(); } window.close(); } }); window.setContent(dialog); UI.getCurrent().addWindow(window); }
From source file:org.opencms.ui.components.fileselect.A_CmsFileSelectField.java
License:Open Source License
/** * Opens the file selector dialog.<p> *///from w w w. ja v a 2s . c o m protected void openFileSelector() { try { final Window window = CmsBasicDialog.prepareWindow(); window.setCaption(m_fileSelectCaption != null ? m_fileSelectCaption : CmsVaadinUtils.getMessageText(org.opencms.ui.components.Messages.GUI_FILE_SELECT_CAPTION_0)); A_CmsUI.get().addWindow(window); CmsResourceSelectDialog fileSelect = new CmsResourceSelectDialog(m_filter); fileSelect.showSitemapView(m_startWithSitemapView); T value = getValue(); if (value instanceof CmsResource) { fileSelect.showStartResource((CmsResource) value); } else if (value instanceof String) { fileSelect.openPath((String) value); } window.setContent(fileSelect); fileSelect.addSelectionHandler(new I_CmsSelectionHandler<CmsResource>() { public void onSelection(CmsResource selected) { setResourceValue(selected); window.close(); } }); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); CmsErrorDialog.showErrorDialog(e); } }
From source file:org.opencms.ui.dialogs.CmsCopyMoveDialog.java
License:Open Source License
/** * Displays the confirm overwrite dialog.<p> * * @param collidingResources the colliding resources *///w ww . j av a 2s . com private void showConfirmOverwrite(List<CmsResource> collidingResources) { final Window window = CmsBasicDialog.prepareWindow(); window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONFIRM_OVERWRITE_TITLE_0)); CmsConfirmationDialog dialog = new CmsConfirmationDialog( CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONFIRM_OVERWRITE_MESSAGE_0), new Runnable() { public void run() { window.close(); submit(true); } }, new Runnable() { public void run() { window.close(); cancel(); } }); dialog.displayResourceInfo(collidingResources); window.setContent(dialog); UI.getCurrent().addWindow(window); }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
@Override public void menuBarUpdated(CommandManager commandManager) { if (m_menuBar != null) { m_rootLayout.removeComponent(m_menuBar); }/*from ww w. ja va 2 s . c o m*/ if (m_contextMenu != null) { m_contextMenu.detach(); } m_menuBar = commandManager.getMenuBar(m_graphContainer, this); m_menuBar.setWidth(100, Unit.PERCENTAGE); // Set expand ratio so that extra space is not allocated to this vertical component if (m_showHeader) { m_rootLayout.addComponent(m_menuBar, 1); } else { m_rootLayout.addComponent(m_menuBar, 0); } m_contextMenu = commandManager .getContextMenu(new DefaultOperationContext(this, m_graphContainer, DisplayLocation.CONTEXTMENU)); m_contextMenu.setAsContextMenuOf(this); // Add Menu Item to share the View with others m_menuBar.addItem("Share", FontAwesome.SHARE, new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { // create the share link String fragment = getPage().getLocation().getFragment(); String url = getPage().getLocation().toString().replace("#" + getPage().getLocation().getFragment(), ""); String shareLink = String.format("%s?%s=%s", url, TopologyUIRequestHandler.PARAMETER_HISTORY_FRAGMENT, fragment); // Create the Window Window shareWindow = new Window(); shareWindow.setCaption("Share Link"); shareWindow.setModal(true); shareWindow.setClosable(true); shareWindow.setResizable(false); shareWindow.setWidth(400, Unit.PIXELS); TextArea shareLinkField = new TextArea(); shareLinkField.setValue(shareLink); shareLinkField.setReadOnly(true); shareLinkField.setRows(3); shareLinkField.setWidth(100, Unit.PERCENTAGE); // Close Button Button close = new Button("Close"); close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); close.addClickListener(event -> shareWindow.close()); // Layout for Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); buttonLayout.addComponent(close); buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT); // Content Layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Please use the following link to share the current view with others.")); verticalLayout.addComponent(shareLinkField); verticalLayout.addComponent(buttonLayout); shareWindow.setContent(verticalLayout); getUI().addWindow(shareWindow); } }); updateMenuItems(); }
From source file:org.opennms.features.topology.app.internal.ui.ToolbarPanel.java
License:Open Source License
public ToolbarPanel(final ToolbarPanelController controller) { addStyleName(Styles.TOOLBAR);/*from ww w. ja va 2 s . c o m*/ this.layoutManager = controller.getLayoutManager(); final Property<Double> scale = controller.getScaleProperty(); final Boolean[] eyeClosed = new Boolean[] { false }; final Button showFocusVerticesBtn = new Button(); showFocusVerticesBtn.setIcon(FontAwesome.EYE); showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes"); showFocusVerticesBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (eyeClosed[0]) { showFocusVerticesBtn.setIcon(FontAwesome.EYE); } else { showFocusVerticesBtn.setIcon(FontAwesome.EYE_SLASH); } eyeClosed[0] = !eyeClosed[0]; // toggle controller.toggleHighlightFocus(); } }); final Button magnifyBtn = new Button(); magnifyBtn.setIcon(FontAwesome.PLUS); magnifyBtn.setDescription("Magnify"); magnifyBtn.addClickListener( (Button.ClickListener) event -> scale.setValue(Math.min(1, scale.getValue() + 0.25))); final Button demagnifyBtn = new Button(); demagnifyBtn.setIcon(FontAwesome.MINUS); demagnifyBtn.setDescription("Demagnify"); demagnifyBtn.addClickListener( (Button.ClickListener) event -> scale.setValue(Math.max(0, scale.getValue() - 0.25))); m_szlOutBtn = new Button(); m_szlOutBtn.setId("szlOutBtn"); m_szlOutBtn.setIcon(FontAwesome.ANGLE_DOWN); m_szlOutBtn.setDescription("Decrease Semantic Zoom Level"); m_szlOutBtn.setEnabled(controller.getSemanticZoomLevel() > 0); m_szlOutBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { int szl = controller.getSemanticZoomLevel(); if (szl > 0) { setSemanticZoomLevel(controller, szl - 1); controller.saveHistory(); } } }); final Button szlInBtn = new Button(); szlInBtn.setId("szlInBtn"); szlInBtn.setIcon(FontAwesome.ANGLE_UP); szlInBtn.setDescription("Increase Semantic Zoom Level"); szlInBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setSemanticZoomLevel(controller, controller.getSemanticZoomLevel() + 1); controller.saveHistory(); } }); m_zoomLevelLabel.setId("szlInputLabel"); m_panBtn = new Button(); m_panBtn.setIcon(FontAwesome.ARROWS); m_panBtn.setDescription("Pan Tool"); m_panBtn.addStyleName(Styles.SELECTED); m_selectBtn = new Button(); m_selectBtn.setIcon(IonicIcons.ANDROID_EXPAND); m_selectBtn.setDescription("Selection Tool"); m_selectBtn.setStyleName("toolbar-button"); m_selectBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { m_selectBtn.addStyleName(Styles.SELECTED); m_panBtn.removeStyleName(Styles.SELECTED); controller.setActiveTool(ActiveTool.select); } }); m_panBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { m_panBtn.addStyleName(Styles.SELECTED); m_selectBtn.removeStyleName(Styles.SELECTED); controller.setActiveTool(ActiveTool.pan); } }); Button showAllMapBtn = new Button(); showAllMapBtn.setId("showEntireMapBtn"); showAllMapBtn.setIcon(FontAwesome.GLOBE); showAllMapBtn.setDescription("Show Entire Map"); showAllMapBtn.addClickListener((Button.ClickListener) event -> controller.showAllMap()); Button centerSelectionBtn = new Button(); centerSelectionBtn.setIcon(FontAwesome.LOCATION_ARROW); centerSelectionBtn.setDescription("Center On Selection"); centerSelectionBtn.addClickListener((Button.ClickListener) event -> controller.centerMapOnSelection()); Button shareButton = new Button("", FontAwesome.SHARE_SQUARE_O); shareButton.setDescription("Share"); shareButton.addClickListener((x) -> { // Create the share link String fragment = getUI().getPage().getLocation().getFragment(); String url = getUI().getPage().getLocation().toString().replace("#" + fragment, ""); String shareLink = String.format("%s?%s=%s", url, PARAMETER_HISTORY_FRAGMENT, fragment); // Create the Window Window shareWindow = new Window(); shareWindow.setCaption("Share Link"); shareWindow.setModal(true); shareWindow.setClosable(true); shareWindow.setResizable(false); shareWindow.setWidth(400, Sizeable.Unit.PIXELS); TextArea shareLinkField = new TextArea(); shareLinkField.setValue(shareLink); shareLinkField.setReadOnly(true); shareLinkField.setRows(3); shareLinkField.setWidth(100, Sizeable.Unit.PERCENTAGE); // Close Button Button close = new Button("Close"); close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); close.addClickListener(event -> shareWindow.close()); // Layout for Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); buttonLayout.addComponent(close); buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT); // Content Layout VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true); verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Please use the following link to share the current view with others.")); verticalLayout.addComponent(shareLinkField); verticalLayout.addComponent(buttonLayout); shareWindow.setContent(verticalLayout); getUI().addWindow(shareWindow); }); // Refresh Button Button refreshButton = new Button(); refreshButton.setId("refreshNow"); refreshButton.setIcon(FontAwesome.REFRESH); refreshButton.setDescription("Refresh Now"); refreshButton.addClickListener((event) -> controller.refreshUI()); // Layer Layout layerLayout = new VerticalLayout(); layerLayout.setId("layerComponent"); layerLayout.setSpacing(true); layerLayout.setMargin(true); // Layer Button layerButton = new Button(); layerButton.setId("layerToggleButton"); layerButton.setIcon(FontAwesome.BARS); layerButton.setDescription("Layers"); layerButton.addClickListener((event) -> { boolean isCollapsed = layerButton.getStyleName().contains(Styles.EXPANDED); setLayerLayoutVisible(!isCollapsed); }); // Save button layerSaveButton = new Button(); layerSaveButton.setId("saveLayerButton"); layerSaveButton.setIcon(FontAwesome.FLOPPY_O); layerSaveButton.addClickListener((event) -> controller.saveLayout()); // Actual Layout for the Toolbar CssLayout contentLayout = new CssLayout(); contentLayout.addStyleName("toolbar-component"); contentLayout.addComponent(createGroup(szlInBtn, m_zoomLevelLabel, m_szlOutBtn)); contentLayout.addComponent( createGroup(refreshButton, centerSelectionBtn, showAllMapBtn, layerButton, showFocusVerticesBtn)); contentLayout.addComponent(createGroup(m_panBtn, m_selectBtn)); contentLayout.addComponent(createGroup(magnifyBtn, demagnifyBtn)); contentLayout.addComponent(createGroup(shareButton)); contentLayout.addComponent(createGroup(layerSaveButton)); // Toolbar addComponent(contentLayout); }