List of usage examples for com.vaadin.ui Layout removeComponent
public void removeComponent(Component c);
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 ww w . j a va2 s .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 ww . j av a2 s . co 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(); } } }
From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java
/** * Value is optional/*from w w w .j ava2 s . co m*/ * * @param action * @param content * @param value * @return */ private Component getRow(Layout parent, Runnable onDelete, String action, String content, String value) { Panel panelRow = new Panel(); GridLayout layoutRow = new GridLayout(2, 1); Label labelInfo = new Label("", ContentMode.HTML); String stringInfo = action.toUpperCase() + "<br>"; if (value != null) { stringInfo += content + " = " + value; } else { stringInfo += content + " "; } labelInfo.setValue(stringInfo); Button buttonDelete = new Button(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.addClickListener(ce -> { onDelete.run(); parent.removeComponent(panelRow); }); layoutRow.addComponents(labelInfo, buttonDelete); layoutRow.setComponentAlignment(buttonDelete, Alignment.MIDDLE_RIGHT); layoutRow.setComponentAlignment(labelInfo, Alignment.MIDDLE_LEFT); layoutRow.setWidth("100%"); layoutRow.setMargin(true); layoutRow.addStyleName("crawler"); panelRow.setContent(layoutRow); panelRow.setWidth("100%"); return panelRow; }
From source file:org.jpos.qi.QIEntityView.java
License:Open Source License
public void showSpecificView(final String parameter) { Object o = null;// w w w . j ava 2s . co m String[] params = parameter.split("/|\\?"); if (params.length > 0) { if ("new".equals(params[0]) && canAdd()) { o = createNewEntity(); newView = true; } else { o = getEntityByParam(params[0]); } if (parameter.contains("?")) { //Has query params. String[] queryParams = params[params.length - 1].split(","); for (String queryParam : queryParams) { String[] keyValue = queryParam.split("="); if (keyValue.length > 0 && "back".equals(keyValue[0])) { setGeneralRoute("/" + keyValue[1].replace(".", "/")); } } } } if (o == null) { getApp().getNavigator().navigateTo(""); getApp().displayNotification(getApp().getMessage("errorMessage.notExists", "<strong>" + getEntityName().toUpperCase() + "</strong>: " + params[0])); return; } Layout header = createHeader(title + ": " + getHeaderSpecificTitle(o)); addComponent(header); Panel panel = new Panel(); panel.setSizeFull(); addComponent(panel); final Layout formLayout = createForm(o, params, "new".equals(params[0])); panel.setContent(formLayout); setExpandRatio(panel, 1); if (!"new".equals(params[0]) && isShowRevisionHistoryButton()) { final Button showRevision = new Button(getApp().getMessage("showRevisionHistory")); showRevision.setStyleName(ValoTheme.BUTTON_LINK); showRevision.addClickListener(event -> { if (getApp().getMessage("showRevisionHistory").equals(event.getButton().getCaption())) { event.getButton().setCaption(getApp().getMessage("hideRevisionHistory")); loadRevisionHistory(formLayout, getEntityName().toLowerCase() + "." + params[0]); } else { event.getButton().setCaption(getApp().getMessage("showRevisionHistory")); formLayout.removeComponent(revisionsPanel); } }); formLayout.addComponent(showRevision); } }
From source file:org.jpos.qi.QIEntityView.java
License:Open Source License
protected boolean saveClick(Button.ClickEvent event, Layout formLayout) { if (binder.validate().isOk()) { if (getEntity(bean) == null) { try { saveEntity();/*from www . jav a 2s .c o m*/ } catch (BLException e) { getApp().getLog().error(e); getApp().displayNotification(e.getDetailedMessage()); return false; } } else { try { updateEntity(); } catch (BLException e) { getApp().getLog().error(e); getApp().displayNotification(e.getDetailedMessage()); return false; } } binder.setReadOnly(true); formLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); event.getButton().setVisible(false); cancelBtn.setVisible(false); editBtn.setVisible(true); removeBtn.setVisible(true); errorLabel.setValue(null); errorLabel.setVisible(false); if (revisionsPanel != null && revisionsPanel.getParent() != null) { Layout parent = (Layout) revisionsPanel.getParent(); parent.removeComponent(revisionsPanel); loadRevisionHistory(parent, revisionsPanel.getRef()); } return true; } else { BindingValidationStatus<?> result = binder.validate().getFieldValidationErrors().get(0); getApp().displayNotification(result.getResult().get().getErrorMessage()); return false; } }