use of com.vaadin.data.Item in project opennms by OpenNMS.
the class MbeansHierarchicalContainer method addItem.
private void addItem(String parentItemId, String childItemId, Object childData, boolean hasChildren) {
if (!containsId(childItemId)) {
LOG.debug("Adding child {} to parent {}.", childItemId, parentItemId);
Item item = addItem(childItemId);
if (item == null) {
LOG.error("Could not add item with item id {}.", childItemId);
} else {
// 1:1 mapping
itemIdToDataMapping.put(childItemId, childData);
// kein 1:1 mapping, n:1 mapping
dataToItemIdMapping.put(childData, childItemId);
setItemProperties(item, childData);
setParent(childItemId, parentItemId);
//if we do not set childrenAllowed a "expand/collapse" icon is shown. We do not want that
setChildrenAllowed(childItemId, hasChildren);
}
} else {
LOG.debug("Child with id {} already added.", childItemId);
}
}
use of com.vaadin.data.Item in project opennms by OpenNMS.
the class AttributesTable method modelChanged.
public void modelChanged(Item parentItem, Object parentData, SelectableBeanItemContainer<T> container) {
try {
blockValidation = true;
if (getParentItem() == parentItem)
return;
setParentItem(parentItem);
setParentData(parentData);
// we initialize the tableFieldFactory because by default pagination is enabled, which
// causes the table not to know all fields. But the validation is bound to a field, therefore
// we need to create all fields in advance.
aliasFieldsMap.clear();
fields.clear();
for (Object eachItemId : container.getItemIds()) {
for (Object eachPropertyId : container.getContainerPropertyIds()) {
Field<?> eachField = tableFieldFactory.createField(container, eachItemId, eachPropertyId, this);
if (eachField != null) {
fields.put(computeKey(eachItemId, eachPropertyId), eachField);
if (MetaAttribItem.ALIAS.equals(eachPropertyId)) {
aliasFieldsMap.put(eachItemId, (Field<String>) eachField);
// we have to set this manually, otherwise validation does not work
Item item = container.getItem(eachItemId);
Property property = item.getItemProperty(eachPropertyId);
((Field<String>) eachField).setValue((String) property.getValue());
}
}
}
}
setContainerDataSource(container);
setVisibleColumns(MetaAttribItem.SELECTED, MetaAttribItem.NAME, MetaAttribItem.ALIAS, MetaAttribItem.TYPE);
// enable/disable fields according to parent selection
Property itemProperty = parentItem.getItemProperty(MBeansTree.MetaMBeansTreeItem.SELECTED);
enableFields(fields.values(), (Boolean) itemProperty.getValue());
if ((Boolean) itemProperty.getValue()) {
updateCheckBoxes();
}
// we initially validate to ensure the ui is ok ant not in a broken state.
// Only to allow this validation we have to do the initialization of the fields (See above) manually.
// This is not ideal, but it seems to be the only way.
validateFields(true);
} finally {
blockValidation = false;
}
}
use of com.vaadin.data.Item in project opennms by OpenNMS.
the class MBeansController method selectionValueChanged.
@Override
public void selectionValueChanged(SelectionValueChangedEvent selectionValueChangedEvent) {
Object itemId = selectionValueChangedEvent.getItemId();
Item item = mbeansContainer.getItem(itemId);
if (item != null) {
handleSelectDeselect(item, selectionValueChangedEvent.getNewValue());
Object data = mbeansContainer.getDataFor((String) itemId);
forwardSelectionToCompAttribute(itemId, data, selectionValueChangedEvent.getNewValue());
validateCurrentSelection();
}
}
use of com.vaadin.data.Item in project opennms by OpenNMS.
the class MBeansController method updateValidState.
private void updateValidState(Object data, boolean valid) {
final String itemId = mbeansContainer.getItemIdFor(data);
final Item theItem = mbeansContainer.getItem(itemId);
updateValidState(theItem, valid);
if (!valid) {
// make sure the error element is visible
mbeansTree.expandItemsUpToParent(itemId);
}
}
use of com.vaadin.data.Item in project Activiti by Activiti.
the class ArchivedListQuery method loadItems.
public List<Item> loadItems(int start, int count) {
List<HistoricTaskInstance> historicTaskInstances = createQuery().listPage(start, count);
List<Item> items = new ArrayList<Item>();
for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
items.add(new TaskListItem(historicTaskInstance));
}
return items;
}
Aggregations