List of usage examples for com.vaadin.ui CheckBox CheckBox
public CheckBox()
From source file:pl.exsio.ca.module.terrain.evidence.TerrainDataTable.java
License:Open Source License
protected void addSelectTerrainColumn() { dataComponent.addGeneratedColumn("", new ColumnGenerator() { @Override//from w ww.j av a 2 s. c o m public Component generateCell(final Table source, final Object itemId, final Object columnId) { final CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true); checkBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { Terrain terrain = ((EntityItem<Terrain>) dataComponent.getItem(itemId)).getEntity(); if ((Boolean) event.getProperty().getValue()) { selectedTerrains.add(terrain); } else { selectedTerrains.remove(terrain); } quickNotification.setEnabled(!selectedTerrains.isEmpty()); } }); return checkBox; } }); }
From source file:pt.ist.vaadinframework.ui.DefaultFieldFactory.java
License:Open Source License
/** * @see pt.ist.vaadinframework.ui.AbstractFieldFactory#makeField(com.vaadin.data.Item, java.lang.Object, * com.vaadin.ui.Component)/*from w ww. ja va 2 s .c om*/ */ @Override protected Field makeField(Item item, Object propertyId, Component uiContext) { Class<?> type = item.getItemProperty(propertyId).getType(); if (String.class.isAssignableFrom(type)) { TextField field = new TextField(); field.setNullSettingAllowed(true); field.setNullRepresentation(StringUtils.EMPTY); return field; } if (Collection.class.isAssignableFrom(type) && item.getItemProperty(propertyId) instanceof AbstractBufferedContainer) { return new ContainerEditor<Object>(this, bundlename, ((AbstractBufferedContainer<?, ?, ?>) item.getItemProperty(propertyId)).getElementType()); } if (AbstractDomainObject.class.isAssignableFrom(type)) { Select select = new Select(); select.setWidth(100, Sizeable.UNITS_PERCENTAGE); select.setImmediate(true); return select; } if (Collection.class.isAssignableFrom(type)) { OptionGroup group = new OptionGroup(); group.setMultiSelect(true); group.setWidth(100, Sizeable.UNITS_PERCENTAGE); group.setImmediate(true); return group; } if (Byte.class.isAssignableFrom(type)) { return new PrimitiveField(new ByteValidator(), Byte.toString(Byte.MAX_VALUE).length() + 1); } if (Short.class.isAssignableFrom(type)) { return new PrimitiveField(new ShortValidator(), Short.toString(Short.MAX_VALUE).length() + 1); } if (Integer.class.isAssignableFrom(type)) { return new PrimitiveField(new IntegerValidator(), Integer.toString(Integer.MAX_VALUE).length() + 1); } if (Long.class.isAssignableFrom(type)) { return new PrimitiveField(new LongValidator(), Long.toString(Long.MAX_VALUE).length() + 1); } if (Float.class.isAssignableFrom(type)) { return new PrimitiveField(new FloatValidator(), Float.toString(Float.MAX_VALUE).length() + 1); } if (Double.class.isAssignableFrom(type)) { return new PrimitiveField(new DoubleValidator(), Double.toString(Double.MAX_VALUE).length() + 1); } if (Boolean.class.isAssignableFrom(type)) { return new CheckBox(); } if (Character.class.isAssignableFrom(type)) { return new PrimitiveField(new CharacterValidator(), 1); } if (BigDecimal.class.isAssignableFrom(type)) { return new PrimitiveField(new BigDecimalValidator(), -1); } if (Enum.class.isAssignableFrom(type)) { return new EnumField((Class<? extends Enum<?>>) item.getItemProperty(propertyId).getType()); } if (Date.class.isAssignableFrom(type)) { DateField field = new DateField(); field.setResolution(DateField.RESOLUTION_DAY); return field; } if (Item.class.isAssignableFrom(type)) { Form form = new Form() { @Override public void setPropertyDataSource(Property newDataSource) { setItemDataSource((Item) newDataSource); }; }; form.setImmediate(true); form.setFormFieldFactory(this); return form; } if (MultiLanguageString.class.isAssignableFrom(type)) { return new MultiLanguageStringField(bundlename, Language.pt, Language.en); } if (DateTime.class.isAssignableFrom(type)) { PopupDateTimeField field = new PopupDateTimeField(); field.setResolution(DateField.RESOLUTION_SEC); return field; } if (LocalDate.class.isAssignableFrom(type)) { PopupLocalDateField field = new PopupLocalDateField(); field.setResolution(DateField.RESOLUTION_DAY); return field; } if (URL.class.isAssignableFrom(type)) { TextField field = new TextField(); field.setNullSettingAllowed(true); field.setNullRepresentation(StringUtils.EMPTY); field.addValidator(new URLValidator()); return field; } Select select = new Select(); select.setWidth(100, Sizeable.UNITS_PERCENTAGE); select.setImmediate(true); return select; }
From source file:qbic.vaadincomponents.GroupSpecificParameterComponent.java
License:Open Source License
private FormLayout initParameters() { // select the type FormLayout parameterLayout = new FormLayout(); labelfreequant = new CheckBox(); labelfreequant.setCaption("Label-Free Quantification"); parameterLayout.addComponent(labelfreequant); typeSelect = new NativeSelect(); typeSelect.setCaption("Type"); typeSelect.addItem("Standard"); typeSelect.addItem("Reporter Ion"); // add it/* w w w .j a va2 s . c o m*/ parameterLayout.addComponent(typeSelect); // select multiplicity. multiplicitySelect = new NativeSelect(); multiplicitySelect.setCaption("Multiplicity"); multiplicitySelect.addItem("1 - label-free quantification"); multiplicitySelect.addItem("2 - light and heavy labels"); multiplicitySelect.addItem("3 - light, medium, and heavy lables"); multiplicitySelect.setNullSelectionAllowed(false); parameterLayout.addComponent(multiplicitySelect); // add labels labels = new QuantificationLabelComponent(); parameterLayout.addComponent(labels); multiplicitySelect.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 2788813707970284834L; @Override public void valueChange(ValueChangeEvent event) { String multiplicity = (String) event.getProperty().getValue(); if (multiplicity.startsWith("1")) { labels.noLables(); } else if (multiplicity.startsWith("2")) { labels.lightAndHeavyLabels(); } else if (multiplicity.startsWith("3")) { labels.lightMediumAndHeavyLabels(); } } }); parameterLayout.addComponent(labels); // variable modifications variableModifications = new TwinColSelect("Variable Modifications"); variableModifications.addItems("Acetyl (Protein N-term)", "Acetyl (K)", "Oxidation (M)", "Ala->Arg"); parameterLayout.addComponent(variableModifications); // digestion mode digestionMode = new NativeSelect("Digestion mode"); digestionMode.addItem("Specific"); parameterLayout.addComponent(digestionMode); // enzyme enzyme = new TwinColSelect("Enzyme"); enzyme.addItems("Trypsin/P", "ArgC", "Trypsin", "GluN"); parameterLayout.addComponent(enzyme); // missed cleavage missedcleavage = new TextField("Max Missed Cleavage"); parameterLayout.addComponent(missedcleavage); matchType = new NativeSelect("Match type"); matchType.addItem("MatchFromAndTo"); parameterLayout.addComponent(matchType); return parameterLayout; }
From source file:rds.vaadin.beanfaces.ExtendedTable.java
License:Apache License
private void addGeneratedCheckboxColumn() { // Keep references on all Checkbox final List<CheckBox> data = new ArrayList<CheckBox>(); addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override//from ww w. j a v a2s . co m public void itemClick(ItemClickEvent event) { if (ExtendedTable.this.isReadOnly()) { return; } boolean selected = ExtendedTable.this.isSelected(event.getItemId()); for (CheckBox c : data) { if (c.getData().toString().equals(event.getItemId().toString())) { c.setReadOnly(false); if (!selected) { c.setValue(Boolean.TRUE); } else { c.setValue(Boolean.FALSE); } c.setReadOnly(true); } } } }); addGeneratedColumn("", new ColumnGenerator() { @Override public Object generateCell(Table source, final Object itemId, Object columnId) { final CheckBox checkBox = new CheckBox(); checkBox.setImmediate(false); checkBox.setBuffered(true); checkBox.setData(itemId); data.add(checkBox); // Update if (source.isSelected(itemId)) { checkBox.setValue(Boolean.TRUE); } checkBox.setReadOnly(true); return checkBox; } }); // Attach the list of checkbox in order to be linked // with the component, and accessible outside. setData(data); }
From source file:ro.zg.netcell.vaadin.action.FormGenerator.java
License:Apache License
private Field getFieldForType(String uiType) { if (uiType == null) { return new TextField(); }/*from w w w . j a v a2s .c om*/ if (uiType.equals("richtextarea")) { return new RichTextArea(); } if (uiType.equals("checkbox")) { return new CheckBox(); } if (uiType.equals("combobox")) { return new ComboBox(); } if (uiType.equals("date")) { final DateField df = new DateField(); df.setResolution(DateField.RESOLUTION_DAY); return df; } return new TextField(); }
From source file:ro.zg.opengroups.views.UserNotificationRuleView.java
License:Apache License
private void displayEnabledCheckBox(final MultitypeNotificationRule rule) { CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true);/*from ww w . j a v a 2s .com*/ checkBox.setValue(rule.getCommonFields().isEnabled()); checkBox.addStyleName("notification-rules-list-row-cell-content"); // container.addComponent(cell); addToContainer(checkBox); checkBox.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { rule.getCommonFields().setEnabled((Boolean) event.getProperty().getValue()); rule.getRulesList().onRuleUpdated(); } }); }
From source file:ru.codeinside.adm.ui.TreeTableOrganization.java
License:Mozilla Public License
private Component buttonCreateEmployee(final Long id) { HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true);/* w w w . j av a 2 s. c om*/ buttons.setMargin(false, true, false, false); addComponent(buttons); Button createUser = new Button(" ?", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { showOrganizationLabelsAndButtons(id); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); panel.addComponent(layout); String widthColumn = "100px"; final TextField fieldLogin = TableEmployee.addTextField(layout, widthColumn, ""); final PasswordField fieldPass = TableEmployee.addPasswordField(layout, widthColumn, ""); final PasswordField fieldPassRepeat = TableEmployee.addPasswordField(layout, widthColumn, " "); final MaskedTextField fieldSnils = TableEmployee.addMaskedTextField(layout, widthColumn, "?"); fieldSnils.setMask("###-###-### ##"); fieldPassRepeat.addValidator(new RepeatPasswordValidator(fieldPass)); final TextField fieldFIO = TableEmployee.addTextField(layout, widthColumn, ""); HorizontalLayout l1 = new HorizontalLayout(); Label labelRole = new Label(""); labelRole.setWidth(widthColumn); l1.addComponent(labelRole); l1.setComponentAlignment(labelRole, Alignment.MIDDLE_LEFT); final OptionGroup roleOptionGroup = TableEmployee.createRoleOptionGroup(null); l1.addComponent(roleOptionGroup); layout.addComponent(l1); UserItem emptyItem = new UserItem(); emptyItem.setGroups(ImmutableSet.<String>of()); final CertificateBlock certificateBlock = new CertificateBlock(emptyItem); layout.addComponent(certificateBlock); final ExecutorGroupsBlock executorGroupsBlock = new ExecutorGroupsBlock(emptyItem); layout.addComponent(executorGroupsBlock); final HorizontalLayout supervisorGroupsEmp = new HorizontalLayout(); supervisorGroupsEmp.setMargin(true, true, true, false); supervisorGroupsEmp.setSpacing(true); supervisorGroupsEmp.setCaption( "? ? ? ?"); final FilterTable allSupervisorGroupsEmp = new FilterTable(); allSupervisorGroupsEmp.setCaption("?"); TableEmployee.table(supervisorGroupsEmp, allSupervisorGroupsEmp); final FilterTable currentSupervisorGroupsEmp = new FilterTable(); currentSupervisorGroupsEmp.setCaption(""); TableEmployee.table(supervisorGroupsEmp, currentSupervisorGroupsEmp); for (String groupName : AdminServiceProvider.get().getEmpGroupNames()) { for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) { allSupervisorGroupsEmp.addItem(new Object[] { groupName, group.getTitle() }, groupName); } } TableEmployee.addListener(allSupervisorGroupsEmp, currentSupervisorGroupsEmp); TableEmployee.addListener(currentSupervisorGroupsEmp, allSupervisorGroupsEmp); layout.addComponent(supervisorGroupsEmp); final HorizontalLayout supervisorGroupsOrg = new HorizontalLayout(); supervisorGroupsOrg.setMargin(true, true, true, false); supervisorGroupsOrg.setSpacing(true); supervisorGroupsOrg.setCaption( "? ? ?"); final FilterTable allSupervisorGroupsOrg = new FilterTable(); allSupervisorGroupsOrg.setCaption("?"); TableEmployee.table(supervisorGroupsOrg, allSupervisorGroupsOrg); final FilterTable currentSupervisorGroupsOrg = new FilterTable(); currentSupervisorGroupsOrg.setCaption(""); TableEmployee.table(supervisorGroupsOrg, currentSupervisorGroupsOrg); for (String groupName : AdminServiceProvider.get().getOrgGroupNames()) { for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) { allSupervisorGroupsOrg.addItem(new Object[] { groupName, group.getTitle() }, groupName); } } TableEmployee.addListener(allSupervisorGroupsOrg, currentSupervisorGroupsOrg); TableEmployee.addListener(currentSupervisorGroupsOrg, allSupervisorGroupsOrg); layout.addComponent(supervisorGroupsOrg); TableEmployee.setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock, supervisorGroupsEmp, supervisorGroupsOrg); roleOptionGroup.addListener(new Listener() { private static final long serialVersionUID = 1L; public void componentEvent(Event event) { TableEmployee.setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock, supervisorGroupsEmp, supervisorGroupsOrg); } }); HorizontalLayout l2 = new HorizontalLayout(); Label labelPrint = new Label("? ?"); labelPrint.setWidth(widthColumn); l2.addComponent(labelPrint); l2.setComponentAlignment(labelPrint, Alignment.MIDDLE_LEFT); final CheckBox checkBoxPrint = new CheckBox(); checkBoxPrint.setDescription("? ?"); l2.addComponent(checkBoxPrint); layout.addComponent(l2); HorizontalLayout layoutButton = new HorizontalLayout(); layoutButton.setSpacing(true); Button buttonUserForm = new Button("", new Button.ClickListener() { private static final long serialVersionUID = -7193894183022375021L; public void buttonClick(ClickEvent event) { if (!fieldPassRepeat.isValid()) { return; } String snilsFieldValue = fieldSnils.getValue() == null ? "" : (String) fieldSnils.getValue(); String snilsValue = snilsFieldValue.replaceAll("\\D+", ""); Pattern snilsPattern = Pattern.compile("\\d{11}"); Matcher snilsMatcher = snilsPattern.matcher(snilsValue); if (!snilsFieldValue.isEmpty() && !snilsMatcher.matches()) { getWindow().showNotification("? ", Window.Notification.TYPE_ERROR_MESSAGE); return; } String loginUser = (String) fieldLogin.getValue(); if (!AdminServiceProvider.get().isUniqueSnils(loginUser, snilsValue)) { getWindow().showNotification(" ? ", Window.Notification.TYPE_ERROR_MESSAGE); return; } String password = (String) fieldPass.getValue(); String passwordRepeat = (String) fieldPassRepeat.getValue(); String fio = (String) fieldFIO.getValue(); Set<Role> roles = (Set) roleOptionGroup.getValue(); TreeSet<String> groupExecutor = executorGroupsBlock.getGroups(); TreeSet<String> groupSupervisorEmp = new TreeSet<String>( (Collection<String>) currentSupervisorGroupsEmp.getItemIds()); TreeSet<String> groupSupervisorOrg = new TreeSet<String>( (Collection<String>) currentSupervisorGroupsOrg.getItemIds()); if (loginUser.equals("") || password.equals("") || passwordRepeat.equals("") || fio.equals("")) { getWindow().showNotification(" ? ?!", Notification.TYPE_WARNING_MESSAGE); } else if (!(password.equals(passwordRepeat))) { getWindow().showNotification(" ?!", Notification.TYPE_WARNING_MESSAGE); } else if (AdminServiceProvider.get().findEmployeeByLogin(loginUser) == null) { if (roles.contains(Role.SuperSupervisor)) { groupSupervisorEmp = new TreeSet<String>( AdminServiceProvider.get().selectGroupNamesBySocial(true)); groupSupervisorOrg = new TreeSet<String>( AdminServiceProvider.get().selectGroupNamesBySocial(false)); } String creator = getApplication().getUser().toString(); AdminServiceProvider.get().createEmployee(loginUser, password, fio, snilsValue, roles, creator, id, groupExecutor, groupSupervisorEmp, groupSupervisorOrg); showOrganization(id); getWindow().showNotification(" " + loginUser + " ?"); if (checkBoxPrint.booleanValue()) { // Create a window that contains what you want to print Window window = new Window(); window.addComponent(new Label("<h1>: " + loginUser + "</h1>\n" + "<h1>: " + password + "</h1>\n", Label.CONTENT_XHTML)); getApplication().addWindow(window); getWindow().open(new ExternalResource(window.getURL()), "_blank", 500, 200, // Width and // height Window.BORDER_NONE); window.executeJavaScript("print();"); window.executeJavaScript("self.close();"); } } else { getWindow().showNotification(" ?!", Notification.TYPE_WARNING_MESSAGE); } } }); layoutButton.addComponent(buttonUserForm); Button buttonCancel = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { showOrganization(id); } }); layoutButton.addComponent(buttonCancel); layout.addComponent(layoutButton); } }); createUser.addListener(this); buttons.addComponent(createUser); return buttons; }
From source file:ru.codeinside.gses.activiti.ftarchive.CustomCheckBox.java
License:Mozilla Public License
public CustomCheckBox() { checkBox = new CheckBox(); checkBox.setImmediate(true); setCompositionRoot(checkBox); }
From source file:steps.TailoringStep.java
License:Open Source License
private void initPooling(String name) { poolSelect = new CheckBox(); poolSelect.setCaption("Pool " + name); main.addComponent(Styles.questionize(poolSelect, "Select if multiple tissue extracts are pooled into a single sample " + "before measurement.", "Pooling")); }
From source file:uk.co.intec.keyDatesApp.components.MainViewFilter.java
License:Apache License
/** * Main method to load the filtering fields and valueChangeListeners for * those fields.//from w ww .j a v a2s. c om */ public void loadContent() { final FormLayout cust = new FormLayout(); cust.setMargin(false); setCustField(new ComboBox("Customer:", KeyDateDatabaseUtils.getCustContainer())); getCustField().setInputPrompt("No Customer Selected"); getCustField().setFilteringMode(FilteringMode.STARTSWITH); getCustField().setImmediate(true); getCustField().setInvalidAllowed(false); getCustField().setNullSelectionAllowed(true); getCustField().setPageLength(5); getCustField().setWidth("95%"); getCustField().setResponsive(true); getCustField().addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.data.Property.ValueChangeListener#valueChange(com. * vaadin.data.Property.ValueChangeEvent) */ @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper(); getParentView().loadRowData(viewWrapper.getEntriesAsMap((String) event.getProperty().getValue(), viewWrapper.getStartDate(), viewWrapper.isSingleCat(), viewWrapper.getCount())); getParentView().getPager().loadPagerPagesButtons(); } }); cust.addComponent(getCustField()); final FormLayout date = new FormLayout(); date.setMargin(false); setDateField(new PopupDateField("Start Date:")); getDateField().setValue(new Date()); getDateField().setResolution(Resolution.DAY); getDateField().setLocale(Locale.getDefault()); getDateField().setResponsive(true); getDateField().setTextFieldEnabled(false); getDateField().setWidth("95%"); getDateField().setRequired(true); getDateField().setRequiredError("A date is required!"); getDateField().addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.data.Property.ValueChangeListener#valueChange(com. * vaadin.data.Property.ValueChangeEvent) */ @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper(); getParentView().loadRowData(viewWrapper.getEntriesAsMap(viewWrapper.getCustomerName(), (Date) event.getProperty().getValue(), viewWrapper.isSingleCat(), viewWrapper.getCount())); getParentView().getPager().loadPagerPagesButtons(); } }); date.addComponent(getDateField()); final FormLayout singleCatLayout = new FormLayout(); singleCatLayout.setMargin(false); singleCatLayout.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT); setSingleCatButton(new CheckBox()); getSingleCatButton().setStyleName(ValoTheme.CHECKBOX_SMALL); getSingleCatButton().setResponsive(true); getSingleCatButton().setCaption("Restrict to Date"); getSingleCatButton().setWidth("95%"); getSingleCatButton().addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.data.Property.ValueChangeListener#valueChange(com. * vaadin.data.Property.ValueChangeEvent) */ @Override public void valueChange(ValueChangeEvent event) { final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper(); final Boolean val = (Boolean) event.getProperty().getValue(); getParentView().loadRowData(viewWrapper.getEntriesAsMap(viewWrapper.getCustomerName(), viewWrapper.getStartDate(), val.booleanValue(), viewWrapper.getCount())); getParentView().getPager().loadPagerPagesButtons(); } }); singleCatLayout.addComponent(getSingleCatButton()); addComponents(cust, date, singleCatLayout); setExpandRatio(cust, 2); setExpandRatio(date, 1); setExpandRatio(singleCatLayout, 1); setComponentAlignment(singleCatLayout, Alignment.MIDDLE_RIGHT); }