Java Code Examples for com.vaadin.ui.ComboBox

The following are top voted examples for showing how to use com.vaadin.ui.ComboBox. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: hawkbit   File: ComboBoxBuilder.java   Source Code and License 7 votes vote down vote up
/**
 * @return a new ComboBox
 */
public ComboBox buildCombBox() {
    final ComboBox targetFilter = SPUIComponentProvider.getComboBox(null, "", null, ValoTheme.COMBOBOX_SMALL, false,
            "", prompt);
    targetFilter.setImmediate(true);
    targetFilter.setPageLength(7);
    targetFilter.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
    targetFilter.setSizeUndefined();
    if (id != null) {
        targetFilter.setId(id);
    }
    if (valueChangeListener != null) {
        targetFilter.addValueChangeListener(valueChangeListener);
    }
    return targetFilter;
}
 
Example 2
Project: extacrm   File: MainSettingsForm.java   Source Code and License 7 votes vote down vote up
@Override
protected ComponentContainer createEditFields() {
    final ExtaFormLayout form = new ExtaFormLayout();

    appTitleField = new EditField("Заголовок приложения");
    form.addComponent(appTitleField);

    iconPathField = new ComboBox("Иконка приложения");
    for (final String icon : lookup(UserSettingsService.class).getFaviconPathList()) {
        iconPathField.addItem(icon);
        iconPathField.setItemIcon(icon, new ThemeResource(getLast(Splitter.on('/').split(icon))));
    }
    iconPathField.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ICON_ONLY);
    iconPathField.setWidth(85, Unit.PIXELS);
    iconPathField.setTextInputAllowed(false);
    iconPathField.setNullSelectionAllowed(false);
    form.addComponent(iconPathField);

    isShowSalePointIdsField = new MCheckBox("Показывать раздел \"Идентификация\" в карточке торговой точки");
    form.addComponent(isShowSalePointIdsField);

    isDevServerField = new MCheckBox("Режим отладки");
    form.addComponent(isDevServerField);

    return form;
}
 
Example 3
Project: esup-ecandidat   File: CandidatureViewTemplate.java   Source Code and License 6 votes vote down vote up
/**
 * @param propertyId
 * @param libNull
 * @return les filtres perso en ComboBox
 */
public ComboBox getComboBoxFilterComponent(final Object propertyId, final String libNull) {
	List<String> list = new ArrayList<>();
	if (propertyId.equals(Candidature_.typeTraitement.getName() + "." + TypeTraitement_.libTypTrait.getName())) {
		cacheController.getListeTypeTraitement().forEach(e -> list.add(e.getLibTypTrait()));
		return generateComboBox(list, libNull);
	} else if (propertyId.equals(Candidature_.typeStatut.getName() + "." + TypeStatut_.libTypStatut.getName())) {
		cacheController.getListeTypeStatut().forEach(e -> list.add(e.getLibTypStatut()));
		return generateComboBox(list, libNull);
	} else if (propertyId.equals(LAST_TYPE_DECISION_PREFIXE + TypeDecisionCandidature_.typeDecision.getName() + "."
			+ TypeDecision_.libTypDec.getName())) {
		typeDecisionController.getTypeDecisionsEnService().forEach(e -> list.add(e.getLibTypDec()));
		return generateComboBox(list, libNull);
	}
	return null;
}
 
Example 4
Project: esup-ecandidat   File: CandidatureViewTemplate.java   Source Code and License 6 votes vote down vote up
/**
 * @param liste
 * @param libNull
 * @return une combo grace a la liste
 */
private ComboBox generateComboBox(final List<String> liste, final String libNull) {
	ComboBox sampleIdCB = new ComboBox();
	sampleIdCB.setPageLength(20);
	sampleIdCB.setTextInputAllowed(false);
	BeanItemContainer<String> dataList = new BeanItemContainer<>(String.class);
	dataList.addBean(applicationContext.getMessage("filter.all", null, UI.getCurrent().getLocale()));
	if (libNull != null) {
		dataList.addBean(libNull);
	}
	dataList.addAll(liste);
	sampleIdCB
			.setNullSelectionItemId(applicationContext.getMessage("filter.all", null, UI.getCurrent().getLocale()));
	sampleIdCB.setContainerDataSource(dataList);
	sampleIdCB.setImmediate(true);
	return sampleIdCB;
}
 
Example 5
Project: esup-ecandidat   File: GridFormatting.java   Source Code and License 6 votes vote down vote up
/**
 * Ajoute un filtre en combobox String sur une colonne
 * 
 * @param property
 * @param cb
 */
public void addComboBoxFilters(String property, ComboBox cb, String libNull) {
	HeaderCell cell = getFilterCell(property);
	cb.addValueChangeListener(e -> {
		container.removeContainerFilters(property);
		if (cb.getValue() != null && !((String) cb.getValue()).isEmpty()
				&& !((String) cb.getValue()).equals(libNull)) {
			container.addContainerFilter(new SimpleStringFilter(property, (String) cb.getValue(), true, true));
		} else if (cb.getValue() != null && !((String) cb.getValue()).isEmpty()
				&& ((String) cb.getValue()).equals(libNull)) {
			container.addContainerFilter(new IsNull(property));
		}
		fireFilterListener();
		fireFilterListener();
	});
	cb.setImmediate(true);
	cb.setWidth(100, Unit.PERCENTAGE);
	cb.addStyleName(ValoTheme.COMBOBOX_TINY);
	cell.setComponent(cb);
}
 
Example 6
Project: osc-core   File: BaseDeploymentSpecWindow.java   Source Code and License 6 votes vote down vote up
@Override
public void initForm() {
    this.form.addComponent(getName());
    this.form.addComponent(getProjects());
    this.form.addComponent(getRegion());
    this.form.addComponent(getUserOptions());
    this.form.addComponent(getOptionTable());

    List<ComboBox> networks = getNetworkComboBoxes();
    for (ComboBox combobox : networks) {
        this.form.addComponent(combobox);
    }
    this.form.addComponent(getIPPool());
    this.form.addComponent(getCount());
    this.form.addComponent(getSharedCheckBox());
    this.name.focus();
    getCount().setEnabled(false);
}
 
Example 7
Project: osc-core   File: BaseDeploymentSpecWindow.java   Source Code and License 6 votes vote down vote up
protected Component getProjects() {
    try {
        this.project = new ComboBox("Select Project");
        this.project.setTextInputAllowed(true);
        this.project.setNullSelectionAllowed(false);
        this.project.setImmediate(true);
        this.project.setRequired(true);
        this.project.setRequiredError("Project cannot be empty");

    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Error populating Project List combobox", e);
    }

    return this.project;
}
 
Example 8
Project: osc-core   File: BaseDeploymentSpecWindow.java   Source Code and License 6 votes vote down vote up
protected List<ComboBox> getNetworkComboBoxes() {

        List<ComboBox> networkComboBox = new ArrayList<>();
        this.managementNetwork = new ComboBox("Select Management Network");
        this.managementNetwork.setTextInputAllowed(false);
        this.managementNetwork.setNullSelectionAllowed(false);
        this.managementNetwork.setImmediate(true);
        this.managementNetwork.setRequired(true);
        this.managementNetwork.setRequiredError("Management Network cannot be empty");

        networkComboBox.add(this.managementNetwork);

        this.inspectionNetwork = new ComboBox("Select Inspection Network");
        this.inspectionNetwork.setTextInputAllowed(false);
        this.inspectionNetwork.setNullSelectionAllowed(false);
        this.inspectionNetwork.setImmediate(true);
        this.inspectionNetwork.setRequired(true);
        this.inspectionNetwork.setRequiredError("Inspection Network cannot be empty");

        networkComboBox.add(this.inspectionNetwork);

        return networkComboBox;

    }
 
Example 9
Project: osc-core   File: BaseDeploymentSpecWindow.java   Source Code and License 6 votes vote down vote up
private void populateNetworks(ComboBox networkComboBox, List<OsNetworkDto> networkList) {
    try {
        networkComboBox.removeAllItems();
        if (networkList != null) {
            // Calling List Network Service
            BeanItemContainer<OsNetworkDto> networkListContainer = new BeanItemContainer<>(OsNetworkDto.class,
                    networkList);

            networkComboBox.setContainerDataSource(networkListContainer);
            networkComboBox.setItemCaptionPropertyId("name");
            if (networkList.size() > 0) {
                networkComboBox.select(networkListContainer.getIdByIndex(0));
            }
        }
    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Error getting Network List", e);
    }
}
 
Example 10
Project: osc-core   File: BaseSecurityGroupInterfaceWindow.java   Source Code and License 6 votes vote down vote up
protected Component getPolicy() {
    try {
        this.policy = new ComboBox("Select Policy");
        this.policy.setTextInputAllowed(false);
        this.policy.setNullSelectionAllowed(false);
        this.policy.setImmediate(true);
        this.policy.setRequired(true);
        this.policy.setRequiredError("Policy cannot be empty");
        populatePolicy();

    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Error populating Policy List combobox", e);
    }

    return this.policy;
}
 
Example 11
Project: osc-core   File: BindSecurityGroupWindow.java   Source Code and License 6 votes vote down vote up
private ComboBox getPolicyComboBox(List<PolicyDto> policyDtoList) {
	ComboBox policy = new ComboBox("Select Policy");
	policy.setTextInputAllowed(false);
	policy.setNullSelectionAllowed(false);
	policy.setImmediate(true);
	policy.setRequired(true);
	policy.setRequiredError("Policy cannot be empty");

	BeanItemContainer<PolicyDto> policyListContainer = new BeanItemContainer<>(PolicyDto.class,
			policyDtoList);
	policy.setContainerDataSource(policyListContainer);
	policy.setItemCaptionPropertyId("policyName");

	if (policyListContainer.size() > 0) {
		policy.select(policyListContainer.getIdByIndex(0));
	}

	policy.setEnabled(false);

	return policy;
}
 
Example 12
Project: osc-core   File: BindSecurityGroupWindow.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings({ "rawtypes" })
private void serviceTableClicked(long itemId) {
	ComboBox policyComboBox = (ComboBox) this.serviceTable.getContainerProperty(itemId, PROPERTY_ID_POLICY)
			.getValue();
	ComboBox failurePolicyComboBox = (ComboBox) this.serviceTable
			.getContainerProperty(itemId, PROPERTY_ID_FAILURE_POLICY).getValue();
	Property itemProperty = this.serviceTable.getContainerProperty(itemId, PROPERTY_ID_ENABLED);

	boolean currentValue = (boolean) itemProperty.getValue();
	if (policyComboBox.getContainerDataSource().size() > 0) {
		if (isBindedWithMultiplePolicies(itemId)) {
			policyComboBox.setEnabled(false);
		} else {
			policyComboBox.setEnabled(currentValue);
		}
	}
	if (failurePolicyComboBox.getData() != null) {
		failurePolicyComboBox.setEnabled(currentValue);
	}
}
 
Example 13
Project: osc-core   File: BaseSecurityGroupWindow.java   Source Code and License 6 votes vote down vote up
protected ComboBox getProject() {
    try {
        this.project = new ComboBox("Select Project");
        this.project.setTextInputAllowed(true);
        this.project.setNullSelectionAllowed(false);
        this.project.setImmediate(true);
        this.project.setRequired(true);
        this.project.setRequiredError("Project cannot be empty");

    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Error populating Project List combobox", e);
    }

    return this.project;
}
 
Example 14
Project: osc-core   File: BaseDAWindow.java   Source Code and License 6 votes vote down vote up
private ComboBox createDomainComboBox(List<DomainDto> dl) {
    ComboBox domainComboBox = new ComboBox();
    BeanItemContainer<DomainDto> domainContainer = new BeanItemContainer<DomainDto>(DomainDto.class, dl);
    ApplianceManagerConnectorDto mc = (ApplianceManagerConnectorDto) this.managerConnector.getValue();

    domainComboBox.setContainerDataSource(domainContainer);
    domainComboBox.setTextInputAllowed(false);
    domainComboBox.setNullSelectionAllowed(false);
    domainComboBox.setItemCaptionPropertyId("name");
    domainComboBox.setEnabled(mc.isPolicyMappingSupported());

    if (domainComboBox.getItemIds().size() > 0) {
        domainComboBox.select(domainContainer.getIdByIndex(0));
    }
    return domainComboBox;
}
 
Example 15
Project: osc-core   File: BaseDAWindow.java   Source Code and License 6 votes vote down vote up
private ComboBox createEncapsulationTypeComboBox(VirtualizationType virtualizationType,
        List<TagEncapsulationType> types) {
    ComboBox encapsulationType = new ComboBox();
    encapsulationType.setTextInputAllowed(false);
    encapsulationType.setNullSelectionAllowed(true);

    BeanItemContainer<TagEncapsulationType> encapsulationTypeContainer = new BeanItemContainer<TagEncapsulationType>(
            TagEncapsulationType.class, types);
    encapsulationType.setContainerDataSource(encapsulationTypeContainer);
    ApplianceManagerConnectorDto currentMc = (ApplianceManagerConnectorDto) this.managerConnector.getValue();

    if (!virtualizationType.isOpenstack() || (currentMc != null && !currentMc.isPolicyMappingSupported())) {
        encapsulationType.setEnabled(false);
    }
    return encapsulationType;
}
 
Example 16
Project: osc-core   File: BaseDAWindow.java   Source Code and License 6 votes vote down vote up
/**
 * @return AD ComboBox
 */
protected ComboBox getApplianceDefinition() {
    try {
        this.applianceDefinition = new ComboBox("Service Function Definition");
        this.applianceDefinition.setTextInputAllowed(false);
        this.applianceDefinition.setNullSelectionAllowed(false);
        this.applianceDefinition.setRequired(true);
        this.applianceDefinition.setRequiredError("Service Function Definition cannot be Empty");
        this.applianceDefinition.setWidth(100, Unit.PERCENTAGE);

        updateAppliances();
    } catch (Exception e) {
        log.error("Error populating appliance list combobox", e);
    }

    return this.applianceDefinition;
}
 
Example 17
Project: md-stepper   File: StepperPropertiesLayout.java   Source Code and License 6 votes vote down vote up
private ComboBox createThemeChooserBox() {
  List<String> themes = Arrays.asList("Blueprint", "Dark", "Default", "Facebook", "Flat",
                                      "Flat-Dark", "Light", "Metro");

  ComboBox comboBox = new ComboBox("Choose theme", themes);
  comboBox.setWidth(100, Unit.PERCENTAGE);
  comboBox.setValue("Default");
  comboBox.addValueChangeListener(e -> {
    Object value = e.getValue();
    String theme = value != null ? String.valueOf(value) : "";
    if (!"".equals(theme.trim())) {
      getUI().setTheme(theme.toLowerCase());
    }
  });

  return comboBox;
}
 
Example 18
Project: HomeWire-Server   File: ConditionPanel.java   Source Code and License 6 votes vote down vote up
public ConditionPanel(ConditionDTO conditionDTO,
                      ConditionWidgetRepository conditionWidgetRepository,
                      Consumer<ConditionDTO> changeListener) {
  this.conditionWidgetRepository = conditionWidgetRepository;
  this.conditionDTO = conditionDTO;

  this.mainPanel = new Panel("Condition");
  this.mainTypeComboBox = new ComboBox("Type");

  this.currentConditionWidget = conditionWidgetRepository
      .getFactory(TypeViewDTO.ConditionTypes.ofConditionDto(conditionDTO))
      .createWidget(conditionDTO);
  currentConditionWidget.setChangeListener(changeListener);

  this.changeListener = changeListener;

  setupPanel();

  setCompositionRoot(mainPanel);
  setSizeUndefined();
}
 
Example 19
Project: HomeWire-Server   File: ActionPanel.java   Source Code and License 6 votes vote down vote up
public ActionPanel(ActionDTO actionDTO,
                   ActionWidgetRepository actionWidgetRepository,
                   Consumer<ActionDTO> changeListener) {
  this.actionWidgetRepository = actionWidgetRepository;
  this.actionDTO = actionDTO;

  this.mainPanel = new Panel("Action");
  this.mainTypeComboBox = new ComboBox("Type");

  this.currentActionWidget = actionWidgetRepository
      .getFactory(TypeViewDTO.ActionTypes.ofActionDto(actionDTO))
      .createWidget(actionDTO);
  currentActionWidget.setChangeListener(changeListener);

  this.changeListener = changeListener;

  setupPanel();

  setCompositionRoot(mainPanel);
  setSizeUndefined();
}
 
Example 20
Project: dungeonstory-java   File: SkillForm.java   Source Code and License 6 votes vote down vote up
@Override
protected Component createContent() {
    FormLayout layout = new FormLayout();

    name = new FTextField("Nom");
    shortDescription = new FTextField("Description courte").withFullWidth();
    description = new FTextArea("Description").withFullWidth();
    keyAbility = new ComboBox<Ability>("Attribut clé", Services.getAbilityService().findAll());

    layout.addComponent(name);
    layout.addComponent(shortDescription);
    layout.addComponent(description);
    layout.addComponent(keyAbility);
    layout.addComponent(getToolbar());

    return layout;
}
 
Example 21
Project: dungeonstory-java   File: CityForm.java   Source Code and License 6 votes vote down vote up
@Override
protected Component createContent() {
    FormLayout layout = new FormLayout();

    name = new FTextField("Nom");
    region = new ComboBox<Region>("Région", regionService.findAll());
    shortDescription = new FTextField("Description courte");
    description = new FTextArea("Description").withFullWidth();

    layout.addComponent(name);
    layout.addComponent(region);
    layout.addComponent(shortDescription);
    layout.addComponent(description);
    layout.addComponent(getToolbar());

    return layout;
}
 
Example 22
Project: dungeonstory-java   File: FeatForm.java   Source Code and License 6 votes vote down vote up
@Override
protected Component createContent() {
    FormLayout layout = new FormLayout();

    name = new FTextField("Nom").withWidth(50, Unit.PERCENTAGE);
    description = new FTextArea("Description").withFullWidth().withRows(10);
    usage = new EnumComboBox<FeatUsage>(FeatUsage.class, "Usage");
    prerequisiteType = new EnumComboBox<PrerequisiteType>(PrerequisiteType.class, "Type de prérequis");
    prerequisiteArmorProficiency = new EnumComboBox<>(ArmorType.ProficiencyType.class, "Maitrise d'armure prérequise");
    prerequisiteAbility = new ComboBox<Ability>("Caractéristique prérequise", abilityService.findAll());
    prerequisiteAbilityScore = new DSIntegerField("Score de caractéristique");

    prerequisiteType.addSelectionListener(event -> adjustTypeVisibility(event.getValue()));

    layout.addComponent(name);
    layout.addComponent(description);
    layout.addComponent(usage);
    layout.addComponents(prerequisiteType, prerequisiteArmorProficiency, prerequisiteAbility, prerequisiteAbilityScore);
    layout.addComponent(getToolbar());

    return layout;
}
 
Example 23
Project: dungeonstory-java   File: AdventureForm.java   Source Code and License 6 votes vote down vote up
@Override
protected Component createContent() {
    layout = new FormLayout();

    name = new FTextField("Titre").withWidth("50%");
    description = new FTextArea("Description").withFullWidth();
    challengeRating = new ComboBox<>("Degré de difficulté");
    challengeRating.setItems(Services.getLevelService().findAll());
    status = new EnumComboBox<>(AdventureStatus.class, "Statut");
    layout.addComponents(name, description, challengeRating, status);
    layout.addComponent(getToolbar());

    messageButton = new Button("Messages", event -> {
        EventBus.post(new NavigationEvent(AdventureView.URI + "/" + getEntity().getId()));
    });
    layout.addComponent(messageButton);

    return layout;
}
 
Example 24
Project: cuba   File: WebSearchPickerField.java   Source Code and License 6 votes vote down vote up
public WebSearchPickerField() {
    final ComboBox selectComponent = component;
    WebPickerField.Picker picker = new WebPickerField.Picker(this, component) {
        @Override
        public void setRequired(boolean required) {
            super.setRequired(required);
            selectComponent.setNullSelectionAllowed(!required);
        }
    };
    pickerField = new WebPickerField(picker);

    Messages messages = AppBeans.get(Messages.class);
    setInputPrompt(messages.getMainMessage("searchPickerField.inputPrompt"));

    // Required for custom components in fieldgroup
    initValueSync(selectComponent, picker);
}
 
Example 25
Project: incubator-openaz   File: ExpressionEditorWindow.java   Source Code and License 6 votes vote down vote up
@AutoGenerated
private VerticalLayout buildMainLayout() {
	// common part: create layout
	mainLayout = new VerticalLayout();
	mainLayout.setImmediate(false);
	mainLayout.setWidth("-1px");
	mainLayout.setHeight("-1px");
	mainLayout.setMargin(true);
	mainLayout.setSpacing(true);
	
	// top-level component properties
	setWidth("-1px");
	setHeight("-1px");
	
	// comboBox
	comboBox = new ComboBox();
	comboBox.setImmediate(false);
	comboBox.setWidth("-1px");
	comboBox.setHeight("-1px");
	mainLayout.addComponent(comboBox);
	
	// treeExpression
	treeExpression = new Tree();
	treeExpression.setImmediate(false);
	treeExpression.setWidth("100.0%");
	treeExpression.setHeight("-1px");
	mainLayout.addComponent(treeExpression);
	mainLayout.setExpandRatio(treeExpression, 1.0f);
	
	return mainLayout;
}
 
Example 26
Project: SecureBPMN   File: EnumFormPropertyRenderer.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Field getPropertyField(FormProperty formProperty) {
  ComboBox comboBox = new ComboBox(getPropertyLabel(formProperty));
  comboBox.setRequired(formProperty.isRequired());
  comboBox.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
  comboBox.setEnabled(formProperty.isWritable());

  Map<String, String> values = (Map<String, String>) formProperty.getType().getInformation("values");
  if (values != null) {
    for (Entry<String, String> enumEntry : values.entrySet()) {
      // Add value and label (if any)
      comboBox.addItem(enumEntry.getKey());
      if (enumEntry.getValue() != null) {
        comboBox.setItemCaption(enumEntry.getKey(), enumEntry.getValue());
      }
    }
  }
  return comboBox;
}
 
Example 27
Project: SecureBPMN   File: SelectUsersPopupWindow.java   Source Code and License 6 votes vote down vote up
protected void selectUser(String userId, String userName) {
  if (!selectedUsersTable.containsId(userId)) {
    Item item = selectedUsersTable.addItem(userId);
    item.getItemProperty("userName").setValue(userName);
    
    if (showRoles) {
      ComboBox comboBox = new ComboBox(null, Arrays.asList(
              i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR),
              i18nManager.getMessage(Messages.TASK_ROLE_IMPLEMENTER),
              i18nManager.getMessage(Messages.TASK_ROLE_MANAGER),
              i18nManager.getMessage(Messages.TASK_ROLE_SPONSOR)));
      comboBox.select(i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR));
      comboBox.setNewItemsAllowed(true);
      item.getItemProperty("role").setValue(comboBox);
    }
  }
}
 
Example 28
Project: metl   File: EditAgentDeploymentPanel.java   Source Code and License 6 votes vote down vote up
protected ComboBox getLogLevelComponent() {
    final ComboBox combo = new ComboBox("Log Level");
    combo.setNullSelectionAllowed(false);
    combo.setWidth(200, Unit.PIXELS);
    LogLevel[] levels = LogLevel.values();
    for (LogLevel logLevel : levels) {
        combo.addItem(logLevel.name());
    }
    combo.setValue(agentDeployment.getLogLevel());
    combo.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            agentDeployment.setLogLevel((String) combo.getValue());
            saveAgentDeployment(agentDeployment);
        }
    });
    return combo;
}
 
Example 29
Project: metl   File: EditAgentDeploymentPanel.java   Source Code and License 6 votes vote down vote up
protected ComboBox getStartTypeComponent() {
    startTypeCombo = new ComboBox("Start Type");
    startTypeCombo.setWidth(200, Unit.PIXELS);
    startTypeCombo.setNullSelectionAllowed(false);
    StartType[] values = StartType.values();
    for (StartType value : values) {
        startTypeCombo.addItem(value.name());
    }
    startTypeCombo.setValue(agentDeployment.getStartType());
    startTypeCombo.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            agentDeployment.setStartType((String) startTypeCombo.getValue());
            updateScheduleEnable();
            for (int i = 0; i < 7; i++) {
                ListSelect listSelect = ((ListSelect) cronLayout.getComponent(i));
                for (Object itemId : listSelect.getItemIds()) {
                    listSelect.unselect(itemId);
                }
                listSelect.select(listSelect.getItemIds().iterator().next());
            }
            String startExpression = null;
            if (agentDeployment.getStartType().equals(StartType.SCHEDULED_CRON.name())) {
                startExpression = "0 0 0 * * ?";
            }
            startExpressionTextField.setValue(startExpression);
            agentDeployment.setStartExpression(startExpression);
            updateScheduleFields();
            saveAgentDeployment(agentDeployment);
        }
    });
    return startTypeCombo;
}
 
Example 30
Project: metl   File: ImportXmlTemplateWindow.java   Source Code and License 6 votes vote down vote up
protected ComboBox createResourceCB() {
    ComboBox cb = new ComboBox("HTTP Resource");
    
    String projectVersionId = component.getProjectVersionId();
    IConfigurationService configurationService = context.getConfigurationService();

    Set<XMLResourceDefinition> types = context.getDefinitionFactory()
            .getResourceDefinitions(projectVersionId, ResourceCategory.HTTP);
    String[] typeStrings = new String[types.size()];
    int i = 0;
    for (XMLResourceDefinition type : types) {
        typeStrings[i++] = type.getId();
    }
    List<Resource> resources = new ArrayList<>(configurationService.findResourcesByTypes(projectVersionId, true, typeStrings));
    if (resources != null) {
        for (Resource resource : resources) {
            cb.addItem(resource);
        }
    }

    cb.setWidth(50.0f, Unit.PERCENTAGE);
    return cb;
}
 
Example 31
Project: metl   File: EditXmlFormatPanel.java   Source Code and License 6 votes vote down vote up
protected void buildXpathChoices() {
    SAXBuilder builder = new SAXBuilder();
    builder.setXMLReaderFactory(XMLReaders.NONVALIDATING);
    builder.setFeature("http://xml.org/sax/features/validation", false);
    Setting setting = component.findSetting(XmlFormatter.XML_FORMATTER_TEMPLATE);
    xpathChoices = new TreeSet<String>();
    if (StringUtils.isNotBlank(setting.getValue())) {
        try {
            Document document = builder.build(new StringReader(setting.getValue()));
            
            buildXpathChoicesFromElement("/" + document.getRootElement().getName(),
                    document.getRootElement());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    ComboBox combo = (ComboBox) grid.getColumn("xpath").getEditorField();
    combo.removeAllItems();
    combo.addItems(xpathChoices);
}
 
Example 32
Project: field-binder   File: SearchPatternComboBox.java   Source Code and License 6 votes vote down vote up
private void setFieldDefaults(ComboBox backingField) {
    backingField.setImmediate(true);

    backingField.removeAllItems();
    for (Object p : backingField.getContainerPropertyIds()) {
        backingField.removeContainerProperty(p);
    }

    // setup displaying property ids
    backingField.addContainerProperty(CAPTION_PROPERTY_ID, String.class, "");
    backingField.setItemCaptionPropertyId(CAPTION_PROPERTY_ID);

    @SuppressWarnings("unchecked")
    EnumSet<?> enumSet = EnumSet.allOf((Class<java.lang.Enum>) getTargetPropertyType());
    for (Object r : enumSet) {
        Item newItem = backingField.addItem(r);
        newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(r.toString());
    }
}
 
Example 33
Project: primecloud-controller   File: WinServerEdit.java   Source Code and License 6 votes vote down vote up
@Override
public void attach() {
    setHeight(TAB_HEIGHT);
    setMargin(false, true, false, true);
    setSpacing(false);

    // サーバサイズ
    sizeSelect = new ComboBox(ViewProperties.getCaption("field.serverSize"));
    sizeSelect.setNullSelectionAllowed(false);
    form.getLayout().addComponent(sizeSelect);

    // キーペア
    keySelect = new ComboBox(ViewProperties.getCaption("field.keyPair"));
    keySelect.setNullSelectionAllowed(false);
    form.getLayout().addComponent(keySelect);

    addComponent(form);
}
 
Example 34
Project: primecloud-controller   File: WinServerAddSimple.java   Source Code and License 6 votes vote down vote up
@Override
public void attach() {
    // サーバ名(Prefix)
    prefixField = new TextField(ViewProperties.getCaption("field.serverNamePrefix"));
    getLayout().addComponent(prefixField);

    // プラットフォーム
    cloudTable = new SelectCloudTable();
    getLayout().addComponent(cloudTable);

    // サーバ台数
    serverNumber = new ComboBox(ViewProperties.getCaption("field.serverNumber"));
    serverNumber.setWidth("110px");
    serverNumber.setMultiSelect(false);
    for (int i = 1; i <= MAX_ADD_SERVER; i++) {
        serverNumber.addItem(i);
    }
    serverNumber.setNullSelectionAllowed(false);
    serverNumber.setValue(1); // 初期値は1
    getLayout().addComponent(serverNumber);

    initValidation();
}
 
Example 35
Project: dhconvalidator   File: UserSwitchPanel.java   Source Code and License 6 votes vote down vote up
/**
 * Setup UI.
 */
private void initComponents() {
	List<User> users = UserList.INSTANCE.getUsers();
	userSwitchBox = new ComboBox(Messages.getString("UserSwitchPanel.boxCaption")); //$NON-NLS-1$
	setUsers(users);
	User current = (User) VaadinSession.getCurrent().getAttribute(SessionStorageKey.USER.name());
	userSwitchBox.setValue(current);
	
	userSwitchBox.setDescription(
		Messages.getString("UserSwitchPanel.boxDescription")); //$NON-NLS-1$
	userSwitchBox.setNewItemsAllowed(false);
	userSwitchBox.setNullSelectionAllowed(false);
	
	addComponent(userSwitchBox);
	btReload = new Button(Messages.getString("UserSwitchPanel.reloadCaption")); //$NON-NLS-1$
	btReload.setStyleName(BaseTheme.BUTTON_LINK);
	btReload.addStyleName("plain-link"); //$NON-NLS-1$
	
	addComponent(btReload);
}
 
Example 36
Project: mycollab   File: TimeZoneSelectionField.java   Source Code and License 6 votes vote down vote up
public TimeZoneSelectionField(boolean isVerticalDisplay) {
    this.isVerticalDisplay = isVerticalDisplay;
    areaSelection = new ValueComboBox(false, TimezoneVal.getAreas());
    areaSelection.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            setCboTimeZone((String) areaSelection.getValue());
        }
    });
    timezoneSelection = new ComboBox();
    timezoneSelection.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID);
    String area = (String) areaSelection.getItemIds().iterator().next();
    areaSelection.setValue(area);
    setCboTimeZone(area);
}
 
Example 37
Project: mycollab   File: DateSelectionField.java   Source Code and License 6 votes vote down vote up
public DateSelectionField() {
    cboMonth = new ComboBox();
    cboMonth.setNullSelectionAllowed(true);
    cboMonth.setPageLength(12);
    cboMonth.setImmediate(true);

    addMonthItems();
    cboMonth.setWidth("117px");

    cboDate = new ComboBox();
    cboDate.setNullSelectionAllowed(true);
    cboDate.setImmediate(true);

    addDayItems();
    cboDate.setWidth("80px");

    cboYear = new ComboBox();
    cboYear.setNullSelectionAllowed(true);
    cboYear.setImmediate(true);

    addYearItems();
    cboYear.setWidth("80px");
}
 
Example 38
Project: XACML   File: ExpressionEditorWindow.java   Source Code and License 6 votes vote down vote up
@AutoGenerated
private VerticalLayout buildMainLayout() {
	// common part: create layout
	mainLayout = new VerticalLayout();
	mainLayout.setImmediate(false);
	mainLayout.setWidth("-1px");
	mainLayout.setHeight("-1px");
	mainLayout.setMargin(true);
	mainLayout.setSpacing(true);
	
	// top-level component properties
	setWidth("-1px");
	setHeight("-1px");
	
	// comboBox
	comboBox = new ComboBox();
	comboBox.setImmediate(false);
	comboBox.setWidth("-1px");
	comboBox.setHeight("-1px");
	mainLayout.addComponent(comboBox);
	
	// treeExpression
	treeExpression = new Tree();
	treeExpression.setImmediate(false);
	treeExpression.setWidth("100.0%");
	treeExpression.setHeight("-1px");
	mainLayout.addComponent(treeExpression);
	mainLayout.setExpandRatio(treeExpression, 1.0f);
	
	return mainLayout;
}
 
Example 39
Project: FiWare-Template-Handler   File: EnumFormPropertyRenderer.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Field getPropertyField(FormProperty formProperty) {
  ComboBox comboBox = new ComboBox(getPropertyLabel(formProperty));
  comboBox.setRequired(formProperty.isRequired());
  comboBox.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
  comboBox.setEnabled(formProperty.isWritable());

  Map<String, String> values = (Map<String, String>) formProperty.getType().getInformation("values");
  if (values != null) {
    for (Entry<String, String> enumEntry : values.entrySet()) {
      // Add value and label (if any)
      comboBox.addItem(enumEntry.getKey());
      if (enumEntry.getValue() != null) {
        comboBox.setItemCaption(enumEntry.getKey(), enumEntry.getValue());
      }
    }
  }
  return comboBox;
}
 
Example 40
Project: FiWare-Template-Handler   File: SelectUsersPopupWindow.java   Source Code and License 6 votes vote down vote up
protected void selectUser(String userId, String userName) {
  if (!selectedUsersTable.containsId(userId)) {
    Item item = selectedUsersTable.addItem(userId);
    item.getItemProperty("userName").setValue(userName);
    
    if (showRoles) {
      ComboBox comboBox = new ComboBox(null, Arrays.asList(
              i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR),
              i18nManager.getMessage(Messages.TASK_ROLE_IMPLEMENTER),
              i18nManager.getMessage(Messages.TASK_ROLE_MANAGER),
              i18nManager.getMessage(Messages.TASK_ROLE_SPONSOR)));
      comboBox.select(i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR));
      comboBox.setNewItemsAllowed(true);
      item.getItemProperty("role").setValue(comboBox);
    }
  }
}