use of com.vaadin.ui.ComboBox in project Activiti by Activiti.
the class NewGroupPopupWindow method initInputFields.
protected void initInputFields() {
// Input fields
form.addField("id", new TextField(i18nManager.getMessage(Messages.GROUP_ID)));
// Set id field to required
form.getField("id").setRequired(true);
form.getField("id").setRequiredError(i18nManager.getMessage(Messages.GROUP_ID_REQUIRED));
form.getField("id").focus();
// Set id field to be unique
form.getField("id").addValidator(new Validator() {
public void validate(Object value) throws InvalidValueException {
if (!isValid(value)) {
throw new InvalidValueException(i18nManager.getMessage(Messages.GROUP_ID_UNIQUE));
}
}
public boolean isValid(Object value) {
if (value != null) {
return identityService.createGroupQuery().groupId(value.toString()).singleResult() == null;
}
return false;
}
});
form.addField("name", new TextField(i18nManager.getMessage(Messages.GROUP_NAME)));
ComboBox typeComboBox = new ComboBox(i18nManager.getMessage(Messages.GROUP_TYPE), Arrays.asList("assignment", "security-role"));
typeComboBox.select("assignment");
form.addField("type", typeComboBox);
}
use of com.vaadin.ui.ComboBox in project opennms by OpenNMS.
the class MibObjFieldFactory method createField.
/* (non-Javadoc)
* @see com.vaadin.ui.TableFieldFactory#createField(com.vaadin.data.Container, java.lang.Object, java.lang.Object, com.vaadin.ui.Component)
*/
@Override
public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) {
if (propertyId.equals("oid")) {
final TextField field = new TextField();
field.setSizeFull();
field.setRequired(true);
field.setImmediate(true);
field.addValidator(new RegexpValidator("^\\.[.\\d]+$", "Invalid OID {0}"));
return field;
}
if (propertyId.equals("instance")) {
final ComboBox field = new ComboBox();
field.setSizeFull();
field.setRequired(true);
field.setImmediate(true);
field.setNullSelectionAllowed(false);
field.setNewItemsAllowed(true);
field.setNewItemHandler(new NewItemHandler() {
@Override
public void addNewItem(String newItemCaption) {
if (!field.containsId(newItemCaption)) {
field.addItem(newItemCaption);
field.setValue(newItemCaption);
}
}
});
field.addItem("0");
field.addItem("ifIndex");
for (String rt : resourceTypes) {
field.addItem(rt);
}
return field;
}
if (propertyId.equals("alias")) {
final TextField field = new TextField();
field.setSizeFull();
field.setRequired(true);
field.setImmediate(true);
field.addValidator(new StringLengthValidator("Invalid alias. It should not contain more than 19 characters.", 1, 19, false));
return field;
}
if (propertyId.equals("type")) {
final TextField field = new TextField();
field.setSizeFull();
field.setRequired(true);
field.setImmediate(true);
field.addValidator(new // Based on NumericAttributeType and StringAttributeType
RegexpValidator(// Based on NumericAttributeType and StringAttributeType
"^(?i)(counter|gauge|timeticks|integer|octetstring|string)?\\d*$", "Invalid type {0}. Valid types are: counter, gauge, timeticks, integer, octetstring, string"));
return field;
}
return null;
}
use of com.vaadin.ui.ComboBox in project Activiti by Activiti.
the class EnumFormPropertyRenderer method getPropertyField.
@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());
comboBox.setNullSelectionAllowed(false);
Object firstItemId = null;
Object itemToSelect = null;
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 (firstItemId == null) {
// select first element
firstItemId = enumEntry.getKey();
}
String selectedValue = formProperty.getValue();
if (selectedValue != null && selectedValue.equals(enumEntry.getKey())) {
// select first element
itemToSelect = enumEntry.getKey();
}
if (enumEntry.getValue() != null) {
comboBox.setItemCaption(enumEntry.getKey(), enumEntry.getValue());
}
}
}
// Select value or first element
if (itemToSelect != null) {
comboBox.select(itemToSelect);
} else if (firstItemId != null) {
comboBox.select(firstItemId);
}
return comboBox;
}
use of com.vaadin.ui.ComboBox in project Activiti by Activiti.
the class SelectUsersPopupWindow method selectUser.
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);
}
}
}
use of com.vaadin.ui.ComboBox in project charts by vaadin.
the class ChartsDemoUI method init.
@Override
protected void init(VaadinRequest request) {
initGATracker();
tabSheet = new TabSheet();
tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {
@Override
public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
com.vaadin.ui.JavaScript.eval("setTimeout(function(){prettyPrint();},300);");
}
});
tabSheet.setSizeFull();
tabSheet.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
Link homepage = new Link("Home page", new ExternalResource("https://vaadin.com/add-ons/charts"));
Link javadoc = new Link("JavaDoc", new ExternalResource("http://demo.vaadin.com/javadoc/com.vaadin/vaadin-charts/" + getVersion() + "/"));
Link manual = new Link("Manual", new ExternalResource("https://vaadin.com/docs/-/part/charts/charts-overview.html"));
Label version = new Label("Version " + getVersion());
version.addStyleName("version");
HorizontalLayout links = new HorizontalLayout(homepage, javadoc, manual);
links.setSpacing(true);
links.addStyleName("links");
final HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
horizontalSplitPanel.setSecondComponent(tabSheet);
horizontalSplitPanel.setSplitPosition(300, Unit.PIXELS);
horizontalSplitPanel.addStyleName("main-layout");
ChartOptions.get().setTheme(new ValoLightTheme());
themeSelector = new ComboBox("Charts Theme:");
themeSelector.addStyleName("theme-selector");
themeSelector.addStyleName(ValoTheme.COMBOBOX_SMALL);
themeSelector.setTextInputAllowed(false);
com.vaadin.addon.charts.model.style.Theme defaultTheme = new ValoLightTheme();
Map<com.vaadin.addon.charts.model.style.Theme, String> mapThemes = new HashMap<>();
com.vaadin.addon.charts.model.style.Theme[] themes = new com.vaadin.addon.charts.model.style.Theme[] { defaultTheme, new ValoDarkTheme(), new VaadinTheme(), new HighChartsDefaultTheme(), new GridTheme(), new GrayTheme(), new SkiesTheme() };
mapThemes.put(themes[0], "Valo Light");
mapThemes.put(themes[1], "Valo Dark");
mapThemes.put(themes[2], "Vaadin");
mapThemes.put(themes[3], "HighCharts");
mapThemes.put(themes[4], "Grid");
mapThemes.put(themes[5], "Gray");
mapThemes.put(themes[6], "Skies");
themeSelector.setEmptySelectionAllowed(false);
themeSelector.setItems(themes);
themeSelector.setSelectedItem(defaultTheme);
themeSelector.setItemCaptionGenerator(mapThemes::get);
themeSelector.addSelectionListener(e -> {
ChartOptions.get().setTheme(e.getValue());
});
final HierarchicalContainer container = getContainer();
VerticalLayout content = new VerticalLayout();
content.setSpacing(true);
content.setMargin(false);
Label logo = new Label("Vaadin Charts");
logo.setWidth("100%");
logo.addStyleName("h3");
logo.addStyleName("logo");
TextField filterField = new TextField();
filterField.setPlaceholder("Filter examples");
filterField.setIcon(FontAwesome.SEARCH);
filterField.addStyleName("filter");
filterField.setWidth("100%");
filterField.addValueChangeListener(e -> {
container.removeAllContainerFilters();
String text = e.getValue();
if (text != null && !text.isEmpty()) {
expandForFiltering();
container.addContainerFilter("searchName", text, true, false);
} else {
restoreExpandedStates();
}
});
tree = new Tree();
tree.setImmediate(true);
tree.setContainerDataSource(container);
tree.setItemCaptionPropertyId("displayName");
tree.setNullSelectionAllowed(false);
tree.setWidth("100%");
tree.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent event) {
Object value = event.getProperty().getValue();
if (value instanceof Class) {
updateTabSheet((Class) value);
} else {
tree.expandItemsRecursively(value);
}
}
});
Button feedback = new Button("Got feedback?", FontAwesome.COMMENTING_O);
feedback.addStyleName("feedback-button");
feedback.addStyleName(ValoTheme.BUTTON_PRIMARY);
feedback.addStyleName(ValoTheme.BUTTON_TINY);
feedback.addClickListener(e -> {
getUI().addWindow(new FeedbackForm());
});
content.addComponents(logo, links, feedback, filterField, tree, version);
content.setComponentAlignment(feedback, Alignment.MIDDLE_CENTER);
horizontalSplitPanel.setFirstComponent(content);
selectItem();
Page.getCurrent().addUriFragmentChangedListener(new Page.UriFragmentChangedListener() {
@Override
public void uriFragmentChanged(Page.UriFragmentChangedEvent event) {
selectItem();
}
});
setContent(new CssLayout() {
{
setSizeFull();
addComponent(horizontalSplitPanel);
addComponent(themeSelector);
}
});
if (tracker != null) {
tracker.trackPageview("/charts");
}
}
Aggregations