List of usage examples for com.vaadin.ui Layout addComponent
public void addComponent(Component c);
From source file:annis.gui.ReportBugWindow.java
License:Apache License
private void addScreenshotPreview(Layout layout, final byte[] rawImage, String mimeType) { StreamResource res = new StreamResource(new ScreenDumpStreamSource(rawImage), "screendump_" + UUID.randomUUID().toString() + ".png"); res.setMIMEType(mimeType);/*ww w. ja v a2s . c om*/ final Image imgScreenshot = new Image("Attached screenshot", res); imgScreenshot.setAlternateText( "Screenshot of the ANNIS browser window, " + "no other window or part of the desktop is captured."); imgScreenshot.setVisible(false); imgScreenshot.setWidth("100%"); Button btShowScreenshot = new Button("Show attached screenshot", new ShowScreenshotClickListener(imgScreenshot)); btShowScreenshot.addStyleName(BaseTheme.BUTTON_LINK); btShowScreenshot.setIcon(FontAwesome.PLUS_SQUARE_O); layout.addComponent(btShowScreenshot); layout.addComponent(imgScreenshot); }
From source file:annis.visualizers.component.RawTextVisualizer.java
License:Apache License
@Override public Panel createComponent(VisualizerInput visInput, VisualizationToggle visToggle) { // get config for alignment boolean vertical = Boolean.parseBoolean(visInput.getMappings().getProperty("vertical", "true")); // get the texts RawTextWrapper texts = visInput.getRawText(); // create the main panel Panel p = new Panel(); p.setSizeFull();/*from ww w .ja v a 2 s . c om*/ // some layout configuration p.addStyleName(ChameleonTheme.PANEL_BORDERLESS); p.addStyleName(PANEL_CLASS); // enable webfonts p.addStyleName(Helper.CORPUS_FONT_FORCE); Layout l; // if no text available inform user and exit if (texts == null) { Label text = new Label(NO_TEXT); text.addStyleName(LABEL_CLASS); text.setSizeFull(); p.setContent(text); return p; } if (texts.hasMultipleTexts()) { // set the aligmnent if (vertical) { l = new VerticalLayout(); } else { l = new GridLayout(texts.getTexts().size(), 1); } // limit the size to the parent panel. l.setSizeFull(); // add the texts to the layout for (int i = 0; i < texts.getTexts().size(); i++) { String s = texts.getTexts().get(i); Label lblText; // check if the text is empty if (s == null || hasOnlyWhiteSpace(s)) { lblText = new Label(NO_TEXT); } else { lblText = new Label(s, ContentMode.TEXT); } lblText.setCaption("text " + (i + 1)); lblText.addStyleName(LABEL_CLASS); lblText.setWidth(98, Sizeable.Unit.PERCENTAGE); l.addComponent(lblText); } // apply the panel p.setContent(l); return p; } Label lblText; if (texts.hasTexts() && !hasOnlyWhiteSpace(texts.getFirstText())) { lblText = new Label(texts.getFirstText(), ContentMode.TEXT); } else { lblText = new Label(NO_TEXT); } lblText.setSizeFull(); lblText.addStyleName(LABEL_CLASS); p.setContent(lblText); return p; }
From source file:ch.bfh.due1.srs.views.ReservationView.java
License:Open Source License
public ReservationView(Navigator navigator, RoomController roomController, ReservationController reservationController) { this.roomController = roomController; this.reservationController = reservationController; // setSizeFull(); addComponent(this.tabsheet); // Button button = new Button("Go to Room List View", new // Button.ClickListener() { // @Override//from w w w. ja va 2 s. c om // public void buttonClick(ClickEvent event) { // navigator.navigateTo(RoomListView.VIEWNAME); // } // }); // addComponent(button); // setComponentAlignment(button, Alignment.MIDDLE_CENTER); this.tabsheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() { @Override public void selectedTabChange(SelectedTabChangeEvent event) { // Find the tab sheet TabSheet tabsheet = event.getTabSheet(); // Find the tab (it's a layout) Layout tab = (Layout) tabsheet.getSelectedTab(); // Get the tab caption from the tab object String roomName = tabsheet.getTab(tab).getCaption(); // Fill the tab content tab.removeAllComponents(); // Create table for selected room table = createTimeSlotTable(roomName); tab.addComponent(table); } }); }
From source file:com.arcusys.liferay.vaadinplugin.ui.DetailsWindow.java
License:Apache License
private Layout createVaadinDetails() { Layout vaadinDetailLayout = new VerticalLayout(); vaadinDetailLayout.setWidth("900px"); VerticalLayout vaadinDetails = new VerticalLayout(); vaadinDetails.setMargin(new MarginInfo(true, true, false, true)); Version currentVersion = ControlPanelPortletUtil.getPortalVaadinVersion(); VaadinVersion currentVaadinInfo = VaadinVersion.getVaadinVersion(currentVersion); Collection<VaadinFileInfo> fileInfos = currentVaadinInfo.getVaadinFilesInfo(); Collections.sort((List<VaadinFileInfo>) fileInfos, new Comparator<VaadinFileInfo>() { @Override/* w w w .java 2 s.c o m*/ public int compare(VaadinFileInfo o1, VaadinFileInfo o2) { if (o1 == null) return -1; if (o2 == null) return 1; return o1.getOrderPriority().compareTo(o2.getOrderPriority()); } }); for (VaadinFileInfo info : fileInfos) { VerticalLayout infoLayout = new VerticalLayout(); infoLayout.setCaption(info.getName()); infoLayout.setMargin(new MarginInfo(false, true, true, false)); Layout versionLayout = new HorizontalLayout(); versionLayout.setSizeUndefined(); versionLayout.addComponent(new Label("Version: ")); String vaadinJarVersion; try { vaadinJarVersion = ControlPanelPortletUtil.getPortalVaadinJarVersion( info.getPlace() + ControlPanelPortletUtil.FileSeparator + info.getName()); } catch (Exception ex) { vaadinJarVersion = ""; log.warn("Version for " + vaadinJarVersion + " couldn't be read.", ex); } versionLayout.addComponent(new Label(vaadinJarVersion)); infoLayout.addComponent(versionLayout); Layout pathLayout = new HorizontalLayout(); pathLayout.setSizeUndefined(); pathLayout.addComponent(new Label("Path: ")); String path = info.getPlace(); pathLayout.addComponent(new Label(path)); infoLayout.addComponent(pathLayout); vaadinDetails.addComponent(infoLayout); } vaadinDetailLayout.addComponent(vaadinDetails); return vaadinDetailLayout; }
From source file:com.cms.utils.ComboComponent.java
public ComboComponent(String all, String vaDefault, List<AppParamsDTO> appPatamDTO, String parType) { if (DataUtil.isListNullOrEmpty(appPatamDTO)) { appPatamDTO = Lists.newArrayList(); }/*w w w . j ava2 s .com*/ Layout layout = new HorizontalLayout(); final BeanItemContainer<AppParamsDTO> container = new BeanItemContainer<AppParamsDTO>(AppParamsDTO.class); parType = parType.replace('_', '.').toLowerCase() + "."; if (appPatamDTO != null && appPatamDTO.size() > 0) { for (int i = 0; i < appPatamDTO.size(); i++) { if (appPatamDTO.get(i).getParCode().equalsIgnoreCase(vaDefault) && !DataUtil.isStringNullOrEmpty(vaDefault)) { appPatamDTO.get(i) .setDisplayName(BundleUtils.getString(parType + appPatamDTO.get(i).getParName())); objDefault = appPatamDTO.get(i); } } } // select all if (!DataUtil.isStringNullOrEmpty(all)) { objall.setDisplayName(BundleUtils.getString(parType + all)); appPatamDTO.add(0, objall); } container.addAll(appPatamDTO); combo = new ComboBox("", container); layout.addComponent(combo); combo.setItemCaptionPropertyId("valueLangView"); combo.setNullSelectionAllowed(false); // default if (!DataUtil.isStringNullOrEmpty(all)) { combo.setValue(objall); } else if (objDefault != null && !DataUtil.isStringNullOrEmpty(vaDefault)) { combo.setValue(objDefault); } setCompositionRoot(layout); setSizeFull(); }
From source file:com.coatl.vaadin.abc.ixABCDialogos.java
private void agregar(Stack<AbstractComponent> pila, AbstractComponent comp) { try {/* w w w . j a v a 2 s . c o m*/ if (pila.size() == 0) { //System.out.println(" +Agregando " + comp + " a pila"); pila.add(comp); return; } //System.out.println(" +Agregando " + comp + " a " + pila); Layout lo = (Layout) pila.peek(); lo.addComponent(comp); if (comp instanceof Layout) { pila.add(comp); } } catch (Exception e) { e.printStackTrace(); } return; }
From source file:com.haulmont.cuba.web.sys.WindowBreadCrumbs.java
License:Apache License
public WindowBreadCrumbs(AppWorkArea workArea) { setWidth(100, Unit.PERCENTAGE);//from w w w. j a v a 2 s .c o m setHeightUndefined(); setPrimaryStyleName(C_HEADLINE_CONTAINER); tabbedMode = workArea.getMode() == AppWorkArea.Mode.TABBED; if (tabbedMode) { super.setVisible(false); } addAttachListener((AttachListener) event -> adjustParentStyles()); logoLayout = createLogoLayout(); linksLayout = createLinksLayout(); linksLayout.setSizeUndefined(); if (!tabbedMode) { closeBtn = new CubaButton("", (Button.ClickListener) event -> { Window window = getCurrentWindow(); if (!isCloseWithCloseButtonPrevented(window)) { window.close(Window.CLOSE_ACTION_ID); } }); closeBtn.setIcon(WebComponentsHelper.getIcon("icons/close.png")); closeBtn.setStyleName("c-closetab-button"); } AppUI ui = AppUI.getCurrent(); if (ui.isTestMode()) { TestIdManager testIdManager = ui.getTestIdManager(); linksLayout.setId(testIdManager.getTestId("breadCrumbs")); linksLayout.setCubaId("breadCrumbs"); if (closeBtn != null) { closeBtn.setId(testIdManager.getTestId("closeBtn")); closeBtn.setCubaId("closeBtn"); } } Layout enclosingLayout = createEnclosingLayout(); enclosingLayout.addComponent(linksLayout); addComponent(logoLayout); addComponent(enclosingLayout); boolean controlsVisible = AppBeans.get(Configuration.class).getConfig(WebConfig.class).getShowBreadCrumbs(); enclosingLayout.setVisible(controlsVisible); if (closeBtn != null) { addComponent(closeBtn); } }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
protected Layout createNewTabLayout(final Window window, final boolean multipleOpen, WindowBreadCrumbs breadCrumbs, Component... additionalComponents) { Layout layout = new CssLayout(); layout.setPrimaryStyleName("c-app-window-wrap"); layout.setSizeFull();//from w ww. j ava 2 s. c o m layout.addComponent(breadCrumbs); if (additionalComponents != null) { for (final Component c : additionalComponents) { layout.addComponent(c); } } final Component component = WebComponentsHelper.getComposition(window); component.setSizeFull(); layout.addComponent(component); WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window)); if (workArea.getMode() == Mode.TABBED) { layout.addStyleName("c-app-tabbed-window"); TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour(); String tabId; Integer hashCode = getWindowHashCode(window); ComponentContainer tab = null; if (hashCode != null) { tab = findTab(hashCode); } if (tab != null && !multipleOpen) { tabSheet.replaceComponent(tab, layout); tabSheet.removeComponent(tab); tabs.put(layout, breadCrumbs); tabId = tabSheet.getTab(layout); } else { tabs.put(layout, breadCrumbs); tabId = "tab_" + uuidSource.createUuid(); tabSheet.addTab(layout, tabId); if (ui.isTestMode()) { String id = "tab_" + window.getId(); tabSheet.setTabTestId(tabId, ui.getTestIdManager().getTestId(id)); tabSheet.setTabCubaId(tabId, id); } } String windowContentSwitchMode = window.getContentSwitchMode().name(); ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(windowContentSwitchMode); tabSheet.setContentSwitchMode(tabId, contentSwitchMode); String formattedCaption = formatTabCaption(window.getCaption(), window.getDescription()); tabSheet.setTabCaption(tabId, formattedCaption); String formattedDescription = formatTabDescription(window.getCaption(), window.getDescription()); if (!Objects.equals(formattedCaption, formattedDescription)) { tabSheet.setTabDescription(tabId, formattedDescription); } else { tabSheet.setTabDescription(tabId, null); } tabSheet.setTabIcon(tabId, WebComponentsHelper.getIcon(window.getIcon())); tabSheet.setTabClosable(tabId, true); tabSheet.setTabCloseHandler(layout, (targetTabSheet, tabContent) -> { //noinspection SuspiciousMethodCalls WindowBreadCrumbs breadCrumbs1 = tabs.get(tabContent); if (!canWindowBeClosed(breadCrumbs1.getCurrentWindow())) { return; } Runnable closeTask = new TabCloseTask(breadCrumbs1); closeTask.run(); // it is needed to force redraw tabsheet if it has a lot of tabs and part of them are hidden targetTabSheet.markAsDirty(); }); tabSheet.setSelectedTab(layout); } else { tabs.put(layout, breadCrumbs); layout.addStyleName("c-app-single-window"); VerticalLayout mainLayout = workArea.getSingleWindowContainer(); mainLayout.removeAllComponents(); mainLayout.addComponent(layout); } return layout; }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
protected Component showWindowThisTab(final Window window, final String caption, final String description) { getDialogParams().reset();//from w w w . j ava 2s . c o m WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window)); Layout layout; if (workArea.getMode() == Mode.TABBED) { TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour(); layout = (Layout) tabSheet.getSelectedTab(); } else { layout = (Layout) workArea.getSingleWindowContainer().getComponent(0); } final WindowBreadCrumbs breadCrumbs = tabs.get(layout); if (breadCrumbs == null) { throw new IllegalStateException("BreadCrumbs not found"); } final Window currentWindow = breadCrumbs.getCurrentWindow(); Set<Map.Entry<Window, Integer>> set = windows.entrySet(); boolean pushed = false; for (Map.Entry<Window, Integer> entry : set) { if (entry.getKey().equals(currentWindow)) { windows.remove(currentWindow); getStack(breadCrumbs).push(new Pair<>(entry.getKey(), entry.getValue())); pushed = true; break; } } if (!pushed) { getStack(breadCrumbs).push(new Pair<>(currentWindow, null)); } removeFromWindowMap(currentWindow); layout.removeComponent(WebComponentsHelper.getComposition(currentWindow)); final Component component = WebComponentsHelper.getComposition(window); component.setSizeFull(); layout.addComponent(component); breadCrumbs.addWindow(window); if (workArea.getMode() == Mode.TABBED) { TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour(); String tabId = tabSheet.getTab(layout); String formattedCaption = formatTabCaption(caption, description); tabSheet.setTabCaption(tabId, formattedCaption); String formattedDescription = formatTabDescription(caption, description); if (!Objects.equals(formattedCaption, formattedDescription)) { tabSheet.setTabDescription(tabId, formattedDescription); } else { tabSheet.setTabDescription(tabId, null); } tabSheet.setTabIcon(tabId, WebComponentsHelper.getIcon(window.getIcon())); ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(window.getContentSwitchMode().name()); tabSheet.setContentSwitchMode(tabId, contentSwitchMode); } else { layout.markAsDirtyRecursive(); } return layout; }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
protected void closeWindow(Window window, WindowOpenInfo openInfo) { if (!disableSavingScreenHistory) { screenHistorySupport.saveScreenHistory(window, openInfo.getOpenMode()); }//w w w .j a v a 2s . c o m WebWindow webWindow = (WebWindow) window; webWindow.stopTimers(); switch (openInfo.getOpenMode()) { case DIALOG: { final CubaWindow cubaDialogWindow = (CubaWindow) openInfo.getData(); cubaDialogWindow.forceClose(); fireListeners(window, tabs.size() != 0); break; } case NEW_WINDOW: case NEW_TAB: { final Layout layout = (Layout) openInfo.getData(); layout.removeComponent(WebComponentsHelper.getComposition(window)); WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window)); if (workArea.getMode() == Mode.TABBED) { TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour(); tabSheet.silentCloseTabAndSelectPrevious(layout); tabSheet.removeComponent(layout); } else { VerticalLayout singleLayout = workArea.getSingleWindowContainer(); singleLayout.removeComponent(layout); } WindowBreadCrumbs windowBreadCrumbs = tabs.get(layout); if (windowBreadCrumbs != null) { windowBreadCrumbs.clearListeners(); windowBreadCrumbs.removeWindow(); } tabs.remove(layout); stacks.remove(windowBreadCrumbs); fireListeners(window, !tabs.isEmpty()); if (tabs.isEmpty() && app.getConnection().isConnected()) { workArea.switchTo(AppWorkArea.State.INITIAL_LAYOUT); } break; } case THIS_TAB: { final Layout layout = (Layout) openInfo.getData(); final WindowBreadCrumbs breadCrumbs = tabs.get(layout); if (breadCrumbs == null) { throw new IllegalStateException("Unable to close screen: breadCrumbs not found"); } breadCrumbs.removeWindow(); Window currentWindow = breadCrumbs.getCurrentWindow(); if (!getStack(breadCrumbs).empty()) { Pair<Window, Integer> entry = getStack(breadCrumbs).pop(); putToWindowMap(entry.getFirst(), entry.getSecond()); } Component component = WebComponentsHelper.getComposition(currentWindow); component.setSizeFull(); WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window)); layout.removeComponent(WebComponentsHelper.getComposition(window)); if (app.getConnection().isConnected()) { layout.addComponent(component); if (workArea.getMode() == Mode.TABBED) { TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour(); String tabId = tabSheet.getTab(layout); String formattedCaption = formatTabCaption(currentWindow.getCaption(), currentWindow.getDescription()); tabSheet.setTabCaption(tabId, formattedCaption); String formattedDescription = formatTabDescription(currentWindow.getCaption(), currentWindow.getDescription()); if (!Objects.equals(formattedCaption, formattedDescription)) { tabSheet.setTabDescription(tabId, formattedDescription); } else { tabSheet.setTabDescription(tabId, null); } tabSheet.setTabIcon(tabId, WebComponentsHelper.getIcon(currentWindow.getIcon())); ContentSwitchMode contentSwitchMode = ContentSwitchMode .valueOf(currentWindow.getContentSwitchMode().name()); tabSheet.setContentSwitchMode(tabId, contentSwitchMode); } } fireListeners(window, !tabs.isEmpty()); if (tabs.isEmpty() && app.getConnection().isConnected()) { workArea.switchTo(AppWorkArea.State.INITIAL_LAYOUT); } break; } default: { throw new UnsupportedOperationException(); } } }