List of usage examples for com.vaadin.ui CheckBox CheckBox
public CheckBox()
From source file:org.iespuigcastellar.attendancemanager.screenlayouts.NoModalWindowTeacherMainLayout.java
License:Open Source License
/** Loads students data into table. */ public void loadTable(int idgroup) { table.removeAllItems();//from w ww .ja va2s . c o m Collection<Student> collection = app.storage.studentsOfGroup(idgroup); for (Iterator<Student> it = collection.iterator(); it.hasNext();) { Student student = it.next(); CheckBox missCheckBox = new CheckBox(); missCheckBox.setData(student); if (app.storage.existsMiss(Miss.MISS, (Date) datePopupDateField.getValue(), ((Classblock) classblockComboBox.getValue()).getID(), student.getID())) { missCheckBox.setValue(true); } missCheckBox.setImmediate(true); missCheckBox.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Student student = (Student) event.getButton().getData(); Miss miss = new Miss(0, Miss.MISS, (Date) datePopupDateField.getValue(), "", student.getID(), app.user.getID(), ((Classblock) classblockComboBox.getValue()).getIDSubject(), ((Classblock) classblockComboBox.getValue()).getID()); if ((Boolean) event.getButton().getValue()) { app.storage.addMiss(miss); } else { // Delete Miss app.storage.deleteMiss(Miss.MISS, miss.getDate(), miss.getIDStudent(), miss.getIDClassblock()); } updateEnabledCheckBoxes(student); } }); CheckBox excusedmissCheckBox = new CheckBox(); excusedmissCheckBox.setData(student); if (app.storage.existsMiss(Miss.EXCUSED_MISS, (Date) datePopupDateField.getValue(), ((Classblock) classblockComboBox.getValue()).getID(), student.getID())) { excusedmissCheckBox.setValue(true); } excusedmissCheckBox.setImmediate(true); excusedmissCheckBox.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Student student = (Student) event.getButton().getData(); Miss miss = new Miss(0, Miss.EXCUSED_MISS, (Date) datePopupDateField.getValue(), "", student.getID(), app.user.getID(), ((Classblock) classblockComboBox.getValue()).getIDSubject(), ((Classblock) classblockComboBox.getValue()).getID()); if ((Boolean) event.getButton().getValue()) { // New Miss app.storage.addMiss(miss); } else { // Delete Miss app.storage.deleteMiss(Miss.EXCUSED_MISS, miss.getDate(), miss.getIDStudent(), miss.getIDClassblock()); } updateEnabledCheckBoxes(student); } }); CheckBox delayCheckBox = new CheckBox(); delayCheckBox.setData(student); if (app.storage.existsMiss(Miss.DELAY, (Date) datePopupDateField.getValue(), ((Classblock) classblockComboBox.getValue()).getID(), student.getID())) { delayCheckBox.setValue(true); } delayCheckBox.setImmediate(true); delayCheckBox.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Student student = (Student) event.getButton().getData(); Miss miss = new Miss(0, Miss.DELAY, (Date) datePopupDateField.getValue(), "", student.getID(), app.user.getID(), ((Classblock) classblockComboBox.getValue()).getIDSubject(), ((Classblock) classblockComboBox.getValue()).getID()); if ((Boolean) event.getButton().getValue()) { app.storage.addMiss(miss); } else { app.storage.deleteMiss(Miss.DELAY, miss.getDate(), miss.getIDStudent(), miss.getIDClassblock()); } updateEnabledCheckBoxes(student); } }); CheckBox expulsionCheckBox = new CheckBox(); expulsionCheckBox.setData(student); if (app.storage.existsMiss(Miss.EXPULSION, (Date) datePopupDateField.getValue(), ((Classblock) classblockComboBox.getValue()).getID(), student.getID())) { expulsionCheckBox.setValue(true); } expulsionCheckBox.setImmediate(true); expulsionCheckBox.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Student student = (Student) event.getButton().getData(); Miss miss = new Miss(0, Miss.EXPULSION, (Date) datePopupDateField.getValue(), "", student.getID(), app.user.getID(), ((Classblock) classblockComboBox.getValue()).getIDSubject(), ((Classblock) classblockComboBox.getValue()).getID()); if ((Boolean) event.getButton().getValue()) { app.storage.addMiss(miss); } else { app.storage.deleteMiss(Miss.EXPULSION, miss.getDate(), miss.getIDStudent(), miss.getIDClassblock()); } updateEnabledCheckBoxes(student); } }); Object row[] = { student.getName(), student.getSurname1(), student.getSurname2(), missCheckBox, excusedmissCheckBox, delayCheckBox, expulsionCheckBox }; table.addItem(row, new Integer(student.getID())); updateEnabledCheckBoxes(student); } }
From source file:org.jpos.ee.pm.vaadin.converters.EditBooleanConverter.java
License:Open Source License
@Override public Object visualize(PMContext ctx) throws ConverterException { Field f = new CheckBox(); Boolean p = (Boolean) ctx.get(PM_FIELD_VALUE); boolean withnull = Boolean.parseBoolean(getConfig("with-null", "false")); //TO-DO if (p == null) { f.setValue(false);/*from ww w. j a v a2 s . c om*/ } else { f.setValue(p); } return f; }
From source file:org.jpos.ee.pm.vaadin.converters.ShowBooleanConverter.java
License:Open Source License
@Override public Object visualize(PMContext ctx) throws ConverterException { Field f = new CheckBox(); Boolean p = (Boolean) ctx.get(PM_FIELD_VALUE); boolean withnull = Boolean.parseBoolean(getConfig("with-null", "false")); //TO-DO if (p == null) { f.setValue(false);//from w w w. ja va 2 s . c o m } else { f.setValue(p); } f.setReadOnly(true); return f; }
From source file:org.jumpmind.metl.ui.views.design.EditDataDiffPanel.java
License:Open Source License
protected CheckBox createEntityCheckBox(final EntitySettings settings, final String key) { final CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true);// w w w . j a v a2s. c om checkBox.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { ComponentEntitySetting setting = component.getSingleEntitySetting(settings.getEntityId(), key); String oldValue = setting == null ? Boolean.TRUE.toString() : setting.getValue(); if (setting == null) { setting = new ComponentEntitySetting(settings.getEntityId(), component.getId(), key, Boolean.TRUE.toString()); component.addEntitySetting(setting); } setting.setValue(checkBox.getValue().toString()); if (!oldValue.equals(setting.getValue())) { context.getConfigurationService().save(setting); } } }); checkBox.setReadOnly(readOnly); return checkBox; }
From source file:org.jumpmind.metl.ui.views.design.EditDataDiffPanel.java
License:Open Source License
protected CheckBox createAttributeCheckBox(final AttributeSettings settings, final String key) { final CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true);//from w ww . ja v a 2s . c om if (settings.isPrimaryKey()) { checkBox.setEnabled(false); } checkBox.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { ComponentAttributeSetting setting = component.getSingleAttributeSetting(settings.getAttributeId(), key); String oldValue = setting == null ? Boolean.TRUE.toString() : setting.getValue(); if (setting == null) { setting = new ComponentAttributeSetting(settings.getAttributeId(), component.getId(), key, Boolean.TRUE.toString()); component.addAttributeSetting(setting); } setting.setValue(checkBox.getValue().toString()); if (!oldValue.equals(setting.getValue())) { context.getConfigurationService().save(setting); } } }); checkBox.setReadOnly(readOnly); return checkBox; }
From source file:org.jumpmind.metl.ui.views.design.EditDeduperPanel.java
License:Open Source License
protected CheckBox createAttributeCheckBox(final AttributeSettings settings, final String key) { final CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true);// w w w .j a v a 2 s . c o m checkBox.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { ComponentAttributeSetting setting = component.getSingleAttributeSetting(settings.getAttributeId(), key); String oldValue = setting == null ? Boolean.FALSE.toString() : setting.getValue(); if (setting == null) { setting = new ComponentAttributeSetting(settings.getAttributeId(), component.getId(), key, Boolean.TRUE.toString()); component.addAttributeSetting(setting); } setting.setValue(checkBox.getValue().toString()); if (!oldValue.equals(setting.getValue())) { context.getConfigurationService().save(setting); } } }); checkBox.setReadOnly(readOnly); return checkBox; }
From source file:org.jumpmind.metl.ui.views.design.EditMergerPanel.java
License:Open Source License
private CheckBox createCheckBox(final AttributeSettings settings, final String key) { final CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true);// w w w .j av a2 s . com checkBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { ComponentAttributeSetting setting = component.getSingleAttributeSetting(settings.getAttributeId(), key); String oldValue = setting == null ? Boolean.FALSE.toString() : setting.getValue(); if (setting == null) { setting = new ComponentAttributeSetting(settings.getAttributeId(), component.getId(), key, Boolean.TRUE.toString()); component.addAttributeSetting(setting); } setting.setValue(checkBox.getValue().toString()); if (!oldValue.equals(setting.getValue())) { context.getConfigurationService().save(setting); } } }); checkBox.setReadOnly(readOnly); return checkBox; }
From source file:org.jumpmind.metl.ui.views.design.EditModelPanel.java
License:Open Source License
public EditModelPanel(ApplicationContext context, String modelId, boolean readOnly) { this.context = context; this.model = new Model(modelId); this.readOnly = readOnly; context.getConfigurationService().refresh(model); ButtonBar buttonBar = new ButtonBar(); addComponent(buttonBar);/* ww w .j a va 2s. co m*/ if (!readOnly) { addEntityButton = buttonBar.addButton("Add Entity", FontAwesome.TABLE); addEntityButton.addClickListener(new AddEntityClickListener()); addAttributeButton = buttonBar.addButton("Add Attribute", FontAwesome.COLUMNS); addAttributeButton.addClickListener(new AddAttributeClickListener()); editButton = buttonBar.addButton("Edit", FontAwesome.EDIT); editButton.addClickListener(new EditClickListener()); removeButton = buttonBar.addButton("Remove", FontAwesome.TRASH_O); removeButton.addClickListener(new RemoveClickListener()); importButton = buttonBar.addButton("Import ...", FontAwesome.DOWNLOAD); importButton.addClickListener(new ImportClickListener()); } filterField = buttonBar.addFilter(); filterField.addTextChangeListener(new TextChangeListener() { public void textChange(TextChangeEvent event) { filterField.setValue(event.getText()); treeTable.removeAllItems(); addAll(event.getText(), EditModelPanel.this.model.getModelEntities()); } }); treeTable.setSizeFull(); treeTable.setCacheRate(100); treeTable.setPageLength(100); treeTable.setImmediate(true); treeTable.setSelectable(true); treeTable.setMultiSelect(true); treeTable.addGeneratedColumn("name", new ColumnGenerator() { public Object generateCell(Table source, Object itemId, Object columnId) { final AbstractObject obj = (AbstractObject) itemId; if (lastEditItemIds.contains(itemId) && !readOnly) { ImmediateUpdateTextField t = new ImmediateUpdateTextField(null) { protected void save(String text) { obj.setName(text); EditModelPanel.this.context.getConfigurationService().save(obj); }; }; t.setWidth(100, Unit.PERCENTAGE); t.setValue(obj.getName()); t.focus(); t.selectAll(); return t; } else { return UiUtils.getName(filterField.getValue(), obj.getName()); } } }); treeTable.setColumnHeader("name", "Name"); treeTable.addGeneratedColumn("description", new ColumnGenerator() { public Object generateCell(Table source, Object itemId, Object columnId) { if (itemId instanceof ModelAttribute) { final ModelAttribute obj = (ModelAttribute) itemId; if (lastEditItemIds.contains(itemId) && !readOnly) { ImmediateUpdateTextField t = new ImmediateUpdateTextField(null) { protected void save(String text) { obj.setDescription(text); EditModelPanel.this.context.getConfigurationService().save(obj); }; }; t.setWidth(100, Unit.PERCENTAGE); t.setValue(obj.getDescription()); return t; } else { return UiUtils.getName(filterField.getValue(), obj.getDescription()); } } if (itemId instanceof ModelEntity) { final ModelEntity obj = (ModelEntity) itemId; if (lastEditItemIds.contains(itemId) && !readOnly) { ImmediateUpdateTextField t = new ImmediateUpdateTextField(null) { protected void save(String text) { obj.setDescription(text); EditModelPanel.this.context.getConfigurationService().save(obj); }; }; t.setWidth(100, Unit.PERCENTAGE); t.setValue(obj.getDescription()); return t; } else { return UiUtils.getName(filterField.getValue(), obj.getDescription()); } } else return null; } }); treeTable.setColumnHeader("description", "Description"); treeTable.addGeneratedColumn("type", new ColumnGenerator() { public Object generateCell(Table source, Object itemId, Object columnId) { if (itemId instanceof ModelAttribute) { final ModelAttribute obj = (ModelAttribute) itemId; if (lastEditItemIds.contains(itemId) && !readOnly) { final ComboBox cbox = new ComboBox(); cbox.setNullSelectionAllowed(false); for (DataType dataType : DataType.values()) { cbox.addItem(dataType.name()); } cbox.setValue(obj.getType()); cbox.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { obj.setType((String) cbox.getValue()); EditModelPanel.this.context.getConfigurationService().save(obj); } }); cbox.addBlurListener(new BlurListener() { public void blur(BlurEvent event) { Collection<?> items = treeTable.getItemIds(); boolean found = false; for (Object item : items) { if (item.equals(obj)) { found = true; } else if (found) { selectOnly(item); editSelectedItem(); break; } } } }); return cbox; } else { return obj.getType(); } } else { return null; } } }); treeTable.setColumnHeader("type", "Type"); treeTable.addGeneratedColumn("pk", new ColumnGenerator() { public Object generateCell(Table source, Object itemId, Object columnId) { if (itemId instanceof ModelAttribute) { final ModelAttribute obj = (ModelAttribute) itemId; if (lastEditItemIds.contains(itemId) && !readOnly) { final CheckBox cbox = new CheckBox(); cbox.setValue(obj.isPk()); cbox.setImmediate(true); cbox.addValueChangeListener(event -> togglePk(obj)); cbox.addBlurListener(new BlurListener() { public void blur(BlurEvent event) { Collection<?> items = treeTable.getItemIds(); boolean found = false; for (Object item : items) { if (item.equals(obj)) { found = true; } else if (found) { selectOnly(item); editSelectedItem(); break; } } } }); return cbox; } else if (obj.isPk()) { return new Label(FontAwesome.KEY.getHtml(), ContentMode.HTML); } } return null; } }); treeTable.setColumnHeader("pk", "PK"); treeTable.setColumnWidth("pk", 40); treeTable.addItemClickListener(new TreeTableItemClickListener()); treeTable.addValueChangeListener(new TreeTableValueChangeListener()); enterKeyListener = new ShortcutListener("Enter", KeyCode.ENTER, null) { public void handleAction(Object sender, Object target) { lastEditItemIds = Collections.emptySet(); treeTable.refreshRowCache(); } }; addComponent(treeTable); setExpandRatio(treeTable, 1.0f); HorizontalLayout hlayout = new HorizontalLayout(); addComponent(hlayout); Button collapseAll = new Button("Collapse All"); collapseAll.addStyleName(ValoTheme.BUTTON_LINK); collapseAll.addStyleName(ValoTheme.BUTTON_SMALL); hlayout.addComponent(collapseAll); collapseAll.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { for (Object itemId : treeTable.getItemIds()) { treeTable.setCollapsed(itemId, true); } } }); Button expandAll = new Button("Expand All"); expandAll.addStyleName(ValoTheme.BUTTON_LINK); expandAll.addStyleName(ValoTheme.BUTTON_SMALL); hlayout.addComponent(expandAll); expandAll.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { for (Object itemId : treeTable.getItemIds()) { treeTable.setCollapsed(itemId, false); } } }); addAll("", model.getModelEntities()); setButtonsEnabled(); }
From source file:org.jumpmind.metl.ui.views.design.EditRdbmsWriterPanel.java
License:Open Source License
private CheckBox createCheckBox(final AttributeSettings settings, final String key) { final CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true);/*from w w w. ja v a2s . c om*/ if (!readOnly) { checkBox.addValueChangeListener((event) -> { ComponentAttributeSetting setting = component.getSingleAttributeSetting(settings.getAttributeId(), key); String oldValue = setting == null ? Boolean.TRUE.toString() : setting.getValue(); if (setting == null) { setting = new ComponentAttributeSetting(settings.getAttributeId(), component.getId(), key, Boolean.TRUE.toString()); component.addAttributeSetting(setting); } setting.setValue(checkBox.getValue().toString()); if (!oldValue.equals(setting.getValue())) { context.getConfigurationService().save(setting); } }); } checkBox.setReadOnly(readOnly); return checkBox; }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.TableSelectionLayout.java
License:Open Source License
private void populateTable(final String table) { final CheckBox checkBox = new CheckBox(); checkBox.setValue(select(getSelectedCatalog(), getSelectedSchema(), table)); listOfTablesTable.addItem(new Object[] { checkBox, table }, table); checkBox.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override//w w w. ja v a2 s . c o m public void valueChange(ValueChangeEvent event) { if (checkBox.getValue()) { org.jumpmind.db.model.Table t = new org.jumpmind.db.model.Table(table); selectedTablesSet.add(t); } else { Iterator<org.jumpmind.db.model.Table> selectedIterator = selectedTablesSet.iterator(); boolean notFound = true; while (selectedIterator.hasNext() || notFound) { if (selectedIterator.next().getName().equals(table)) { selectedIterator.remove(); notFound = false; } } } selectionChanged(); } }); }