List of usage examples for com.vaadin.ui CheckBox getValue
@Override
public Boolean getValue()
From source file:com.mycollab.module.project.view.user.UserUnresolvedTicketWidget.java
License:Open Source License
public UserUnresolvedTicketWidget() { super("", new CssLayout()); this.setWidth("100%"); final CheckBox myItemsSelection = new CheckBox(UserUIContext.getMessage(GenericI18Enum.OPT_MY_ITEMS)); myItemsSelection.addValueChangeListener(valueChangeEvent -> { boolean isMyItemsOption = myItemsSelection.getValue(); if (searchCriteria != null) { if (isMyItemsOption) { searchCriteria.setAssignUser(StringSearchField.and(UserUIContext.getUsername())); } else { searchCriteria.setAssignUser(null); }/* w ww . j av a2 s. c o m*/ updateSearchResult(); } }); ticketList = new DefaultBeanPagedList<ProjectTicketService, ProjectTicketSearchCriteria, ProjectTicket>( AppContextUtil.getSpringBean(ProjectTicketService.class), new TicketRowDisplayHandler(), 10) { @Override protected String stringWhenEmptyList() { return UserUIContext.getMessage(ProjectI18nEnum.OPT_NO_TICKET); } }; this.addHeaderElement(myItemsSelection); this.bodyContent.addComponent(ticketList); }
From source file:com.mycollab.shell.view.SetupNewInstanceView.java
License:Open Source License
SetupNewInstanceView() { this.setDefaultComponentAlignment(Alignment.TOP_CENTER); MHorizontalLayout content = new MHorizontalLayout().withFullHeight(); this.with(content); content.with(new MHorizontalLayout( ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO)) .withStyleName(WebThemes.META_COLOR)).withMargin(true).withWidth("400px") .withStyleName("separator")); MVerticalLayout formLayout = new MVerticalLayout().withWidth("600px"); content.with(formLayout).withAlign(formLayout, Alignment.TOP_LEFT); formLayout.with(ELabel.h2("Last step, you are almost there!").withWidthUndefined()); formLayout.with(ELabel.h3("All fields are required *").withStyleName("overdue").withWidthUndefined()); GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 8, "200px"); formLayoutHelper.getLayout().setWidth("600px"); final TextField adminField = formLayoutHelper.addComponent(new TextField(), "Admin email", 0, 0); final PasswordField passwordField = formLayoutHelper.addComponent(new PasswordField(), "Admin password", 0, 1);//w w w. ja v a2s. c o m final PasswordField retypePasswordField = formLayoutHelper.addComponent(new PasswordField(), "Retype Admin password", 0, 2); final DateFormatField dateFormatField = formLayoutHelper.addComponent( new DateFormatField(SimpleBillingAccount.DEFAULT_DATE_FORMAT), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT), UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 3); final DateFormatField shortDateFormatField = formLayoutHelper.addComponent( new DateFormatField(SimpleBillingAccount.DEFAULT_SHORT_DATE_FORMAT), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT), UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 4); final DateFormatField longDateFormatField = formLayoutHelper.addComponent( new DateFormatField(SimpleBillingAccount.DEFAULT_LONG_DATE_FORMAT), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT), UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 5); final TimeZoneSelectionField timeZoneSelectionField = formLayoutHelper.addComponent( new TimeZoneSelectionField(false), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0, 6); timeZoneSelectionField.setValue(TimeZone.getDefault().getID()); final LanguageSelectionField languageBox = formLayoutHelper.addComponent(new LanguageSelectionField(), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 0, 7); languageBox.setValue(Locale.US.toLanguageTag()); formLayout.with(formLayoutHelper.getLayout()); CheckBox createSampleDataSelection = new CheckBox("Create sample data", true); MButton installBtn = new MButton("Setup", clickEvent -> { String adminName = adminField.getValue(); String password = passwordField.getValue(); String retypePassword = retypePasswordField.getValue(); if (!StringUtils.isValidEmail(adminName)) { NotificationUtil.showErrorNotification("Invalid email value"); return; } if (!password.equals(retypePassword)) { NotificationUtil.showErrorNotification("Password is not match"); return; } String dateFormat = dateFormatField.getValue(); String shortDateFormat = shortDateFormatField.getValue(); String longDateFormat = longDateFormatField.getValue(); if (!isValidDayPattern(dateFormat) || !isValidDayPattern(shortDateFormat) || !isValidDayPattern(longDateFormat)) { NotificationUtil.showErrorNotification("Invalid date format"); return; } String language = languageBox.getValue(); String timezoneDbId = timeZoneSelectionField.getValue(); BillingAccountMapper billingAccountMapper = AppContextUtil.getSpringBean(BillingAccountMapper.class); BillingAccountExample ex = new BillingAccountExample(); ex.createCriteria().andIdEqualTo(MyCollabUI.getAccountId()); List<BillingAccount> billingAccounts = billingAccountMapper.selectByExample(ex); BillingAccount billingAccount = billingAccounts.get(0); billingAccount.setDefaultlanguagetag(language); billingAccount.setDefaultyymmddformat(dateFormat); billingAccount.setDefaultmmddformat(shortDateFormat); billingAccount.setDefaulthumandateformat(longDateFormat); billingAccount.setDefaulttimezone(timezoneDbId); billingAccountMapper.updateByPrimaryKey(billingAccount); BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class); billingAccountService.createDefaultAccountData(adminName, password, timezoneDbId, language, true, createSampleDataSelection.getValue(), MyCollabUI.getAccountId()); ((DesktopApplication) UI.getCurrent()).doLogin(adminName, password, false); }).withStyleName(WebThemes.BUTTON_ACTION); MHorizontalLayout buttonControls = new MHorizontalLayout(createSampleDataSelection, installBtn) .alignAll(Alignment.MIDDLE_RIGHT); formLayout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT); }
From source file:com.mycompany.project.components.ContactDetails.java
public ContactDetails() { // setCaption("Contact Details"); VerticalLayout mainVLayout = new VerticalLayout(); mainVLayout.setMargin(true);/* ww w.j a va 2 s . co m*/ mainVLayout.setSpacing(true); setContent(mainVLayout); tfName.setSizeFull(); tfAddress.setSizeFull(); tfPhone.setSizeFull(); tfEmail.setSizeFull(); Panel panel = new Panel("Grupos"); panel.setWidth("100%"); panel.setHeight("50px"); panel.setContent(groupsHLayout); mainVLayout.addComponent(tfName); mainVLayout.addComponent(tfAddress); mainVLayout.addComponent(tfPhone); mainVLayout.addComponent(tfEmail); mainVLayout.addComponent(groupsHLayout); Button btnUpdate = new Button("Actualizar"); mainVLayout.addComponent(btnUpdate); btnUpdate.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //invoke business logic BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic(); String name = tfName.getValue(); String address = tfAddress.getValue(); String phone = tfPhone.getValue(); String email = tfEmail.getValue(); ArrayList<String> selectedGroupIds = new ArrayList<String>(); Set<String> groupIdSet = groupsMap.keySet(); for (String groupId : groupIdSet) { CheckBox cb = groupsMap.get(groupId); if (cb.getValue()) { selectedGroupIds.add(groupId); } } boolean success = bl.updateContact(selectedContactId, name, address, phone, email, selectedGroupIds); if (success) { load(selectedContactId); Notification.show("Informacion", "Contacto Actualizado", Notification.Type.TRAY_NOTIFICATION); } else { Notification.show("Error", "\nSomething bad happened", Notification.Type.ERROR_MESSAGE); } } }); ContactDetails.this.setVisible(false); }
From source file:com.skysql.manager.ui.MonitorsSettings.java
License:Open Source License
/** * Monitor form.//from w w w . j a v a 2 s . c o m * * @param monitor the monitor * @param title the title * @param description the description * @param button the button */ public void monitorForm(final MonitorRecord monitor, String title, String description, String button) { final TextField monitorName = new TextField("Monitor Name"); final TextField monitorDescription = new TextField("Description"); final TextField monitorUnit = new TextField("Measurement Unit"); final TextArea monitorSQL = new TextArea("SQL Statement"); final CheckBox monitorDelta = new CheckBox("Is Delta"); final CheckBox monitorAverage = new CheckBox("Is Average"); final NativeSelect validationTarget = new NativeSelect("Validate SQL on"); final NativeSelect monitorInterval = new NativeSelect("Sampling interval"); final NativeSelect monitorChartType = new NativeSelect("Default display"); secondaryDialog = new ModalWindow(title, null); UI.getCurrent().addWindow(secondaryDialog); secondaryDialog.addCloseListener(this); final VerticalLayout formContainer = new VerticalLayout(); formContainer.setMargin(new MarginInfo(true, true, false, true)); formContainer.setSpacing(false); final Form form = new Form(); formContainer.addComponent(form); form.setImmediate(false); form.setFooter(null); form.setDescription(description); String value; if ((value = monitor.getName()) != null) { monitorName.setValue(value); } form.addField("monitorName", monitorName); form.getField("monitorName").setRequired(true); form.getField("monitorName").setRequiredError("Monitor Name is missing"); monitorName.focus(); monitorName.setImmediate(true); monitorName.addValidator(new MonitorNameValidator(monitor.getName())); if ((value = monitor.getDescription()) != null) { monitorDescription.setValue(value); } monitorDescription.setWidth("24em"); form.addField("monitorDescription", monitorDescription); if ((value = monitor.getUnit()) != null) { monitorUnit.setValue(value); } form.addField("monitorUnit", monitorUnit); if ((value = monitor.getSql()) != null) { monitorSQL.setValue(value); } monitorSQL.setWidth("24em"); monitorSQL.addValidator(new SQLValidator()); form.addField("monitorSQL", monitorSQL); final String noValidation = "None - Skip Validation"; validationTarget.setImmediate(true); validationTarget.setNullSelectionAllowed(false); validationTarget.addItem(noValidation); validationTarget.select(noValidation); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); ArrayList<NodeInfo> nodes = overviewPanel.getNodes(); if (nodes == null || nodes.isEmpty()) { SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); String systemID = systemInfo.getCurrentID(); String systemType = systemInfo.getCurrentSystem().getSystemType(); if (systemID.equals(SystemInfo.SYSTEM_ROOT)) { ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class); systemID = clusterComponent.getID(); systemType = clusterComponent.getSystemType(); } nodes = new ArrayList<NodeInfo>(); for (String nodeID : systemInfo.getSystemRecord(systemID).getNodes()) { NodeInfo nodeInfo = new NodeInfo(systemID, systemType, nodeID); nodes.add(nodeInfo); } } for (NodeInfo node : nodes) { validationTarget.addItem(node.getID()); validationTarget.setItemCaption(node.getID(), node.getName()); } validationTarget.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { nodeID = (String) event.getProperty().getValue(); validateSQL = nodeID.equals(noValidation) ? false : true; } }); form.addField("validationTarget", validationTarget); monitorDelta.setValue(monitor.isDelta()); form.addField("monitorDelta", monitorDelta); monitorAverage.setValue(monitor.isAverage()); form.addField("monitorAverage", monitorAverage); SettingsValues intervalValues = new SettingsValues(SettingsValues.SETTINGS_MONITOR_INTERVAL); String[] intervals = intervalValues.getValues(); for (String interval : intervals) { monitorInterval.addItem(Integer.parseInt(interval)); } Collection<?> validIntervals = monitorInterval.getItemIds(); if (validIntervals.contains(monitor.getInterval())) { monitorInterval.select(monitor.getInterval()); } else { SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class); String defaultInterval = systemInfo.getSystemRecord(systemID).getProperties() .get(SystemInfo.PROPERTY_DEFAULTMONITORINTERVAL); if (defaultInterval != null && validIntervals.contains(Integer.parseInt(defaultInterval))) { monitorInterval.select(Integer.parseInt(defaultInterval)); } else if (!validIntervals.isEmpty()) { monitorInterval.select(validIntervals.toArray()[0]); } else { new ErrorDialog(null, "No set of permissible monitor intervals found"); } monitorInterval.setNullSelectionAllowed(false); form.addField("monitorInterval", monitorInterval); } for (UserChart.ChartType type : UserChart.ChartType.values()) { monitorChartType.addItem(type.name()); } monitorChartType .select(monitor.getChartType() == null ? UserChart.ChartType.values()[0] : monitor.getChartType()); monitorChartType.setNullSelectionAllowed(false); form.addField("monitorChartType", monitorChartType); HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Cancel"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { form.discard(); secondaryDialog.close(); } }); Button okButton = new Button(button); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { try { form.setComponentError(null); form.commit(); monitor.setName(monitorName.getValue()); monitor.setDescription(monitorDescription.getValue()); monitor.setUnit(monitorUnit.getValue()); monitor.setSql(monitorSQL.getValue()); monitor.setDelta(monitorDelta.getValue()); monitor.setAverage(monitorAverage.getValue()); monitor.setInterval((Integer) monitorInterval.getValue()); monitor.setChartType((String) monitorChartType.getValue()); String ID; if ((ID = monitor.getID()) == null) { if (Monitors.setMonitor(monitor)) { ID = monitor.getID(); select.addItem(ID); select.select(ID); Monitors.reloadMonitors(); monitorsAll = Monitors.getMonitorsList(systemType); } } else { Monitors.setMonitor(monitor); ChartProperties chartProperties = getSession().getAttribute(ChartProperties.class); chartProperties.setDirty(true); settingsDialog.setRefresh(true); } if (ID != null) { select.setItemCaption(ID, monitor.getName()); displayMonitorRecord(ID); secondaryDialog.close(); } } catch (EmptyValueException e) { return; } catch (InvalidValueException e) { return; } catch (Exception e) { ManagerUI.error(e.getMessage()); return; } } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(formContainer); windowLayout.addComponent(buttonsBar); }
From source file:com.wcs.wcslib.vaadin.widget.multifileupload.WidgetTestApplication.java
License:Apache License
private void addOverallProgressSwitcher() { final CheckBox cb = new CheckBox("Overall progress"); cb.setValue(true);/*from w ww .j a v a 2 s . co m*/ cb.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { uploadStateWindow.setOverallProgressVisible(cb.getValue()); } }); form.addComponent(cb); }
From source file:com.wcs.wcslib.vaadin.widget.multifileupload.WidgetTestApplication.java
License:Apache License
private void addUploadAttachedCheckBoxes() { for (final MultiFileUpload multiFileUpload : uploads) { final CheckBox cb = new CheckBox(multiFileUpload.getCaption() + " attached"); cb.setValue(true);/*from w w w . j av a 2 s .c o m*/ cb.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (cb.getValue()) { form.addComponent(multiFileUpload, 0); } else { form.removeComponent(multiFileUpload); } } }); form.addComponent(cb); } }
From source file:de.catma.ui.tagger.MarkupCollectionsPanel.java
License:Open Source License
private Set<TagDefinition> getCurrentlySelectedValidTagDefinitions(UserMarkupCollection userMarkupCollection) { HashSet<TagDefinition> result = new HashSet<TagDefinition>(); for (TagsetDefinition tagsetDefinition : userMarkupCollection.getTagLibrary()) { for (TagDefinition td : tagsetDefinition) { Item item = markupCollectionsTree.getItem(td); if (item != null) { Property property = (Property) item.getItemProperty(MarkupCollectionsTreeProperty.visible); CheckBox checkBox = (CheckBox) property.getValue(); boolean selected = (Boolean) checkBox.getValue(); if (selected) { result.add(td);//from www .j a v a2 s . c o m } } } } return result; }
From source file:de.catma.ui.tagger.PropertyEditDialog.java
License:Open Source License
private CheckBox createCheckBox(final Property p, final String pValue) { final CheckBox cb = new CheckBox(null, p.getPropertyValueList().getValues().contains(pValue)); cb.addValueChangeListener(new ValueChangeListener() { @Override//from www. j a v a 2 s . c o m public void valueChange(ValueChangeEvent event) { propertyValueChanged(p, pValue, cb.getValue()); } }); return cb; }
From source file:de.unioninvestment.portal.explorer.view.vfs.ConfigView.java
License:Apache License
public ConfigView(ConfigBean cb, VFSFileExplorerPortlet instance) { final OptionGroup group = new OptionGroup("Type"); group.addItem("FILE"); group.addItem("FTP"); group.addItem("SFTP"); group.setValue(cb.getVfsType());/*from w w w . ja v a 2 s . co m*/ group.setImmediate(true); final TextField tfDirectory = new TextField("Directory"); tfDirectory.setValue(cb.getVfsUrl()); final TextField tfKeyFile = new TextField("Keyfile"); tfKeyFile.setValue(cb.getKeyfile()); final TextField tfProxyHost = new TextField("Proxy Host (sftp)"); tfProxyHost.setValue(cb.getProxyHost()); final TextField tfProxyPort = new TextField("Proxy Port (sftp)"); tfProxyPort.setValue(cb.getProxyPort()); final TextField tfUser = new TextField("User"); tfUser.setValue(cb.getUsername()); final PasswordField tfPw = new PasswordField("Password"); tfPw.setValue(cb.getPassword()); final CheckBox cbUploadEnabled = new CheckBox("Upload Enabled"); if (cb.isUploadEnabled()) { cbUploadEnabled.setValue(true); } else cbUploadEnabled.setValue(false); final TextField tfRolesUpload = new TextField("Upload Rollen"); tfRolesUpload.setValue(cb.getUploadRoles()); final CheckBox cbDeleteEnabled = new CheckBox("Delete Enabled"); if (cb.isDeleteEnabled()) { cbDeleteEnabled.setValue(true); } else cbDeleteEnabled.setValue(false); final TextField tfRolesDelete = new TextField("Delete Rollen"); tfRolesDelete.setValue(cb.getDeleteRoles()); group.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { setVisibleFields(group, tfKeyFile, tfProxyHost, tfProxyPort, tfUser, tfPw); } }); setVisibleFields(group, tfKeyFile, tfProxyHost, tfProxyPort, tfUser, tfPw); Button saveProps = new Button("Save"); final VFSFileExplorerPortlet app = instance; saveProps.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { try { PortletPreferences prefs = app.getPortletPreferences(); String type = group.getValue().toString(); prefs.setValue("type", type); String con = tfDirectory.getValue().toString(); prefs.setValue("directory", con); String key = tfKeyFile.getValue().toString(); prefs.setValue("keyfile", key); String proxyHost = tfProxyHost.getValue().toString(); prefs.setValue("proxyHost", proxyHost); String proxyPort = tfProxyPort.getValue().toString(); prefs.setValue("proxyPort", proxyPort); String uploadRoles = tfRolesUpload.getValue().toString(); prefs.setValue("uploadRoles", uploadRoles); String deleteRoles = tfRolesDelete.getValue().toString(); prefs.setValue("deleteRoles", deleteRoles); String username = tfUser.getValue().toString(); prefs.setValue("username", username); String password = tfPw.getValue().toString(); prefs.setValue("password", password); Boolean bDel = (Boolean) cbDeleteEnabled.getValue(); Boolean bUpl = (Boolean) cbUploadEnabled.getValue(); if (bDel) prefs.setValue("deleteEnabled", "true"); else prefs.setValue("deleteEnabled", "false"); if (bUpl) prefs.setValue("uploadEnabled", "true"); else prefs.setValue("uploadEnabled", "false"); prefs.store(); logger.log(Level.INFO, "Roles Upload " + prefs.getValue("uploadEnabled", "-")); logger.log(Level.INFO, "Roles Delete " + prefs.getValue("deleteEnabled", "-")); ConfigBean cb = new ConfigBean(type, bDel, false, bUpl, con, username, password, key, proxyHost, proxyPort, uploadRoles, deleteRoles); app.getEventBus().fireEvent(new ConfigChangedEvent(cb)); } catch (Exception e) { logger.log(Level.INFO, "Exception " + e.toString()); e.printStackTrace(); } } }); addComponent(group); addComponent(tfDirectory); addComponent(tfKeyFile); addComponent(tfProxyHost); addComponent(tfProxyPort); addComponent(tfUser); addComponent(tfPw); HorizontalLayout ul = new HorizontalLayout(); ul.setSpacing(true); ul.addComponent(cbUploadEnabled); ul.addComponent(tfRolesUpload); ul.setComponentAlignment(cbUploadEnabled, Alignment.MIDDLE_CENTER); ul.setComponentAlignment(tfRolesUpload, Alignment.MIDDLE_CENTER); addComponent(ul); HorizontalLayout dl = new HorizontalLayout(); dl.setSpacing(true); dl.addComponent(cbDeleteEnabled); dl.addComponent(tfRolesDelete); dl.setComponentAlignment(cbDeleteEnabled, Alignment.MIDDLE_CENTER); dl.setComponentAlignment(tfRolesDelete, Alignment.MIDDLE_CENTER); addComponent(dl); addComponent(saveProps); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.CheckListPanel.java
License:Open Source License
public boolean allChecked() { for (Component i : checkList) { //System.out.println(((AbstractField<Boolean>) i).getValue().toString()); if (i.getClass().equals(CheckBox.class)) { System.out.println(i.getClass() + ""); CheckBox tmp = (CheckBox) i; if (!tmp.getValue()) { return false; }/*from www. j a v a 2 s. c om*/ } } return true; }