List of usage examples for com.vaadin.ui HorizontalLayout replaceComponent
@Override public void replaceComponent(Component oldComponent, Component newComponent)
From source file:com.skysql.manager.ui.OverviewPanel.java
License:Open Source License
/** * Instantiates a new overview panel.//from w ww . j av a2 s .co m */ public OverviewPanel() { HorizontalLayout overviewContainer = new HorizontalLayout(); overviewContainer.addStyleName("overviewPanel"); overviewContainer.setWidth("100%"); setContent(overviewContainer); systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); systemRecord = systemInfo.getCurrentSystem(); systemLayout = new SystemLayout(systemRecord); overviewContainer.addComponent(systemLayout); VerticalLayout nodesSlot = new VerticalLayout(); nodesSlot.addStyleName("nodesSlot"); nodesSlot.setMargin(new MarginInfo(false, false, false, false)); overviewContainer.addComponent(nodesSlot); overviewContainer.setExpandRatio(nodesSlot, 1.0f); final HorizontalLayout nodesHeader = new HorizontalLayout(); nodesHeader.setStyleName("panelHeaderLayout"); nodesHeader.setWidth("100%"); nodesSlot.addComponent(nodesHeader); nodesLabel = new Label(" "); nodesLabel.setSizeUndefined(); nodesHeader.addComponent(nodesLabel); nodesHeader.setComponentAlignment(nodesLabel, Alignment.MIDDLE_CENTER); nodesHeader.setExpandRatio(nodesLabel, 1.0f); final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(new MarginInfo(false, true, false, false)); nodesHeader.addComponent(buttonsLayout); nodesHeader.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT); addSystemButton = new Button("Add System..."); addSystemButton.setDescription("Add System"); addSystemButton.setVisible(false); buttonsLayout.addComponent(addSystemButton); addSystemButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new SystemDialog(null, null); } }); addNodeButton = new Button("Add Node..."); addNodeButton.setDescription("Add Node to the current System"); addNodeButton.setVisible(false); buttonsLayout.addComponent(addNodeButton); addNodeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new NodeDialog(null, null); } }); final Button editButton = new Button("Edit"); editButton.setDescription("Enter Editing mode"); final Button saveButton = new Button("Done"); saveButton.setDescription("Exit Editing mode"); buttonsLayout.addComponent(editButton); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(editButton, saveButton); isEditable = true; systemLayout.setEditable(true); nodesLayout.setEditable(true); nodesHeader.setStyleName("panelHeaderLayout-editable"); if (systemRecord != null && !SystemInfo.SYSTEM_ROOT.equals(systemRecord.getID())) { addNodeButton.setVisible(true); } else { addSystemButton.setVisible(true); } if (systemRecord == null || (systemRecord != null && systemRecord.getNodes().length == 0)) { nodesLayout.placeholderLayout(null); } } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(saveButton, editButton); isEditable = false; systemLayout.setEditable(false); nodesLayout.setEditable(false); nodesHeader.setStyleName("panelHeaderLayout"); if (systemRecord != null && systemRecord.getNodes().length == 0) { nodesLayout.placeholderLayout(null); } addNodeButton.setVisible(false); addSystemButton.setVisible(false); } }); Panel panel = new Panel(); panel.setHeight(PANEL_HEIGHT, Unit.PIXELS); panel.addStyleName(Runo.PANEL_LIGHT); nodesSlot.addComponent(panel); nodesLayout = new NodesLayout(systemRecord); nodesLayout.addStyleName("nodesLayout"); nodesLayout.setWidth("100%"); panel.setContent(nodesLayout); }
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the charts layout.//from w w w . ja va2 s. c o m */ private void createChartsLayout() { chartsLayout = new VerticalLayout(); chartsLayout.addStyleName("chartsLayout"); chartsLayout.setHeight("100%"); chartsLayout.setSpacing(true); addComponent(chartsLayout); final HorizontalLayout chartsHeaderLayout = new HorizontalLayout(); chartsHeaderLayout.setStyleName("panelHeaderLayout"); chartsHeaderLayout.setWidth("100%"); chartsHeaderLayout.setSpacing(true); chartsHeaderLayout.setMargin(new MarginInfo(false, true, false, true)); chartsLayout.addComponent(chartsHeaderLayout); chartControls = new ChartControls(); chartControls.addIntervalSelectionListener(chartIntervalListener); chartControls.addThemeSelectionListener(chartThemeListener); chartsHeaderLayout.addComponent(chartControls); chartsHeaderLayout.setComponentAlignment(chartControls, Alignment.MIDDLE_LEFT); final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); chartsHeaderLayout.addComponent(buttonsLayout); chartsHeaderLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT); SettingsDialog settingsDialog = new SettingsDialog("Edit Monitors...", "Monitors"); final Button editMonitorsButton = settingsDialog.getButton(); editMonitorsButton.setVisible(false); buttonsLayout.addComponent(editMonitorsButton); final Button addChartButton = new Button("Add Chart..."); addChartButton.setVisible(false); buttonsLayout.addComponent(addChartButton); addChartButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new ChartsDialog(chartsArrayLayout, null); } }); final Button editButton = new Button("Edit"); editButton.setDescription("Enter Editing mode"); final Button saveButton = new Button("Done"); saveButton.setDescription("Exit Editing mode"); buttonsLayout.addComponent(editButton); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(editButton, saveButton); chartsArrayLayout.setDragMode(LayoutDragMode.CLONE); chartsArrayLayout.setEditable(true); chartsHeaderLayout.setStyleName("panelHeaderLayout-editable"); editMonitorsButton.setVisible(true); addChartButton.setVisible(true); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(false); } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(saveButton, editButton); chartsArrayLayout.setDragMode(LayoutDragMode.NONE); chartsArrayLayout.setEditable(false); chartsHeaderLayout.setStyleName("panelHeaderLayout"); editMonitorsButton.setVisible(false); addChartButton.setVisible(false); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(true); refresh(); } }); final Button expandButton = new NativeButton(); expandButton.setStyleName("expandButton"); expandButton.setDescription("Expand/Reduce viewing area"); buttonsLayout.addComponent(expandButton); buttonsLayout.setComponentAlignment(expandButton, Alignment.MIDDLE_CENTER); expandButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { isExpanded = !isExpanded; AnimatorProxy proxy = getSession().getAttribute(AnimatorProxy.class); proxy.addListener(new AnimationListener() { public void onAnimation(AnimationEvent event) { Component component = event.getComponent(); component.setVisible(isExpanded ? false : true); } }); // OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); // if (!isExpanded) { // overviewPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(overviewPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); // // TopPanel topPanel = getSession().getAttribute(TopPanel.class); // if (!isExpanded) { // topPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(topPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); VerticalLayout topMid = getSession().getAttribute(VerticalLayout.class); if (!isExpanded) { topMid.setVisible(isExpanded ? false : true); } proxy.animate(topMid, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN) .setDuration(500).setDelay(100); expandButton.setStyleName(isExpanded ? "contractButton" : "expandButton"); } }); chartsPanel = new Panel(); chartsPanel.setSizeFull(); chartsPanel.addStyleName(Runo.PANEL_LIGHT); chartsLayout.addComponent(chartsPanel); chartsLayout.setExpandRatio(chartsPanel, 1.0f); }
From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java
License:Open Source License
/** * Returns with a label based on the edited field. * /*from w w w. j ava 2s .c om*/ * @param property * @return boolean an element switch happened or not */ public static boolean switchToLabelFromEditedField(HorizontalLayout parentLayout) { Preconditions.checkNotNull(parentLayout, "ParentLayout on DynamicLayout is null"); Component staticLabelComponent = null, dataComponent = null; try { staticLabelComponent = parentLayout.getComponent(0); dataComponent = parentLayout.getComponent(1); } catch (IndexOutOfBoundsException e) { LOG.error("This layout should contain only 2 components!"); return false; } Property dataProperty = null; Label label = null; if (dataComponent instanceof TextField) { dataProperty = ((TextField) dataComponent).getPropertyDataSource(); label = new Label(dataProperty); } else if (dataComponent instanceof ComboBox) { if (((ComboBox) dataComponent).getValue() instanceof String) { dataProperty = ((ComboBox) dataComponent).getPropertyDataSource(); if (dataProperty == null) { label = new Label((String) ((ComboBox) dataComponent).getValue()); } else { label = new Label(dataProperty); } } else if (((ComboBox) dataComponent).getValue() instanceof RigBean) { label = new Label(((RigBean) ((ComboBox) dataComponent).getValue()).getComplexId()); } else if (((ComboBox) dataComponent).getValue() instanceof UserBean) { label = new Label(((UserBean) ((ComboBox) dataComponent).getValue()).getComplexId()); } else if (((ComboBox) dataComponent).getValue() instanceof OrgUnitBean) { label = new Label(((OrgUnitBean) ((ComboBox) dataComponent).getValue()).getComplexId()); } else if (((ComboBox) dataComponent).getValue() instanceof FileFormatBean) { label = new Label(((FileFormatBean) ((ComboBox) dataComponent).getValue()).getTitle()); } else { LOG.error("Incorrect data type at the switch to label"); } } else if (dataComponent instanceof Label) { label = (Label) dataComponent; } else if (dataComponent instanceof CheckBox || dataComponent instanceof VerticalLayout) { return true; } if (label == null) { LOG.debug("The wrong dataComponent is " + dataComponent.toString()); return false; } label.setWidth(TEXT_WIDTH); label.setStyleName(STYLE_ELABS_TEXT_AS_LABEL); label.setDescription(USER_DESCR_ON_LABEL_TO_EDIT); parentLayout.replaceComponent(dataComponent, label); parentLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); ((Label) staticLabelComponent).setDescription(USER_DESCR_ON_LABEL_TO_EDIT); parentLayout.setDescription(USER_DESCR_ON_HOR_LAYOUT_TO_EDIT); return true; }
From source file:org.robot.gtf.gui.GTFApplication.java
License:Apache License
public void refreshTable(String mainProjectName, String scenarioName) { TestScenarioService testScenarioService = new DummyTestScenarioService(); List<TestcaseParametersTO> scenarioParameters = testScenarioService.readParameters(mainProjectName, scenarioName);/*from www .j av a2s . co m*/ if (table2 == null) { table2 = new Table("Testcases"); table2.setStyleName("iso3166"); table2.setWidth("100%"); table2.setHeight("170px"); table2.setEditable(true); for (TestcaseParametersTO testcaseParameterTO : scenarioParameters) { table2.addContainerProperty(testcaseParameterTO.getName(), String.class, null); } HorizontalLayout parent = (HorizontalLayout) table.getParent(); parent.replaceComponent(table, table2); table = null; } else { table = new Table("Testcases"); table.setStyleName("iso3166"); table.setWidth("100%"); table.setHeight("170px"); table.setEditable(true); for (TestcaseParametersTO testcaseParameterTO : scenarioParameters) { table.addContainerProperty(testcaseParameterTO.getName(), String.class, null); } HorizontalLayout parent = (HorizontalLayout) table2.getParent(); parent.replaceComponent(table2, table); table2 = null; } }