本文整理汇总了Java中com.vaadin.ui.ComboBox.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java ComboBox.setValue方法的具体用法?Java ComboBox.setValue怎么用?Java ComboBox.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.ui.ComboBox
的用法示例。
在下文中一共展示了ComboBox.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createThemeChooserBox
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例2: getLogLevelComponent
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例3: attach
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
@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();
}
示例4: initComponents
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
* 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);
}
示例5: createStepperTypeBox
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例6: createIconStyleBox
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例7: getStartTypeComponent
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例8: ReportParameterReportChooser
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
*
* @param caption
* @param defaultValue
* @param parameterName
* @param enumClass
*/
public ReportParameterReportChooser(String caption, T defaultValue, String parameterName, Class<T> enumClass)
{
super(caption, parameterName);
field = new ComboBox(caption);
this.enumClass = enumClass;
field.setContainerDataSource(FormHelper.createContainerFromEnumClass("value", enumClass));
field.setNewItemsAllowed(false);
field.setNullSelectionAllowed(false);
field.setTextInputAllowed(false);
field.setValue(defaultValue);
}
示例9: ReportParameterEnum
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
*
* @param caption
* @param defaultValue
* @param parameterName
* @param enumClass
*/
public ReportParameterEnum(String caption, T defaultValue, String parameterName, Class<T> enumClass)
{
super(caption, parameterName);
field = new ComboBox(caption);
this.enumClass = enumClass;
field.setContainerDataSource(FormHelper.createContainerFromEnumClass("value", enumClass));
field.setNewItemsAllowed(false);
field.setNullSelectionAllowed(false);
field.setTextInputAllowed(false);
field.setValue(defaultValue);
}
示例10: fillCombo
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
* Fill combo with a list of objeces.
* @param data list to fill with.
* @param clear true if clear all items before adding new ones.
*/
public static void fillCombo(ComboBox combo, List<?> data, boolean clear) {
Object selected = combo.getValue();
if (clear) {
combo.removeAllItems();
}
for (Object o : data) {
combo.addItem(o);
}
if (data.contains(selected))
combo.setValue(selected);
}
示例11: createField
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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;
}
示例12: initComponents
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
/**
* Setup UI.
*/
private void initComponents() {
Label info = new Label(
Messages.getString("PaperSelectionPanel.hintMsg"), //$NON-NLS-1$
ContentMode.HTML);
languages =
new ComboBox(Messages.getString("PaperSelectionPanel.language"), //$NON-NLS-1$
Arrays.asList(SubmissionLanguage.values()));
languages.setNullSelectionAllowed(false);
languages.setValue(SubmissionLanguage.valueOf(PropertyKey.defaultSubmissionLanguage.getValue(SubmissionLanguage.ENGLISH.name())));
paperTable = new Table(Messages.getString("PaperSelectionPanel.tableTitle")); //$NON-NLS-1$
paperTable.setSelectable(true);
paperTable.setMultiSelect(true);
paperTable.setPageLength(4);
paperTable.addContainerProperty("title", String.class, null); //$NON-NLS-1$
paperTable.setColumnHeader(
"title",
Messages.getString("PaperSelectionPanel.titleColumnTitle")); //$NON-NLS-1$ //$NON-NLS-2$
paperTable.setWidth("100%"); //$NON-NLS-1$
paperTable.setImmediate(true);
btGenerate = new Button(
Messages.getString(
"PaperSelectionPanel.generateButtonCaption")); //$NON-NLS-1$
StreamResource templateStreamResource =
new StreamResource(
new StreamSource() {
@Override
public InputStream getStream() {
return createTemplates();
}
}, "your_personal_dh_templates.zip" ); //$NON-NLS-1$
templateStreamResource.setCacheTime(0);
new FileDownloader(templateStreamResource).extend(btGenerate);
addCenteredComponent(info);
addCenteredComponent(languages);
addCenteredComponent(paperTable);
addCenteredComponent(btGenerate);
postDownloadLabel =
new Label(
Messages.getString("PaperSelectionPanel.postDownloadInfo",
inputConverter.getTextEditorDescription(),
PropertyKey.base_url.getValue()+"popup/DHConvalidatorServices#!converter"),
ContentMode.HTML);
postDownloadLabel.addStyleName("postDownloadInfoRedAndBold");
postDownloadLabel.setVisible(false);
addCenteredComponent(postDownloadLabel);
}
示例13: TicketDashboardViewImpl
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
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);
}
示例14: setupAddFilterWindow
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
private void setupAddFilterWindow(Window window) {
// General variables
// Layouts
GridLayout mainLayout = new GridLayout(1, 3);
HorizontalLayout axisLayout = new HorizontalLayout();
HorizontalLayout criteriaLayout = new HorizontalLayout();
HorizontalLayout buttonLayout = new HorizontalLayout();
hznCriteria = criteriaLayout;
// Buttons
ExpressZipButton btnAdd = new ExpressZipButton("Add", Style.ACTION);
btnAdd.setClickShortcut(KeyCode.ENTER);
btnAdd.addStyleName("primary");
ExpressZipButton btnCancel = new ExpressZipButton("Cancel", Style.ACTION);
// Fields
ComboBox cmbAxis = new ComboBox();
cmbAxis.setTextInputAllowed(false);
cmbAxis.setNullSelectionAllowed(false);
// Labels
Label lblAxis = new Label("Axis");
btnAdd.addListener(filterButtonListener);
btnCancel.addListener(filterButtonListener);
for (Filter.AxisFilters f : Filter.axisArray) {
cmbAxis.addItem(filter.getNameOfFilter(f));
}
cmbAxis.setImmediate(true);
cmbAxis.addListener(axisSelectedListener);
cmbAxis.setValue(filter.getNameOfFilter(Filter.axisArray[0]));
mainLayout.addComponent(axisLayout, 0, 0);
mainLayout.addComponent(criteriaLayout, 0, 1);
mainLayout.addComponent(buttonLayout, 0, 2);
mainLayout.setSpacing(true);
axisLayout.setSpacing(true);
axisLayout.addComponent(lblAxis);
axisLayout.addComponent(cmbAxis);
axisLayout.setExpandRatio(lblAxis, .2f);
axisLayout.setExpandRatio(cmbAxis, .8f);
axisLayout.setComponentAlignment(lblAxis, Alignment.MIDDLE_LEFT);
axisLayout.setComponentAlignment(cmbAxis, Alignment.MIDDLE_LEFT);
axisLayout.setSizeFull();
criteriaLayout.setSizeFull();
buttonLayout.setSpacing(true);
buttonLayout.addComponent(btnAdd);
buttonLayout.addComponent(btnCancel);
buttonLayout.setComponentAlignment(btnAdd, Alignment.BOTTOM_RIGHT);
buttonLayout.setComponentAlignment(btnCancel, Alignment.BOTTOM_RIGHT);
buttonLayout.setExpandRatio(btnAdd, 1f);
buttonLayout.setExpandRatio(btnCancel, 0f);
buttonLayout.setSizeFull();
mainLayout.setRowExpandRatio(0, 1f);
mainLayout.setRowExpandRatio(1, 1f);
mainLayout.setRowExpandRatio(2, 1f);
mainLayout.setSizeFull();
window.addComponent(mainLayout);
window.getContent().setSizeFull();
}
示例15: OldLoginView
import com.vaadin.ui.ComboBox; //导入方法依赖的package包/类
public OldLoginView() {
setSizeFull();
// Language bar in the top-right corner for selecting
// invitation interface language
final HorizontalLayout languageBar = new HorizontalLayout();
languageBar.setHeight("50px");
// addComponent(languageBar);
// setComponentAlignment(languageBar, Alignment.TOP_RIGHT);
// Allow selecting a language. We are in a constructor of a
// CustomComponent, so preselecting the current
// language of the application can not be done before
// this (and the selection) component are attached to
// the application.
final ComboBox languageSelector = new ComboBox("Select a language") {
@Override
public void attach() {
super.attach();
// setValue(getLocale());
}
};
// for (int i=0; i<locales.length; i++) {
String locale = "es";
languageSelector.addItem(locale);
languageSelector.setItemCaption(locale, "español");
// Automatically select the current locale
// if (locales[i].equals(getLocale()))
languageSelector.setValue(locale);
// }
// Create the invitation input field
invitationTextField = new TextField("Invitation key:");
invitationTextField.setWidth("300px");
invitationTextField.setRequired(true);
invitationTextField.setInputPrompt("Your questionnair invitation key (eg. 12345678)");
invitationTextField.setInvalidAllowed(false);
// Create login button
enterButton = new Button("Enter", this);
// Add both to a panel
VerticalLayout fields = new VerticalLayout(languageSelector, invitationTextField, enterButton);
fields.setCaption("Please enter your invitation key to access the questionnair");
fields.setSpacing(true);
fields.setMargin(new MarginInfo(true, true, true, false));
fields.setSizeUndefined();
// The view root layout
VerticalLayout viewLayout = new VerticalLayout(fields);
viewLayout.setSizeFull();
viewLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER);
viewLayout.setStyleName(Reindeer.LAYOUT_BLUE);
setCompositionRoot(viewLayout);
}