use of com.vaadin.data.Property in project Activiti by Activiti.
the class AdminRunningInstancesPanel method initDefinitionsTable.
protected void initDefinitionsTable() {
if (instanceList == null || instanceList.isEmpty()) {
noMembersTable = new Label(i18nManager.getMessage(Messages.ADMIN_RUNNING_NONE_FOUND));
definitionsLayout.addComponent(noMembersTable);
} else {
runningDefinitions = new HashMap<String, ManagementProcessDefinition>();
for (HistoricProcessInstance instance : instanceList) {
String processDefinitionId = instance.getProcessDefinitionId();
ManagementProcessDefinition managementDefinition = null;
if (runningDefinitions.containsKey(processDefinitionId)) {
managementDefinition = runningDefinitions.get(processDefinitionId);
} else {
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
if (definition == null) {
// this process has a missing definition - skip
continue;
}
managementDefinition = new ManagementProcessDefinition();
managementDefinition.processDefinition = definition;
managementDefinition.runningInstances = new ArrayList<HistoricProcessInstance>();
runningDefinitions.put(definition.getId(), managementDefinition);
}
managementDefinition.runningInstances.add(instance);
}
definitionsTable = new Table();
definitionsTable.setWidth(100, UNITS_PERCENTAGE);
definitionsTable.setHeight(250, UNITS_PIXELS);
definitionsTable.setEditable(false);
definitionsTable.setImmediate(true);
definitionsTable.setSelectable(true);
definitionsTable.setSortDisabled(false);
definitionsTable.addContainerProperty("id", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_ID), null, Table.ALIGN_LEFT);
definitionsTable.addContainerProperty("name", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_NAME), null, Table.ALIGN_LEFT);
definitionsTable.addContainerProperty("nr of instances", String.class, null, i18nManager.getMessage(Messages.ADMIN_NR_INSTANCES), null, Table.ALIGN_LEFT);
for (ManagementProcessDefinition managementDefinition : runningDefinitions.values()) {
definitionsTable.addItem(new String[] { managementDefinition.processDefinition.getId(), managementDefinition.processDefinition.getName(), String.valueOf(managementDefinition.runningInstances.size()) }, managementDefinition.processDefinition.getId());
}
definitionsTable.addListener(new Property.ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
// the value of the property is the itemId of the table entry
Item item = definitionsTable.getItem(event.getProperty().getValue());
if (item != null) {
String definitionId = (String) item.getItemProperty("id").getValue();
selectedManagementDefinition = runningDefinitions.get(definitionId);
refreshInstancesTable();
}
}
});
definitionsLayout.addComponent(definitionsTable);
}
}
use of com.vaadin.data.Property in project Activiti by Activiti.
the class AdminRunningInstancesPanel method initInstancesTable.
protected void initInstancesTable() {
instancesTable = new Table();
instancesTable.setWidth(100, UNITS_PERCENTAGE);
instancesTable.setHeight(250, UNITS_PIXELS);
instancesTable.setEditable(false);
instancesTable.setImmediate(true);
instancesTable.setSelectable(true);
instancesTable.setSortDisabled(false);
instancesTable.addContainerProperty("id", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_ID), null, Table.ALIGN_LEFT);
instancesTable.addContainerProperty("business key", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_BUSINESSKEY), null, Table.ALIGN_LEFT);
instancesTable.addContainerProperty("start user id", String.class, null, i18nManager.getMessage(Messages.ADMIN_STARTED_BY), null, Table.ALIGN_LEFT);
instancesTable.addContainerProperty("start activity id", String.class, null, i18nManager.getMessage(Messages.ADMIN_START_ACTIVITY), null, Table.ALIGN_LEFT);
instancesTable.addContainerProperty("start time", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_STARTED), null, Table.ALIGN_LEFT);
instancesTable.addListener(new Property.ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
// the value of the property is the itemId of the table entry
Item item = instancesTable.getItem(event.getProperty().getValue());
if (item != null) {
String instanceId = (String) item.getItemProperty("id").getValue();
HistoricProcessInstance processInstance = null;
for (HistoricProcessInstance instance : selectedManagementDefinition.runningInstances) {
if (instance.getId().equals(instanceId)) {
processInstance = instance;
break;
}
}
if (processInstance != null)
addProcessImage(selectedManagementDefinition.processDefinition, processInstance);
addTasks(processInstance);
addVariables(processInstance);
}
}
});
instancesLayout.addComponent(instancesTable);
}
use of com.vaadin.data.Property in project Activiti by Activiti.
the class GroupPage method createList.
protected Table createList() {
groupTable = new Table();
groupTable.setEditable(false);
groupTable.setImmediate(true);
groupTable.setSelectable(true);
groupTable.setNullSelectionAllowed(false);
groupTable.setSortDisabled(true);
groupTable.setSizeFull();
groupListQuery = new GroupListQuery();
groupListContainer = new LazyLoadingContainer(groupListQuery, 30);
groupTable.setContainerDataSource(groupListContainer);
// Column headers
groupTable.addGeneratedColumn("icon", new ThemeImageColumnGenerator(Images.GROUP_22));
groupTable.setColumnWidth("icon", 22);
groupTable.addContainerProperty("name", String.class, null);
groupTable.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
// Listener to change right panel when clicked on a user
groupTable.addListener(new Property.ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
// the value of the property is the itemId of the table entry
Item item = groupTable.getItem(event.getProperty().getValue());
if (item != null) {
String groupId = (String) item.getItemProperty("id").getValue();
setDetailComponent(new GroupDetailPanel(GroupPage.this, groupId));
// Update URL
ExplorerApp.get().setCurrentUriFragment(new UriFragment(GroupNavigator.GROUP_URI_PART, groupId));
} else {
// Nothing is selected
setDetailComponent(null);
ExplorerApp.get().setCurrentUriFragment(new UriFragment(GroupNavigator.GROUP_URI_PART, groupId));
}
}
});
return groupTable;
}
use of com.vaadin.data.Property 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.Property in project cuba by cuba-platform.
the class WebEntityLinkField method setDatasource.
@Override
public void setDatasource(Datasource datasource, String property) {
Preconditions.checkNotNullArgument(datasource, "datasource is null");
if (this.datasource != null) {
throw new UnsupportedOperationException("Changing datasource is not supported by the EntityLinkField component");
}
// noinspection unchecked
this.datasource = datasource;
MetaClass metaClass = datasource.getMetaClass();
resolveMetaPropertyPath(metaClass, property);
if (metaProperty.getRange().isClass()) {
this.metaClass = metaProperty.getRange().asClass();
}
ItemWrapper wrapper = createDatasourceWrapper(datasource, Collections.singleton(metaPropertyPath));
Property itemProperty = wrapper.getItemProperty(metaPropertyPath);
component.setPropertyDataSource(itemProperty);
itemChangeListener = e -> {
Object newValue = InstanceUtils.getValueEx(e.getItem(), metaPropertyPath.getPath());
setValue(newValue);
};
// noinspection unchecked
datasource.addItemChangeListener(new WeakItemChangeListener(datasource, itemChangeListener));
itemPropertyChangeListener = e -> {
if (e.getProperty().equals(metaPropertyPath.toString())) {
setValue(e.getValue());
}
};
// noinspection unchecked
datasource.addItemPropertyChangeListener(new WeakItemPropertyChangeListener(datasource, itemPropertyChangeListener));
if (datasource.getState() == Datasource.State.VALID && datasource.getItem() != null) {
if (property.equals(metaPropertyPath.toString())) {
Object newValue = InstanceUtils.getValueEx(datasource.getItem(), metaPropertyPath.getPath());
setValue(newValue);
}
}
setRequired(metaProperty.isMandatory());
if (StringUtils.isEmpty(getRequiredMessage())) {
MessageTools messageTools = AppBeans.get(MessageTools.NAME);
setRequiredMessage(messageTools.getDefaultRequiredMessage(metaClass, property));
}
}
Aggregations