use of com.vaadin.ui.NativeSelect in project Activiti by Activiti.
the class EventOverviewPanel method initProcessInstances.
protected void initProcessInstances() {
HorizontalLayout instancesHeader = new HorizontalLayout();
instancesHeader.setSpacing(false);
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();
}
use of com.vaadin.ui.NativeSelect in project opennms by OpenNMS.
the class SimulationModeReductionKeyInfoPanelItemProvider method createComponent.
private Component createComponent(ReductionKeyVertex vertex, GraphContainer container) {
final FormLayout formLayout = new FormLayout();
formLayout.setSpacing(false);
formLayout.setMargin(false);
NativeSelect dropdown = new NativeSelect("Severity");
dropdown.setMultiSelect(false);
dropdown.setNewItemsAllowed(false);
dropdown.setNullSelectionAllowed(true);
dropdown.setImmediate(true);
dropdown.setRequired(true);
dropdown.addItems(Arrays.asList(Status.values()));
SetStatusToCriteria setStatusTo = findCriteria(container, vertex);
if (setStatusTo != null) {
dropdown.setValue(setStatusTo.getStatus());
} else {
dropdown.setValue(null);
}
dropdown.addValueChangeListener(event -> {
// The set of criteria may have changed since we last queried it above
// do we issue try finding it again, instead of using the same existing object
SetStatusToCriteria currentSetStatusTo = findCriteria(container, vertex);
Status selectedStatus = (Status) dropdown.getValue();
if (currentSetStatusTo != null) {
currentSetStatusTo.setStatus(selectedStatus);
} else {
currentSetStatusTo = new SetStatusToCriteria(vertex.getReductionKey(), selectedStatus);
container.addCriteria(currentSetStatusTo);
}
// Remove the current selection before redrawing the layout in order
// to avoid centering on the current vertex
container.getSelectionManager().setSelectedVertexRefs(Collections.emptyList());
container.getSelectionManager().setSelectedEdgeRefs(Collections.emptyList());
container.redoLayout();
});
formLayout.addComponent(dropdown);
return formLayout;
}
use of com.vaadin.ui.NativeSelect in project charts by vaadin.
the class BasicColumnWithPointWidthAndRange method setup.
@Override
protected void setup() {
super.setup();
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setMargin(true);
horizontalLayout.setSpacing(true);
final Slider slider = new Slider("Value (1-100)", 1, 100);
slider.setWidth("200px");
slider.setValue(100d);
final NativeSelect<String> option = new NativeSelect<>();
option.setCaption("Option");
option.setItems("", "pointWidth", "pointRange");
option.setSelectedItem("pointWidth");
option.addSelectionListener(sc -> {
slider.setEnabled(!sc.getSelectedItem().get().equals(""));
});
horizontalLayout.addComponent(option);
horizontalLayout.addComponent(slider);
Button button = new Button("Apply");
button.addClickListener(e -> {
if (slider.isEnabled()) {
if (option.getSelectedItem().get().equals("pointWidth")) {
plotOptions.setPointWidth(slider.getValue());
plotOptions.setPointRange(null);
} else {
plotOptions.setPointRange(slider.getValue());
plotOptions.setPointWidth(null);
}
} else {
plotOptions.setPointRange(null);
plotOptions.setPointWidth(null);
}
chart.drawChart();
});
horizontalLayout.addComponent(button);
addComponent(horizontalLayout);
}
use of com.vaadin.ui.NativeSelect in project ANNIS by korpling.
the class FlatQueryBuilder method launch.
private void launch(QueryController cp) {
this.cp = cp;
rsc = new ReducingStringComparator();
this.query = "";
mainLayout = new VerticalLayout();
// tracking lists for vertical nodes, edgeboxes and metaboxes
vnodes = new ArrayList<>();
eboxes = new ArrayList<>();
mboxes = new ArrayList<>();
spbox = null;
// buttons and checks
btGo = new Button(BUTTON_GO_LABEL, (Button.ClickListener) this);
btGo.setStyleName(ChameleonTheme.BUTTON_SMALL);
btClear = new Button(BUTTON_CLEAR_LABEL, (Button.ClickListener) this);
btClear.setStyleName(ChameleonTheme.BUTTON_SMALL);
btInverse = new Button(BUTTON_INV_LABEL, (Button.ClickListener) this);
btInverse.setStyleName(ChameleonTheme.BUTTON_SMALL);
btInitLanguage = new Button("Initialize", (Button.ClickListener) this);
btInitLanguage.setDescription(INFO_INIT_LANG);
btInitSpan = new Button("Initialize", (Button.ClickListener) this);
btInitSpan.setDescription(INFO_INIT_SPAN);
btInitMeta = new Button("Initialize", (Button.ClickListener) this);
btInitMeta.setDescription(INFO_INIT_META);
filtering = new NativeSelect("Filtering mechanisms");
filtering.setDescription(INFO_FILTER);
ReducingStringComparator rdc = new ReducingStringComparator();
Set mappings = rdc.getMappings().keySet();
int i;
for (i = 0; i < mappings.size(); i++) {
String mapname = (String) mappings.toArray()[i];
filtering.addItem(i);
filtering.setItemCaption(i, mapname);
}
filtering.addItem(i + 1);
filtering.setItemCaption(i + 1, "generic");
filtering.select(i + 1);
filtering.setNullSelectionAllowed(false);
filtering.setImmediate(true);
// language layout
language = new HorizontalLayout();
languagenodes = new HorizontalLayout();
language.addComponent(languagenodes);
language.addComponent(btInitLanguage);
language.setMargin(true);
language.setCaption(LANG_CAPTION);
language.addStyleName("linguistics-panel");
// span layout
span = new HorizontalLayout();
span.setSpacing(true);
span.addComponent(btInitSpan);
span.setMargin(true);
span.setCaption(SPAN_CAPTION);
span.addStyleName("span-panel");
// meta layout
meta = new HorizontalLayout();
meta.setSpacing(true);
meta.addComponent(btInitMeta);
meta.setMargin(true);
meta.setCaption(META_CAPTION);
meta.addStyleName("meta-panel");
// toolbar layout
toolbar = new HorizontalLayout();
toolbar.setSpacing(true);
toolbar.addComponent(btGo);
toolbar.addComponent(btClear);
toolbar.addComponent(btInverse);
toolbar.setMargin(true);
toolbar.setCaption(TOOLBAR_CAPTION);
toolbar.addStyleName("toolbar-panel");
// advanced
advanced = new HorizontalLayout();
advanced.setSpacing(true);
advanced.addComponent(filtering);
advanced.setMargin(true);
advanced.setCaption(ADVANCED_CAPTION);
advanced.addStyleName("advanced-panel");
// put everything on the layout
mainLayout.setSpacing(true);
mainLayout.addComponent(language);
mainLayout.addComponent(span);
mainLayout.addComponent(meta);
mainLayout.addComponent(toolbar);
mainLayout.addComponent(advanced);
setContent(mainLayout);
getContent().setWidth("100%");
getContent().setHeight("-1px");
}
use of com.vaadin.ui.NativeSelect in project tutorials by eugenp.
the class VaadinUI method init.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.setSpacing(true);
verticalLayout.setMargin(true);
final GridLayout gridLayout = new GridLayout(3, 2);
gridLayout.setSpacing(true);
gridLayout.setMargin(true);
final HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setSpacing(true);
horizontalLayout.setMargin(true);
final FormLayout formLayout = new FormLayout();
formLayout.setSpacing(true);
formLayout.setMargin(true);
final GridLayout buttonLayout = new GridLayout(3, 5);
buttonLayout.setMargin(true);
buttonLayout.setSpacing(true);
final Label label = new Label();
label.setId("Label");
label.setValue("Label Value");
label.setCaption("Label");
gridLayout.addComponent(label);
final Link link = new Link("Baeldung", new ExternalResource("http://www.baeldung.com/"));
link.setId("Link");
link.setTargetName("_blank");
gridLayout.addComponent(link);
final TextField textField = new TextField();
textField.setId("TextField");
textField.setCaption("TextField:");
textField.setValue("TextField Value");
textField.setIcon(FontAwesome.USER);
gridLayout.addComponent(textField);
final TextArea textArea = new TextArea();
textArea.setCaption("TextArea");
textArea.setId("TextArea");
textArea.setValue("TextArea Value");
gridLayout.addComponent(textArea);
final DateField dateField = new DateField("DateField", new Date(0));
dateField.setId("DateField");
gridLayout.addComponent(dateField);
final PasswordField passwordField = new PasswordField();
passwordField.setId("PasswordField");
passwordField.setCaption("PasswordField:");
passwordField.setValue("password");
gridLayout.addComponent(passwordField);
final RichTextArea richTextArea = new RichTextArea();
richTextArea.setCaption("Rich Text Area");
richTextArea.setValue("<h1>RichTextArea</h1>");
richTextArea.setSizeFull();
Panel richTextPanel = new Panel();
richTextPanel.setContent(richTextArea);
final InlineDateField inlineDateField = new InlineDateField();
inlineDateField.setValue(new Date(0));
inlineDateField.setCaption("Inline Date Field");
horizontalLayout.addComponent(inlineDateField);
Button normalButton = new Button("Normal Button");
normalButton.setId("NormalButton");
normalButton.addClickListener(e -> {
label.setValue("CLICK");
});
buttonLayout.addComponent(normalButton);
Button tinyButton = new Button("Tiny Button");
tinyButton.addStyleName("tiny");
buttonLayout.addComponent(tinyButton);
Button smallButton = new Button("Small Button");
smallButton.addStyleName("small");
buttonLayout.addComponent(smallButton);
Button largeButton = new Button("Large Button");
largeButton.addStyleName("large");
buttonLayout.addComponent(largeButton);
Button hugeButton = new Button("Huge Button");
hugeButton.addStyleName("huge");
buttonLayout.addComponent(hugeButton);
Button disabledButton = new Button("Disabled Button");
disabledButton.setDescription("This button cannot be clicked");
disabledButton.setEnabled(false);
buttonLayout.addComponent(disabledButton);
Button dangerButton = new Button("Danger Button");
dangerButton.addStyleName("danger");
buttonLayout.addComponent(dangerButton);
Button friendlyButton = new Button("Friendly Button");
friendlyButton.addStyleName("friendly");
buttonLayout.addComponent(friendlyButton);
Button primaryButton = new Button("Primary Button");
primaryButton.addStyleName("primary");
buttonLayout.addComponent(primaryButton);
NativeButton nativeButton = new NativeButton("Native Button");
buttonLayout.addComponent(nativeButton);
Button iconButton = new Button("Icon Button");
iconButton.setIcon(FontAwesome.ALIGN_LEFT);
buttonLayout.addComponent(iconButton);
Button borderlessButton = new Button("BorderLess Button");
borderlessButton.addStyleName("borderless");
buttonLayout.addComponent(borderlessButton);
Button linkButton = new Button("Link Button");
linkButton.addStyleName("link");
buttonLayout.addComponent(linkButton);
Button quietButton = new Button("Quiet Button");
quietButton.addStyleName("quiet");
buttonLayout.addComponent(quietButton);
horizontalLayout.addComponent(buttonLayout);
final CheckBox checkbox = new CheckBox("CheckBox");
checkbox.setValue(true);
checkbox.addValueChangeListener(e -> checkbox.setValue(!checkbox.getValue()));
formLayout.addComponent(checkbox);
List<String> numbers = new ArrayList<String>();
numbers.add("One");
numbers.add("Ten");
numbers.add("Eleven");
ComboBox comboBox = new ComboBox("ComboBox");
comboBox.addItems(numbers);
formLayout.addComponent(comboBox);
ListSelect listSelect = new ListSelect("ListSelect");
listSelect.addItems(numbers);
listSelect.setRows(2);
formLayout.addComponent(listSelect);
NativeSelect nativeSelect = new NativeSelect("NativeSelect");
nativeSelect.addItems(numbers);
formLayout.addComponent(nativeSelect);
TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect");
twinColSelect.addItems(numbers);
Grid grid = new Grid("Grid");
grid.setColumns("Column1", "Column2", "Column3");
grid.addRow("Item1", "Item2", "Item3");
grid.addRow("Item4", "Item5", "Item6");
Panel panel = new Panel("Panel");
panel.setContent(grid);
panel.setSizeUndefined();
Panel serverPushPanel = new Panel("Server Push");
FormLayout timeLayout = new FormLayout();
timeLayout.setSpacing(true);
timeLayout.setMargin(true);
currentTime = new Label("No TIME...");
timeLayout.addComponent(currentTime);
serverPushPanel.setContent(timeLayout);
serverPushPanel.setSizeUndefined();
ScheduledExecutorService scheduleExecutor = Executors.newScheduledThreadPool(1);
Runnable task = () -> {
currentTime.setValue("Current Time : " + Instant.now());
};
scheduleExecutor.scheduleWithFixedDelay(task, 0, 1, TimeUnit.SECONDS);
FormLayout dataBindingLayout = new FormLayout();
dataBindingLayout.setSpacing(true);
dataBindingLayout.setMargin(true);
BindData bindData = new BindData("BindData");
BeanFieldGroup beanFieldGroup = new BeanFieldGroup(BindData.class);
beanFieldGroup.setItemDataSource(bindData);
TextField bindedTextField = (TextField) beanFieldGroup.buildAndBind("BindName", "bindName");
bindedTextField.setWidth("250px");
dataBindingLayout.addComponent(bindedTextField);
FormLayout validatorLayout = new FormLayout();
validatorLayout.setSpacing(true);
validatorLayout.setMargin(true);
HorizontalLayout textValidatorLayout = new HorizontalLayout();
textValidatorLayout.setSpacing(true);
textValidatorLayout.setMargin(true);
TextField stringValidator = new TextField();
stringValidator.setNullSettingAllowed(true);
stringValidator.setNullRepresentation("");
stringValidator.addValidator(new StringLengthValidator("String must have 2-5 characters lenght", 2, 5, true));
stringValidator.setValidationVisible(false);
textValidatorLayout.addComponent(stringValidator);
Button buttonStringValidator = new Button("Validate String");
buttonStringValidator.addClickListener(e -> {
try {
stringValidator.setValidationVisible(false);
stringValidator.validate();
} catch (InvalidValueException err) {
stringValidator.setValidationVisible(true);
}
});
textValidatorLayout.addComponent(buttonStringValidator);
validatorLayout.addComponent(textValidatorLayout);
verticalLayout.addComponent(gridLayout);
verticalLayout.addComponent(richTextPanel);
verticalLayout.addComponent(horizontalLayout);
verticalLayout.addComponent(formLayout);
verticalLayout.addComponent(twinColSelect);
verticalLayout.addComponent(panel);
verticalLayout.addComponent(serverPushPanel);
verticalLayout.addComponent(dataBindingLayout);
verticalLayout.addComponent(validatorLayout);
setContent(verticalLayout);
}
Aggregations