Example usage for com.vaadin.ui ComboBox ComboBox

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

Introduction

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

Prototype

protected ComboBox(DataCommunicator<T> dataCommunicator) 

Source Link

Document

Constructs and initializes an empty combo box.

Usage

From source file:org.opennms.features.vaadin.datacollection.SnmpCollectionFieldFactory.java

License:Open Source License

public Field createField(Item item, Object propertyId, Component uiContext) {
    if ("name".equals(propertyId)) {
        final TextField f = new TextField("SNMP Collection Name");
        f.setRequired(true);/*from w w w  .  jav  a 2 s. c o m*/
        f.setWidth("100%");
        return f;
    }
    if ("snmpStorageFlag".equals(propertyId)) {
        final ComboBox f = new ComboBox("SNMP Storage Flag");
        f.setRequired(true);
        f.addItem("select");
        f.addItem("all");
        return f;
    }
    if ("rrd".equals(propertyId)) {
        final RrdField f = new RrdField("RRD");
        f.setRequired(true);
        f.setWidth("100%");
        return f;
    }
    if ("includeCollectionCollection".equals(propertyId)) {
        IncludeCollectionField f = new IncludeCollectionField(dataCollectionConfigDao);
        f.setCaption("Include Collections");
        return f;
    }
    return null;
}

From source file:org.opennms.features.vaadin.events.EventFormFieldFactory.java

License:Open Source License

public Field createField(Item item, Object propertyId, Component uiContext) {
    if ("logMsgDest".equals(propertyId)) {
        final ComboBox dest = new ComboBox("Destination");
        dest.addItem("logndisplay");
        dest.addItem("logonly");
        dest.addItem("suppress");
        dest.addItem("donotpersist");
        dest.addItem("discardtraps");
        dest.setNullSelectionAllowed(false);
        dest.setRequired(true);//from   w w  w  .  j  a  v  a  2s.  c  o  m
        return dest;
    }
    if ("logMsgContent".equals(propertyId)) {
        final TextArea content = new TextArea("Log Message");
        content.setWidth("100%");
        content.setRows(10);
        content.setRequired(true);
        content.setNullRepresentation("");
        return content;
    }
    if ("alarmDataAlarmType".equals(propertyId)) {
        final ComboBox f = new ComboBox("Alarm Type");
        f.addItem(new Integer(1));
        f.addItem(new Integer(2));
        f.addItem(new Integer(3));
        f.setNewItemHandler(new NewItemHandler() {
            @Override
            public void addNewItem(String newItemCaption) {
                try {
                    f.addItem(new Integer(newItemCaption));
                } catch (Exception e) {
                }
            }
        });
        f.setDescription(
                "<b>1</b> to be a problem that has a possible resolution, alarm-type set to <b>2</b> to be a resolution event, and alarm-type set to <b>3</b> for events that have no possible resolution");
        f.setNullSelectionAllowed(false);
        return f;
    }
    if ("alarmDataAutoClean".equals(propertyId)) {
        final CheckBox f = new CheckBox("Auto Clean");
        f.setWidth("100%");
        return f;
    }
    if ("alarmDataReductionKey".equals(propertyId)) {
        final TextField f = new TextField("Reduction Key");
        f.setWidth("100%");
        f.setNullRepresentation("");
        return f;
    }
    if ("alarmDataClearKey".equals(propertyId)) {
        final TextField f = new TextField("Clear Key");
        f.setWidth("100%");
        f.setNullRepresentation("");
        return f;
    }
    if ("severity".equals(propertyId)) {
        final ComboBox severity = new ComboBox("Severity");
        for (String sev : OnmsSeverity.names()) {
            severity.addItem(sev.substring(0, 1).toUpperCase() + sev.substring(1).toLowerCase());
        }
        severity.setNullSelectionAllowed(false);
        severity.setRequired(true);
        return severity;
    }
    if ("descr".equals(propertyId)) {
        final TextArea descr = new TextArea("Description");
        descr.setWidth("100%");
        descr.setRows(10);
        descr.setRequired(true);
        descr.setNullRepresentation("");
        return descr;
    }
    if ("operinstruct".equals(propertyId)) {
        final TextArea oper = new TextArea("Operator Instructions") {
            @Override
            public Object getValue() { // This is because of the intern usage on Event.setOperInstruct()
                return super.getValue() == null ? "" : super.getValue();
            }
        };
        oper.setWidth("100%");
        oper.setRows(10);
        oper.setNullRepresentation("");
        return oper;
    }
    if ("maskElements".equals(propertyId)) {
        final MaskElementField field = new MaskElementField();
        field.setCaption("Mask Elements");
        return field;
    }
    if ("maskVarbinds".equals(propertyId)) {
        final MaskVarbindField field = new MaskVarbindField();
        field.setCaption("Mask Varbinds");
        return field;
    }
    if ("varbindsdecodeCollection".equals(propertyId)) {
        final VarbindsDecodeField field = new VarbindsDecodeField();
        field.setCaption("Varbind Decodes");
        return field;
    }
    if ("uei".equals(propertyId)) {
        final TextField f = new TextField("Event UEI");
        f.setRequired(true);
        f.setWidth("100%");
        return f;
    }
    if ("eventLabel".equals(propertyId)) {
        final TextField f = new TextField("Event Label");
        f.setRequired(true);
        f.setWidth("100%");
        return f;
    }
    final Field f = DefaultFieldFactory.get().createField(item, propertyId, uiContext);
    f.setWidth("100%");
    return f;
}

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

License:Open Source License

/**
 * Constructor//  ww w  . jav  a2  s  .  c o  m
 *
 * @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.ow2.sirocco.cloudmanager.AddressAssociateDialog.java

License:Open Source License

public AddressAssociateDialog(final List<MachineChoice> choices, final DialogCallback callback) {
    super("Associate Address");
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    FormLayout content = new FormLayout();
    content.setMargin(true);//from   ww w  . j  a v a 2 s.  co m
    content.setWidth("400px");
    content.setHeight("150px");

    this.machineBox = new ComboBox("Machine");
    this.machineBox.setRequired(true);
    this.machineBox.setTextInputAllowed(false);
    this.machineBox.setNullSelectionAllowed(false);
    this.machineBox.setInputPrompt("select machine");
    this.machineBox.setImmediate(true);
    content.addComponent(this.machineBox);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    this.okButton = new Button("Ok", this);
    this.cancelButton = new Button("Cancel", this);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    this.setContent(content);

    for (MachineChoice choice : choices) {
        this.machineBox.addItem(choice.id);
        this.machineBox.setItemCaption(choice.id, choice.name);
    }

}

From source file:org.ow2.sirocco.cloudmanager.SecurityGroupRuleCreationDialog.java

License:Open Source License

public SecurityGroupRuleCreationDialog(final List<SecGroupChoice> choices, final DialogCallback callback) {
    super("Add Rule");
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    FormLayout content = new FormLayout();
    content.setMargin(true);/*from w ww .ja  v a  2s .co m*/
    content.setWidth("500px");
    content.setHeight("350px");

    this.protocolBox = new ComboBox("IP Protocol");
    this.protocolBox.setRequired(true);
    this.protocolBox.setTextInputAllowed(false);
    this.protocolBox.setNullSelectionAllowed(false);
    this.protocolBox.setImmediate(true);
    this.protocolBox.addItem("TCP");
    this.protocolBox.addItem("UDP");
    this.protocolBox.addItem("ICMP");
    this.protocolBox.setValue("TCP");
    content.addComponent(this.protocolBox);

    this.portField = new TextField("Port range");
    this.portField.setRequired(true);
    this.portField.setWidth("80%");
    this.portField.setRequired(true);
    this.portField.setRequiredError("Please provide a port range");
    this.portField.setImmediate(true);
    content.addComponent(this.portField);

    this.sourceChoice = new OptionGroup("Source");
    this.sourceChoice.addItem("CIDR");
    this.sourceChoice.addItem("Security Group");
    this.sourceChoice.setValue("CIDR");
    this.sourceChoice.setImmediate(true);
    this.sourceChoice.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(final ValueChangeEvent event) {
            boolean sourceIsCidr = SecurityGroupRuleCreationDialog.this.sourceChoice.getValue().equals("CIDR");
            SecurityGroupRuleCreationDialog.this.sourceIpRangeField.setEnabled(sourceIsCidr);
            SecurityGroupRuleCreationDialog.this.sourceSecGroupBox.setEnabled(!sourceIsCidr);
        }
    });
    content.addComponent(this.sourceChoice);

    this.sourceIpRangeField = new TextField("CIDR");
    this.sourceIpRangeField.setRequired(true);
    this.sourceIpRangeField.setWidth("80%");
    this.sourceIpRangeField.setRequired(true);
    this.sourceIpRangeField.setRequiredError("Please provide a CIDR");
    this.sourceIpRangeField.setImmediate(true);
    this.sourceIpRangeField.setValue("0.0.0.0/0");
    content.addComponent(this.sourceIpRangeField);

    this.sourceSecGroupBox = new ComboBox("Security Group");
    this.sourceSecGroupBox.setRequired(true);
    this.sourceSecGroupBox.setTextInputAllowed(false);
    this.sourceSecGroupBox.setNullSelectionAllowed(false);
    this.sourceSecGroupBox.setInputPrompt("select machine");
    this.sourceSecGroupBox.setImmediate(true);
    for (SecGroupChoice choice : choices) {
        this.sourceSecGroupBox.addItem(choice.id);
        this.sourceSecGroupBox.setItemCaption(choice.id, choice.name);
    }
    this.sourceSecGroupBox.setValue(choices.get(0).id);
    this.sourceSecGroupBox.setEnabled(false);
    content.addComponent(this.sourceSecGroupBox);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setSpacing(true);

    this.errorLabel = new Label("                                       ");
    this.errorLabel.setStyleName("errorMsg");
    this.errorLabel.setWidth("100%");
    buttonLayout.addComponent(this.errorLabel);
    buttonLayout.setExpandRatio(this.errorLabel, 1.0f);

    this.okButton = new Button("Ok", this);
    this.cancelButton = new Button("Cancel", this);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    // content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    this.setContent(content);

}

From source file:org.ow2.sirocco.cloudmanager.VolumeAttachDialog.java

License:Open Source License

public VolumeAttachDialog(final List<MachineChoice> choices, final DialogCallback callback) {
    super("Attach Volume");
    this.callback = callback;
    this.center();
    this.setClosable(false);
    this.setModal(true);
    this.setResizable(false);

    FormLayout content = new FormLayout();
    content.setMargin(true);//from   w  ww.java  2  s  .  c  o m
    content.setWidth("400px");
    content.setHeight("150px");

    this.machineBox = new ComboBox("Machine");
    this.machineBox.setRequired(true);
    this.machineBox.setTextInputAllowed(false);
    this.machineBox.setNullSelectionAllowed(false);
    this.machineBox.setInputPrompt("select machine");
    this.machineBox.setImmediate(true);
    content.addComponent(this.machineBox);

    this.deviceField = new TextField("Device location");
    this.deviceField.setRequired(true);
    this.deviceField.setWidth("80%");
    this.deviceField.setRequired(true);
    this.deviceField.setRequiredError("Please provide a device location");
    this.deviceField.setImmediate(true);
    content.addComponent(this.deviceField);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    this.okButton = new Button("Ok", this);
    this.cancelButton = new Button("Cancel", this);
    this.cancelButton.focus();
    buttonLayout.addComponent(this.okButton);
    buttonLayout.addComponent(this.cancelButton);
    content.addComponent(buttonLayout);
    content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);

    this.setContent(content);

    for (MachineChoice choice : choices) {
        this.machineBox.addItem(choice.id);
        this.machineBox.setItemCaption(choice.id, choice.name);
    }

}

From source file:org.processbase.ui.bpm.admin.CategoryWindow.java

License:Open Source License

public void initUI() {
    try {/*from  w  ww .  ja va  2  s. co m*/
        setModal(true);
        VerticalLayout layout = (VerticalLayout) this.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName(Reindeer.LAYOUT_WHITE);

        processesComboBox = new ComboBox(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("processToCategory"));
        processesComboBox.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS);
        //            processesComboBox.setItemCaptionPropertyId("name");
        processesComboBox.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_EXPLICIT);
        processesComboBox.setWidth("100%");

        bar.setWidth("100%");
        bar.addComponent(processesComboBox);
        bar.setExpandRatio(processesComboBox, 1);

        addBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnAdd"), this);
        bar.addComponent(addBtn);
        bar.setComponentAlignment(addBtn, Alignment.BOTTOM_RIGHT);

        layout.addComponent(bar);
        layout.addComponent(table);

        deleteBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDelete"),
                this);
        deleteBtn.setDescription(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("deleteCategory"));
        cancelBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnCancel"),
                this);
        saveBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnSave"), this);
        buttons.addButton(deleteBtn);
        buttons.setComponentAlignment(deleteBtn, Alignment.MIDDLE_RIGHT);
        buttons.addButton(saveBtn);
        buttons.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT);
        buttons.setExpandRatio(saveBtn, 1);
        buttons.addButton(cancelBtn);
        buttons.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);
        buttons.setMargin(false);
        buttons.setHeight("30px");
        buttons.setWidth("100%");
        addComponent(buttons);
        setWidth("70%");
        //            setHeight("70%");
        setResizable(false);

        table.addContainerProperty("name", String.class, null,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("tableCaptionProcessName"), null,
                null);
        table.setColumnExpandRatio("name", 1);
        table.addContainerProperty("version", String.class, null,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("tableCaptionVersion"), null,
                null);
        table.setColumnWidth("version", 50);
        table.addContainerProperty("deployedBy", String.class, null,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("tableCaptionDeployedBy"), null,
                null);
        table.addContainerProperty("actions", TableLinkButton.class, null,
                ProcessbaseApplication.getCurrent().getPbMessages().getString("tableCaptionActions"), null,
                null);
        table.setColumnWidth("actions", 50);
        table.setSelectable(false);
        table.setImmediate(true);
        table.setWidth("100%");
        table.setPageLength(10);
        refreshTable();
    } catch (Exception ex) {
        ex.printStackTrace();
        showError(ex.getMessage());
    }
}

From source file:org.processbase.ui.bpm.identity.GroupWindow.java

License:Open Source License

public void initUI() {
    try {//from w  w  w.  j  av a2  s  . c  o m
        if (group == null) {
            setCaption(ProcessbaseApplication.getCurrent().getPbMessages().getString("newGroup"));
        } else {
            setCaption(ProcessbaseApplication.getCurrent().getPbMessages().getString("group"));
        }
        setModal(true);
        VerticalLayout layout = (VerticalLayout) this.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName(Reindeer.LAYOUT_WHITE);

        cancelBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnCancel"),
                this);
        applyBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnSave"), this);
        groupName = new TextField(ProcessbaseApplication.getCurrent().getPbMessages().getString("groupName"));
        groupLabel = new TextField(ProcessbaseApplication.getCurrent().getPbMessages().getString("groupLabel"));
        groupDescription = new TextArea(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("groupDescription"));
        parentGroup = new ComboBox(
                ProcessbaseApplication.getCurrent().getPbMessages().getString("groupParent"));

        parentGroup.setWidth("270px");
        parentGroup.setContainerDataSource(getGroups());
        parentGroup.setItemCaptionPropertyId("path");
        parentGroup.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS);
        addComponent(parentGroup);
        groupName.setWidth("270px");
        addComponent(groupName);
        groupLabel.setWidth("270px");
        addComponent(groupLabel);
        groupDescription.setWidth("270px");
        addComponent(groupDescription);

        if (group != null) {
            groupName.setValue(group.getName());
            groupLabel.setValue(group.getLabel());
            groupDescription.setValue(group.getDescription());
            if (group.getParentGroup() != null) {
                parentGroup.setValue(group.getParentGroup().getUUID());
            }
        }

        buttons.addButton(applyBtn);
        buttons.setComponentAlignment(applyBtn, Alignment.MIDDLE_RIGHT);
        buttons.setExpandRatio(applyBtn, 1);
        buttons.addButton(cancelBtn);
        buttons.setComponentAlignment(cancelBtn, 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.ripla.web.util.LanguageSelect.java

License:Open Source License

private ComboBox createSelect() {
    final ComboBox outSelect = new ComboBox(null);
    outSelect.setStyleName("ripla-select"); //$NON-NLS-1$
    outSelect.setWidth(55, Unit.PIXELS);
    outSelect.setNullSelectionAllowed(false);
    outSelect.setImmediate(true);//from  w w w .j  av  a 2 s .co m
    return outSelect;
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.field.ListField.java

License:Mozilla Public License

public ListField(final String title, final String caption, final BeanItemContainer<SetData> container) {
    pcs = new PropertyChangeSupport(this);
    this.caption = caption;
    this.container = container;
    setRequired(true);/*  w w w. java2s  .c  o  m*/
    setRequiredError(title + " must be set.");
    selectList = new ComboBox(title);
    selectList.setImmediate(true);
    init();
}