Search in sources :

Example 1 with Item

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);
    }
}
Also used : Item(com.vaadin.data.Item)

Example 2 with Item

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;
    }
}
Also used : MetaAttribItem(org.opennms.features.vaadin.jmxconfiggenerator.data.MetaAttribItem) Item(com.vaadin.data.Item) Field(com.vaadin.ui.Field) TextField(com.vaadin.ui.TextField) Property(com.vaadin.data.Property)

Example 3 with Item

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();
    }
}
Also used : Item(com.vaadin.data.Item)

Example 4 with Item

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);
    }
}
Also used : Item(com.vaadin.data.Item)

Example 5 with Item

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;
}
Also used : Item(com.vaadin.data.Item) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ArrayList(java.util.ArrayList)

Aggregations

Item (com.vaadin.data.Item)65 Table (com.vaadin.ui.Table)23 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)20 ArrayList (java.util.ArrayList)20 Property (com.vaadin.data.Property)19 UriFragment (org.activiti.explorer.navigation.UriFragment)12 LazyLoadingContainer (org.activiti.explorer.data.LazyLoadingContainer)11 ThemeImageColumnGenerator (org.activiti.explorer.ui.util.ThemeImageColumnGenerator)11 PropertysetItem (com.vaadin.data.util.PropertysetItem)9 Label (com.vaadin.ui.Label)9 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)8 Embedded (com.vaadin.ui.Embedded)7 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)6 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6 ComboBox (com.vaadin.ui.ComboBox)4 Component (com.vaadin.ui.Component)4 Group (org.activiti.engine.identity.Group)4 LazyLoadingQuery (org.activiti.explorer.data.LazyLoadingQuery)4 ValueChangeListener (com.vaadin.data.Property.ValueChangeListener)3 Button (com.vaadin.ui.Button)3