Example usage for com.vaadin.ui HorizontalLayout setMargin

List of usage examples for com.vaadin.ui HorizontalLayout setMargin

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setMargin.

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:com.save.client.ClientInformationForm.java

FormLayout clientInformationForm() {
    form.setMargin(false);/*from w  w w .  ja  v a  2s  .  c  o  m*/
    form.setWidth("100%");
    form.addStyleName("light");
    form.setReadOnly(readOnly);
    form.setImmediate(true);

    editClientBtn = new Button(EDIT_BUTTON_CAPTION, editBtnListener);
    editClientBtn.setEnabled(false);

    cancelBtn = new Button(CANCEL_BUTTON_CAPTION, cancelBtnListener);
    cancelBtn.setEnabled(false);

    newClientBtn = new Button(NEW_BUTTON_CAPTION, newBtnListener);

    client = new TextField("Name: ");
    client.setWidth("50%");
    client.setRequired(true);
    client.setRequiredError("Required Name!");
    form.addComponent(client);

    province.setInputPrompt("Select Province..");
    province.setRequired(true);
    province.setRequiredError("Required Province!");

    city.setInputPrompt("Select City..");
    city.setRequired(true);
    city.setRequiredError("Required City/Town!");

    province.addValueChangeListener(new ProvincePropertyChangeListener(city));
    province.setWidth("100%");
    form.addComponent(province);

    city.setWidth("100%");
    form.addComponent(city);

    address = new TextField("Street/Brgy: ");
    address.setWidth("50%");
    address.setRequired(true);
    address.setRequiredError("Required Street/Brgy!");
    form.addComponent(address);

    landline = new TextField("Landline No: ");
    landline.setWidth("50%");
    landline.setRequired(true);
    landline.setRequiredError("Required Contact No!");
    form.addComponent(landline);

    mobile = new TextField("Mobile No: ");
    mobile.setWidth("50%");
    mobile.setRequired(true);
    mobile.setRequiredError("Required Contact No!");
    form.addComponent(mobile);

    setAsDistributor = new OptionGroup("Distributor");
    setAsDistributor.addItems("Yes", "No");
    setAsDistributor.addStyleName("horizontal");
    setAsDistributor.setRequired(readOnly);
    setAsDistributor.setRequiredError("Set option(Y/N) As Distrbutor!");
    setAsDistributor.addValueChangeListener(distributorCheckboxListener);
    form.addComponent(setAsDistributor);

    clientType.setWidth("90%");
    clientType.setRequired(true);
    clientType.setRequiredError("Required Client Type!");
    clientType.setVisible(false);
    form.addComponent(clientType);

    if (getClientId() != 0) {
        editClientBtn.setEnabled(true);
        Client c = clientService.getClientDataById(getClientId());

        client.setValue(c.getClientName().toUpperCase());
        province.setValue(c.getProvince().getProvinceId());
        city.setValue(c.getCityId());
        address.setValue(c.getStreet());
        landline.setValue(c.getLandline());
        mobile.setValue(c.getMobile());

        if (c.getAsDistributor() == 0) {
            setAsDistributor.setValue("No");
            clientType.setVisible(true);
            clientType.setValue(c.getClientType());
        } else {
            setAsDistributor.setValue("Yes");
            clientType.setVisible(false);
            clientType.setValue("distributor");
        }
    }

    form.setReadOnly(true);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, true, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(editClientBtn);
    footer.addComponent(cancelBtn);
    footer.addComponent(newClientBtn);

    removeBtn = new Button("Remove Account");
    removeBtn.addClickListener(removeBtnListener);
    form.addComponent(removeBtn);

    disableFields(false);
    return form;
}

From source file:com.save.employee.PersonalInformationForm.java

public PersonalInformationForm(HorizontalSplitPanel hsplit, int employeeId, Grid grid, Object itemId) {
    this.hsplit = hsplit;
    this.employeeId = employeeId;
    this.grid = grid;
    this.itemId = itemId;

    setMargin(new MarginInfo(true, true, false, false));
    setWidth("80%");
    addStyleName("light");

    editBtn = new Button(BUTTON_CAPTION, editBtnListener);
    editBtn.setEnabled(false);//from   ww  w .  ja v a  2s.  c  o  m

    cancelBtn = new Button("CANCEL");
    cancelBtn.setEnabled(false);

    newEntryBtn = new Button("NEW ACCOUNT");

    employeeNoField = new TextField("Employee ID: ");
    employeeNoField.setWidth("50%");
    employeeNoField.setRequired(true);
    employeeNoField.setRequiredError("Required Employee ID!");
    addComponent(employeeNoField);

    firstname = new TextField("Firstname: ");
    firstname.setWidth("50%");
    firstname.setRequired(true);
    firstname.setRequiredError("Required Firstname!");
    addComponent(firstname);

    middlename = new TextField("Middlename: ");
    middlename.setWidth("50%");
    middlename.setRequired(true);
    middlename.setRequiredError("Required Middlename!");
    addComponent(middlename);

    lastname = new TextField("Lastname: ");
    lastname.setWidth("50%");
    lastname.setRequired(true);
    lastname.setRequiredError("Required Lastname!");
    addComponent(lastname);

    gender = new OptionGroup("Gender: ");
    gender.addItem("Female");
    gender.addItem("Male");
    gender.addStyleName("horizontal");
    addComponent(gender);

    status = new ComboBox("Status: ");
    status.setNullSelectionAllowed(false);
    status.addItem("Single");
    status.addItem("Married");
    status.addItem("Widow");
    status.addItem("Separated");
    addComponent(status);

    birthday = new DateField("Birthday");
    birthday.setValue(new Date());
    addComponent(birthday);

    if (getEmployeeId() != 0) {
        Employee e = es.getEmployeesPersonalDataById(getEmployeeId());
        employeeNoField.setValue(e.getEmployeeNo());
        firstname.setValue(e.getFirstname());
        middlename.setValue(e.getMiddlename());
        lastname.setValue(e.getLastname());
        gender.setValue(CommonUtilities.capitalizeFirstLetter(e.getGender()));
        status.setValue(e.getPersonalStatus());
        birthday.setValue((e.getDob() == null) ? new Date() : e.getDob());
        editBtn.setEnabled(true);
        cancelBtn.setEnabled(true);
    }

    setReadOnly(true);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    addComponent(footer);
    footer.addComponent(editBtn);
    footer.addComponent(cancelBtn);
    footer.addComponent(newEntryBtn);

    removeBtn = new Button("REMOVE ACCOUNT");
    removeBtn.addClickListener(removeBtnListener);
    addComponent(removeBtn);

    cancelBtn.addClickListener((Button.ClickEvent event) -> {
        setReadOnly(false);
        addStyleName("light");
        editBtn.setCaption(BUTTON_CAPTION);
        editBtn.removeStyleName("primary");
        setReadOnly(true);
        disableFields(false);
        newEntryBtn.setEnabled(true);
    });

    newEntryBtn.addClickListener((Button.ClickEvent event) -> {
        setReadOnly(true);
        addStyleName("light");
        editBtn.setCaption(BUTTON_CAPTION);
        editBtn.removeStyleName("primary");

        Window sub = new CreateNewAccountWindow(getHsplit());
        UI.getCurrent().addWindow(sub);
    });

    disableFields(false);
}

From source file:com.save.reports.maintenance.MaintenanceReportUI.java

public MaintenanceReportUI() {
    setSizeFull();//  w  w  w.j a  v  a 2s  . c om

    mrDataGrid.setFrozenColumnCount(2);
    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 exportToExcel = new CommonButton("EXPORT TO EXCEL");
    exportToExcel.setWidth("200px");
    exportToExcel.addClickListener(this);
    h.addComponent(exportToExcel);
    h.setComponentAlignment(exportToExcel, Alignment.MIDDLE_RIGHT);

    addComponent(h);
}

From source file:com.save.reports.promodeals.PromoDealReportUI.java

public PromoDealReportUI() {
    setSizeFull();/*from w w w. j  a v a 2 s.  c  o  m*/

    addComponent(promoDealGrid);
    setExpandRatio(promoDealGrid, 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 exportToExcel = new CommonButton("EXPORT TO EXCEL");
    exportToExcel.setWidth("200px");
    exportToExcel.addClickListener(this);
    h.addComponent(exportToExcel);
    h.setComponentAlignment(exportToExcel, Alignment.MIDDLE_RIGHT);

    addComponent(h);
}

From source file:com.save.reports.reimbursement.ReimbursementReportUI.java

public ReimbursementReportUI() {
    setSizeFull();/*  w w w.  j a  v a  2  s  . 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.siemens.ct.osgi.vaadin.pm.main.MainApplication.java

License:Open Source License

private Layout getHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setMargin(true);
    header.setSpacing(true);//from  w  ww.ja  va2s  .com
    // header.setStyleName(Reindeer.LAYOUT_BLACK);

    CssLayout titleLayout = new CssLayout();
    H2 title = new H2("Dynamic Vaadin OSGi Demo");
    titleLayout.addComponent(title);
    SmallText description = new SmallText(
            "Select the \"Bundle View\" tab and activate/stop OSGi bundles dynamically.");
    description.setSizeUndefined();
    titleLayout.addComponent(description);

    header.addComponent(titleLayout);

    return header;
}

From source file:com.skysql.manager.ui.CalendarDialog.java

License:Open Source License

/**
 * Inits the layout content.//from ww w  .j  a v a 2s  . co  m
 */
private void initLayoutContent() {
    initNavigationButtons();
    initAddNewEventButton();
    initHideWeekEndButton();
    //initAllScheduleButton();

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    hl.setSpacing(true);
    hl.setMargin(new MarginInfo(false, false, true, false));
    hl.addComponent(prevButton);
    hl.addComponent(captionLabel);
    hl.addComponent(monthButton);
    hl.addComponent(weekButton);
    hl.addComponent(nextButton);
    hl.setComponentAlignment(prevButton, Alignment.MIDDLE_LEFT);
    hl.setComponentAlignment(captionLabel, Alignment.MIDDLE_CENTER);
    hl.setComponentAlignment(monthButton, Alignment.MIDDLE_CENTER);
    hl.setComponentAlignment(weekButton, Alignment.MIDDLE_CENTER);
    hl.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT);

    monthButton.setVisible(viewMode == Mode.WEEK);
    weekButton.setVisible(viewMode == Mode.DAY);

    HorizontalLayout controlPanel = new HorizontalLayout();
    controlPanel.setSpacing(true);
    controlPanel.setMargin(new MarginInfo(false, false, true, false));
    controlPanel.setWidth("100%");
    //controlPanel.addComponent(localeSelect);
    //controlPanel.setComponentAlignment(localeSelect, Alignment.MIDDLE_LEFT);
    controlPanel.addComponent(timeZoneSelect);
    controlPanel.setComponentAlignment(timeZoneSelect, Alignment.MIDDLE_LEFT);
    //controlPanel.addComponent(formatSelect);
    //controlPanel.setComponentAlignment(formatSelect, Alignment.MIDDLE_LEFT);
    controlPanel.addComponent(addNewEvent);
    controlPanel.setComponentAlignment(addNewEvent, Alignment.BOTTOM_LEFT);
    controlPanel.addComponent(hideWeekendsButton);
    controlPanel.setComponentAlignment(hideWeekendsButton, Alignment.BOTTOM_LEFT);
    //controlPanel.addComponent(allScheduleButton);
    //controlPanel.setComponentAlignment(allScheduleButton, Alignment.MIDDLE_LEFT);

    VerticalLayout layout = (VerticalLayout) dialogWindow.getContent();
    layout.addComponent(controlPanel);
    layout.addComponent(hl);
    layout.addComponent(calendarComponent);
    layout.setExpandRatio(calendarComponent, 1);
}

From source file:com.skysql.manager.ui.ChartsDialog.java

License:Open Source License

/**
 * Instantiates a new charts dialog.//  www. jav a  2  s .c  o m
 *
 * @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.ErrorDialog.java

License:Open Source License

/**
 * Instantiates a new error dialog.//from  ww w . j  a  v  a  2  s . co  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

/**
 * Monitor form./* w w w.j a  v a2s .  c  om*/
 *
 * @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);

}