List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:com.skysql.manager.ui.GeneralSettings.java
License:Open Source License
/** * Time layout./*from w w w . jav a 2 s .co m*/ * * @return the vertical layout */ private VerticalLayout timeLayout() { VerticalLayout layout = new VerticalLayout(); layout.setWidth("100%"); layout.setSpacing(true); layout.setMargin(new MarginInfo(false, true, false, true)); HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setSpacing(true); layout.addComponent(titleLayout); final Label title = new Label("<h3>Date & Time Presentation</h3>", ContentMode.HTML); title.setSizeUndefined(); titleLayout.addComponent(title); Embedded info = new Embedded(null, new ThemeResource("img/info.png")); info.addStyleName("infoButton"); info.setDescription( "Determines if date & time stamps are displayed in the originally recorded format or adjusted to the local timezone.<br/>The format can be customized by using the following Java 6 SimpleDateFormat patterns:" + "</blockquote>" + " <table border=0 cellspacing=3 cellpadding=0 summary=\"Chart shows pattern letters, date/time component, presentation, and examples.\">\n" + " <tr bgcolor=\"#ccccff\">\n" + " <th align=left>Letter\n" + " <th align=left>Date or Time Component\n" + " <th align=left>Presentation\n" + " <th align=left>Examples\n" + " <tr>\n" + " <td><code>G</code>\n" + " <td>Era designator\n" + " <td><a href=\"#text\">Text</a>\n" + " <td><code>AD</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>y</code>\n" + " <td>Year\n" + " <td><a href=\"#year\">Year</a>\n" + " <td><code>1996</code>; <code>96</code>\n" + " <tr>\n" + " <td><code>M</code>\n" + " <td>Month in year\n" + " <td><a href=\"#month\">Month</a>\n" + " <td><code>July</code>; <code>Jul</code>; <code>07</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>w</code>\n" + " <td>Week in year\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>27</code>\n" + " <tr>\n" + " <td><code>W</code>\n" + " <td>Week in month\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>2</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>D</code>\n" + " <td>Day in year\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>189</code>\n" + " <tr>\n" + " <td><code>d</code>\n" + " <td>Day in month\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>10</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>F</code>\n" + " <td>Day of week in month\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>2</code>\n" + " <tr>\n" + " <td><code>E</code>\n" + " <td>Day in week\n" + " <td><a href=\"#text\">Text</a>\n" + " <td><code>Tuesday</code>; <code>Tue</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>a</code>\n" + " <td>Am/pm marker\n" + " <td><a href=\"#text\">Text</a>\n" + " <td><code>PM</code>\n" + " <tr>\n" + " <td><code>H</code>\n" + " <td>Hour in day (0-23)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>0</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>k</code>\n" + " <td>Hour in day (1-24)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>24</code>\n" + " <tr>\n" + " <td><code>K</code>\n" + " <td>Hour in am/pm (0-11)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>0</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>h</code>\n" + " <td>Hour in am/pm (1-12)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>12</code>\n" + " <tr>\n" + " <td><code>m</code>\n" + " <td>Minute in hour\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>30</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>s</code>\n" + " <td>Second in minute\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>55</code>\n" + " <tr>\n" + " <td><code>S</code>\n" + " <td>Millisecond\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>978</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>z</code>\n" + " <td>Time zone\n" + " <td><a href=\"#timezone\">General time zone</a>\n" + " <td><code>Pacific Standard Time</code>; <code>PST</code>; <code>GMT-08:00</code>\n" + " <tr>\n" + " <td><code>Z</code>\n" + " <td>Time zone\n" + " <td><a href=\"#rfc822timezone\">RFC 822 time zone</a>\n" + " <td><code>-0800</code>\n" + " </table>\n" + " </blockquote>\n" + ""); titleLayout.addComponent(info); titleLayout.setComponentAlignment(info, Alignment.MIDDLE_CENTER); final DateConversion dateConversion = VaadinSession.getCurrent().getAttribute(DateConversion.class); OptionGroup option = new OptionGroup("Display options"); option.addItem(false); option.setItemCaption(false, "Show time in UTC/GMT"); option.addItem(true); option.setItemCaption(true, "Adjust to local timezone (" + dateConversion.getClientTZname() + ")"); String propertyTimeAdjust = userObject.getProperty(UserObject.PROPERTY_TIME_ADJUST); option.select(propertyTimeAdjust == null ? DEFAULT_TIME_ADJUST : Boolean.valueOf(propertyTimeAdjust)); option.setNullSelectionAllowed(false); option.setHtmlContentAllowed(true); option.setImmediate(true); layout.addComponent(option); final HorizontalLayout defaultLayout = new HorizontalLayout(); defaultLayout.setSpacing(true); layout.addComponent(defaultLayout); final Form form = new Form(); form.setFooter(null); final TextField timeFormat = new TextField("Format"); form.addField("timeFormat", timeFormat); defaultLayout.addComponent(form); option.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); dateConversion.setAdjustedToLocal(value); userObject.setProperty(UserObject.PROPERTY_TIME_ADJUST, String.valueOf(value)); settingsDialog.setRefresh(true); if (value == false) { timeFormat.removeAllValidators(); timeFormat.setComponentError(null); form.setComponentError(null); form.setValidationVisible(false); settingsDialog.setClose(true); } else { timeFormat.addValidator(new TimeFormatValidator()); timeFormat.setInputPrompt(DateConversion.DEFAULT_TIME_FORMAT); //timeFormat.setClickShortcut(KeyCode.ENTER); } } }); String propertyTimeFormat = userObject.getProperty(UserObject.PROPERTY_TIME_FORMAT); propertyTimeFormat = (propertyTimeFormat == null ? DateConversion.DEFAULT_TIME_FORMAT : String.valueOf(propertyTimeFormat)); timeFormat.setColumns(16); timeFormat.setValue(propertyTimeFormat); timeFormat.setImmediate(true); timeFormat.setRequired(true); timeFormat.setRequiredError("Format cannot be empty."); timeFormat.addValidator(new TimeFormatValidator()); timeFormat.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); try { form.setComponentError(null); form.commit(); timeFormat.setComponentError(null); form.setValidationVisible(false); dateConversion.setFormat(value); userObject.setProperty(UserObject.PROPERTY_TIME_FORMAT, value); settingsDialog.setClose(true); settingsDialog.setRefresh(true); } catch (InvalidValueException e) { settingsDialog.setClose(false); timeFormat.setComponentError(new UserError("Invalid Format (Java SimpleDateFormat).")); timeFormat.focus(); } } }); Button defaultButton = new Button("Restore Default"); defaultLayout.addComponent(defaultButton); defaultLayout.setComponentAlignment(defaultButton, Alignment.MIDDLE_LEFT); defaultButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(Button.ClickEvent event) { timeFormat.setValue(DateConversion.DEFAULT_TIME_FORMAT); } }); return layout; }
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 w w.ja v a 2s . c o m * @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 ww . j a va 2 s . 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.NodeForm.java
License:Open Source License
/** * Instantiates a new node form.//from w ww . jav a 2 s . c o m * * @param node the node * @param description the description */ NodeForm(final NodeInfo node, String description) { this.node = node; setMargin(new MarginInfo(true, true, false, true)); setSpacing(false); isGalera = node.getSystemType().equals(SystemTypes.Type.galera.name()); HorizontalLayout formDescription = new HorizontalLayout(); formDescription.setSpacing(true); Embedded info = new Embedded(null, new ThemeResource("img/info.png")); info.addStyleName("infoButton"); String infoText = "<table border=0 cellspacing=3 cellpadding=0 summary=\"\">\n" + " <tr bgcolor=\"#ccccff\">" + " <th align=left>Field" + " <th align=left>Description" + " <tr>" + " <td><code>Name</code>" + " <td>Name of the Node" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Hostname</code>" + " <td>In some systems, a hostname that identifies the node" + " <tr>" + " <td><code>Instance ID</code>" + " <td>The instance ID field is for information only and is not used within the Manager" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Public IP</code>" + " <td>In some systems, the public IP address of the node" + " <tr>" + " <td><code>Private IP</code>" + " <td>The IP address that accesses the node internally to the manager"; if (!isGalera) { infoText += " <tr bgcolor=\"#eeeeff\">" + " <td><code>Database Username</code>" + " <td>Node system override for database user name" + " <tr>" + " <td><code>Database Password</code>" + " <td>Node system override for database password" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Replication Username</code>" + " <td>Node system override for replication user name" + " <tr>" + " <td><code>Replication Password</code>" + " <td>Node system override for replication password"; } infoText += " </table>" + " </blockquote>"; info.setDescription(infoText); formDescription.addComponent(info); Label labelDescription = new Label(description); formDescription.addComponent(labelDescription); formDescription.setComponentAlignment(labelDescription, Alignment.MIDDLE_LEFT); addComponent(formDescription); addComponent(form); form.setImmediate(false); form.setFooter(null); form.setDescription(null); String value; if ((value = node.getName()) != null) { name.setValue(value); } form.addField("name", name); name.focus(); name.setImmediate(true); name.addValidator(new NodeNameValidator(node.getName())); if ((value = node.getHostname()) != null) { hostname.setValue(value); } form.addField("hostname", hostname); if ((value = node.getInstanceID()) != null) { instanceID.setValue(value); } form.addField("instanceID", instanceID); if ((value = node.getPublicIP()) != null) { publicIP.setValue(value); } form.addField("publicIP", publicIP); if ((value = node.getPrivateIP()) != null) { privateIP.setValue(value); } form.addField("privateIP", privateIP); privateIP.setRequired(true); privateIP.setRequiredError("Private IP is a required field"); if (!isGalera) { if ((value = node.getDBUsername()) != null) { dbUsername.setValue(value); } form.addField("dbusername", dbUsername); dbUsername.setRequired(true); dbUsername.setImmediate(false); dbUsername.setRequiredError("Database Username is a required field"); dbUsername.addValidator(new UserNotRootValidator(dbUsername.getCaption())); if ((value = node.getDBPassword()) != null) { dbPassword.setValue(value); } form.addField("dbpassword", dbPassword); dbPassword.setRequired(true); dbPassword.setImmediate(false); dbPassword.setRequiredError("Database Password is a required field"); if ((value = node.getDBPassword()) != null) { dbPassword2.setValue(value); } form.addField("dbpassword2", dbPassword2); dbPassword2.setRequired(true); dbPassword2.setImmediate(true); dbPassword2.setRequiredError("Confirm Password is a required field"); dbPassword2.addValidator(new Password2Validator(dbPassword)); if ((value = node.getRepUsername()) != null) { repUsername.setValue(value); } form.addField("repusername", repUsername); repUsername.setRequired(true); repUsername.setImmediate(false); repUsername.setRequiredError("Replication Username is a required field"); repUsername.addValidator(new UserNotRootValidator(repUsername.getCaption())); if ((value = node.getRepPassword()) != null) { repPassword.setValue(value); } form.addField("reppassword", repPassword); repPassword.setRequired(true); repPassword.setImmediate(false); repPassword.setRequiredError("Replication Password is a required field"); if ((value = node.getRepPassword()) != null) { repPassword2.setValue(value); } form.addField("reppassword2", repPassword2); repPassword2.setRequired(true); repPassword2.setImmediate(true); repPassword2.setRequiredError("Confirm Password is a required field"); repPassword2.addValidator(new Password2Validator(repPassword)); } if (node.getID() == null) { Layout layout = form.getLayout(); { Label spacer = new Label(); spacer.setWidth("40px"); layout.addComponent(spacer); } HorizontalLayout optionLayout = new HorizontalLayout(); optionLayout.addStyleName("formInfoLayout"); optionLayout.setSpacing(true); optionLayout.setSizeUndefined(); layout.addComponent(optionLayout); Label padding = new Label("\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0"); optionLayout.addComponent(padding); Embedded info2 = new Embedded(null, new ThemeResource("img/info.png")); info2.addStyleName("infoButton"); info2.setDescription(connectionInfo); optionLayout.addComponent(info2); final Validator validator = new Password2Validator(connectPassword); final OptionGroup connectOption = new OptionGroup("Connection options"); connectOption.setSizeUndefined(); connectOption.addItem(false); connectOption.setItemCaption(false, "Node is not available, user will run connect later"); connectOption.addItem(true); connectOption.setItemCaption(true, "Node is available now, connect automatically"); connectOption.setImmediate(true); connectOption.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; @Override public void valueChange(ValueChangeEvent event) { runConnect = (Boolean) event.getProperty().getValue(); passwordOption.setVisible(runConnect); connectPassword.setRequired(runConnect && usePassword); connectPassword2.setRequired(runConnect && usePassword); connectKey.setRequired(runConnect && !usePassword); if (!runConnect) { connectPassword.setVisible(false); connectPassword2.setVisible(false); connectPassword2.removeValidator(validator); connectKey.setVisible(false); } else { if (usePassword) { connectPassword.setVisible(true); connectPassword2.setVisible(true); connectPassword2.addValidator(validator); } else { connectKey.setVisible(true); } } form.setComponentError(null); form.setValidationVisible(false); } }); optionLayout.addComponent(connectOption); optionLayout.setComponentAlignment(connectOption, Alignment.MIDDLE_LEFT); connectOption.select(true); passwordOption.addItem(true); passwordOption.setItemCaption(true, "Authenticate with root user"); passwordOption.addItem(false); passwordOption.setItemCaption(false, "Authenticate with SSH Key"); passwordOption.setImmediate(true); passwordOption.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; @Override public void valueChange(ValueChangeEvent event) { usePassword = (Boolean) event.getProperty().getValue(); if (usePassword) { connectPassword2.addValidator(validator); } else { connectPassword2.removeValidator(validator); } connectPassword.setVisible(usePassword); connectPassword.setRequired(usePassword); connectPassword2.setVisible(usePassword); connectPassword2.setRequired(usePassword); connectKey.setVisible(!usePassword); connectKey.setRequired(!usePassword); form.setComponentError(null); form.setValidationVisible(false); } }); layout.addComponent(passwordOption); passwordOption.select(false); form.addField("connectPassword", connectPassword); connectPassword.setImmediate(false); connectPassword.setRequiredError("Root Password is a required field"); form.addField("connectPassword2", connectPassword2); connectPassword2.setImmediate(true); connectPassword2.setRequiredError("Confirm Password is a required field"); form.addField("connectKey", connectKey); connectKey.setStyleName("sshkey"); connectKey.setColumns(41); connectKey.setRequiredError("SSH Key is a required field"); } }
From source file:com.skysql.manager.ui.OverviewPanel.java
License:Open Source License
/** * Instantiates a new overview panel./*from w w w.ja v a 2 s .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.PanelInfo.java
License:Open Source License
/** * Creates the info layout./*from www. ja v a 2s. c om*/ */ private void createInfoLayout() { infoLayout = new VerticalLayout(); infoLayout.addStyleName("infoLayout"); infoLayout.setWidth(PANEL_SPLIT_X, Unit.PIXELS); infoLayout.setSpacing(true); addComponent(infoLayout); final HorizontalLayout headerLayout = new HorizontalLayout(); headerLayout.addStyleName("panelHeaderLayout"); headerLayout.setWidth("100%"); headerLayout.setSpacing(true); headerLayout.setMargin(new MarginInfo(false, true, false, true)); infoLayout.addComponent(headerLayout); nameLabel = new Label(); nameLabel.addStyleName("nameLabel"); nameLabel.setSizeUndefined(); headerLayout.addComponent(nameLabel); headerLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT); final Button editButton = new Button("Edit"); editButton.setEnabled(false); headerLayout.addComponent(editButton); headerLayout.setComponentAlignment(editButton, Alignment.MIDDLE_RIGHT); // this will become the editing function of what properties are displayed in the info layout /*** final Button saveButton = new Button("Done"); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { nameField = new TextField(); nameField.setImmediate(true); nameField.setValue(nameLabel.getValue()); nameField.setWidth("12em"); nameField.focus(); nameField.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { saveButton.click(); } }); headerLayout.replaceComponent(nameLabel, nameField); headerLayout.setComponentAlignment(nameField, Alignment.MIDDLE_LEFT); headerLayout.replaceComponent(editButton, saveButton); headerLayout.setComponentAlignment(saveButton, Alignment.MIDDLE_RIGHT); } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { String name = nameField.getValue(); nameLabel.setValue(name); headerLayout.replaceComponent(nameField, nameLabel); headerLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT); headerLayout.replaceComponent(saveButton, editButton); headerLayout.setComponentAlignment(editButton, Alignment.MIDDLE_RIGHT); lastComponent.setName(name); if (lastComponent instanceof NodeInfo) { //((NodeInfo) lastComponent).saveName(name); } else if (lastComponent instanceof SystemRecord) { //systemInfo.saveName(name); } ComponentButton componentButton = lastComponent.getButton(); componentButton.setName(name); } }); ***/ systemLabels = new Label[systemLabelsStrings.length]; systemGrid = createCurrentInfo(systemLabels, systemLabelsStrings); nodeLabels = new Label[nodeLabelsStrings.length]; nodeGrid = createCurrentInfo(nodeLabels, nodeLabelsStrings); }
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the charts layout.//from w ww . j ava 2 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:com.skysql.manager.ui.SystemForm.java
License:Open Source License
/** * Instantiates a new system form./*from w w w .j a v a 2 s.co m*/ * * @param system the system * @param description the description * @param commitButton the commit button */ SystemForm(final SystemRecord system, String description, final Button commitButton) { this.system = system; setMargin(new MarginInfo(true, true, false, true)); setSpacing(false); HorizontalLayout formDescription = new HorizontalLayout(); formDescription.setSpacing(true); Embedded info = new Embedded(null, new ThemeResource("img/info.png")); info.addStyleName("infoButton"); String infoText = "<table border=0 cellspacing=3 cellpadding=0 summary=\"\">\n" + " <tr bgcolor=\"#ccccff\">" + " <th align=left>Field" + " <th align=left>Description" + " <tr>" + " <td><code>Name</code>" + " <td>Name of the system" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Type</code>" + " <td>Type of the system e.g. aws or galera" + " <tr>" + " <td><code>Database Username</code>" + " <td>System default for database user name" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Database Password</code>" + " <td>System default for database password" + " <tr>" + " <td><code>Replication Username</code>" + " <td>System default for replication user name" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Replication Password</code>" + " <td>System default for replication password" + " </table>" + " </blockquote>"; info.setDescription(infoText); formDescription.addComponent(info); Label labelDescription = new Label(description); formDescription.addComponent(labelDescription); formDescription.setComponentAlignment(labelDescription, Alignment.MIDDLE_LEFT); addComponent(formDescription); addComponent(form); form.setImmediate(false); form.setFooter(null); form.setDescription(null); String value; if ((value = system.getName()) != null) { name.setValue(value); } form.addField("name", name); name.focus(); name.setImmediate(true); name.addValidator(new SystemNameValidator(system.getName())); for (String systemType : SystemTypes.getList().keySet()) { this.systemType.addItem(systemType); } systemType.select(system.getSystemType() != null ? system.getSystemType() : SystemTypes.DEFAULT_SYSTEMTYPE); systemType.setNullSelectionAllowed(false); systemType.setEnabled(false); form.addField("systemType", systemType); if ((value = system.getDBUsername()) != null) { dbUsername.setValue(value); } else { dbUsername.setValue("skysql"); } form.addField("dbusername", dbUsername); dbUsername.setRequired(true); dbUsername.setImmediate(true); dbUsername.setRequiredError("Database Username is a required field"); dbUsername.addValidator(new UserNotRootValidator(dbUsername.getCaption())); if ((value = system.getDBPassword()) != null) { dbPassword.setValue(value); } form.addField("dbpassword", dbPassword); dbPassword.setRequired(true); dbPassword.setImmediate(false); dbPassword.setRequiredError("Database Password is a required field"); if ((value = system.getDBPassword()) != null) { dbPassword2.setValue(value); } form.addField("dbpassword2", dbPassword2); dbPassword2.setRequired(true); dbPassword2.setImmediate(true); dbPassword2.setRequiredError("Confirm Password is a required field"); dbPassword2.addValidator(new Password2Validator(dbPassword)); if ((value = system.getRepUsername()) != null) { repUsername.setValue(value); } else { repUsername.setValue("repluser"); } form.addField("repusername", repUsername); repUsername.setRequired(true); repUsername.setImmediate(true); repUsername.setRequiredError("Replication Username is a required field"); repUsername.addValidator(new UserNotRootValidator(repUsername.getCaption())); repUsername.addValidator(new UserDifferentValidator(dbUsername)); if ((value = system.getRepPassword()) != null) { repPassword.setValue(value); } form.addField("reppassword", repPassword); repPassword.setRequired(true); repPassword.setImmediate(true); repPassword.setRequiredError("Replication Password is a required field"); repPassword.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { commitButton.setClickShortcut(KeyCode.ENTER); } }); if ((value = system.getRepPassword()) != null) { repPassword2.setValue(value); } form.addField("reppassword2", repPassword2); repPassword2.setRequired(true); repPassword2.setImmediate(true); repPassword2.setRequiredError("Confirm Password is a required field"); repPassword2.addValidator(new Password2Validator(repPassword)); repPassword2.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { commitButton.focus(); } }); }
From source file:com.skysql.manager.ui.TopPanel.java
License:Open Source License
/** * Instantiates a new top panel./* www . ja v a 2 s.c om*/ */ public TopPanel() { setSpacing(true); addStyleName("titleLayout"); setWidth("100%"); Embedded logo = new Embedded(null, new ThemeResource("img/productlogo.png")); addComponent(logo); setComponentAlignment(logo, Alignment.BOTTOM_LEFT); // LINKS AREA (TOP-RIGHT) HorizontalLayout userSettingsLayout = new HorizontalLayout(); userSettingsLayout.setSizeUndefined(); userSettingsLayout.setSpacing(true); addComponent(userSettingsLayout); setComponentAlignment(userSettingsLayout, Alignment.MIDDLE_RIGHT); // User icon and name VerticalLayout userLayout = new VerticalLayout(); userSettingsLayout.addComponent(userLayout); userSettingsLayout.setComponentAlignment(userLayout, Alignment.BOTTOM_CENTER); UserObject userObject = VaadinSession.getCurrent().getAttribute(UserObject.class); String name = userObject.getAnyName(); userName = new Label("Welcome, " + name); userName.setSizeUndefined(); userLayout.addComponent(userName); // buttons HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSizeUndefined(); buttonsLayout.setSpacing(true); userSettingsLayout.addComponent(buttonsLayout); userSettingsLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_CENTER); // Settings button SettingsDialog settingsDialog = new SettingsDialog("Settings"); Button settingsButton = settingsDialog.getButton(); buttonsLayout.addComponent(settingsButton); buttonsLayout.setComponentAlignment(settingsButton, Alignment.MIDDLE_CENTER); // Logout Button logoutButton = new Button("Logout"); logoutButton.setSizeUndefined(); buttonsLayout.addComponent(logoutButton); buttonsLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_CENTER); logoutButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { UI.getCurrent().getPage().setLocation(""); UI.getCurrent().close(); getSession().setAttribute(UserObject.class, null); getSession().close(); } }); }
From source file:com.skysql.manager.ui.UsersSettings.java
License:Open Source License
/** * Instantiates a new users settings./*from w w w . java 2s . c om*/ */ 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); }