/** * Method to return the {@link BeanItemContainer} associated with this object. * * @return the {@link BeanItemContainer} */ public BeanItemContainer<Wallboard> getBeanContainer() { return new BeanItemContainer<Wallboard>(Wallboard.class, m_wallboards.getWallboards()); }
/** * Reloads the configuration. */ public void reloadSurveillanceViews() { m_beanItemContainer.removeAllItems(); m_beanItemContainer.addAll(SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().getViews()); } }
/** * Adds the bean to the Container. * * The bean is used both as the item contents and as the item identifier. * * @see com.vaadin.v7.data.Container#addItem(Object) Container#addItem(Object) */ @Override public BeanItem<BEANTYPE> addBean(BEANTYPE bean) { return addItem(bean); }
columnsTable.setWidth(25, Unit.PERCENTAGE); final BeanItemContainer<ColumnDef> columns = new BeanItemContainer<ColumnDef>(ColumnDef.class, view.getColumns()); columns.setItemSorter(new DefaultItemSorter() { @Override public int compare(Object o1, Object o2) { rowsTable.setWidth(25, Unit.PERCENTAGE); final BeanItemContainer<RowDef> rows = new BeanItemContainer<RowDef>(RowDef.class, view.getRows()); rows.setItemSorter(new DefaultItemSorter() { @Override public int compare(Object o1, Object o2) {
public Object generateCell(Table source, final Object itemId, Object columnId) { CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true); checkBox.setDescription("Make this Surveillance View configuration the default"); final View view = m_beanItemContainer.getItem(itemId).getBean(); checkBox.setValue(SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().getDefaultView().equals(view.getName())); checkBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue()); if (newValue) { SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().setDefaultView(view.getName()); } m_table.refreshRowCache(); SurveillanceViewProvider.getInstance().save(); ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved", "Default surveillance view"); } }); return checkBox; } }
@Override public void buttonClick(Button.ClickEvent event) { if (!titleField.isValid()) { ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Error", "Please use an unique title", Notification.Type.ERROR_MESSAGE); return; } if (!refreshSecondsField.isValid()) { ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Error", "Please enter a valid number in the \"Refresh seconds\" field", Notification.Type.ERROR_MESSAGE); return; } if (columns.getItemIds().isEmpty() || rows.getItemIds().isEmpty()) { ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Error", "You must define at least one row category and one column category", Notification.Type.ERROR_MESSAGE); return; } View finalView = new View(); for (ColumnDef columnDef : columns.getItemIds()) { finalView.getColumns().add(columnDef); } for (RowDef rowDef : rows.getItemIds()) { finalView.getRows().add(rowDef); } finalView.setName(titleField.getValue()); finalView.setRefreshSeconds(Integer.parseInt(refreshSecondsField.getValue())); saveActionListener.save(finalView); close(); } });
/** * Constructs a {@code BeanItemContainer} and adds the given beans to it. * * @param type * the type of the beans that will be added to the container. * @param collection * a {@link Collection} of beans (can be empty or null). * @throws IllegalArgumentException * If {@code type} is null */ public BeanItemContainer(Class<? super BEANTYPE> type, Collection<? extends BEANTYPE> collection) throws IllegalArgumentException { super(type); super.setBeanIdResolver(new IdentityBeanIdResolver<BEANTYPE>()); if (collection != null) { addAll(collection); } }
@Override public void buttonClick(Button.ClickEvent clickEvent) { ColumnDef columnDef = (ColumnDef) columnsTable.getValue(); if (columnDef != null) { columnsTable.unselect(columnDef); columns.removeItem(columnDef); } columnsTable.refreshRowCache(); } });
/** * Constructs a {@code BeanItemContainer} and adds the given beans to it. * The collection must not be empty. * {@link BeanItemContainer#BeanItemContainer(Class)} can be used for * creating an initially empty {@code BeanItemContainer}. * * Note that when using this constructor, the actual class of the first item * in the collection is used to determine the bean properties supported by * the container instance, and only beans of that class or its subclasses * can be added to the collection. If this is problematic or empty * collections need to be supported, use {@link #BeanItemContainer(Class)} * and {@link #addAll(Collection)} instead. * * @param collection * a non empty {@link Collection} of beans. * @throws IllegalArgumentException * If the collection is null or empty. * * @deprecated As of 6.5, use {@link #BeanItemContainer(Class, Collection)} * instead */ @SuppressWarnings("unchecked") @Deprecated public BeanItemContainer(Collection<? extends BEANTYPE> collection) throws IllegalArgumentException { // must assume the class is BT // the class information is erased by the compiler this((Class<BEANTYPE>) getBeanClassForCollection(collection), collection); }
WallboardProvider.getInstance().getBeanContainer().addItemSetChangeListener(new Container.ItemSetChangeListener() { public void containerItemSetChange(Container.ItemSetChangeEvent itemSetChangeEvent) { List<Wallboard> wallboardsToRemove = new ArrayList<>();
public Object generateCell(Table source, final Object itemId, Object columnId) { CheckBox checkBox = new CheckBox(); checkBox.setImmediate(true); checkBox.setDescription("Make this Ops Board configuration the default"); final Wallboard wallboard = m_beanItemContainer.getItem(itemId).getBean(); checkBox.setValue(wallboard.isDefault()); checkBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue()); if (newValue) { for (Wallboard wallboard1 : m_beanItemContainer.getItemIds()) { wallboard1.setDefault(false); } } wallboard.setDefault(newValue); m_table.refreshRowCache(); WallboardProvider.getInstance().save(); } }); return checkBox; } });
navigator.navigateTo("wallboard"); for (Wallboard wallboard : beanItemContainer.getItemIds()) { if (wallboard.isDefault()) { headerLayout.gotoWallboard(wallboard);
@Override public void buttonClick(Button.ClickEvent clickEvent) { RowDef rowDef = (RowDef) rowsTable.getValue(); if (rowDef != null) { rowsTable.unselect(rowDef); rows.removeItem(rowDef); } rowsTable.refreshRowCache(); } });
@SuppressWarnings("deprecation") public void setOptions(Collection<T> options) { select.setContainerDataSource(new BeanItemContainer<>(options)); }