List of usage examples for com.vaadin.ui HorizontalLayout removeAllComponents
@Override public void removeAllComponents()
From source file:nl.amc.biolab.nsg.display.VaadinTestApplication.java
License:Open Source License
@Override public void onRequestStart(PortletRequest request, PortletResponse response) { this.portletSession = request.getPortletSession(); // final Object phase = request.getAttribute("javax.portlet.lifecycle_phase"); // logger.debug("Lifecycle phase is: " + phase); if (getUser() == null) { logger.debug("User is null, so checking theme display."); PermissionChecker permissionChecker = null; ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (themeDisplay != null) { permissionChecker = themeDisplay.getPermissionChecker(); }/* w w w . ja v a 2s.c o m*/ if (permissionChecker == null || !permissionChecker.isSignedIn()) { setUser(null); return; } setUser(themeDisplay.getUser()); } // logger.debug("Setting the URL and page."); if (PortalUtil.getCurrentURL(request).contains(PROJECTS_URL)) { this.page = PROJECTS; } else if (PortalUtil.getCurrentURL(request).contains(DATA_URL)) { this.page = DATA; } else if (PortalUtil.getCurrentURL(request).contains(PROCESSING_URL)) { this.page = PROCESSING; } if (getUser() != null && getUserDataService() != null) { if (!(PortalUtil.getCurrentURL(request).contains(PROJECTS_URL) || PortalUtil.getCurrentURL(request).contains(DATA_URL) || PortalUtil.getCurrentURL(request).contains(PROCESSING_URL))) { return; } try { if (portletSession.getAttribute(SESS_PROJECT, PortletSession.APPLICATION_SCOPE) != null) { final Long projectId = (Long) portletSession.getAttribute(SESS_PROJECT, PortletSession.APPLICATION_SCOPE); getUserDataService().setProjectDbId(projectId); // logger.debug("Selected Project is: " + projectId); } if (portletSession.getAttribute(SESS_PROCESSING, PortletSession.APPLICATION_SCOPE) != null) { getUserDataService().setProcessingDbId( (Long) portletSession.getAttribute(SESS_PROCESSING, PortletSession.APPLICATION_SCOPE)); // logger.debug("Processing session is read."); } } catch (Exception e) { e.printStackTrace(); } if (PortalUtil.getCurrentURL(request).contains("wsver") && mainControl != null) { try { if (getPage() == DATA && (this.getUserDataService().getUserId() == 0L || getUserDataService().getProjectDbId() != null)) { this.getUserDataService().xnatLogin(); } mainControl.update(); } catch (RuntimeException e) { if (e == null || e.getMessage() == null || !(e.getMessage().equals("No Password.") || e.getMessage().equals("Wrong Password.") || e.getMessage().equals("No User login."))) { HorizontalLayout layout = new HorizontalLayout(); Label label = new Label( "Server error. Please sign out and sign in again, and if the problem persists, contact the administrator."); layout.setWidth("100%"); layout.setHeight("300px"); layout.removeAllComponents(); layout.addComponent(label); getMainWindow().removeAllComponents(); getMainWindow().addComponent(layout); e.printStackTrace(); return; } else if (e.getMessage().equals("No Password.") || e.getMessage().equals("Wrong Password.")) { HorizontalLayout layout = new HorizontalLayout(); layout.removeAllComponents(); LoginUI loginUI = new LoginUI(mainControl); loginUI.addListener(new Component.Listener() { private static final long serialVersionUID = -2775815874196476965L; @Override public void componentEvent(Component.Event event) { // login failed mainControl.init((nl.amc.biolab.datamodel.objects.User) ((Button) event.getSource()) .getData()); } }); layout.addComponent(new LoginUI(mainControl)); getMainWindow().removeAllComponents(); getMainWindow().showNotification("Your XNAT password was not recognized."); getMainWindow().addComponent(layout); } else if (e.getMessage().equals("No User login.")) { //nsgdm api not returning this message? getMainWindow().showNotification("No User login."); HorizontalLayout layout = new HorizontalLayout(); Label label = new Label("Loading page."); layout.setWidth("100%"); layout.setHeight("300px"); layout.addComponent(label); label = new Label("Please contact the administrator for XNAT user setup"); layout.removeAllComponents(); layout.addComponent(label); getMainWindow().removeAllComponents(); getMainWindow().addComponent(layout); return; } } } } }
From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java
License:Apache License
/** * Invoked when view is entered.//from w w w . jav a2 s .c o m * @param parameters the parameters */ public final synchronized void enter(final String parameters) { if (recordReaderThread != null) { recordReaderExitRequested = true; recordReaderThread.interrupt(); try { recordReaderThread.join(); } catch (final InterruptedException e) { LOGGER.debug("Record reader thread death wait interrupted."); } } elementLayout.removeAllComponents(); recordsLayouts.clear(); recordsQueue.clear(); recordReaderExitRequested = false; final Company company = siteContext.getObject(Company.class); if (company == null || parameters == null || parameters.length() == 0) { return; } final String buildingId = parameters; final List<Element> elements = ElementDao.getElements(entityManager, company); boolean started = false; for (final Element element : elements) { if (element.getElementId().equals(buildingId)) { started = true; continue; } if (!started) { continue; } if (element.getTreeDepth() == 0) { break; } final HorizontalLayout elementLayout = new HorizontalLayout(); this.elementLayout.addComponent(elementLayout); elementLayout.setSpacing(true); final Resource elementIcon; switch (element.getType()) { case ROOM: elementIcon = roomIcon; break; case DEVICE: elementIcon = deviceIcon; break; default: elementIcon = deviceIcon; break; } final Embedded embedded = new Embedded(null, elementIcon); elementLayout.addComponent(embedded); elementLayout.setExpandRatio(embedded, 0.1f); embedded.setWidth(32, Unit.PIXELS); embedded.setHeight(32, Unit.PIXELS); final Label label = new Label(); elementLayout.addComponent(label); elementLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); label.setValue(element.toString()); final GridLayout recordLayout = new GridLayout(); recordLayout.setSpacing(true); recordLayout.setColumns(4); recordLayout.setRows(1); this.elementLayout.addComponent(recordLayout); recordsLayouts.put(element.getElementId(), recordLayout); } recordReaderThread = new Thread(new Runnable() { @Override public void run() { try { final EntityManager threadEntityManager = ((EntityManagerFactory) getSite().getSiteContext() .getObject(EntityManagerFactory.class)).createEntityManager(); for (final Element element : elements) { final List<RecordSet> recordSets = RecordSetDao.getRecordSets(threadEntityManager, element); if (recordsLayouts.containsKey(element.getElementId())) { for (final RecordSet recordSet : recordSets) { recordsQueue.put(RecordDao.getRecords(threadEntityManager, recordSet, 1)); if (recordReaderExitRequested) { break; } } } } Thread.sleep(10); } catch (InterruptedException e) { } } }); recordReaderThread.start(); }
From source file:org.eclipse.emf.ecp.controls.vaadin.AbstractVaadinSimpleControlRenderer.java
License:Open Source License
protected void createSetOrUnsetComponent(final Component component, final HorizontalLayout horizontalLayout, final Setting setting) { final Label unsetLabel = getUnsetComponent(); final Button setButton = getUnsetButton(component, horizontalLayout, setting); setButton.setEnabled(getVElement().isEnabled()); setButton.setVisible(getVElement().isVisible()); setButton.setReadOnly(getVElement().isReadonly()); horizontalLayout.addStyleName("textheight"); horizontalLayout.removeAllComponents(); Component addComponent = component; if (setting.isSet()) { setButton.setCaption(VaadinRendererMessages.AbstractVaadinSimpleControlRenderer_Set); unsetLabel.setCaption(getUnsetLabel()); addComponent = unsetLabel;/* w w w . j a v a 2 s. c o m*/ } else { setButton.setCaption(VaadinRendererMessages.AbstractVaadinSimpleControlRenderer_Unset); } horizontalLayout.setData(addComponent); horizontalLayout.addComponent(addComponent); horizontalLayout.setExpandRatio(addComponent, 1f); horizontalLayout.addComponent(setButton); horizontalLayout.setComponentAlignment(setButton, Alignment.BOTTOM_RIGHT); }
From source file:org.escidoc.browser.elabsmodul.views.InstrumentView.java
License:Open Source License
@Override public void showButtonLayout() { HorizontalLayout horizontalLayout = null; if (this.dynamicLayout != null && this.buttonLayout != null) { try {//from w ww.j av a 2 s. c o m horizontalLayout = (HorizontalLayout) this.dynamicLayout.getComponent(COMPONENT_COUNT); } catch (ClassCastException e) { LOG.error(e.getMessage()); } if (horizontalLayout != null) { horizontalLayout.removeAllComponents(); horizontalLayout.addComponent(this.buttonLayout); } } }
From source file:org.escidoc.browser.elabsmodul.views.InvestigationView.java
License:Open Source License
@Override public void showButtonLayout() { HorizontalLayout horizontalLayout = null; if (this.dynamicLayout != null && this.buttonLayout != null) { try {/*from w w w . j a v a 2s . com*/ horizontalLayout = (HorizontalLayout) this.dynamicLayout.getComponent(COMPONENT_COUNT); } catch (final ClassCastException e) { LOG.error(e.getMessage()); } if (horizontalLayout != null) { horizontalLayout.removeAllComponents(); horizontalLayout.addComponent(this.buttonLayout); } } }
From source file:org.escidoc.browser.ui.useraccount.OnAddPreference.java
License:Open Source License
@Override public void buttonClick(@SuppressWarnings("unused") final com.vaadin.ui.Button.ClickEvent event) { addPreference.setEnabled(false);/*from w w w . j av a 2 s . co m*/ final HorizontalLayout hl = new HorizontalLayout(); final TextField key = new TextField(); key.setCaption("Name"); key.setImmediate(false); key.setWidth("-1px"); key.setHeight("-1px"); key.setInvalidAllowed(false); key.setRequired(true); final TextField value = new TextField(); value.setCaption("Value"); value.setImmediate(false); value.setWidth("-1px"); value.setHeight("-1px"); value.setInvalidAllowed(false); value.setRequired(true); final Button addButton = new Button(); addButton.setIcon(new ThemeResource("images/assets/plus.png")); addButton.addListener(new Button.ClickListener() { @Override public void buttonClick(@SuppressWarnings("unused") final com.vaadin.ui.Button.ClickEvent event) { if (UserAccountView.isNotValid(key, value)) { OnAddPreference.this.userAccountView.showMessage(); } else { try { OnAddPreference.this.userAccountView.ur.createPreference( OnAddPreference.this.userAccountView.userProxy, new Preference(key.getValue().toString(), value.getValue().toString())); OnAddPreference.this.userAccountView.router.getMainWindow().showNotification( "Preference added successfully ", Window.Notification.TYPE_TRAY_NOTIFICATION); hl.removeAllComponents(); addPreference.setEnabled(true); userPrefTable.createItem(userPrefTable.getTableContainer(), key.getValue().toString(), key.getValue().toString(), value.getValue().toString()); } catch (final EscidocClientException e) { OnAddPreference.this.userAccountView.router.getMainWindow().showNotification( ViewConstants.ERROR_CREATING_USER_PREFERENCE + e.getLocalizedMessage(), Window.Notification.TYPE_ERROR_MESSAGE); } } } }); hl.addComponent(key); hl.addComponent(value); hl.addComponent(addButton); hl.setComponentAlignment(addButton, Alignment.BOTTOM_RIGHT); preferencePanel.addComponent(hl); }
From source file:org.openeos.services.ui.vaadin.internal.notifications.VaadinNotificationManager.java
License:Apache License
private void refreshLayout(final IUnoVaadinApplication application, HorizontalLayout layout) { layout.removeAllComponents(); for (final Notification notification : resolveAndSortNotifications(application)) { VerticalLayout vLayout = new VerticalLayout(); vLayout.setMargin(false);/*from w ww .j a v a 2s . co m*/ vLayout.setSpacing(false); Button button = new Button(); button.addListener(new Button.ClickListener() { private static final long serialVersionUID = 3202745949615598633L; @Override public void buttonClick(ClickEvent event) { notification.onClick(applicationFactory.createApplication(application)); ; } }); button.setStyleName(Reindeer.BUTTON_LINK); button.setIcon(createIconResource(application, notification)); button.setDescription(notification.getText()); //createOverlay(application, notification, button, layout); vLayout.addComponent(button); if (notification.getNumber() != null) { Label label = new Label(notification.getNumber().toString()); label.setSizeUndefined(); vLayout.addComponent(label); vLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); } layout.addComponent(vLayout); } }
From source file:org.opennms.features.topology.app.internal.ui.breadcrumbs.BreadcrumbComponent.java
License:Open Source License
@Override public void graphChanged(GraphContainer graphContainer) { final BreadcrumbCriteria criteria = Criteria.getSingleCriteriaForGraphContainer(graphContainer, BreadcrumbCriteria.class, true); final HorizontalLayout breadcrumbLayout = (HorizontalLayout) getCompositionRoot(); breadcrumbLayout.removeAllComponents(); // Verify that breadcrumbs are enabled if (graphContainer.getMetaTopologyProvider() .getBreadcrumbStrategy() == BreadcrumbStrategy.SHORTEST_PATH_TO_ROOT) { final Collection<Vertex> displayVertices = graphContainer.getGraph().getDisplayVertices(); if (!displayVertices.isEmpty()) { final PathTree pathTree = BreadcrumbPathCalculator.findPath( graphContainer.getMetaTopologyProvider(), displayVertices.stream().map(v -> (VertexRef) v).collect(Collectors.toSet())); final List<Breadcrumb> breadcrumbs = pathTree.toBreadcrumbs(); criteria.setBreadcrumbs(breadcrumbs); }/*from w w w . jav a 2 s . c o m*/ for (Breadcrumb eachBreadcrumb : criteria.getBreadcrumbs()) { if (breadcrumbLayout.getComponentCount() >= 1) { breadcrumbLayout.addComponent(new Label(" > ")); } breadcrumbLayout.addComponent(createButton(graphContainer, eachBreadcrumb)); } } }
From source file:org.ripla.web.controllers.RiplaBody.java
License:Open Source License
private Component createMenubar(final HorizontalLayout inMenuBarMedium, final HorizontalLayout inMenuBarLayout, final Resource inSubMenuIcon) { final HorizontalLayout outComponent = inMenuBarMedium == null ? getDftMenuBarLayout() : inMenuBarMedium; menuBar = new MenuBar(); menuBar.setAutoOpen(true);/*from w w w.j a v a 2 s .c o m*/ menuBar.setStyleName("ripla-menu"); //$NON-NLS-1$ createMenu(menuBar, inSubMenuIcon); if (inMenuBarLayout == null) { outComponent.addComponent(menuBar); } else { inMenuBarLayout.removeAllComponents(); inMenuBarLayout.addComponent(menuBar); } return outComponent; }
From source file:pt.ist.vaadinframework.ui.PaginatedSorterViewer.java
License:Open Source License
public void setGrouper(Alignment position, Object[] grouperIds, boolean[] initialAscending, String[] grouperLabels) { HorizontalLayout controls = new HorizontalLayout(); controls.setSpacing(true);//www .ja va 2 s . com if (grouperIds.length > 0) { controls.setVisible(true); controls.addComponent(new Label(VaadinResources.getString(COMMONS_GROUPBY_LABEL) + ":")); currentGrouper = new GroupControl(grouperIds[0], initialAscending[0], grouperLabels[0]); controls.addComponent(currentGrouper); for (int i = 1; i < grouperIds.length; i++) { controls.addComponent(new Label("|")); controls.addComponent(new GroupControl(grouperIds[i], initialAscending[i], grouperLabels[i])); } } else { controls.removeAllComponents(); controls.setVisible(false); } addControls(controls, position); }