List of usage examples for com.vaadin.ui CheckBox CheckBox
public CheckBox()
From source file:org.lunarray.model.generation.vaadin.render.factories.form.vaadin.components.CheckboxPropertyStrategy.java
License:Open Source License
/** {@inheritDoc} */ @Override protected Component createComponent() { return new CheckBox(); }
From source file:org.lunifera.runtime.web.ecview.presentation.vaadin.internal.CheckBoxPresentation.java
License:Open Source License
/** * {@inheritDoc}/* w w w . j ava 2 s . c o m*/ */ @Override public Component doCreateWidget(Object parent) { if (componentBase == null) { componentBase = new CssLayout(); componentBase.addStyleName(CSS_CLASS_CONTROL_BASE); if (modelAccess.isCssIdValid()) { componentBase.setId(modelAccess.getCssID()); } else { componentBase.setId(getEditpart().getId()); } associateWidget(componentBase, modelAccess.yCheckBox); checkBox = new CheckBox(); checkBox.addStyleName(CSS_CLASS_CONTROL); checkBox.setImmediate(true); associateWidget(checkBox, modelAccess.yCheckBox); property = new ObjectProperty<Boolean>(false, Boolean.class); checkBox.setPropertyDataSource(property); // creates the binding for the field createBindings(modelAccess.yCheckBox, checkBox); componentBase.addComponent(checkBox); if (modelAccess.isCssClassValid()) { checkBox.addStyleName(modelAccess.getCssClass()); } applyCaptions(); initializeField(checkBox); } return componentBase; }
From source file:org.lunifera.runtime.web.ecview.presentation.vaadin.tests.ui.samples.CheckBoxSample.java
License:Open Source License
protected void init() { CheckBox checkbox = new CheckBox(); layout.addComponent(checkbox); }
From source file:org.lunifera.vaaclipse.ui.preferences.addon.internal.BooleanFieldEditorRenderer.java
License:Open Source License
@Override public void render() { renderInternal(booleanFieldEditor);//from w w w.j a v a 2 s . c o m cb = new CheckBox(); cb.setValue(getValue()); if (booleanFieldEditor.getStyle() == BooleanFieldStyle.DEFAULT) { cb.setCaption(booleanFieldEditor.getLabel()); component = cb; } else if (booleanFieldEditor.getStyle() == BooleanFieldStyle.SEPARATE_LABEL) { HorizontalLayout hl = new HorizontalLayout(); Label separateLabel = new Label(booleanFieldEditor.getLabel()); separateLabel.addStyleName("boolean-separate-label"); cb.addStyleName("boolean-separate-checkbox"); hl.addComponent(separateLabel); hl.addComponent(cb); component = hl; } }
From source file:org.lunifera.vaaclipse.ui.preferences.addon.internal.impexp.BasicImpExp.java
License:Open Source License
protected void createPreferencesTable(CssLayout layout, List<PreferencesPage> pageList) { container = new BeanItemContainer<>(PreferencesPage.class); container.addNestedContainerProperty("category.name"); refreshPreferences(pageList);//from www .j a v a2 s . c om table = new Table(); table.setSizeFull(); table.setContainerDataSource(container); table.addGeneratedColumn("description", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { PreferencesPage page = (PreferencesPage) itemId; String d = page.getDescription(); if (d.length() > MAX_DESCRIPTION_LENGTH) { d = d.substring(0, MAX_DESCRIPTION_LENGTH).trim() + "..."; } return d; } }); table.addGeneratedColumn("include", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(); cb.setData(itemId); checkBoxes.add(cb); return cb; } }); table.setColumnHeader("include", " "); table.setColumnHeader("category.name", "Name"); table.setColumnHeader("description", "Description"); table.setVisibleColumns("include", "category.name", "description"); Panel panel = new Panel(table); panel.setWidth("100%"); panel.setHeight("200px"); layout.addComponent(panel); }
From source file:org.lunifera.web.ecp.uimodel.presentation.vaadin.internal.CheckBoxPresentation.java
License:Open Source License
/** * {@inheritDoc}/*from w ww . j a v a 2s . co m*/ */ @Override public Component createWidget(Object parent) { if (componentBase == null) { componentBase = new CssLayout(); componentBase.addStyleName(CSS_CLASS__CONTROL_BASE); if (modelAccess.isCssIdValid()) { componentBase.setId(modelAccess.getCssID()); } else { componentBase.setId(getEditpart().getId()); } checkBox = new CheckBox(); checkBox.addStyleName(CSS_CLASS__CONTROL); checkBox.setSizeFull(); componentBase.addComponent(checkBox); if (modelAccess.isCssClassValid()) { checkBox.addStyleName(modelAccess.getCssClass()); } if (modelAccess.isLabelValid()) { checkBox.setCaption(modelAccess.getLabel()); } } return componentBase; }
From source file:org.metawidget.vaadin.ui.widgetbuilder.VaadinWidgetBuilder.java
License:LGPL
public Component buildWidget(String elementName, Map<String, String> attributes, VaadinMetawidget metawidget) { // Hidden// w w w . java 2 s. c o m if (TRUE.equals(attributes.get(HIDDEN))) { return new Stub(); } // Action if (ACTION.equals(elementName)) { return new Button(); } // Lookup the Class Class<?> clazz = WidgetBuilderUtils.getActualClassOrType(attributes, String.class); // Support mandatory Booleans (can be rendered as a checkbox, even // though they have a Lookup) if (Boolean.class.equals(clazz) && TRUE.equals(attributes.get(REQUIRED))) { return new CheckBox(); } // Lookups String lookup = attributes.get(LOOKUP); if (lookup != null && !"".equals(lookup)) { return createSelectComponent(attributes, lookup, metawidget); } if (clazz != null) { // Primitives if (clazz.isPrimitive()) { // booleans if (boolean.class.equals(clazz)) { return new CheckBox(); } // chars if (char.class.equals(clazz)) { TextField textField = new TextField(); textField.setMaxLength(1); return textField; } // Ranged String minimumValue = attributes.get(MINIMUM_VALUE); String maximumValue = attributes.get(MAXIMUM_VALUE); if (minimumValue != null && !"".equals(minimumValue) && maximumValue != null && !"".equals(maximumValue)) { Slider slider = new Slider(); slider.setMin(Double.parseDouble(minimumValue)); try { // Use big 'D' Double for Vaadin 6/7 compatibility slider.setValue(Double.valueOf(slider.getMin())); } catch (ValueOutOfBoundsException e) { throw WidgetBuilderException.newException(e); } slider.setMax(Double.parseDouble(maximumValue)); return slider; } // Not-ranged return createTextField(attributes); } // Strings if (String.class.equals(clazz)) { if (TRUE.equals(attributes.get(MASKED))) { return new PasswordField(); } if (TRUE.equals(attributes.get(LARGE))) { return new TextArea(); } return createTextField(attributes); } // Characters if (Character.class.isAssignableFrom(clazz)) { TextField textField = new TextField(); textField.setMaxLength(1); return textField; } // Dates if (Date.class.equals(clazz)) { return new PopupDateField(); } // Numbers // // Note: we use a text field, not a JSpinner or JSlider, because // BeansBinding gets upset at doing 'setValue( null )' if the Integer // is null. We can still use JSpinner/JSliders for primitives, though. if (Number.class.isAssignableFrom(clazz)) { return createTextField(attributes); } // Collections if (Collection.class.isAssignableFrom(clazz)) { return new Stub(); } } // Not simple, but don't expand if (TRUE.equals(attributes.get(DONT_EXPAND))) { return createTextField(attributes); } return null; }
From source file:org.opencms.ui.dataview.CmsDataViewPanel.java
License:Open Source License
/** * Gets the check box for the item with the given id.<p> * * @param id the item id//from www .j a v a 2s.c o m * @return the check box */ private CheckBox getCheckBox(Object id) { if (!m_checkBoxes.containsKey(id)) { m_checkBoxes.put(id, new CheckBox()); } return m_checkBoxes.get(id); }
From source file:org.opencms.ui.dialogs.CmsRestoreDeletedDialog.java
License:Open Source License
/** * Fills the list of resources to select from.<p> * * @param cms the cms context//from w w w . j ava 2 s .c om * @param deletedResources the deleted resources * * @throws CmsException if something goes wrong */ private void initDeletedResources(CmsObject cms, List<I_CmsHistoryResource> deletedResources) throws CmsException { Collections.sort(deletedResources, new Comparator<I_CmsHistoryResource>() { public int compare(I_CmsHistoryResource first, I_CmsHistoryResource second) { return first.getRootPath().compareTo(second.getRootPath()); } }); m_deletedResourceContainer.removeAllComponents(); m_selectionContainer = new IndexedContainer(); m_selectionContainer.addContainerProperty(PROP_SELECTED, Boolean.class, Boolean.FALSE); m_okButton.setEnabled(!deletedResources.isEmpty()); if (deletedResources.isEmpty()) { m_deletedResourceContainer.addComponent( new Label(CmsVaadinUtils.getMessageText(org.opencms.workplace.list.Messages.GUI_LIST_EMPTY_0))); } for (I_CmsHistoryResource deleted : deletedResources) { I_CmsResourceType resType = OpenCms.getResourceManager().getResourceType(deleted.getTypeId()); String typeName = resType.getTypeName(); CmsExplorerTypeSettings explorerType = OpenCms.getWorkplaceManager().getExplorerTypeSetting(typeName); String title = cms.getRequestContext().removeSiteRoot(deleted.getRootPath()); String subtitle = CmsVaadinUtils.getMessageText( org.opencms.ui.Messages.GUI_RESTOREDELETED_DATE_VERSION_2, CmsVfsService.formatDateTime(cms, deleted.getDateLastModified()), "" + deleted.getVersion()); String iconPath = OpenCms.getWorkplaceManager() .getExplorerTypeSetting(deleted.isFile() ? "unknown_file" : "unknown_folder") .getBigIconIfAvailable(); if (explorerType != null) { iconPath = CmsWorkplace.RES_PATH_FILETYPES + explorerType.getBigIconIfAvailable(); } CmsResourceInfo info = new CmsResourceInfo(title, subtitle, CmsWorkplace.getResourceUri(iconPath)); info.setWidth("100%"); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); CheckBox checkbox = new CheckBox(); hl.addComponent(checkbox); hl.addComponent(info); hl.setExpandRatio(info, 1); hl.setComponentAlignment(checkbox, Alignment.MIDDLE_LEFT); m_selectionContainer.addItem(deleted.getStructureId()); checkbox.setPropertyDataSource( m_selectionContainer.getItem(deleted.getStructureId()).getItemProperty(PROP_SELECTED)); m_deletedResourceContainer.addComponent(hl); } }
From source file:org.opencms.workplace.tools.git.ui.CmsGitToolOptionsPanel.java
License:Open Source License
/** * Adds a check box and info widget for a module which should be selectable for check-in.<p> * * @param moduleName the name of the module *//*from w ww . j av a2 s . c o m*/ public void addSelectableModule(final String moduleName) { boolean enabled = true; /* OpenCms.getModuleManager().hasModule(moduleName); */ CheckBox moduleCheckBox = new CheckBox(); String iconUri = CmsWorkplace.getResourceUri("tools/modules/buttons/modules.png"); CmsResourceInfo info = new CmsResourceInfo(moduleName, "", iconUri); HorizontalLayout line = new HorizontalLayout(); line.setWidth("100%"); line.addComponent(moduleCheckBox); info.setWidth("100%"); line.addComponent(info); line.setComponentAlignment(moduleCheckBox, Alignment.MIDDLE_CENTER); line.setExpandRatio(info, 1.0f); moduleCheckBox.setEnabled(true); moduleCheckBox.setValue(Boolean.valueOf(enabled)); // If enabled, then checked by default m_moduleCheckboxes.put(moduleName, moduleCheckBox); m_moduleSelectionContainer.addComponent(line, m_moduleSelectionContainer.getComponentCount() - 1); setTab(m_dialogTab); }