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:fi.jasoft.qrcode.demo.QRCodeDemo.java

License:Apache License

private NativeSelect<Integer> createSizeSelect() {
    final NativeSelect<Integer> size = new NativeSelect<Integer>("Size");
    size.setWidth("100px");
    size.setItemCaptionGenerator(s -> s + "x" + s);
    size.setItems(50, 100, 150, 300, 500, 750, 1000);
    size.setValue(100);//from www .j av a  2s .  c  o  m
    size.addValueChangeListener(e -> {
        code.setWidth(e.getValue(), Unit.PIXELS);
        code.setHeight(e.getValue(), Unit.PIXELS);
    });
    return size;
}

From source file:org.activiti.explorer.ui.management.crystalball.EventOverviewPanel.java

License:Apache License

protected void initProcessInstances() {
    HorizontalLayout instancesHeader = new HorizontalLayout();
    instancesHeader.setSpacing(false);//from  ww  w . j a  v a  2s . c  om
    instancesHeader.setMargin(false);
    instancesHeader.setWidth(100, UNITS_PERCENTAGE);
    instancesHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    addDetailComponent(instancesHeader);

    initProcessInstanceTitle(instancesHeader);

    HorizontalLayout selectLayout = new HorizontalLayout();
    selectLayout.setSpacing(true);
    selectLayout.setMargin(true);
    selectLayout.setWidth(50, UNITS_PERCENTAGE);
    addDetailComponent(selectLayout);

    definitionSelect = new NativeSelect(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_DEFINITIONS));
    definitionSelect.setImmediate(true);
    for (ProcessDefinition definition : definitionList) {
        definitionSelect.addItem(definition.getId());
        definitionSelect.setItemCaption(definition.getId(), definition.getName());
    }
    definitionSelect.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (definitionSelect.getValue() != null) {
                String selectedDefinitionId = (String) definitionSelect.getValue();
                ExplorerApp.get().setCrystalBallCurrentDefinitionId(selectedDefinitionId);
                refreshInstances(selectedDefinitionId);
            }
        }
    });

    selectLayout.addComponent(definitionSelect);

    replayButton = new Button(i18nManager.getMessage(Messages.CRYSTALBALL_BUTTON_REPLAY));
    replayButton.setEnabled(false);
    replayButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (instanceTable.getValue() != null) {
                String processInstanceId = (String) instanceTable.getValue();
                ExplorerApp.get().setCrystalBallCurrentInstanceId(processInstanceId);
                List<EventLogEntry> eventLogEntries = managementService
                        .getEventLogEntriesByProcessInstanceId(processInstanceId);
                if (eventLogEntries == null || eventLogEntries.isEmpty())
                    return;
                EventLogTransformer transformer = new EventLogTransformer(getTransformers());
                simulationEvents = transformer.transform(eventLogEntries);
                ExplorerApp.get().setCrystalBallSimulationEvents(simulationEvents);

                SimpleEventCalendar eventCalendar = new SimpleEventCalendar(
                        ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration().getClock(),
                        new SimulationEventComparator());
                eventCalendar.addEvents(simulationEvents);

                // replay process instance run
                simulationDebugger = new ReplaySimulationRun(ProcessEngines.getDefaultProcessEngine(),
                        eventCalendar, getReplayHandlers(processInstanceId));
                ExplorerApp.get().setCrystalBallSimulationDebugger(simulationDebugger);

                simulationDebugger.init(new NoExecutionVariableScope());

                simulationDebugger.step();

                // replay process was started
                List<HistoricProcessInstance> replayProcessInstanceList = historyService
                        .createHistoricProcessInstanceQuery()
                        .processInstanceBusinessKey(SIMULATION_BUSINESS_KEY).orderByProcessInstanceStartTime()
                        .desc().list();
                if (replayProcessInstanceList != null && !replayProcessInstanceList.isEmpty()) {
                    replayHistoricInstance = replayProcessInstanceList.get(0);
                }

                refreshEvents();
            }
        }
    });
    selectLayout.addComponent(replayButton);
    selectLayout.setComponentAlignment(replayButton, Alignment.MIDDLE_LEFT);

    instanceLayout = new HorizontalLayout();
    instanceLayout.setWidth(100, UNITS_PERCENTAGE);
    addDetailComponent(instanceLayout);

    initInstancesTable();
}

From source file:org.axonframework.examples.addressbook.vaadin.ui.SearchView.java

License:Apache License

public SearchView() {
    setCaption("Search for contacts");
    setSizeFull();/*from  w w w  . j a va2 s .co m*/

    FormLayout formLayout = new FormLayout();
    setContent(formLayout);

    tf = new TextField("Search term");
    fieldToSearch = new NativeSelect("Field to search");
    saveSearch = new CheckBox("Save search");
    searchName = new TextField("Search name");
    Button search = new Button("Search");
    search.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            performSearch();
        }
    });
    for (int i = 0; i < ContactContainer.NATURAL_COL_ORDER.length; i++) {
        fieldToSearch.addItem(ContactContainer.NATURAL_COL_ORDER[i]);
        fieldToSearch.setItemCaption(ContactContainer.NATURAL_COL_ORDER[i],
                ContactContainer.COL_HEADERS_ENGLISH[i]);
    }
    fieldToSearch.setValue("name");
    fieldToSearch.setNullSelectionAllowed(false);
    saveSearch.setValue(true);
    addComponent(tf);
    addComponent(fieldToSearch);
    addComponent(saveSearch);
    addComponent(searchName);
    addComponent(search);

    saveSearch.setImmediate(true);
    saveSearch.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            searchName.setVisible(event.getButton().booleanValue());
        }
    });
}

From source file:org.escidoc.browser.ui.role.RoleAssignView.java

License:Open Source License

private void addGroupRoleSelection() {
    groupRoleSelection = new NativeSelect(ViewConstants.SELECT_ROLE_LABEL);
    groupRoleSelection.setWidth(300 + "px");
    groupRoleSelection.setNullSelectionAllowed(false);
    groupRoleSelection.setImmediate(true);
    groupRoleSelection.setRequired(true);
    groupRoleSelection.addListener(new OnRoleSelect(groupResourcetypeSelection, footer, resourceSelection));
    mainLayoutGroupRoles.addComponent(groupRoleSelection);
}

From source file:org.escidoc.browser.ui.role.RoleAssignView.java

License:Open Source License

private void addRoleSelection() {
    roleSelection = new NativeSelect(ViewConstants.SELECT_ROLE_LABEL);
    roleSelection.setWidth(300 + "px");
    roleSelection.setNullSelectionAllowed(false);
    roleSelection.setImmediate(true);/* w ww  .  jav  a  2 s.  c o  m*/
    roleSelection.setRequired(true);
    roleSelection.addListener(new OnRoleSelect(resourcetypeSelection, footer, resourceSelection));
    mainLayout.addComponent(roleSelection);
}

From source file:org.escidoc.browser.ui.role.RoleAssignView.java

License:Open Source License

private void addGroupField() {
    groupSelection = new NativeSelect(ViewConstants.USER_NAME);
    groupSelection.setWidth("300px");
    groupSelection.setNullSelectionAllowed(false);
    groupSelection.setMultiSelect(false);
    groupSelection.setRequired(true);//from  w ww.j av  a  2  s .  co m
    groupSelection.setNewItemsAllowed(false);
    groupSelection.setImmediate(true);
    groupSelection.setRequiredError("User is required");
    mainLayoutGroupRoles.addComponent(groupSelection);

}

From source file:org.escidoc.browser.ui.role.RoleAssignView.java

License:Open Source License

private void addUserField() {
    userSelection = new NativeSelect(ViewConstants.USER_NAME);
    userSelection.setWidth("300px");
    userSelection.setNullSelectionAllowed(false);
    userSelection.setMultiSelect(false);
    userSelection.setRequired(true);/*  w  w w . ja v  a  2  s . c om*/
    userSelection.setNewItemsAllowed(false);
    userSelection.setImmediate(true);
    userSelection.setRequiredError("User is required");
    mainLayout.addComponent(userSelection);
}

From source file:org.escidoc.browser.ui.tools.CreateResourcesView.java

License:Open Source License

private void formAddContext(final VerticalLayout vlAccCreateContext) throws EscidocClientException {
    final Form frm = new Form();
    frm.setImmediate(true);/*w  w  w  . ja  va2  s  . c o  m*/
    // Name
    final TextField txtNameContext = new TextField();
    txtNameContext.setCaption("Name");
    txtNameContext.setImmediate(false);
    txtNameContext.setWidth("-1px");
    txtNameContext.setHeight("-1px");
    txtNameContext.setInvalidAllowed(false);
    txtNameContext.setRequired(true);
    frm.addField("txtNameContext", txtNameContext);

    // Description
    final TextField txtDescContext = new TextField("Description");
    txtDescContext.setImmediate(false);
    txtDescContext.setWidth("-1px");
    txtDescContext.setHeight("-1px");
    frm.addField("txtDescContext", txtDescContext);

    // Description
    final TextField txtType = new TextField("Type");
    txtType.setImmediate(false);
    txtType.setWidth("-1px");
    txtType.setHeight("-1px");
    frm.addField("txtType", txtType);

    // OrgUnit
    final NativeSelect slOrgUnit = new NativeSelect("Organizational Unit");
    slOrgUnit.setImmediate(true);
    slOrgUnit.setWidth("-1px");
    slOrgUnit.setHeight("-1px");
    slOrgUnit.setRequired(true);
    slOrgUnit.setNullSelectionAllowed(false);
    frm.addField("slOrgUnit", slOrgUnit);

    final OrgUnitService orgUnitService = new OrgUnitService(router.getServiceLocation().getEscidocUri(),
            router.getApp().getCurrentUser().getToken());
    final Collection<OrganizationalUnit> orgUnits = orgUnitService.findAll();
    for (final OrganizationalUnit organizationalUnit : orgUnits) {
        slOrgUnit.addItem(organizationalUnit.getObjid());
        slOrgUnit.setItemCaption(organizationalUnit.getObjid(), organizationalUnit.getXLinkTitle());
    }

    frm.getLayout().addComponent(slOrgUnit);
    final CheckBox checkStatusOpened = new CheckBox("Create Context in Status opened?", true);
    checkStatusOpened.setImmediate(true);
    frm.addField("checkStatusOpened", checkStatusOpened);

    // btnAddContext
    final Button btnAddContext = new Button("Submit", new Button.ClickListener() {
        private static final long serialVersionUID = -4696167135894721166L;

        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                frm.commit();
                controller.createResourceAddContext(txtNameContext.getValue().toString(),
                        txtDescContext.getValue().toString(), txtType.getValue().toString(),
                        slOrgUnit.getValue().toString(), (Boolean) checkStatusOpened.getValue(), repositories,
                        router.getServiceLocation());
                router.getMainWindow().showNotification(
                        "Context " + txtNameContext.getValue().toString() + " created successfully ",
                        Window.Notification.TYPE_TRAY_NOTIFICATION);
                frm.getField("txtNameContext").setValue("");
                frm.getField("txtDescContext").setValue("");
                frm.getField("txtType").setValue("");
                frm.getField("slOrgUnit").setValue(null);
                // Ideally here should be a sync method to sync the tree

            } catch (final EmptyValueException e) {
                router.getMainWindow().showNotification("Please fill in all the required elements in the form",
                        Window.Notification.TYPE_TRAY_NOTIFICATION);
            } catch (final EscidocClientException e) {
                router.getMainWindow().showNotification(
                        ViewConstants.ERROR_CREATING_RESOURCE + e.getLocalizedMessage(),
                        Window.Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });

    btnAddContext.setWidth("-1px");
    btnAddContext.setHeight("-1px");
    frm.getLayout().addComponent(btnAddContext);

    frm.getField("txtNameContext").setRequired(true);
    frm.getField("txtNameContext").setRequiredError("Name is missing");

    frm.getField("txtDescContext").setRequired(true);
    frm.getField("txtDescContext").setRequiredError("Description is missing");

    frm.getField("txtType").setRequired(true);
    frm.getField("txtType").setRequiredError("Context Type is missing");
    //
    frm.getField("slOrgUnit").setRequired(true);
    frm.getField("slOrgUnit").setRequiredError("Organizazional Unit is required");

    vlAccCreateContext.addComponent(frm);
}

From source file:org.jumpmind.metl.ui.views.admin.MailServerPanel.java

License:Open Source License

public MailServerPanel(final ApplicationContext context, TabbedPanel tabbedPanel) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;

    final GlobalSetting hostNameSetting = getGlobalSetting(MailSession.SETTING_HOST_NAME, "localhost");
    final GlobalSetting transportSetting = getGlobalSetting(MailSession.SETTING_TRANSPORT, "smtp");
    final GlobalSetting portSetting = getGlobalSetting(MailSession.SETTING_PORT_NUMBER, "25");
    final GlobalSetting fromSetting = getGlobalSetting(MailSession.SETTING_FROM, "metl@localhost");
    final GlobalSetting usernameSetting = getGlobalSetting(MailSession.SETTING_USERNAME, "");
    final GlobalSetting passwordSetting = getGlobalSetting(MailSession.SETTING_PASSWORD, "");
    final GlobalSetting useTlsSetting = getGlobalSetting(MailSession.SETTING_USE_TLS, "false");
    final GlobalSetting useAuthSetting = getGlobalSetting(MailSession.SETTING_USE_AUTH, "false");

    FormLayout form = new FormLayout();
    form.setSpacing(true);//  w  w  w . j av  a  2 s  . c o  m

    ImmediateUpdateTextField hostField = new ImmediateUpdateTextField("Host name") {
        protected void save(String value) {
            saveSetting(hostNameSetting, value);
        }
    };
    hostField.setValue(hostNameSetting.getValue());
    hostField.setWidth(25f, Unit.EM);
    form.addComponent(hostField);
    hostField.focus();

    NativeSelect transportField = new NativeSelect("Transport");
    transportField.addItem("smtp");
    transportField.addItem("smtps");
    transportField.select(transportSetting.getValue() == null ? "smtp" : transportSetting.getValue());
    transportField.setNullSelectionAllowed(false);
    transportField.setImmediate(true);
    transportField.setWidth(10f, Unit.EM);
    transportField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            saveSetting(transportSetting, (String) event.getProperty().getValue());
        }
    });
    form.addComponent(transportField);

    ImmediateUpdateTextField portField = new ImmediateUpdateTextField("Port") {
        protected void save(String value) {
            saveSetting(portSetting, value);
        }
    };
    portField.setValue(portSetting.getValue());
    portField.setWidth(25f, Unit.EM);
    form.addComponent(portField);

    ImmediateUpdateTextField fromField = new ImmediateUpdateTextField("From Address") {
        protected void save(String value) {
            saveSetting(fromSetting, value);
        }
    };
    fromField.setValue(fromSetting.getValue());
    fromField.setWidth(25f, Unit.EM);
    form.addComponent(fromField);

    CheckBox tlsField = new CheckBox("Use TLS", Boolean.valueOf(useTlsSetting.getValue()));
    tlsField.setImmediate(true);
    tlsField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            saveSetting(useTlsSetting, ((Boolean) event.getProperty().getValue()).toString());
        }
    });
    form.addComponent(tlsField);

    final ImmediateUpdateTextField userField = new ImmediateUpdateTextField("Username") {
        protected void save(String value) {
            saveSetting(usernameSetting, value);
        }
    };
    userField.setValue(usernameSetting.getValue());
    userField.setWidth(25f, Unit.EM);

    final ImmediateUpdatePasswordField passwordField = new ImmediateUpdatePasswordField("Password") {
        protected void save(String value) {
            saveSetting(passwordSetting, value);
        }
    };
    passwordField.setValue(passwordSetting.getValue());
    passwordField.setWidth(25f, Unit.EM);

    CheckBox authField = new CheckBox("Use Authentication", Boolean.valueOf(useAuthSetting.getValue()));
    authField.setImmediate(true);
    authField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            Boolean isEnabled = (Boolean) event.getProperty().getValue();
            saveSetting(useAuthSetting, isEnabled.toString());
            userField.setEnabled(isEnabled);
            passwordField.setEnabled(isEnabled);
        }
    });
    form.addComponent(authField);
    userField.setEnabled(authField.getValue());
    form.addComponent(userField);
    passwordField.setEnabled(authField.getValue());
    form.addComponent(passwordField);

    Button testButton = new Button("Test Connection");
    testButton.addClickListener(new TestClickListener());
    form.addComponent(testButton);

    addComponent(form);
    setMargin(true);
}

From source file:org.jumpmind.metl.ui.views.admin.NotificationEditPanel.java

License:Open Source License

public NotificationEditPanel(final ApplicationContext context, final Notification notification) {
    this.context = context;
    this.notification = notification;

    sampleSubjectByEvent = new HashMap<String, String>();
    sampleSubjectByEvent.put(Notification.EventType.FLOW_START.toString(), "Flow $(_flowName) started");
    sampleSubjectByEvent.put(Notification.EventType.FLOW_END.toString(), "Flow $(_flowName) ended");
    sampleSubjectByEvent.put(Notification.EventType.FLOW_ERROR.toString(), "Flow $(_flowName) - ERROR");

    sampleMessageByEvent = new HashMap<String, String>();
    sampleMessageByEvent.put(Notification.EventType.FLOW_START.toString(),
            "Started flow $(_flowName) on agent $(_agentName) at $(_time) on $(_date)");
    sampleMessageByEvent.put(Notification.EventType.FLOW_END.toString(),
            "Ended flow $(_flowName) on agent $(_agent) at $(_time) on $(_date)");
    sampleMessageByEvent.put(Notification.EventType.FLOW_ERROR.toString(),
            "Error in flow $(_flowName) on agent $(_agentName) at $(_time) on $(_date)\n\n$(_errorText)");

    FormLayout form = new FormLayout();
    form.setSizeFull();/*w ww  .j a  v  a 2 s . c o m*/
    form.setSpacing(true);

    levelField = new NativeSelect("Level");
    for (Notification.Level level : Notification.Level.values()) {
        levelField.addItem(level.toString());
    }
    levelField.setNullSelectionAllowed(false);
    levelField.setImmediate(true);
    levelField.setWidth(15f, Unit.EM);
    levelField.addValueChangeListener(new LevelFieldListener());
    form.addComponent(levelField);

    linkField = new ComboBox("Linked To");
    linkField.setNullSelectionAllowed(false);
    linkField.setImmediate(true);
    linkField.setWidth(15f, Unit.EM);
    linkField.addValueChangeListener(new LinkFieldListener());
    form.addComponent(linkField);

    eventField = new NativeSelect("Event");
    eventField.setNullSelectionAllowed(false);
    eventField.setImmediate(true);
    eventField.setWidth(15f, Unit.EM);
    eventField.addValueChangeListener(new EventFieldListener());
    form.addComponent(eventField);

    nameField = new ImmediateUpdateTextField("Name") {
        protected void save(String value) {
            notification.setName(value);
            saveNotification();
        }
    };
    nameField.setValue(StringUtils.trimToEmpty(notification.getName()));
    nameField.setWidth(20f, Unit.EM);
    nameField.setDescription("Display name for the notification");
    form.addComponent(nameField);

    ImmediateUpdateTextArea recipientsField = new ImmediateUpdateTextArea("Recipients") {
        protected void save(String value) {
            notification.setRecipients(value);
            saveNotification();
        }
    };
    recipientsField.setValue(StringUtils.trimToEmpty(notification.getRecipients()));
    recipientsField.setColumns(20);
    recipientsField.setRows(10);
    recipientsField.setInputPrompt("address1@example.com\r\naddress2@example.com");
    recipientsField.setDescription("Email addresses of recipients, separated by commas.");
    form.addComponent(recipientsField);

    subjectField = new ImmediateUpdateTextField("Subject") {
        protected void save(String value) {
            notification.setSubject(value);
            saveNotification();
        }
    };
    subjectField.setValue(StringUtils.trimToEmpty(notification.getSubject()));
    subjectField.setWidth(40f, Unit.EM);
    subjectField.setDescription("The subject of the email can contain...");
    form.addComponent(subjectField);

    messageField = new ImmediateUpdateTextArea("Message") {
        protected void save(String value) {
            notification.setMessage(value);
            saveNotification();
        }
    };
    messageField.setValue(StringUtils.trimToEmpty(notification.getMessage()));
    messageField.setColumns(40);
    messageField.setRows(10);
    messageField.setDescription("The body of the email can contain...");
    form.addComponent(messageField);

    CheckBox enableField = new CheckBox("Enabled", notification.isEnabled());
    enableField.setImmediate(true);
    enableField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            notification.setEnabled((Boolean) event.getProperty().getValue());
            saveNotification();
        }
    });
    form.addComponent(enableField);

    if (notification.getLevel() == null) {
        isInit = true;
        levelField.setValue(Notification.Level.GLOBAL.toString());
        notification.setLevel(Notification.Level.GLOBAL.toString());
        notification.setNotifyType(Notification.NotifyType.MAIL.toString());
        updateLinks();
        updateEventTypes();
        updateName();
    } else {
        levelField.setValue(notification.getLevel());
        updateLinks();
        updateEventTypes();
        linkField.setValue(notification.getLinkId());
        eventField.setValue(notification.getEventType());
        isInit = true;
    }

    addComponent(form);
    setMargin(true);
    autoSave = true;
}