Example usage for com.vaadin.ui NativeSelect NativeSelect

List of usage examples for com.vaadin.ui NativeSelect NativeSelect

Introduction

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

Prototype

public NativeSelect(String caption) 

Source Link

Document

Creates a new NativeSelect with the given caption and no items.

Usage

From source file:org.opennms.features.topology.plugins.topo.bsm.info.SimulationModeReductionKeyInfoPanelItem.java

License:Open Source License

@Override
public Component getComponent(VertexRef ref, GraphContainer container) {
    final ReductionKeyVertex vertex = (ReductionKeyVertex) ref;
    final FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);/*from  w  w  w  .j a  v  a 2 s . c o m*/
    formLayout.setMargin(false);

    NativeSelect dropdown = new NativeSelect("Severity");
    dropdown.setMultiSelect(false);
    dropdown.setNewItemsAllowed(false);
    dropdown.setNullSelectionAllowed(true);
    dropdown.setImmediate(true);
    dropdown.setRequired(true);
    dropdown.addItems(Arrays.asList(Status.values()));

    SetStatusToCriteria setStatusTo = findCriteria(container, vertex);
    if (setStatusTo != null) {
        dropdown.setValue(setStatusTo.getStatus());
    } else {
        dropdown.setValue(null);
    }

    dropdown.addValueChangeListener(event -> {
        // The set of criteria may have changed since we last queried it above
        // do we issue try finding it again, instead of using the same existing object
        SetStatusToCriteria currentSetStatusTo = findCriteria(container, vertex);
        Status selectedStatus = (Status) dropdown.getValue();
        if (currentSetStatusTo != null) {
            currentSetStatusTo.setStatus(selectedStatus);
        } else {
            currentSetStatusTo = new SetStatusToCriteria(vertex.getReductionKey(), selectedStatus);
            container.addCriteria(currentSetStatusTo);
        }

        // Remove the current selection before redrawing the layout in order
        // to avoid centering on the current vertex
        container.getSelectionManager().setSelectedVertexRefs(Collections.emptyList());
        container.getSelectionManager().setSelectedEdgeRefs(Collections.emptyList());
        container.redoLayout();
    });
    formLayout.addComponent(dropdown);

    return formLayout;
}

From source file:org.opennms.features.topology.plugins.topo.bsm.info.SimulationModeReductionKeyInfoPanelItemProvider.java

License:Open Source License

private Component createComponent(ReductionKeyVertex vertex, GraphContainer container) {
    final FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);/*from   ww w  .  j  a  v a 2 s  .c o m*/
    formLayout.setMargin(false);

    NativeSelect dropdown = new NativeSelect("Severity");
    dropdown.setMultiSelect(false);
    dropdown.setNewItemsAllowed(false);
    dropdown.setNullSelectionAllowed(true);
    dropdown.setImmediate(true);
    dropdown.setRequired(true);
    dropdown.addItems(Arrays.asList(Status.values()));

    SetStatusToCriteria setStatusTo = findCriteria(container, vertex);
    if (setStatusTo != null) {
        dropdown.setValue(setStatusTo.getStatus());
    } else {
        dropdown.setValue(null);
    }

    dropdown.addValueChangeListener(event -> {
        // The set of criteria may have changed since we last queried it above
        // do we issue try finding it again, instead of using the same existing object
        SetStatusToCriteria currentSetStatusTo = findCriteria(container, vertex);
        Status selectedStatus = (Status) dropdown.getValue();
        if (currentSetStatusTo != null) {
            currentSetStatusTo.setStatus(selectedStatus);
        } else {
            currentSetStatusTo = new SetStatusToCriteria(vertex.getReductionKey(), selectedStatus);
            container.addCriteria(currentSetStatusTo);
        }

        // Remove the current selection before redrawing the layout in order
        // to avoid centering on the current vertex
        container.getSelectionManager().setSelectedVertexRefs(Collections.emptyList());
        container.getSelectionManager().setSelectedEdgeRefs(Collections.emptyList());
        container.redoLayout();
    });
    formLayout.addComponent(dropdown);

    return formLayout;
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.BSMConfigurationWindow.java

License:Open Source License

/**
 * Constructor for instantiating new objects of this class.
 *
 * @param dashletSpec the {@link DashletSpec} to be edited
 *//*from   w  w w.  j a va 2s. co  m*/
public BSMConfigurationWindow(DashletSpec dashletSpec) {
    /**
     * Setting the members
     */
    m_dashletSpec = dashletSpec;

    /**
     * Setting up the base layouts
     */

    setHeight(91, Unit.PERCENTAGE);
    setWidth(60, Unit.PERCENTAGE);

    /**
     * Retrieve the config...
     */

    boolean filterByName = BSMConfigHelper.getBooleanForKey(getDashletSpec().getParameters(), "filterByName");
    String nameValue = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "nameValue", "");
    boolean filterByAttribute = BSMConfigHelper.getBooleanForKey(getDashletSpec().getParameters(),
            "filterByAttribute");
    String attributeKey = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "attributeKey", "");
    String attributeValue = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "attributeValue",
            "");
    boolean filterBySeverity = BSMConfigHelper.getBooleanForKey(getDashletSpec().getParameters(),
            "filterBySeverity");
    String severityValue = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "severityValue",
            Status.WARNING.name());
    String severityCompareOperator = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(),
            "severityCompareOperator",
            BusinessServiceSearchCriteriaBuilder.CompareOperator.GreaterOrEqual.name());
    String orderBy = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "orderBy",
            BusinessServiceSearchCriteriaBuilder.Order.Name.name());
    String orderSequence = BSMConfigHelper.getStringForKey(getDashletSpec().getParameters(), "orderSequence",
            BusinessServiceSearchCriteriaBuilder.Sequence.Ascending.name());
    int resultsLimit = BSMConfigHelper.getIntForKey(getDashletSpec().getParameters(), "resultsLimit", 10);
    int columnCountBoard = BSMConfigHelper.getIntForKey(getDashletSpec().getParameters(), "columnCountBoard",
            10);
    int columnCountPanel = BSMConfigHelper.getIntForKey(getDashletSpec().getParameters(), "columnCountPanel",
            5);

    /**
     * Adding the "Filter By Name" panel
     */

    m_filterByNameCheckBox = new CheckBox();
    m_filterByNameCheckBox.setCaption("Enable");
    m_filterByNameCheckBox.setDescription("Filter by Business Service name");

    VerticalLayout nameLayout = new VerticalLayout();
    nameLayout.setSpacing(true);
    nameLayout.setMargin(true);
    nameLayout.setSizeFull();

    m_nameTextField = new TextField("Name (REGEXP)");
    m_nameTextField.setEnabled(false);

    addToComponent(nameLayout, m_filterByNameCheckBox);
    addToComponent(nameLayout, m_nameTextField);

    Panel namePanel = new Panel();
    namePanel.setCaption("Filter by Name");
    namePanel.setContent(nameLayout);

    m_filterByNameCheckBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            m_nameTextField.setEnabled(m_filterByNameCheckBox.getValue());
        }
    });

    m_nameTextField.setValue(nameValue);
    m_filterByNameCheckBox.setValue(filterByName);

    /**
     * Adding the "Filter By Attribute" panel
     */

    m_filterByAttributeCheckBox = new CheckBox();
    m_filterByAttributeCheckBox.setCaption("Enable");
    m_filterByAttributeCheckBox.setDescription("Filter by Business Service attribute");

    VerticalLayout attributeLayout = new VerticalLayout();
    attributeLayout.setSpacing(true);
    attributeLayout.setMargin(true);
    attributeLayout.setSizeFull();

    m_attributeKeyTextField = new TextField("Key");
    m_attributeKeyTextField.setEnabled(false);
    m_attributeValueTextField = new TextField("Value (REGEXP)");
    m_attributeValueTextField.setEnabled(false);
    addToComponent(attributeLayout, m_filterByAttributeCheckBox);
    addToComponent(attributeLayout, m_attributeKeyTextField);
    addToComponent(attributeLayout, m_attributeValueTextField);

    Panel attributePanel = new Panel();
    attributePanel.setCaption("Filter by Attribute");
    attributePanel.setContent(attributeLayout);

    m_filterByAttributeCheckBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            m_attributeKeyTextField.setEnabled(m_filterByAttributeCheckBox.getValue());
            m_attributeValueTextField.setEnabled(m_filterByAttributeCheckBox.getValue());
        }
    });

    m_attributeKeyTextField.setValue(attributeKey);
    m_attributeValueTextField.setValue(attributeValue);
    m_filterByAttributeCheckBox.setValue(filterByAttribute);

    /**
     * Adding the "Filter By Severity" panel
     */

    m_filterBySeverityCheckBox = new CheckBox();
    m_filterBySeverityCheckBox.setCaption("Enable");
    m_filterBySeverityCheckBox.setDescription("Filter by Business Service severity");

    VerticalLayout severityLayout = new VerticalLayout();
    severityLayout.setSpacing(true);
    severityLayout.setMargin(true);
    severityLayout.setSizeFull();

    m_severitySelect = new NativeSelect("Severity");
    m_severitySelect.setEnabled(false);
    m_severitySelect.setNullSelectionAllowed(false);
    m_severitySelect.setMultiSelect(false);

    for (Status eachStatus : Status.values()) {
        m_severitySelect.addItem(eachStatus.name());
    }

    m_compareOperatorSelect = new NativeSelect("Comparator");
    m_compareOperatorSelect.setEnabled(false);
    m_compareOperatorSelect.setNullSelectionAllowed(false);
    m_compareOperatorSelect.setMultiSelect(false);

    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.Lower.name());
    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.LowerOrEqual.name());
    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.Equal.name());
    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.GreaterOrEqual.name());
    m_compareOperatorSelect.addItem(BusinessServiceSearchCriteriaBuilder.CompareOperator.Greater.name());

    addToComponent(severityLayout, m_filterBySeverityCheckBox);
    addToComponent(severityLayout, m_severitySelect);
    addToComponent(severityLayout, m_compareOperatorSelect);

    Panel severityPanel = new Panel();
    severityPanel.setCaption("Filter by Severity");
    severityPanel.setContent(severityLayout);

    m_filterBySeverityCheckBox.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            m_severitySelect.setEnabled(m_filterBySeverityCheckBox.getValue());
            m_compareOperatorSelect.setEnabled(m_filterBySeverityCheckBox.getValue());
        }
    });

    m_severitySelect.setValue(severityValue);
    m_compareOperatorSelect.setValue(severityCompareOperator);
    m_filterBySeverityCheckBox.setValue(filterBySeverity);

    /**
     * Adding the "Results" panel
     */

    VerticalLayout limitLayout = new VerticalLayout();
    limitLayout.setSpacing(true);
    limitLayout.setMargin(true);
    limitLayout.setSizeFull();

    m_limitTextField = new TextField("Limit");

    m_orderBy = new NativeSelect("Order by");
    m_orderBy.setNullSelectionAllowed(false);
    m_orderBy.setMultiSelect(false);

    m_orderBy.addItem(BusinessServiceSearchCriteriaBuilder.Order.Name.name());
    m_orderBy.addItem(BusinessServiceSearchCriteriaBuilder.Order.Severity.name());
    m_orderBy.addItem(BusinessServiceSearchCriteriaBuilder.Order.Level.name());

    m_orderSequence = new NativeSelect("Asc/Desc ");
    m_orderSequence.setNullSelectionAllowed(false);
    m_orderSequence.setMultiSelect(false);

    m_orderSequence.addItem("Ascending");
    m_orderSequence.addItem("Descending");

    m_columnCountBoardTextField = new TextField("Ops Board Column Count");
    m_columnCountBoardTextField.addValidator(new AbstractStringValidator("Number greater zero expected") {
        @Override
        protected boolean isValidValue(String value) {
            try {
                int i = Integer.parseInt(value);
                return i > 0;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    });

    m_columnCountPanelTextField = new TextField("Ops Panel Column Count");
    m_columnCountPanelTextField.addValidator(new AbstractStringValidator("Number greater zero expected") {
        @Override
        protected boolean isValidValue(String value) {
            try {
                int i = Integer.parseInt(value);
                return i > 0;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    });

    addToComponent(limitLayout, m_limitTextField);
    addToComponent(limitLayout, m_orderBy);
    addToComponent(limitLayout, m_orderSequence);
    addToComponent(limitLayout, m_columnCountBoardTextField);
    addToComponent(limitLayout, m_columnCountPanelTextField);

    Panel limitPanel = new Panel();
    limitPanel.setSizeFull();
    limitPanel.setCaption("Results");
    limitPanel.setContent(limitLayout);

    m_limitTextField.setValue(String.valueOf(resultsLimit));
    m_orderBy.setValue(orderBy);
    m_orderSequence.setValue(orderSequence);
    m_columnCountBoardTextField.setValue(String.valueOf(columnCountBoard));
    m_columnCountPanelTextField.setValue(String.valueOf(columnCountPanel));

    m_limitTextField.addValidator(new AbstractStringValidator("Number greater or equal zero expected") {
        @Override
        protected boolean isValidValue(String value) {
            try {
                int i = Integer.parseInt(value);
                return i >= 0;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    });

    /**
     * Create the main layout...
     */

    VerticalLayout verticalLayout = new VerticalLayout();

    verticalLayout.setWidth(100, Unit.PERCENTAGE);
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);

    verticalLayout.addComponent(namePanel);
    verticalLayout.addComponent(attributePanel);

    HorizontalLayout bottomLayout = new HorizontalLayout(severityPanel, limitPanel);
    bottomLayout.setSpacing(true);
    bottomLayout.setSizeFull();
    bottomLayout.setWidth(100, Unit.PERCENTAGE);

    verticalLayout.addComponent(bottomLayout);

    /**
     * Using an additional {@link HorizontalLayout} for layouting the buttons
     */
    HorizontalLayout buttonLayout = new HorizontalLayout();

    buttonLayout.setMargin(true);
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth("100%");

    Label label = new Label("Note: Multiple enabled filter constraints will be combined by a logical AND.");
    buttonLayout.addComponent(label);
    buttonLayout.setExpandRatio(label, 1.0f);

    /**
     * Adding the cancel button...
     */
    Button cancel = new Button("Cancel");
    cancel.setDescription("Cancel editing");
    cancel.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });

    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
    buttonLayout.addComponent(cancel);
    buttonLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT);

    /**
     * ...and the OK button
     */
    Button ok = new Button("Save");
    ok.setDescription("Save properties and close");
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!m_limitTextField.isValid() || !m_columnCountPanelTextField.isValid()
                    || !m_columnCountBoardTextField.isValid()) {
                return;
            }

            m_dashletSpec.getParameters().put("filterByName",
                    (m_filterByNameCheckBox.getValue() ? "true" : "false"));

            if (m_filterByNameCheckBox.getValue()) {
                m_dashletSpec.getParameters().put("nameValue", m_nameTextField.getValue());
            } else {
                m_dashletSpec.getParameters().put("nameValue", "");
            }

            m_dashletSpec.getParameters().put("filterByAttribute",
                    (m_filterByAttributeCheckBox.getValue() ? "true" : "false"));

            if (m_filterByAttributeCheckBox.getValue()) {
                m_dashletSpec.getParameters().put("attributeKey", m_attributeKeyTextField.getValue());
                m_dashletSpec.getParameters().put("attributeValue", m_attributeValueTextField.getValue());
            } else {
                m_dashletSpec.getParameters().put("attributeKey", "");
                m_dashletSpec.getParameters().put("attributeValue", "");
            }

            m_dashletSpec.getParameters().put("filterBySeverity",
                    (m_filterBySeverityCheckBox.getValue() ? "true" : "false"));

            if (m_filterBySeverityCheckBox.getValue() && m_severitySelect.getValue() != null) {
                m_dashletSpec.getParameters().put("severityValue", m_severitySelect.getValue().toString());
            } else {
                m_dashletSpec.getParameters().put("severityValue", Status.WARNING.getLabel());
            }

            if (m_filterBySeverityCheckBox.getValue() && m_compareOperatorSelect.getValue() != null) {
                m_dashletSpec.getParameters().put("severityCompareOperator",
                        m_compareOperatorSelect.getValue().toString());
            } else {
                m_dashletSpec.getParameters().put("severityCompareOperator",
                        BusinessServiceSearchCriteriaBuilder.CompareOperator.GreaterOrEqual.name());
            }

            if (m_orderBy.getValue() != null) {
                m_dashletSpec.getParameters().put("orderBy", m_orderBy.getValue().toString());
            } else {
                m_dashletSpec.getParameters().put("orderBy",
                        BusinessServiceSearchCriteriaBuilder.Order.Name.name());
            }

            if (m_orderSequence.getValue() != null) {
                m_dashletSpec.getParameters().put("orderSequence", m_orderSequence.getValue().toString());
            } else {
                m_dashletSpec.getParameters().put("orderSequence", "Ascending");
            }

            m_dashletSpec.getParameters().put("resultsLimit", m_limitTextField.getValue().toString());
            m_dashletSpec.getParameters().put("columnCountBoard",
                    m_columnCountBoardTextField.getValue().toString());
            m_dashletSpec.getParameters().put("columnCountPanel",
                    m_columnCountPanelTextField.getValue().toString());

            WallboardProvider.getInstance().save();
            ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Properties");

            close();
        }
    });

    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    buttonLayout.addComponent(ok);

    /**
     * Adding the layout and setting the content
     */
    verticalLayout.addComponent(buttonLayout);

    setContent(verticalLayout);
}

From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceEdgeEditWindow.java

License:Open Source License

/**
 * Constructor/*from w ww. jav  a2 s. com*/
 *
 * @param businessService        the Business Service DTO instance to be configured
 * @param businessServiceManager the Business Service Manager
 */
@SuppressWarnings("unchecked")
public BusinessServiceEdgeEditWindow(final BusinessService businessService,
        final BusinessServiceManager businessServiceManager, final Edge edge) {
    super("Business Service Edge Edit");

    /**
     * Basic window setup
     */
    setModal(true);
    setClosable(false);
    setResizable(false);
    setWidth(650, Unit.PIXELS);
    setHeight(325, Unit.PIXELS);

    /**
     * Creating the root layout...
     */
    final VerticalLayout rootLayout = new VerticalLayout();
    rootLayout.setSpacing(true);
    rootLayout.setMargin(false);

    /**
     * ...and the nested layout
     */
    final FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(true);
    formLayout.setMargin(true);

    /**
     * type selector box
     */
    m_typeSelect = new NativeSelect("Type");
    m_typeSelect.setId("edgeTypeSelector");
    m_typeSelect.setMultiSelect(false);
    m_typeSelect.setNewItemsAllowed(false);
    m_typeSelect.setNullSelectionAllowed(false);
    m_typeSelect.setRequired(true);
    m_typeSelect.addItem(EdgeType.CHILD_SERVICE);
    m_typeSelect.setItemCaption(EdgeType.CHILD_SERVICE, "Child Service");
    m_typeSelect.addItem(EdgeType.IP_SERVICE);
    m_typeSelect.setItemCaption(EdgeType.IP_SERVICE, "IP Service");
    m_typeSelect.addItem(EdgeType.REDUCTION_KEY);
    m_typeSelect.setItemCaption(EdgeType.REDUCTION_KEY, "Reduction Key");
    m_typeSelect.setWidth(100.0f, Unit.PERCENTAGE);
    formLayout.addComponent(m_typeSelect);

    // List of child services
    m_childServiceComponent = new ComboBox("Child Service");
    m_childServiceComponent.setId("childServiceList");
    m_childServiceComponent.setInputPrompt("No child service selected");
    m_childServiceComponent.setNewItemsAllowed(false);
    m_childServiceComponent.setNullSelectionAllowed(false);
    m_childServiceComponent.setWidth(100.0f, Unit.PERCENTAGE);
    m_childServiceComponent.setVisible(false);
    m_childServiceComponent.setImmediate(true);
    m_childServiceComponent.setValidationVisible(true);
    m_childServiceComponent.setFilteringMode(FilteringMode.CONTAINS);
    m_childServiceComponent.addItems(businessServiceManager.getFeasibleChildServices(businessService).stream()
            .sorted(Ordering.natural().onResultOf(s -> BusinessServiceEditWindow.describeBusinessService(s)))
            .collect(Collectors.toList()));
    m_childServiceComponent.getItemIds().forEach(item -> m_childServiceComponent.setItemCaption(item,
            BusinessServiceEditWindow.describeBusinessService((BusinessService) item)));
    formLayout.addComponent(m_childServiceComponent);

    // List of IP services
    m_ipServiceComponent = new ComboBox("IP Service");
    m_ipServiceComponent.setId("ipServiceList");
    m_ipServiceComponent.setInputPrompt("No IP service selected");
    m_ipServiceComponent.setNewItemsAllowed(false);
    m_ipServiceComponent.setNullSelectionAllowed(false);
    m_ipServiceComponent.setWidth(100.0f, Unit.PERCENTAGE);
    m_ipServiceComponent.setVisible(false);
    m_ipServiceComponent.setImmediate(true);
    m_ipServiceComponent.setValidationVisible(true);
    m_ipServiceComponent.setFilteringMode(FilteringMode.CONTAINS);
    m_ipServiceComponent.addItems(businessServiceManager.getAllIpServices().stream()
            .sorted(Ordering.natural().onResultOf(s -> BusinessServiceEditWindow.describeIpService(s)))
            .collect(Collectors.toList()));
    m_ipServiceComponent.getItemIds().forEach(item -> m_ipServiceComponent.setItemCaption(item,
            BusinessServiceEditWindow.describeIpService((IpService) item)));
    formLayout.addComponent(m_ipServiceComponent);

    /**
     * reduction key input field
     */
    m_reductionKeyComponent = new TextField("Reduction Key");
    m_reductionKeyComponent.setId("reductionKeyField");
    m_reductionKeyComponent.setWidth(100.0f, Unit.PERCENTAGE);
    m_reductionKeyComponent.setVisible(false);
    m_reductionKeyComponent.setImmediate(true);
    m_reductionKeyComponent.setValidationVisible(true);
    formLayout.addComponent(m_reductionKeyComponent);

    /**
     * the friendly name
     */

    m_friendlyNameField = new TextField("Friendly Name");
    m_friendlyNameField.setId("friendlyNameField");
    m_friendlyNameField.setWidth(100.0f, Unit.PERCENTAGE);
    m_friendlyNameField.setVisible(false);
    m_friendlyNameField.setImmediate(true);
    m_friendlyNameField.setValidationVisible(true);
    m_friendlyNameField.setNullSettingAllowed(true);
    m_friendlyNameField.setNullRepresentation("");
    m_friendlyNameField.setMaxLength(FRIENDLY_NAME_MAXLENGTH);
    formLayout.addComponent(m_friendlyNameField);

    /**
     * show and hide components
     */
    m_typeSelect.addValueChangeListener(event -> {
        m_childServiceComponent.setVisible(m_typeSelect.getValue() == EdgeType.CHILD_SERVICE);
        m_childServiceComponent.setRequired(m_typeSelect.getValue() == EdgeType.CHILD_SERVICE);
        m_ipServiceComponent.setVisible(m_typeSelect.getValue() == EdgeType.IP_SERVICE);
        m_ipServiceComponent.setRequired(m_typeSelect.getValue() == EdgeType.IP_SERVICE);
        m_reductionKeyComponent.setVisible(m_typeSelect.getValue() == EdgeType.REDUCTION_KEY);
        m_reductionKeyComponent.setRequired(m_typeSelect.getValue() == EdgeType.REDUCTION_KEY);
        m_friendlyNameField.setVisible(m_typeSelect.getValue() == EdgeType.REDUCTION_KEY
                || m_typeSelect.getValue() == EdgeType.IP_SERVICE);
    });

    /**
     * map function field
     */
    m_mapFunctionSelect = new NativeSelect("Map Function", ImmutableList.builder().add(Decrease.class)
            .add(Identity.class).add(Ignore.class).add(Increase.class).add(SetTo.class).build());
    m_mapFunctionSelect.setId("mapFunctionSelector");
    m_mapFunctionSelect.setNullSelectionAllowed(false);
    m_mapFunctionSelect.setMultiSelect(false);
    m_mapFunctionSelect.setNewItemsAllowed(false);
    m_mapFunctionSelect.setRequired(true);
    m_mapFunctionSelect.setWidth(100.0f, Unit.PERCENTAGE);

    /**
     * setting the captions for items
     */
    m_mapFunctionSelect.getItemIds()
            .forEach(itemId -> m_mapFunctionSelect.setItemCaption(itemId, ((Class<?>) itemId).getSimpleName()));

    formLayout.addComponent(m_mapFunctionSelect);

    /**
     * severity selection field
     */
    m_mapFunctionSeveritySelect = new NativeSelect("Severity");
    m_mapFunctionSeveritySelect.setMultiSelect(false);
    m_mapFunctionSeveritySelect.setNewItemsAllowed(false);
    m_mapFunctionSeveritySelect.setNullSelectionAllowed(false);
    m_mapFunctionSeveritySelect.setRequired(false);
    m_mapFunctionSeveritySelect.addItem(Status.CRITICAL);
    m_mapFunctionSeveritySelect.setItemCaption(Status.CRITICAL, "Critical");
    m_mapFunctionSeveritySelect.addItem(Status.MAJOR);
    m_mapFunctionSeveritySelect.setItemCaption(Status.MAJOR, "Major");
    m_mapFunctionSeveritySelect.addItem(Status.MINOR);
    m_mapFunctionSeveritySelect.setItemCaption(Status.MINOR, "Minor");
    m_mapFunctionSeveritySelect.addItem(Status.WARNING);
    m_mapFunctionSeveritySelect.setItemCaption(Status.WARNING, "Warning");
    m_mapFunctionSeveritySelect.addItem(Status.NORMAL);
    m_mapFunctionSeveritySelect.setItemCaption(Status.NORMAL, "Normal");
    m_mapFunctionSeveritySelect.addItem(Status.INDETERMINATE);
    m_mapFunctionSeveritySelect.setItemCaption(Status.INDETERMINATE, "Indeterminate");
    m_mapFunctionSeveritySelect.setWidth(100.0f, Unit.PERCENTAGE);
    m_mapFunctionSeveritySelect.setEnabled(false);
    m_mapFunctionSeveritySelect.setImmediate(true);
    m_mapFunctionSeveritySelect.setValidationVisible(true);
    formLayout.addComponent(m_mapFunctionSeveritySelect);

    /**
     * hide or show additional severity input field
     */
    m_mapFunctionSelect.addValueChangeListener(event -> {
        m_mapFunctionSeveritySelect.setEnabled(SetTo.class.equals(m_mapFunctionSelect.getValue()));
        m_mapFunctionSeveritySelect.setRequired(SetTo.class.equals(m_mapFunctionSelect.getValue()));
    });

    /**
     * the weight input field
     */
    m_weightField = new TextField("Weight");
    m_weightField.setId("weightField");
    m_weightField.setRequired(true);
    m_weightField.setWidth(100.0f, Unit.PERCENTAGE);
    m_weightField.addValidator(value -> {
        try {
            int intValue = Integer.parseInt((String) value);
            if (intValue <= 0) {
                throw new Validator.InvalidValueException("Weight must be > 0");
            }
        } catch (final NumberFormatException e) {
            throw new Validator.InvalidValueException("Weight must be a number");
        }
    });
    m_weightField.setImmediate(true);
    m_weightField.setValidationVisible(true);
    formLayout.addComponent(m_weightField);

    /**
     * setting the defaults
     */
    m_typeSelect.setValue(EdgeType.CHILD_SERVICE);
    m_mapFunctionSelect.setValue(Identity.class);
    m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE);
    m_weightField.setValue(Integer.toString(Edge.DEFAULT_WEIGHT));

    /**
     * add the button layout...
     */
    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setMargin(true);

    /**
     * ...and the save button
     */
    final Button saveButton = new Button(edge == null ? "Add Edge" : "Update Edge");
    saveButton.setId("saveEdgeButton");
    saveButton.addClickListener(UIHelper.getCurrent(TransactionAwareUI.class)
            .wrapInTransactionProxy((Button.ClickListener) event -> {
                if (!m_weightField.isValid())
                    return;
                if (!m_ipServiceComponent.isValid())
                    return;
                if (!m_childServiceComponent.isValid())
                    return;
                if (!m_reductionKeyComponent.isValid())
                    return;

                final MapFunction mapFunction = getMapFunction();
                final int weight = Integer.parseInt(m_weightField.getValue());

                /**
                 * in the case edge is not null, remove the old object...
                 */
                if (edge != null) {
                    businessService.removeEdge(edge);
                }

                /**
                 * ...and add the new edge
                 */
                switch ((EdgeType) m_typeSelect.getValue()) {
                case CHILD_SERVICE:
                    businessService.addChildEdge((BusinessService) m_childServiceComponent.getValue(),
                            mapFunction, weight);
                    break;
                case IP_SERVICE:
                    businessService.addIpServiceEdge((IpService) m_ipServiceComponent.getValue(), mapFunction,
                            weight, m_friendlyNameField.getValue());
                    break;
                case REDUCTION_KEY:
                    businessService.addReductionKeyEdge(m_reductionKeyComponent.getValue(), mapFunction, weight,
                            m_friendlyNameField.getValue());
                    break;
                }

                close();
            }));
    buttonLayout.addComponent(saveButton);

    /**
     * ...and a cancel button
     */
    final Button cancelButton = new Button("Cancel");
    cancelButton.setId("cancelEdgeButton");
    cancelButton.addClickListener((Button.ClickListener) event -> close());
    buttonLayout.addComponent(cancelButton);

    /**
     * when edge is not null, fill the components with values
     */
    if (edge != null) {
        edge.accept(new EdgeVisitor<Void>() {
            @Override
            public Void visit(IpServiceEdge edge) {
                m_typeSelect.setValue(EdgeType.IP_SERVICE);

                for (IpService ipService : (Collection<IpService>) m_ipServiceComponent.getItemIds()) {
                    if (ipService.getId() == edge.getIpService().getId()) {
                        m_ipServiceComponent.setValue(ipService);
                        break;
                    }
                }
                m_friendlyNameField.setValue(edge.getFriendlyName());
                m_ipServiceComponent.setEnabled(false);
                return null;
            }

            @Override
            public Void visit(ReductionKeyEdge edge) {
                m_typeSelect.setValue(EdgeType.REDUCTION_KEY);
                m_reductionKeyComponent.setValue(edge.getReductionKey());
                m_friendlyNameField.setValue(edge.getFriendlyName());
                m_reductionKeyComponent.setEnabled(false);
                return null;
            }

            @Override
            public Void visit(ChildEdge edge) {
                m_typeSelect.setValue(EdgeType.CHILD_SERVICE);
                m_childServiceComponent.setValue(edge.getChild());
                m_childServiceComponent.setEnabled(false);
                return null;
            }
        });

        m_typeSelect.setEnabled(false);
        m_mapFunctionSelect.setValue(edge.getMapFunction().getClass());

        edge.getMapFunction().accept(new MapFunctionVisitor<Void>() {
            @Override
            public Void visit(Decrease decrease) {
                m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE);
                return null;
            }

            @Override
            public Void visit(Identity identity) {
                m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE);
                return null;
            }

            @Override
            public Void visit(Ignore ignore) {
                m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE);
                return null;
            }

            @Override
            public Void visit(Increase increase) {
                m_mapFunctionSeveritySelect.setValue(Status.INDETERMINATE);
                return null;
            }

            @Override
            public Void visit(SetTo setTo) {
                m_mapFunctionSeveritySelect.setValue(((SetTo) edge.getMapFunction()).getStatus());
                return null;
            }
        });

        m_weightField.setValue(String.valueOf(edge.getWeight()));
    }

    /**
     * now set the root layout
     */
    rootLayout.addComponent(formLayout);
    rootLayout.addComponent(buttonLayout);
    rootLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
    setContent(rootLayout);
}

From source file:org.processbase.ui.bam.admin.DimentionWindow.java

License:Open Source License

public void initUI() {
    try {/*from w w  w .ja v a2s .  c o  m*/
        if (metaDim == null) {
            setCaption(ProcessbaseApplication.getCurrent().getPbMessages().getString("newDimension"));
        } else {
            setCaption(ProcessbaseApplication.getCurrent().getPbMessages().getString("dimension")
                    + metaDim.getCode());
        }
        setModal(true);
        VerticalLayout layout = (VerticalLayout) this.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName(Reindeer.LAYOUT_WHITE);

        closeBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnClose"), this);
        saveBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnSave"), this);
        code = new TextField(ProcessbaseApplication.getCurrent().getPbMessages().getString("code"));
        name = new TextField(ProcessbaseApplication.getCurrent().getPbMessages().getString("name"));
        valueType = new NativeSelect(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("valueType"));
        length = new TextField(ProcessbaseApplication.getCurrent().getPbMessages().getString("length"));

        code.setWidth("270px");
        code.setMaxLength(20);
        code.setRequired(true);
        code.addValidator(new RegexpValidator("^[A-Z]\\w{1,15}$",
                ProcessbaseApplication.getCurrent().getPbMessages().getString("codeValidatorError")));
        addComponent(code);
        name.setWidth("270px");
        name.setMaxLength(500);
        name.setRequired(true);
        addComponent(name);
        valueType.addItem("int");
        valueType.addItem("java.lang.String");
        valueType.addItem("long");
        valueType.setWidth("265px");
        valueType.setNullSelectionAllowed(false);
        valueType.setRequired(true);
        valueType.addListener(this);
        valueType.setImmediate(true);
        addComponent(valueType);
        length.setWidth("270px");
        length.setMaxLength(4);
        length.setEnabled(false);
        length.setRequired(false);
        addComponent(length);

        if (metaDim != null) {
            code.setValue(metaDim.getCode());
            name.setValue(metaDim.getName());
            valueType.setValue(metaDim.getValueType());
            length.setValue(metaDim.getValueLength());
        } else {
            ArrayList<MetaDim> metaDims = ProcessbaseApplication.getCurrent().getBpmModule()
                    .execute(new GetAllMetaDim());
            code.setValue("D" + String.format("%05d", new Integer(metaDims.size() + 1)));
        }

        buttons.addButton(saveBtn);
        buttons.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT);
        buttons.setExpandRatio(saveBtn, 1);
        buttons.addButton(closeBtn);
        buttons.setComponentAlignment(closeBtn, Alignment.MIDDLE_RIGHT);
        buttons.setMargin(false);
        buttons.setHeight("30px");
        buttons.setWidth("100%");
        addComponent(buttons);
        setWidth("310px");
        setResizable(false);
    } catch (Exception ex) {
        ex.printStackTrace();
        showError(ex.getMessage());
    }
}

From source file:org.processbase.ui.portlet.chart.ChartConfigurationPanel.java

License:Open Source License

public ChartConfigurationPanel() {
    super(4, 7);//  w ww  .  j av  a2  s . c  om
    setWidth("100%");
    chartType = new NativeSelect("Chart Type");
    chartType.addItem("BarChart");
    chartType.addItem("ColumnChart");
    chartType.addItem("PieChart");
    chartType.addItem("LineChart");
    chartType.addItem("AreaChart");

    chartType.setWidth("100px");

    refreshInterval = new TextField(ChartPortlet.getCurrent().messages.getString("refreshInterval"));
    refreshInterval.setMaxLength(3);
    refreshInterval.setRequired(true);
    refreshInterval
            .addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("refreshInterval")
                    + " " + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError")));
    refreshInterval.setValue(new Integer("10"));

    title = new TextField(ChartPortlet.getCurrent().messages.getString("title"));
    title.setWidth("100%");
    title.setRequired(true);

    legend = new NativeSelect(ChartPortlet.getCurrent().messages.getString("legend"));
    legend.setWidth("100%");
    legend.addItem("bottom");
    legend.addItem("top");
    legend.addItem("left");
    legend.addItem("right");

    titleX = new TextField(ChartPortlet.getCurrent().messages.getString("titleX"));
    titleX.setWidth("100%");
    titleX.setRequired(true);

    titleY = new TextField(ChartPortlet.getCurrent().messages.getString("titleY"));
    titleY.setWidth("100%");
    titleY.setRequired(true);

    height = new TextField(ChartPortlet.getCurrent().messages.getString("height"));
    height.setWidth("70px");
    //        height.addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("height") + " " + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError")));
    height.setRequired(true);

    width = new TextField(ChartPortlet.getCurrent().messages.getString("width"));
    width.setWidth("70px");
    //        width.addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("width") + " " + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError")));
    width.setRequired(true);

    min = new TextField(ChartPortlet.getCurrent().messages.getString("min"));
    min.setWidth("70px");
    min.addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("min") + " "
            + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError")));

    max = new TextField(ChartPortlet.getCurrent().messages.getString("max"));
    max.setWidth("70px");
    max.addValidator(new IntegerValidator(ChartPortlet.getCurrent().messages.getString("max") + " "
            + ChartPortlet.getCurrent().messages.getString("IntegerValidatorError")));

    sqlText = new TextArea(ChartPortlet.getCurrent().messages.getString("sqlText"));
    sqlText.setWidth("100%");
    sqlText.setRequired(true);
    sqlText.setRows(7);

    isStacked = new CheckBox("Stacked");

    btnSave = new Button(ChartPortlet.getCurrent().messages.getString("btnSave"), this);
    btnTestSQL = new Button(ChartPortlet.getCurrent().messages.getString("btnTestSQL"), this);
    btnView = new Button(ChartPortlet.getCurrent().messages.getString("btnView"), this);

    buttons.addComponent(btnSave);
    buttons.addComponent(btnTestSQL);
    buttons.addComponent(btnView);

    addComponent(chartType, 0, 0, 1, 0);
    addComponent(isStacked, 3, 0);

    addComponent(title, 0, 1, 1, 1);
    addComponent(legend, 2, 1);
    addComponent(refreshInterval, 3, 1);

    addComponent(titleX, 0, 2, 1, 2);
    addComponent(titleY, 2, 2, 3, 2);

    addComponent(height, 0, 3);
    addComponent(width, 1, 3);
    addComponent(max, 2, 3);
    addComponent(min, 3, 3);

    addComponent(sqlText, 0, 4, 3, 4);
    addComponent(buttons, 0, 6, 3, 6);

    setComponentAlignment(btnSave, Alignment.TOP_RIGHT);
    setMargin(true);
    setSpacing(true);

    try {
        portletPreferences = ChartPortlet.portletPreferences.get();
        for (String key : portletPreferences.getMap().keySet()) {
            String[] value = portletPreferences.getMap().get(key);
            if (key.equals("refreshInterval") && value.length > 0) {
                refreshInterval.setValue(value[0]);
            } else if (key.equals("sqlText") && value.length > 0) {
                sqlText.setValue(value[0]);
            } else if (key.equals("chartType") && value.length > 0) {
                chartType.setValue(value[0]);
            } else if (key.equals("title") && value.length > 0) {
                title.setValue(value[0]);
            } else if (key.equals("legend") && value.length > 0) {
                legend.setValue(value[0]);

            } else if (key.equals("height") && value.length > 0) {
                height.setValue(value[0]);
            } else if (key.equals("width") && value.length > 0) {
                width.setValue(value[0]);
            } else if (key.equals("min") && value.length > 0) {
                min.setValue(value[0]);
            } else if (key.equals("max") && value.length > 0) {
                max.setValue(value[0]);
            } else if (key.equals("titleX") && value.length > 0) {
                titleX.setValue(value[0]);
            } else if (key.equals("titleY") && value.length > 0) {
                titleY.setValue(value[0]);
            } else if (key.equals("isStacked") && value.length > 0) {
                isStacked.setValue(Boolean.parseBoolean(value[0]));
            } else if (key.equals("legend") && value.length > 0) {
                legend.setValue(value[0]);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:org.tltv.gantt.demo.DemoUI.java

License:Apache License

private Panel createControls() {
    Panel panel = new Panel();
    panel.setWidth(100, Unit.PERCENTAGE);

    controls = new HorizontalLayout();
    controls.setSpacing(true);//from w ww .  ja  v a 2  s  . c  o  m
    controls.setMargin(true);
    panel.setContent(controls);

    start = createStartDateField();
    end = createEndDateField();

    Button createStep = new Button("Create New Step...", createStepClickListener);

    HorizontalLayout heightAndUnit = new HorizontalLayout(Util.createHeightEditor(gantt),
            Util.createHeightUnitEditor(gantt));

    HorizontalLayout widthAndUnit = new HorizontalLayout(Util.createWidthEditor(gantt),
            Util.createWidthUnitEditor(gantt));

    reso = new NativeSelect("Resolution");
    reso.setNullSelectionAllowed(false);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Hour);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Day);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Week);
    reso.setValue(gantt.getResolution());
    reso.setImmediate(true);
    reso.addValueChangeListener(resolutionValueChangeListener);

    localeSelect = new NativeSelect("Locale") {
        @Override
        public void attach() {
            super.attach();

            if (getValue() == null) {
                // use default locale
                setValue(gantt.getLocale());
                addValueChangeListener(localeValueChangeListener);
            }
        }
    };
    localeSelect.setNullSelectionAllowed(false);
    for (Locale l : Locale.getAvailableLocales()) {
        localeSelect.addItem(l);
        localeSelect.setItemCaption(l, l.getDisplayName(getLocale()));
    }
    localeSelect.setImmediate(true);

    String[] zones = new String[] { "GMT-0", "GMT-1", "GMT-2", "GMT-3", "GMT-4", "GMT-5", "GMT-6", "GMT-7",
            "GMT-8", "GMT-9", "GMT-10", "GMT-11", "GMT-12", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5",
            "GMT+6", "GMT+7", "GMT+8", "GMT+9", "GMT+10", "GMT+11", "GMT+12", "GMT+13", "GMT+14" };
    NativeSelect timezoneSelect = new NativeSelect("Timezone");
    timezoneSelect.setNullSelectionAllowed(false);
    timezoneSelect.addItem("Default");
    timezoneSelect.setItemCaption("Default", "Default (" + TimeZone.getDefault().getDisplayName() + ")");
    for (String timezoneId : zones) {
        TimeZone tz = TimeZone.getTimeZone(timezoneId);
        timezoneSelect.addItem(timezoneId);
        timezoneSelect.setItemCaption(timezoneId, tz.getDisplayName(getLocale()));
    }
    timezoneSelect.setValue("Default");
    timezoneSelect.setImmediate(true);
    timezoneSelect.addValueChangeListener(timezoneValueChangeListener);

    controls.addComponent(start);
    controls.addComponent(end);
    controls.addComponent(reso);
    controls.addComponent(localeSelect);
    controls.addComponent(timezoneSelect);
    controls.addComponent(heightAndUnit);
    controls.addComponent(widthAndUnit);
    controls.addComponent(createStep);
    controls.setComponentAlignment(createStep, Alignment.MIDDLE_LEFT);

    return panel;
}

From source file:org.tltv.gantt.demo.DemoUI.java

License:Apache License

private void openStepEditor(AbstractStep step) {
    final Window win = new Window("Step Editor");
    win.setResizable(false);//w  w w  . j  a v  a  2  s.  c  om
    win.center();

    final Collection<Component> hidden = new ArrayList<Component>();

    BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step);

    final FieldGroup group = new FieldGroup(item);
    group.setBuffered(true);

    TextField captionField = new TextField("Caption");
    captionField.setNullRepresentation("");
    group.bind(captionField, "caption");

    TextField descriptionField = new TextField("Description");
    descriptionField.setNullRepresentation("");
    group.bind(descriptionField, "description");
    descriptionField.setVisible(false);
    hidden.add(descriptionField);

    NativeSelect captionMode = new NativeSelect("Caption Mode");
    captionMode.addItem(Step.CaptionMode.TEXT);
    captionMode.addItem(Step.CaptionMode.HTML);
    group.bind(captionMode, "captionMode");
    captionMode.setVisible(false);
    hidden.add(captionMode);

    CheckBox showProgress = new CheckBox("Show progress");
    group.bind(showProgress, "showProgress");
    showProgress.setVisible(false);
    hidden.add(showProgress);

    Slider progress = new Slider("Progress");
    progress.setWidth(100, Unit.PERCENTAGE);
    group.bind(progress, "progress");
    progress.setVisible(false);
    hidden.add(progress);

    NativeSelect predecessorSelect = new NativeSelect("Predecessor Step");
    predecessorSelect.setWidth(100, Unit.PERCENTAGE);
    fillPredecessorCanditatesToSelect(step, predecessorSelect);
    predecessorSelect.setEnabled(step instanceof Step);
    if (step instanceof Step) {
        group.bind(predecessorSelect, "predecessor");
    }
    predecessorSelect.setVisible(false);
    hidden.add(predecessorSelect);

    final NativeSelect parentStepSelect = new NativeSelect("Parent Step");
    parentStepSelect.setWidth(100, Unit.PERCENTAGE);
    parentStepSelect.setEnabled(false);
    fillParentStepCanditatesToSelect(step, parentStepSelect);
    parentStepSelect.setVisible(false);
    hidden.add(parentStepSelect);

    HorizontalLayout colorLayout = new HorizontalLayout();
    colorLayout.setWidth(100, Unit.PERCENTAGE);
    colorLayout.setVisible(false);
    hidden.add(colorLayout);

    final TextField bgField = new TextField("Background color");
    bgField.setNullRepresentation("");
    group.bind(bgField, "backgroundColor");
    bgField.setEnabled(false);

    final ColorPicker bgColorPicker = new ColorPicker();
    bgColorPicker.setPosition(300, 100);
    bgColorPicker.setColor(new CssColorToColorPickerConverter().convertToModel(step.getBackgroundColor()));
    bgColorPicker.addColorChangeListener(new ColorChangeListener() {
        @Override
        public void colorChanged(ColorChangeEvent event) {
            bgField.setValue(event.getColor().getCSS());
        }
    });

    colorLayout.addComponent(bgField);
    colorLayout.addComponent(bgColorPicker);
    colorLayout.setExpandRatio(bgField, 1);
    colorLayout.setComponentAlignment(bgColorPicker, Alignment.BOTTOM_LEFT);

    DateField startDate = new DateField("Start date");
    startDate.setLocale(gantt.getLocale());
    startDate.setTimeZone(gantt.getTimeZone());
    startDate.setResolution(Resolution.SECOND);
    startDate.setConverter(new DateToLongConverter());
    group.bind(startDate, "startDate");

    DateField endDate = new DateField("End date");
    endDate.setLocale(gantt.getLocale());
    endDate.setTimeZone(gantt.getTimeZone());
    endDate.setResolution(Resolution.SECOND);
    endDate.setConverter(new DateToLongConverter());
    group.bind(endDate, "endDate");

    CheckBox showMore = new CheckBox("Show all settings");
    showMore.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            for (Component c : hidden) {
                c.setVisible((Boolean) event.getProperty().getValue());
            }
            win.center();
        }
    });

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    win.setContent(content);

    content.addComponent(captionField);
    content.addComponent(captionMode);
    content.addComponent(descriptionField);
    content.addComponent(showProgress);
    content.addComponent(progress);
    content.addComponent(predecessorSelect);
    content.addComponent(parentStepSelect);
    content.addComponent(colorLayout);
    content.addComponent(startDate);
    content.addComponent(endDate);
    content.addComponent(showMore);

    HorizontalLayout buttons = new HorizontalLayout();
    content.addComponent(buttons);

    Button ok = new Button("Ok", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            commit(win, group, parentStepSelect);
        }

    });
    Button cancel = new Button("Cancel", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            cancel(win, group);
        }
    });
    Button delete = new Button("Delete", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            delete(win, group);
        }

    });
    buttons.addComponent(ok);
    buttons.addComponent(cancel);
    buttons.addComponent(delete);
    win.setClosable(true);

    getUI().addWindow(win);
}

From source file:org.vaadin.jefferson.content.SelectionControl.java

License:Open Source License

@Override
public AbstractSelect createFallback() {
    return new NativeSelect(getName());
}

From source file:qbic.vaadincomponents.GroupSpecificParameterComponent.java

License:Open Source License

public Component init() {
    // Group specific parameters

    FormLayout groupSpecificParameters = new FormLayout();

    // does not need to be initialized more than once.
    if (groupSelection == null) {
        groupSelection = new NativeSelect("Group:");
        groupSelection.setNullSelectionAllowed(false);
        groupSpecificParameters.addComponent(groupSelection);
        groupSelection.addValueChangeListener(new ValueChangeListener() {
            private static final long serialVersionUID = -2948673674040494963L;

            @Override//from   www  .jav a 2  s  .co  m
            public void valueChange(ValueChangeEvent event) {
                if (event.getProperty() != null && event.getProperty().getValue() != null) {
                    updateParameters((Integer) event.getProperty().getValue());
                }
            }
        });
    }
    parameterlayout = initParameters();
    groupSpecificParameters.addComponent(parameterlayout);
    parameterlayout.setVisible(false);
    return groupSpecificParameters;
}