List of usage examples for com.vaadin.ui HorizontalLayout setExpandRatio
public void setExpandRatio(Component component, float ratio)
This method is used to control how excess space in layout is distributed among components.
From source file:com.save.reports.reimbursement.ReimbursementReportUI.java
public ReimbursementReportUI() { setSizeFull();//from www. j a v a2s . c o m addComponent(mrDataGrid); setExpandRatio(mrDataGrid, 1); HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); h.setSpacing(true); h.setMargin(new MarginInfo(false, true, true, false)); Button filter = new CommonButton("FILTER"); filter.setWidth("200px"); filter.addClickListener(this); h.addComponent(filter); h.setComponentAlignment(filter, Alignment.MIDDLE_RIGHT); h.setExpandRatio(filter, 1); Button print = new CommonButton("EXPORT TO EXCEL"); print.setWidth("200px"); print.addClickListener(this); h.addComponent(print); h.setComponentAlignment(print, Alignment.MIDDLE_RIGHT); addComponent(h); }
From source file:com.selzlein.lojavirtual.vaadin.core.NavigationMenu.java
License:Open Source License
private void buildTopMenu() { final HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName("valo-menu-title"); final Label title = new Label("<h3>LSPS <strong>ProcessApplication</strong></h3>", ContentMode.HTML); title.setSizeUndefined();// ww w. jav a 2 s. c o m top.addComponent(title); top.setExpandRatio(title, 1); this.addComponent(top); final NavigationMenu menuWrapp = this; final Button showMenu = new Button("Menu", new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (menuWrapp.getStyleName().contains("valo-menu-visible")) { menuWrapp.removeStyleName("valo-menu-visible"); } else { menuWrapp.addStyleName("valo-menu-visible"); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName("valo-menu-toggle"); showMenu.setIcon(FontAwesome.LIST); this.addComponent(showMenu); }
From source file:com.selzlein.lojavirtual.vaadin.page.SettingsView.java
License:Open Source License
private void createView() { ui = (LspsUI) getUI();//from ww w . ja va 2 s .c o m user = ui.getUser().getPerson(); userRights = user.getRights(); setTitle(ui.getMessage(TITLE)); Panel panel = new Panel(); panel.addStyleName("l-border-none"); setContent(panel); VerticalLayout layout = new VerticalLayout(); layout.addStyleName("l-settings"); layout.setSizeFull(); layout.setSpacing(true); layout.setMargin(true); panel.setContent(layout); //user data and settings will be laid out next to each other HorizontalLayout topSection = new HorizontalLayout(); topSection.setSpacing(true); topSection.setWidth("100%"); layout.addComponent(topSection); VerticalLayout userData = createUserDataSection(ui, user); topSection.addComponent(userData); topSection.setExpandRatio(userData, 1); Label spacer = new Label(); spacer.setWidth("20px"); topSection.addComponent(spacer); VerticalLayout settings = createSettingsSection(ui); topSection.addComponent(settings); topSection.setExpandRatio(settings, 1); //substitution section VerticalLayout substitution = createSubstitutionSection(); layout.addComponent(substitution); layout.setExpandRatio(substitution, 2); //buttons HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); Button saveButton = new Button(ui.getMessage("action.save"), new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (save()) { if (requestReload) { JavaScript.getCurrent().execute("window.location.reload()"); } else { close(); } } } }); saveButton.setData(BUTTON_TYPE_SAVE); buttons.addComponent(saveButton); Button cancelButton = new Button(ui.getMessage("action.cancel"), new ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); buttons.addComponent(cancelButton); layout.addComponent(buttons); }
From source file:com.skysql.manager.ui.ChartsDialog.java
License:Open Source License
/** * Instantiates a new charts dialog./* w w w .j a v a2s. c om*/ * * @param chartsLayout the charts layout * @param chartButton the chart button */ public ChartsDialog(final ChartsLayout chartsLayout, final ChartButton chartButton) { this.chartButton = chartButton; this.chartsLayout = chartsLayout; dialogWindow = new ModalWindow("Monitors to Chart mapping", "775px"); HorizontalLayout wrapper = new HorizontalLayout(); //wrapper.setWidth("100%"); wrapper.setMargin(true); UI.getCurrent().addWindow(dialogWindow); newUserChart = (chartButton != null) ? new UserChart((UserChart) chartButton.getData()) : newUserChart(); ArrayList<String> monitorIDs = newUserChart.getMonitorIDs(); MonitorsLayout monitorsLayout = new MonitorsLayout(monitorIDs); wrapper.addComponent(monitorsLayout); VerticalLayout separator = new VerticalLayout(); separator.setSizeFull(); Embedded rightArrow = new Embedded(null, new ThemeResource("img/right_arrow.png")); separator.addComponent(rightArrow); separator.setComponentAlignment(rightArrow, Alignment.MIDDLE_CENTER); wrapper.addComponent(separator); ChartPreviewLayout chartPreviewLayout = new ChartPreviewLayout(newUserChart, chartsLayout.getTime(), chartsLayout.getInterval()); wrapper.addComponent(chartPreviewLayout); monitorsLayout.addChartPreview(chartPreviewLayout); HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Cancel"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { dialogWindow.close(); } }); Button okButton = new Button(chartButton != null ? "Save Changes" : "Add Chart"); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { try { ChartButton newChartButton = new ChartButton(newUserChart); newChartButton.setChartsLayout(chartsLayout); newChartButton.setEditable(true); if (chartButton != null) { chartsLayout.replaceComponent(chartButton, newChartButton); } else { chartsLayout.addComponent(newChartButton); } } catch (Exception e) { ManagerUI.error(e.getMessage()); } dialogWindow.close(); } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.addComponent(buttonsBar); }
From source file:com.skysql.manager.ui.components.SystemLayout.java
License:Open Source License
/** * Instantiates a new system layout./*from w w w. jav a 2 s. c o m*/ * * @param systemRecord the system record */ public SystemLayout(SystemRecord systemRecord) { addStyleName("systemLayout"); setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PERCENTAGE); setMargin(new MarginInfo(false, true, false, false)); final HorizontalLayout systemHeader = new HorizontalLayout(); systemHeader.addStyleName("panelHeaderLayout"); systemHeader.setSpacing(true); systemHeader.setWidth("100%"); systemHeader.setHeight("23px"); addComponent(systemHeader); backButton = new NativeButton(); backButton.setStyleName("backButton"); backButton.setDescription("Back to Systems"); systemHeader.addComponent(backButton); backButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { VaadinSession session = getSession(); SystemInfo systemInfo = session.getAttribute(SystemInfo.class); OverviewPanel overviewPanel = session.getAttribute(OverviewPanel.class); ComponentButton button = systemInfo.getCurrentSystem().getButton(); String parentID = systemInfo.getCurrentSystem().getParentID(); systemInfo.setCurrentSystem(parentID); session.setAttribute(SystemInfo.class, systemInfo); ManagerUI.log("new systemID: " + parentID); overviewPanel.clickLayout(button, false); overviewPanel.refresh(); } }); final Label systemLabel = new Label("Systems"); systemLabel.setSizeUndefined(); systemHeader.addComponent(systemLabel); systemHeader.setComponentAlignment(systemLabel, Alignment.MIDDLE_LEFT); systemHeader.setExpandRatio(systemLabel, 1.0f); systemSlot = new HorizontalLayout(); addComponent(systemSlot); // initialize System button refresh(null, null); }
From source file:com.skysql.manager.ui.ErrorDialog.java
License:Open Source License
/** * Instantiates a new error dialog.// w ww. j av a 2s. c o m * * @param e the exception * @param humanizedError the humanized error */ public ErrorDialog(Exception e, String humanizedError) { if (e != null) { ManagerUI.error(e.getMessage()); } dialogWindow = new ModalWindow("An Error has occurred", "775px"); dialogWindow.setHeight("340px"); dialogWindow.addCloseListener(this); UI current = UI.getCurrent(); if (current.getContent() == null) { current.setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null)); } current.addWindow(dialogWindow); HorizontalLayout wrapper = new HorizontalLayout(); wrapper.setSizeFull(); wrapper.setMargin(true); VerticalLayout iconLayout = new VerticalLayout(); iconLayout.setWidth("100px"); wrapper.addComponent(iconLayout); Embedded image = new Embedded(null, new ThemeResource("img/error.png")); iconLayout.addComponent(image); VerticalLayout textLayout = new VerticalLayout(); textLayout.setHeight("100%"); textLayout.setSpacing(true); wrapper.addComponent(textLayout); wrapper.setExpandRatio(textLayout, 1.0f); if (humanizedError != null || e != null) { String error = (humanizedError != null) ? humanizedError : e.toString(); ManagerUI.error(error); Label label = new Label(error, ContentMode.HTML); label.addStyleName("warning"); textLayout.addComponent(label); textLayout.setComponentAlignment(label, Alignment.TOP_CENTER); } if (e != null) { TextArea stackTrace = new TextArea("Error Log"); stackTrace.setSizeFull(); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); stackTrace.setValue(sw.toString()); textLayout.addComponent(stackTrace); textLayout.setComponentAlignment(stackTrace, Alignment.TOP_LEFT); textLayout.setExpandRatio(stackTrace, 1.0f); } HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Close"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { dialogWindow.close(); //UI.getCurrent().close(); } }); Button okButton = new Button("Send Error"); okButton.setEnabled(false); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { dialogWindow.close(); } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent(); windowLayout.setHeight("100%"); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.setExpandRatio(wrapper, 1.0f); windowLayout.addComponent(buttonsBar); }
From source file:com.skysql.manager.ui.MonitorsSettings.java
License:Open Source License
/** * Instantiates a new monitors settings. * * @param settingsDialog the settings dialog * @param systemID the system id//from w ww .j a v a 2 s. c om * @param systemType the system type */ MonitorsSettings(SettingsDialog settingsDialog, String systemID, String systemType) { this.settingsDialog = settingsDialog; this.systemID = systemID; this.systemType = systemType; addStyleName("monitorsTab"); setSizeFull(); setSpacing(true); setMargin(true); HorizontalLayout selectLayout = new HorizontalLayout(); addComponent(selectLayout); selectLayout.setSizeFull(); selectLayout.setSpacing(true); Monitors.reloadMonitors(); monitorsAll = Monitors.getMonitorsList(systemType); select = new ListSelect("Monitors"); select.setImmediate(true); for (MonitorRecord monitor : monitorsAll.values()) { String id = monitor.getID(); select.addItem(id); select.setItemCaption(id, monitor.getName()); } select.setNullSelectionAllowed(false); selectLayout.addComponent(select); select.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String monitorID = (String) event.getProperty().getValue(); displayMonitorRecord(monitorID); MonitorRecord monitor = monitorsAll.get(monitorID); if (monitor != null) { String monitorType = monitor.getType(); for (Monitors.EditableMonitorType editable : EditableMonitorType.values()) { if (editable.name().equals(monitorType)) { editMonitor.setEnabled(true); break; } } } } }); selectLayout.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void layoutClick(LayoutClickEvent event) { Component child; if (event.isDoubleClick() && (child = event.getChildComponent()) != null && (child instanceof ListSelect)) { // Get the child component which was double-clicked ListSelect select = (ListSelect) child; String monitorID = (String) select.getValue(); MonitorRecord monitor = monitorsAll.get(monitorID); String monitorType = monitor.getType(); for (Monitors.EditableMonitorType editable : EditableMonitorType.values()) { if (editable.name().equals(monitorType)) { editMonitor(monitor); break; } } } } }); monitorLayout = new FormLayout(); selectLayout.addComponent(monitorLayout); selectLayout.setExpandRatio(monitorLayout, 1.0f); monitorLayout.setSpacing(false); id.setCaption("ID:"); monitorLayout.addComponent(id); name.setCaption("Name:"); monitorLayout.addComponent(name); description.setCaption("Description:"); monitorLayout.addComponent(description); unit.setCaption("Unit:"); monitorLayout.addComponent(unit); // type.setCaption("Type:"); // monitorLayout.addComponent(type); delta.setCaption("Is Delta:"); monitorLayout.addComponent(delta); average.setCaption("Is Average:"); monitorLayout.addComponent(average); chartType.setCaption("Chart Type:"); monitorLayout.addComponent(chartType); interval.setCaption("Interval:"); monitorLayout.addComponent(interval); sql.setCaption("Statement:"); monitorLayout.addComponent(sql); HorizontalLayout selectButtons = new HorizontalLayout(); selectButtons.setSizeFull(); addComponent(selectButtons); selectButtons.setSpacing(true); Button addMonitor = new Button("Add..."); selectButtons.addComponent(addMonitor); selectButtons.setComponentAlignment(addMonitor, Alignment.MIDDLE_LEFT); addMonitor.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { addMonitor(); } }); deleteMonitor = new Button("Delete"); deleteMonitor.setEnabled(false); selectButtons.addComponent(deleteMonitor); selectButtons.setComponentAlignment(deleteMonitor, Alignment.MIDDLE_LEFT); deleteMonitor.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { String monitorID = (String) select.getValue(); if (monitorID != null) { deleteMonitor(monitorsAll.get(monitorID)); } } }); editMonitor = new Button("Edit..."); editMonitor.setEnabled(false); selectButtons.addComponent(editMonitor); selectButtons.setComponentAlignment(editMonitor, Alignment.MIDDLE_CENTER); selectButtons.setExpandRatio(editMonitor, 1.0f); editMonitor.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { String monitorID = (String) select.getValue(); if (monitorID != null) { editMonitor(monitorsAll.get(monitorID)); } } }); }
From source file:com.skysql.manager.ui.MonitorsSettings.java
License:Open Source License
/** * Monitor form.//from w w w . ja v a 2s . c o m * * @param monitor the monitor * @param title the title * @param description the description * @param button the button */ public void monitorForm(final MonitorRecord monitor, String title, String description, String button) { final TextField monitorName = new TextField("Monitor Name"); final TextField monitorDescription = new TextField("Description"); final TextField monitorUnit = new TextField("Measurement Unit"); final TextArea monitorSQL = new TextArea("SQL Statement"); final CheckBox monitorDelta = new CheckBox("Is Delta"); final CheckBox monitorAverage = new CheckBox("Is Average"); final NativeSelect validationTarget = new NativeSelect("Validate SQL on"); final NativeSelect monitorInterval = new NativeSelect("Sampling interval"); final NativeSelect monitorChartType = new NativeSelect("Default display"); secondaryDialog = new ModalWindow(title, null); UI.getCurrent().addWindow(secondaryDialog); secondaryDialog.addCloseListener(this); final VerticalLayout formContainer = new VerticalLayout(); formContainer.setMargin(new MarginInfo(true, true, false, true)); formContainer.setSpacing(false); final Form form = new Form(); formContainer.addComponent(form); form.setImmediate(false); form.setFooter(null); form.setDescription(description); String value; if ((value = monitor.getName()) != null) { monitorName.setValue(value); } form.addField("monitorName", monitorName); form.getField("monitorName").setRequired(true); form.getField("monitorName").setRequiredError("Monitor Name is missing"); monitorName.focus(); monitorName.setImmediate(true); monitorName.addValidator(new MonitorNameValidator(monitor.getName())); if ((value = monitor.getDescription()) != null) { monitorDescription.setValue(value); } monitorDescription.setWidth("24em"); form.addField("monitorDescription", monitorDescription); if ((value = monitor.getUnit()) != null) { monitorUnit.setValue(value); } form.addField("monitorUnit", monitorUnit); if ((value = monitor.getSql()) != null) { monitorSQL.setValue(value); } monitorSQL.setWidth("24em"); monitorSQL.addValidator(new SQLValidator()); form.addField("monitorSQL", monitorSQL); final String noValidation = "None - Skip Validation"; validationTarget.setImmediate(true); validationTarget.setNullSelectionAllowed(false); validationTarget.addItem(noValidation); validationTarget.select(noValidation); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); ArrayList<NodeInfo> nodes = overviewPanel.getNodes(); if (nodes == null || nodes.isEmpty()) { SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); String systemID = systemInfo.getCurrentID(); String systemType = systemInfo.getCurrentSystem().getSystemType(); if (systemID.equals(SystemInfo.SYSTEM_ROOT)) { ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class); systemID = clusterComponent.getID(); systemType = clusterComponent.getSystemType(); } nodes = new ArrayList<NodeInfo>(); for (String nodeID : systemInfo.getSystemRecord(systemID).getNodes()) { NodeInfo nodeInfo = new NodeInfo(systemID, systemType, nodeID); nodes.add(nodeInfo); } } for (NodeInfo node : nodes) { validationTarget.addItem(node.getID()); validationTarget.setItemCaption(node.getID(), node.getName()); } validationTarget.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { nodeID = (String) event.getProperty().getValue(); validateSQL = nodeID.equals(noValidation) ? false : true; } }); form.addField("validationTarget", validationTarget); monitorDelta.setValue(monitor.isDelta()); form.addField("monitorDelta", monitorDelta); monitorAverage.setValue(monitor.isAverage()); form.addField("monitorAverage", monitorAverage); SettingsValues intervalValues = new SettingsValues(SettingsValues.SETTINGS_MONITOR_INTERVAL); String[] intervals = intervalValues.getValues(); for (String interval : intervals) { monitorInterval.addItem(Integer.parseInt(interval)); } Collection<?> validIntervals = monitorInterval.getItemIds(); if (validIntervals.contains(monitor.getInterval())) { monitorInterval.select(monitor.getInterval()); } else { SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class); String defaultInterval = systemInfo.getSystemRecord(systemID).getProperties() .get(SystemInfo.PROPERTY_DEFAULTMONITORINTERVAL); if (defaultInterval != null && validIntervals.contains(Integer.parseInt(defaultInterval))) { monitorInterval.select(Integer.parseInt(defaultInterval)); } else if (!validIntervals.isEmpty()) { monitorInterval.select(validIntervals.toArray()[0]); } else { new ErrorDialog(null, "No set of permissible monitor intervals found"); } monitorInterval.setNullSelectionAllowed(false); form.addField("monitorInterval", monitorInterval); } for (UserChart.ChartType type : UserChart.ChartType.values()) { monitorChartType.addItem(type.name()); } monitorChartType .select(monitor.getChartType() == null ? UserChart.ChartType.values()[0] : monitor.getChartType()); monitorChartType.setNullSelectionAllowed(false); form.addField("monitorChartType", monitorChartType); HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Cancel"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { form.discard(); secondaryDialog.close(); } }); Button okButton = new Button(button); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { try { form.setComponentError(null); form.commit(); monitor.setName(monitorName.getValue()); monitor.setDescription(monitorDescription.getValue()); monitor.setUnit(monitorUnit.getValue()); monitor.setSql(monitorSQL.getValue()); monitor.setDelta(monitorDelta.getValue()); monitor.setAverage(monitorAverage.getValue()); monitor.setInterval((Integer) monitorInterval.getValue()); monitor.setChartType((String) monitorChartType.getValue()); String ID; if ((ID = monitor.getID()) == null) { if (Monitors.setMonitor(monitor)) { ID = monitor.getID(); select.addItem(ID); select.select(ID); Monitors.reloadMonitors(); monitorsAll = Monitors.getMonitorsList(systemType); } } else { Monitors.setMonitor(monitor); ChartProperties chartProperties = getSession().getAttribute(ChartProperties.class); chartProperties.setDirty(true); settingsDialog.setRefresh(true); } if (ID != null) { select.setItemCaption(ID, monitor.getName()); displayMonitorRecord(ID); secondaryDialog.close(); } } catch (EmptyValueException e) { return; } catch (InvalidValueException e) { return; } catch (Exception e) { ManagerUI.error(e.getMessage()); return; } } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(formContainer); windowLayout.addComponent(buttonsBar); }
From source file:com.skysql.manager.ui.OverviewPanel.java
License:Open Source License
/** * Instantiates a new overview panel.//from w w w . j ava 2s . c o 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.UsersSettings.java
License:Open Source License
/** * Instantiates a new users settings.//from w w w . j a va 2s . c o m */ UsersSettings() { addStyleName("usersTab"); setSizeFull(); setSpacing(true); setMargin(true); UserObject currentUser = VaadinSession.getCurrent().getAttribute(UserObject.class); currentUserID = currentUser.getUserID(); HorizontalLayout usersLayout = new HorizontalLayout(); addComponent(usersLayout); usersLayout.setSizeFull(); usersLayout.setSpacing(true); // make sure we're working with current info userInfo = new UserInfo(null); VaadinSession.getCurrent().setAttribute(UserInfo.class, userInfo); select = new ListSelect("Users"); select.setImmediate(true); for (UserObject user : userInfo.getUsersList().values()) { String id = user.getUserID(); select.addItem(id); if (id.equals(currentUserID)) { select.select(id); userName.setValue(user.getName()); selectedUserID = id; } } select.setNullSelectionAllowed(false); select.setWidth("14em"); usersLayout.addComponent(select); select.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { selectedUserID = (String) event.getProperty().getValue(); if (selectedUserID == null || selectedUserID.equals(currentUserID)) { removeUser.setEnabled(false); } else { removeUser.setEnabled(true); } if (selectedUserID == null) { editUser.setEnabled(false); userName.setEnabled(false); userName.setValue(""); } else { editUser.setEnabled(true); userName.setValue(userInfo.findNameByID(selectedUserID)); userName.setEnabled(true); } } }); usersLayout.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void layoutClick(LayoutClickEvent event) { Component child; if (event.isDoubleClick() && (child = event.getChildComponent()) != null && (child instanceof ListSelect)) { // Get the child component which was double-clicked ListSelect select = (ListSelect) child; String userID = (String) select.getValue(); new UserDialog(userInfo, userInfo.getUsersList().get(selectedUserID), thisObject); } } }); userLayout = new FormLayout(); usersLayout.addComponent(userLayout); usersLayout.setExpandRatio(userLayout, 1.0f); userLayout.setSpacing(false); userName.setCaption("Full Name:"); userLayout.addComponent(userName); HorizontalLayout userButtonsLayout = new HorizontalLayout(); userButtonsLayout.setSpacing(true); addComponent(userButtonsLayout); Button addUser = new Button("Add..."); addUser.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { new UserDialog(userInfo, null, thisObject); } }); userButtonsLayout.addComponent(addUser); userButtonsLayout.setComponentAlignment(addUser, Alignment.MIDDLE_LEFT); removeUser = new Button("Delete"); removeUser.setEnabled(false); removeUser.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { removeUser(event); } }); userButtonsLayout.addComponent(removeUser); userButtonsLayout.setComponentAlignment(removeUser, Alignment.MIDDLE_LEFT); editUser = new Button("Edit..."); editUser.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { new UserDialog(userInfo, userInfo.getUsersList().get(selectedUserID), thisObject); } }); userButtonsLayout.addComponent(editUser); userButtonsLayout.setComponentAlignment(editUser, Alignment.MIDDLE_CENTER); }