Java Code Examples for com.vaadin.ui.ComboBox.addValueChangeListener()

The following are Jave code examples for showing how to use addValueChangeListener() of the com.vaadin.ui.ComboBox class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hawkbit   File: ComboBoxBuilder.java   Source Code and License Vote up 7 votes
/**
 * @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: esup-ecandidat   File: GridFormatting.java   Source Code and License Vote up 6 votes
/**
 * 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 3
Project: md-stepper   File: StepperPropertiesLayout.java   Source Code and License Vote up 6 votes
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 4
Project: metl   File: EditAgentDeploymentPanel.java   Source Code and License Vote up 6 votes
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 5
Project: metl   File: EditAgentDeploymentPanel.java   Source Code and License Vote up 6 votes
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 6
Project: hypothesis   File: ExportScorePresenterImpl.java   Source Code and License Vote up 6 votes
private void buildSelection() {
	exportSelectionType = new ComboBox();
	exportSelectionType.setTextInputAllowed(false);
	exportSelectionType.setNullSelectionAllowed(false);
	exportSelectionType.setEnabled(false);

	exportSelectionType.addItem(Messages.getString("Caption.Item.Selected"));
	exportSelectionType.addItem(Messages.getString("Caption.Item.All"));
	exportSelectionType.select(Messages.getString("Caption.Item.Selected"));

	exportSelectionType.addValueChangeListener(new Property.ValueChangeListener() {
		public void valueChange(ValueChangeEvent event) {
			allTestsSelected = exportSelectionType.getValue().equals(Messages.getString("Caption.Item.All"));
			mainEvent.fire(new MainUIEvent.PackSelectionChangedEvent());
		}
	});
}
 
Example 7
Project: hypothesis   File: UserManagementPresenterImpl.java   Source Code and License Vote up 6 votes
@Override
protected ComboBox buildSelection() {
	final ComboBox selectionType = new ComboBox();
	selectionType.setTextInputAllowed(false);
	selectionType.setNullSelectionAllowed(false);

	selectionType.addItem(Messages.getString("Caption.Item.Selected"));
	selectionType.addItem(Messages.getString("Caption.Item.All"));
	selectionType.select(Messages.getString("Caption.Item.Selected"));

	selectionType.addValueChangeListener(e -> {
		allSelected = selectionType.getValue().equals(Messages.getString("Caption.Item.All"));
		mainEvent.fire(new MainUIEvent.UserSelectionChangedEvent());
	});

	return selectionType;
}
 
Example 8
Project: hypothesis   File: GroupManagementPresenterImpl.java   Source Code and License Vote up 6 votes
@Override
protected ComboBox buildSelection() {
	final ComboBox selectionType = new ComboBox();
	selectionType.setTextInputAllowed(false);
	selectionType.setNullSelectionAllowed(false);

	selectionType.addItem(Messages.getString("Caption.Item.Selected"));
	selectionType.addItem(Messages.getString("Caption.Item.All"));
	selectionType.select(Messages.getString("Caption.Item.Selected"));

	selectionType.addValueChangeListener(e -> {
		allSelected = selectionType.getValue().equals(Messages.getString("Caption.Item.All"));
		mainEvent.fire(new MainUIEvent.GroupSelectionChangedEvent());
	});

	return selectionType;
}
 
Example 9
Project: VaadinUtils   File: DependantComboBox.java   Source Code and License Vote up 6 votes
private void addParentHandler(final ComboBox parent, final EntityContainer<E> childContainer,
		final SingularAttribute<E, Parent> childForeignAttribute)
{
	parent.addValueChangeListener(new ValueChangeListener()
	{
		private static final long serialVersionUID = 1L;

		@Override
		public void valueChange(com.vaadin.data.Property.ValueChangeEvent event)
		{
			@SuppressWarnings("unchecked")
			Parent parentEntity = ((Parent) parent.getConvertedValue());

			childContainer.removeAllContainerFilters();
			childContainer.addContainerFilter(new Compare.Equal(childForeignAttribute.getName(), parentEntity));
			DependantComboBox.this.setContainerDataSource(childContainer);
			DependantComboBox.this.setValue(null);
		}
	});
}
 
Example 10
Project: md-stepper   File: StepperPropertiesLayout.java   Source Code and License Vote up 5 votes
private ComboBox createStepperTypeBox() {
  List<String> stepperTypes = Arrays.asList("Horizontal", "Vertical");

  ComboBox comboBox = new ComboBox("Stepper Type *", stepperTypes);
  comboBox.setWidth(100, Unit.PERCENTAGE);
  comboBox.setValue(stepperTypes.get(0));
  comboBox.addValueChangeListener(event -> {
    createStepper();
    fireEvent(new StepperCreateEvent(StepperPropertiesLayout.this, stepper));
  });
  return comboBox;
}
 
Example 11
Project: md-stepper   File: StepperPropertiesLayout.java   Source Code and License Vote up 5 votes
private ComboBox createIconStyleBox() {
  List<String> iconStyles = Arrays.asList("Square", "Circular");
  ComboBox comboBox = new ComboBox("Choose Icon Style", iconStyles);
  comboBox.setWidth(100, Unit.PERCENTAGE);
  comboBox.setValue("Circular");
  comboBox.addValueChangeListener(event -> updateStepperIconStyles());
  return comboBox;
}
 
Example 12
Project: HomeWire-Server   File: SetActionWidget.java   Source Code and License Vote up 5 votes
private void setup() {
  // Devices
  ComboBox devicesComboBox = new ComboBox("Actors");
  devicesComboBox.setNullSelectionItemId(false);
  devicesComboBox.setContainerDataSource(
      new BeanItemContainer<>(
          DeviceViewDTO.class,
          deviceSetupService.getAllActors().stream()
              .map(deviceDTO -> modelMapper.map(deviceDTO, DeviceViewDTO.class))
              .collect(Collectors.toList())
      )
  );

  DeviceDTO selectedDeviceDTO = deviceSetupService
      .getDeviceDtoByIdAndType(actionDTO.getDevId(), actionDTO.getDevType());
  if (selectedDeviceDTO != null) {
    devicesComboBox.select(modelMapper.map(selectedDeviceDTO, DeviceViewDTO.class));
  }

  devicesComboBox.addValueChangeListener(event -> {
    DeviceViewDTO selected = (DeviceViewDTO) event.getProperty().getValue();

    actionDTO.setDevId(selected.getDevId());
    actionDTO.setDevType(selected.getType());

    changeListener.accept(actionDTO);
  });
  mainLayout.addComponent(devicesComboBox);

  // Target
  TextField targetTextField = new TextField("Target", actionDTO.getParameter());
  targetTextField.addValueChangeListener(event -> {
    actionDTO.setParameter((String) event.getProperty().getValue());

    changeListener.accept(actionDTO);
  });
  mainLayout.addComponent(targetTextField);

}
 
Example 13
Project: KrishnasSpace   File: FilterGrid.java   Source Code and License Vote up 5 votes
/**
 * @param filterRow
 * @return
 */
private HeaderCell setCategoryFilter(HeaderRow filterRow) {
	HeaderCell categoryFilter = filterRow.getCell(CATEGORY);
	ComboBox comboBox = new ComboBox();
	comboBox.setHeight(100, Unit.PERCENTAGE);
	comboBox.setImmediate(true);
	comboBox.setNewItemsAllowed(false);
	comboBox.setTextInputAllowed(false);
	comboBox.addValueChangeListener(getCategoryFilterListener());
	comboBox.setContainerDataSource(getCategoryDataSource());
	categoryFilter.setComponent(comboBox);
	return categoryFilter;
}
 
Example 14
Project: trader   File: TradingAreaView.java   Source Code and License Vote up 5 votes
private Component buildQuoteSelector() {
		quoteSelector = new ComboBox();
		
//		quoteSelector.setInputPrompt("Select Stock/Index...");
		
//		quoteSelector.setItemCaptionPropertyId(Quote.PROPERTY_NAME);
//		quoteSelector.setItemCaptionMode(ItemCaptionMode.PROPERTY);

		
        // Set full width
//		quoteSelector.setWidth(100.0f, Unit.PERCENTAGE);
		quoteSelector.addStyleName("borderless");
		
        // Set the appropriate filtering mode for this example
		quoteSelector.setFilteringMode(FilteringMode.CONTAINS);
		quoteSelector.setImmediate(true);
 
        // Disallow null selections
		quoteSelector.setNullSelectionAllowed(false);
		
		quoteSelector.addValueChangeListener(e -> {
                chart.setChartSymbol(quotes.getItem(e.getProperty().getValue()).getBean().getChartSrc());
                ticker.setSymbol(quotes.getItem(e.getProperty().getValue()).getBean().getTickerSrc());
                chartToolbar.getCharts().getChildren().get(LiveChart.ChartDrawType.LINE.ordinal()*2).setChecked(false);
                chartToolbar.getCharts().getChildren().get(LiveChart.ChartDrawType.CANDLE.ordinal()*2).setChecked(true);
		});
		
		return quoteSelector;
	}
 
Example 15
Project: metl   File: EditXmlFormatPanel.java   Source Code and License Vote up 5 votes
protected void buildGrid() {
    grid = new Grid();
    grid.setSelectionMode(SelectionMode.NONE);
    grid.setSizeFull();
    grid.setEditorEnabled(!readOnly);
    container = new BeanItemContainer<Record>(Record.class);
    grid.setContainerDataSource(container);
    grid.setColumns("entityName", "attributeName", "xpath");
    HeaderRow filterRow = grid.appendHeaderRow();

    addColumn("entityName", filterRow);

    addColumn("attributeName", filterRow);

    ComboBox combo = new ComboBox();
    combo.addValueChangeListener(e->saveXPathSettings());
    combo.setWidth(100, Unit.PERCENTAGE);
    combo.setImmediate(true);
    combo.setNewItemsAllowed(true);
    combo.setInvalidAllowed(true);
    combo.setTextInputAllowed(true);
    combo.setScrollToSelectedItem(true);
    combo.setFilteringMode(FilteringMode.CONTAINS);
    grid.getColumn("xpath").setEditorField(combo).setExpandRatio(1);
    addShowPopulatedFilter("xpath", filterRow);
    grid.setEditorBuffered(false);
    addComponent(grid);
    setExpandRatio(grid, 1);
}
 
Example 16
Project: metl   File: EditTransformerPanel.java   Source Code and License Vote up 5 votes
public Field<?> createField(final Container dataContainer, final Object itemId, final Object propertyId,
        com.vaadin.ui.Component uiContext) {
    final ComponentAttribSetting setting = (ComponentAttribSetting) itemId;
    Field<?> field = null;

    if (propertyId.equals("value") && (setting.getValue() == null || !setting.getValue().contains("\n"))) {
        final ComboBox combo = new ComboBox();
        combo.setWidth(100, Unit.PERCENTAGE);
        String[] functions = ModelAttributeScriptHelper.getSignatures();
        for (String function : functions) {
            combo.addItem(function);
        }
        combo.setPageLength(functions.length > 20 ? 20 : functions.length);
        if (setting.getValue() != null && !combo.getItemIds().contains(setting.getValue())) {
            combo.addItem(setting.getValue());
        }
        combo.setImmediate(true);
        combo.setNewItemsAllowed(true);
        combo.addValueChangeListener(new ValueChangeListener() {
            public void valueChange(ValueChangeEvent event) {
                setting.setValue((String) combo.getValue());
                context.getConfigurationService().save(setting);
            }
        });
        field = combo;
    }
    return field;
}
 
Example 17
Project: mycollab   File: TicketComponentFactoryImpl.java   Source Code and License Vote up 5 votes
NewTicketWindow(Date date, final Integer prjId, final Integer milestoneId, boolean isIncludeMilestone) {
    super(UserUIContext.getMessage(TicketI18nEnum.NEW));
    MVerticalLayout content = new MVerticalLayout();
    withModal(true).withResizable(false).withCenter().withWidth("1200px").withContent(content);

    typeSelection = new ComboBox();
    typeSelection.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID);
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
        typeSelection.addItem(UserUIContext.getMessage(TaskI18nEnum.SINGLE));
        typeSelection.setItemIcon(UserUIContext.getMessage(TaskI18nEnum.SINGLE), ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK));
    }

    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) {
        typeSelection.addItem(UserUIContext.getMessage(BugI18nEnum.SINGLE));
        typeSelection.setItemIcon(UserUIContext.getMessage(BugI18nEnum.SINGLE), ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG));
    }

    if (isIncludeMilestone && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) {
        typeSelection.addItem(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
        typeSelection.setItemIcon(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE), ProjectAssetsManager.getAsset(ProjectTypeConstants.MILESTONE));
    }

    typeSelection.setNullSelectionAllowed(false);
    if (CollectionUtils.isNotEmpty(typeSelection.getItemIds())) {
        typeSelection.select(typeSelection.getItemIds().iterator().next());
    } else {
        throw new SecureAccessException();
    }

    typeSelection.setNullSelectionAllowed(false);
    typeSelection.addValueChangeListener(valueChangeEvent -> doChange(date, prjId, milestoneId));

    GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 1);
    formLayoutHelper.addComponent(typeSelection, UserUIContext.getMessage(GenericI18Enum.FORM_TYPE), 0, 0);
    formLayout = new CssLayout();
    formLayout.setWidth("100%");
    content.with(formLayoutHelper.getLayout(), formLayout);
    doChange(date, prjId, milestoneId);
}
 
Example 18
Project: chipster   File: InputOutputUI.java   Source Code and License Vote up 5 votes
protected void initElements() {
	type2 = new ComboBox();
	type2.setImmediate(true);
	type2.setWidth(WIDTH);
	lbMeta = new Label("Meta:");
	cbMeta = new CheckBox();
	cbMeta.setDescription("Is this element Meta data");
	
	optional.setWidth(WIDTH);
	type = new ComboBox();
	type.setWidth(WIDTH);
	type.setNullSelectionAllowed(false);
	type.setImmediate(true);
	type.addItem(SINGLE_FILE);
	type.addItem(MULTI_FILE);
	type.select(SINGLE_FILE);
	type.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = -1134955257251483403L;

		@Override
		public void valueChange(ValueChangeEvent event) {
			if(type.getValue().toString().contentEquals(SINGLE_FILE)) {
				getSingleFileUI();
			} else if(type.getValue().toString().contentEquals(MULTI_FILE)){
				getMultipleFilesUI();
			}
		}
	});
}
 
Example 19
Project: jdal   File: FormUtils.java   Source Code and License Vote up 5 votes
/**
 * Add a link on primary and dependent ComboBoxes by property name. 
 * When selection changes on primary use propertyName to get a Collection and fill dependent ComboBox with it
 * @param primary ComboBox when selection changes
 * @param dependent ComboBox that are filled with collection   
 * @param propertyName the property name for get the collection from primary selected item
 * @param addNull if true, add a null as first combobox item
 */
@SuppressWarnings("rawtypes")
public static void link(final ComboBox primary, final ComboBox dependent,
		final String propertyName, final boolean addNull) {

	primary.addValueChangeListener(new ValueChangeListener() {

		public void valueChange(ValueChangeEvent event) {
			Object selected = event.getProperty().getValue();
			if (selected != null) {
				BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(selected);
				if (wrapper.isReadableProperty(propertyName)) {
					Collection items = (Collection) wrapper.getPropertyValue(propertyName);
					dependent.removeAllItems();
					
					if (addNull)
						dependent.addItem(null);
					
					for (Object item : items)
						dependent.addItem(item);
				}
				else {
					log.error("Can't write on propety '" + propertyName + "' of class: '" + selected.getClass() + "'");
				}
			}

		}
	});
}
 
Example 20
Project: esup-ecandidat   File: GridFormatting.java   Source Code and License Vote up 4 votes
/**
 * Ajoute un filtre de Boolean sur une liste de colonnes
 * 
 * @param filterRow
 * @param container
 * @param property
 * @param labelTrue
 * @param labelFalse
 * @param labelNull
 */
private void addBooleanFilter(String property, String labelTrue, String labelFalse, String labelNull) {
	HeaderCell cell = getFilterCell(property);
	ComboBox cbOuiNon = new ComboBox();
	cbOuiNon.setTextInputAllowed(false);

	List<BooleanPresentation> liste = new ArrayList<BooleanPresentation>();
	BooleanPresentation nullObject = new BooleanPresentation(BooleanValue.ALL,
			applicationContext.getMessage("filter.all", null, UI.getCurrent().getLocale()), null);
	liste.add(nullObject);

	if (labelTrue != null) {
		liste.add(new BooleanPresentation(BooleanValue.TRUE, labelTrue, FontAwesome.CHECK_SQUARE_O));
	}
	if (labelFalse != null) {
		liste.add(new BooleanPresentation(BooleanValue.FALSE, labelFalse, FontAwesome.SQUARE_O));
	}
	if (labelNull != null) {
		liste.add(new BooleanPresentation(BooleanValue.NULL, labelNull, FontAwesome.HOURGLASS_HALF));
	}

	BeanItemContainer<BooleanPresentation> containerOuiNon = new BeanItemContainer<BooleanPresentation>(
			BooleanPresentation.class, liste);
	cbOuiNon.setNullSelectionItemId(nullObject);
	cbOuiNon.setImmediate(true);
	cbOuiNon.setContainerDataSource(containerOuiNon);
	cbOuiNon.setItemCaptionPropertyId("libelle");
	cbOuiNon.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	cbOuiNon.setItemIconPropertyId("icone");
	cbOuiNon.setWidth(100, Unit.PERCENTAGE);
	cbOuiNon.addStyleName(ValoTheme.COMBOBOX_TINY);

	cbOuiNon.addValueChangeListener(change -> {
		container.removeContainerFilters(property);
		if (cbOuiNon.getValue() != null) {
			BooleanPresentation value = (BooleanPresentation) cbOuiNon.getValue();
			if (value != null) {
				BooleanValue booleanValue = value.getValeur();
				switch (booleanValue) {
				case TRUE:
					container.addContainerFilter(new Equal(property, true));
					break;
				case FALSE:
					container.addContainerFilter(new Equal(property, false));
					break;
				case NULL:
					container.addContainerFilter(new Equal(property, null));
					break;
				default:
					break;
				}
			}
			fireFilterListener();
		}
	});
	cell.setComponent(cbOuiNon);
}
 
Example 21
Project: tree-grid   File: DemoUI.java   Source Code and License Vote up 4 votes
@Override
protected void init(VaadinRequest request) {

    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    final ComboBox combo = new ComboBox(null, Arrays.asList(DEMO_SIMPLE, DEMO_IMAGE));
    combo.setNullSelectionAllowed(false);
    combo.setSizeUndefined();
    layout.addComponent(combo);

    final TreeGrid grid = new TreeGrid();
    grid.setWidth(800, Unit.PIXELS);

    DemoContainer container = new DemoContainer();
    grid.setContainerDataSource(container);

    grid.getColumn(DemoContainer.PROPERTY_ICON).setRenderer(new ImageRenderer());
    grid.getColumn(DemoContainer.PROPERTY_ICON).setEditable(false);

    grid.setSelectionMode(Grid.SelectionMode.SINGLE);
    grid.setColumnReorderingAllowed(true);
    grid.setEditorEnabled(true);

    layout.addComponent(grid);

    combo.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            switch ((String) event.getProperty().getValue()) {
            case DEMO_IMAGE:
                grid.getColumn(DemoContainer.PROPERTY_ICON).setHidden(false);
                grid.setHierarchyColumn(DemoContainer.PROPERTY_ICON);
                grid.setColumnOrder(
                        DemoContainer.PROPERTY_ICON,
                        DemoContainer.PROPERTY_NAME,
                        DemoContainer.PROPERTY_HOURS,
                        DemoContainer.PROPERTY_MODIFIED);
                setTheme("demo2");
                break;
            case DEMO_SIMPLE:
            default:
                grid.getColumn(DemoContainer.PROPERTY_ICON).setHidden(true);
                grid.setHierarchyColumn(DemoContainer.PROPERTY_NAME);
                grid.setColumnOrder(
                        DemoContainer.PROPERTY_NAME,
                        DemoContainer.PROPERTY_HOURS,
                        DemoContainer.PROPERTY_MODIFIED);
                setTheme("demo");
                break;
            }
        }
    });

    combo.select(DEMO_SIMPLE);

    setContent(layout);
}
 
Example 22
Project: incubator-openaz   File: RangeEditorComponent.java   Source Code and License Vote up 4 votes
private void setupComboText(final ComboBox box, final TextField text) {
	//
	// Respond to combo changes
	//
	box.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void valueChange(ValueChangeEvent event) {
			//
			// Get the new value
			//
			String property = (String) box.getValue();
			//
			// Get our constraint object
			//
			ConstraintValue value = (ConstraintValue) box.getData();
			//
			// Update our object
			//
			if (property == null) {
				//
				// Clear the text field and disable it
				//
				text.setEnabled(false);
				text.setValue(null);
			} else {
				//
				// Change the property name
				//
				value.setProperty(property);
				//
				// Focus to the text field and enable it
				//
				text.setEnabled(true);
				text.focus();
			}
		}
	});
	
}
 
Example 23
Project: metl   File: PluginsPanelAddDialog.java   Source Code and License Vote up 4 votes
protected AbstractLayout buildSearchLayout() {
    FormLayout layout = new FormLayout();
    layout.setMargin(true);

    List<Plugin> existingPlugins = context.getPluginService().findPlugins();
    Set<String> groups = new HashSet<>();
    Set<String> names = new HashSet<>();
    for (Plugin plugin : existingPlugins) {
        groups.add(plugin.getArtifactGroup());
        names.add(plugin.getArtifactName());
    }

    versionSelect = new ListSelect("Versions");
    groupCombo = new ComboBox("Group");
    nameCombo = new ComboBox("Name");

    versionSelect.setRows(4);
    versionSelect.setMultiSelect(false);
    versionSelect.setNullSelectionAllowed(false);
    versionSelect.setWidth(100, Unit.PERCENTAGE);
    versionSelect.addValueChangeListener(e -> versionSelected());

    groupCombo.setWidth(100, Unit.PERCENTAGE);
    groupCombo.setNewItemsAllowed(true);
    groupCombo.addItems(groups);
    groupCombo.addValueChangeListener(e -> {
        populateNameField(nameCombo);
        setSearchButtonEnabled();
    });
    groupCombo.setNewItemHandler((newItemCaption) -> {
        groupCombo.removeItem(handEnteredGroup);
        handEnteredGroup = newItemCaption;
        groupCombo.addItem(handEnteredGroup);
        groupCombo.setValue(handEnteredGroup);
        setSearchButtonEnabled();
    });
    layout.addComponent(groupCombo);

    nameCombo.setWidth(100, Unit.PERCENTAGE);
    nameCombo.setNewItemsAllowed(true);
    nameCombo.addItems(names);
    nameCombo.addValueChangeListener(e -> {
        setSearchButtonEnabled();
    });
    nameCombo.setNewItemHandler((newItemCaption) -> {
        nameCombo.removeItem(handEnteredName);
        handEnteredName = newItemCaption;
        nameCombo.addItem(handEnteredName);
        nameCombo.setValue(handEnteredName);
        setSearchButtonEnabled();
    });
    layout.addComponent(nameCombo);

    layout.addComponent(versionSelect);

    return layout;
}
 
Example 24
Project: metl   File: EditContentRouterPanel.java   Source Code and License Vote up 4 votes
public Field<?> createField(final Container dataContainer, final Object itemId, final Object propertyId,
        com.vaadin.ui.Component uiContext) {
    final Route route = (Route) itemId;
    Field<?> field = null;
    if (propertyId.equals("matchExpression")) {
        final TextField textField = new ImmediateUpdateTextField(null) {
            @Override
            protected void save(String text) {
                route.setMatchExpression(text);
                EditContentRouterPanel.this.save();
            }
        };
        textField.setWidth(100, Unit.PERCENTAGE);
        textField.setValue(route.getMatchExpression());
        field = textField;
    } else if (propertyId.equals("targetStepId")) {
        final ComboBox combo = new ComboBox();
        combo.setWidth(100, Unit.PERCENTAGE);
        flow = context.getConfigurationService().findFlow(flow.getId());
        List<FlowStepLink> stepLinks = flow.findFlowStepLinksWithSource(flowStep.getId());
        for (FlowStepLink flowStepLink : stepLinks) {
            FlowStep comboStep = flow.findFlowStepWithId(flowStepLink.getTargetStepId());
            combo.addItem(comboStep.getId());
            combo.setItemCaption(comboStep.getId(), comboStep.getName());

            if (flowStepLink.getTargetStepId().equals(route.getTargetStepId()) || combo.getValue() == null) {
                combo.setValue(comboStep.getId());
            }
        }

        combo.setImmediate(true);
        combo.setNewItemsAllowed(false);
        combo.setNullSelectionAllowed(false);
        combo.addValueChangeListener(new ValueChangeListener() {
            public void valueChange(ValueChangeEvent event) {
                String stepId = (String) event.getProperty().getValue();
                if (stepId != null) {
                    route.setTargetStepId(stepId);
                    EditContentRouterPanel.this.save();
                }
            }
        });
        field = combo;
    }
    if (field != null) {
        field.setReadOnly(readOnly);
    }
    return field;
}
 
Example 25
Project: mycollab   File: TicketDashboardViewImpl.java   Source Code and License Vote up 4 votes
public TicketDashboardViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));
    ticketSearchPanel = new TicketSearchPanel();

    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    groupWrapLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.ACTION_SORT)));
    final ComboBox sortCombo = new ValueComboBox(false, UserUIContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING),
            UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING));
    sortCombo.addValueChangeListener(valueChangeEvent -> {
        String sortValue = (String) sortCombo.getValue();
        if (UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) {
            sortDirection = SearchCriteria.ASC;
        } else {
            sortDirection = SearchCriteria.DESC;
        }
        queryAndDisplayTickets();
    });
    sortDirection = SearchCriteria.DESC;
    groupWrapLayout.addComponent(sortCombo);

    groupWrapLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.OPT_GROUP)));
    final ComboBox groupCombo = new ValueComboBox(false, UserUIContext.getMessage(GenericI18Enum.FORM_DUE_DATE),
            UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE), UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME),
            UserUIContext.getMessage(GenericI18Enum.OPT_PLAIN), UserUIContext.getMessage(GenericI18Enum.OPT_USER),
            UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
    groupByState = UserUIContext.getMessage(MilestoneI18nEnum.SINGLE);
    groupCombo.setValue(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
    groupCombo.addValueChangeListener(valueChangeEvent -> {
        groupByState = (String) groupCombo.getValue();
        queryAndDisplayTickets();
    });

    groupWrapLayout.addComponent(groupCombo);

    ticketSearchPanel.addHeaderRight(groupWrapLayout);

    MButton printBtn = new MButton("", clickEvent -> UI.getCurrent().addWindow(
            new TicketCustomizeReportOutputWindow(new LazyValueInjector() {
                @Override
                protected Object doEval() {
                    return baseCriteria;
                }
            }))).withIcon(FontAwesome.PRINT).withStyleName(WebThemes.BUTTON_OPTION)
            .withDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    groupWrapLayout.addComponent(printBtn);

    MButton newTicketBtn = new MButton(UserUIContext.getMessage(TicketI18nEnum.NEW), clickEvent -> {
        UI.getCurrent().addWindow(AppContextUtil.getSpringBean(TicketComponentFactory.class)
                .createNewTicketWindow(null, CurrentProjectVariables.getProjectId(), null, false));
    }).withIcon(FontAwesome.PLUS).withStyleName(WebThemes.BUTTON_ACTION)
            .withVisible(CurrentProjectVariables.canWriteTicket());
    groupWrapLayout.addComponent(newTicketBtn);

    if (!SiteConfiguration.isCommunityEdition()) {
        MButton advanceDisplayBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_LIST))
                .withIcon(FontAwesome.NAVICON).withWidth("100px");

        MButton kanbanBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_KANBAN), clickEvent ->
                displayKanbanView()).withWidth("100px").withIcon(FontAwesome.TH);

        ToggleButtonGroup viewButtons = new ToggleButtonGroup();
        viewButtons.addButton(advanceDisplayBtn);
        viewButtons.addButton(kanbanBtn);
        viewButtons.withDefaultButton(advanceDisplayBtn);
        groupWrapLayout.addComponent(viewButtons);
    }

    MHorizontalLayout mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth();
    wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false));
    rightColumn = new MVerticalLayout().withWidth("370px").withMargin(new MarginInfo(true, false, false, false));
    mainLayout.with(wrapBody, rightColumn).expand(wrapBody);
    this.with(ticketSearchPanel, mainLayout);
}
 
Example 26
Project: XACML   File: RangeEditorComponent.java   Source Code and License Vote up 4 votes
private void setupComboText(final ComboBox box, final TextField text) {
	//
	// Respond to combo changes
	//
	box.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void valueChange(ValueChangeEvent event) {
			//
			// Get the new value
			//
			String property = (String) box.getValue();
			//
			// Get our constraint object
			//
			ConstraintValue value = (ConstraintValue) box.getData();
			//
			// Update our object
			//
			if (property == null) {
				//
				// Clear the text field and disable it
				//
				text.setEnabled(false);
				text.setValue(null);
			} else {
				//
				// Change the property name
				//
				value.setProperty(property);
				//
				// Focus to the text field and enable it
				//
				text.setEnabled(true);
				text.focus();
			}
		}
	});
	
}
 
Example 27
Project: extacrm   File: ProductField.java   Source Code and License Vote up 4 votes
@Override
    protected Component initContent() {
        // A vertical layout with undefined width
        final VerticalLayout box = new VerticalLayout();
        box.setSizeUndefined();

        final ComboBox productSelect = new ComboBox();
        productSelect.setInputPrompt("Выберите продукт...");
        productSelect.setImmediate(true);
        productSelect.setNullSelectionAllowed(false);

        // Инициализация контейнера
        final ExtaDbContainer<TProduct> clientsCont = new ExtaDbContainer<>(productCls);
        clientsCont.addContainerFilter(new Compare.Equal("active", true));
        clientsCont.sort(new Object[]{"name"}, new boolean[]{true});

        // Устанавливаем контент выбора
        productSelect.setFilteringMode(FilteringMode.CONTAINS);
        productSelect.setContainerDataSource(clientsCont);
        productSelect.setItemCaptionMode(ItemCaptionMode.PROPERTY);
        productSelect.setItemCaptionPropertyId("name");
        productSelect.addStyleName(ExtaTheme.COMBOBOX_BORDERLESS);

        productSelect.setPropertyDataSource(getPropertyDataSource());
        productSelect.addValueChangeListener(e -> setValue((TProduct) productSelect.getConvertedValue()));
//        productSelect.setValue(getValue());
        clientsCont.setSingleSelectConverter(productSelect);

        productSelect.setWidth(100, Unit.PERCENTAGE);
        box.addComponent(productSelect);
        // The layout shrinks to fit this label
        final Label label = new Label(getFieldTextLabel());
        label.addStyleName("ea-widthfittin-label");
        label.setWidthUndefined();
        label.setHeight("0px"); // Hide: Could be 0px
        box.addComponent(label);

        addValueChangeListener(e -> label.setValue(getFieldTextLabel()));

        return box;
    }