@Override public void setItemProperties(Item item, Object itemId) { item.getItemProperty(MBeansTree.MetaMBeansTreeItem.ICON).setValue(Config.Icons.DUMMY); item.getItemProperty(MBeansTree.MetaMBeansTreeItem.CAPTION).setValue(((Map.Entry) itemId).getValue()); item.getItemProperty(MBeansTree.MetaMBeansTreeItem.TOOLTIP).setValue(((Map.Entry) itemId).getValue()); } }
@Override public Object generateCell(Table source, Object itemId, Object columnId) { Property property = source.getContainerProperty(itemId, columnId); if (property == null || property.getValue() == null) { return null; } String formattedValue; if(property.getType().equals(Instant.class)){ formattedValue = timeformatService.format((Instant) property.getValue(), UserTimeZoneExtractor.extractUserTimeZoneIdOrNull()); } else if(property.getType().equals(Date.class)){ formattedValue = timeformatService.format((Date) property.getValue(), UserTimeZoneExtractor.extractUserTimeZoneIdOrNull()); } else { formattedValue = property.toString(); } return formattedValue; } }
component.setValue(value); ((ProcessInstanceSimpleAttribute) value).getValue() : value; if (value != null) { boolean readonly = component.isReadOnly(); if (readonly) { component.setReadOnly(false); if (Date.class.isAssignableFrom(component.getType())) { DateWidgetElement dwe = Lang2.assumeType(element, DateWidgetElement.class); Date v = new SimpleDateFormat(dwe.getFormat()).parse(String.valueOf(value)); component.setValue(v); } else if (String.class.isAssignableFrom(component.getType())) { component.setValue(nvl(value, "")); } else if (component instanceof Container && component.getType().isAssignableFrom(value.getClass())) { if (((Container) component).containsId(value)) { component.setValue(value); component.setReadOnly(true);
/** * Event handler for value change events. Adds the item to modified list if * value was actually changed. Change can be committed or discarded with * respective methods. * * @param event the ValueChangeEvent */ @Override public void valueChange(final ValueChangeEvent event) { final Property property = event.getProperty(); final Item item = propertyItemMapCache.get(property); if (property == item.getItemProperty(PROPERTY_ID_ITEM_STATUS)) { return; } if (item.getItemProperty(PROPERTY_ID_ITEM_STATUS) != null && ((QueryItemStatus) item.getItemProperty(PROPERTY_ID_ITEM_STATUS).getValue()) != QueryItemStatus.Modified) { item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(false); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setValue(QueryItemStatus.Modified); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(true); } if (!addedItems.contains(item) && !modifiedItems.contains(item)) { modifiedItems.add(item); } }
/** * Removes item at given index by adding it to the removed list. Change can * be committed or discarded with respective methods. * * @param index of the item to be removed. */ @Override public void removeItem(final int index) { final Item item = getItem(index); if (item.getItemProperty(PROPERTY_ID_ITEM_STATUS) != null) { item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(false); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setValue(QueryItemStatus.Removed); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(true); } for (final Object propertyId : item.getItemPropertyIds()) { final Property property = item.getItemProperty(propertyId); property.setReadOnly(true); } removedItems.add(item); }
@Override public void evaluate(Property component, WidgetElement element) throws Exception { if (!component.isReadOnly()) { ProcessInstanceAttribute attribute = fetchOrCreateAttribute(element); if (component instanceof FileUploadComponent) { ProcessInstanceAttachmentAttribute attachment = (ProcessInstanceAttachmentAttribute) component.getValue(); if (attachment==null) return; attachment.setProcessState(task.getTaskName()); attachment.setProcessInstance(task.getProcessInstance()); attachment.setKey(attribute.getKey()); PropertyUtils.setProperty(processAttributes, element.getBind(), component.getValue()); } else if (attribute instanceof ProcessInstanceSimpleAttribute) { if (element instanceof DateWidgetElement) { String dateString = null; if (component.getValue() != null) dateString = new SimpleDateFormat(((DateWidgetElement) element).getFormat()).format(component.getValue()); ((ProcessInstanceSimpleAttribute) attribute).setValue(dateString); } else if (component.getValue() != null) { ((ProcessInstanceSimpleAttribute) attribute).setValue(component.getValue().toString()); } } else { PropertyUtils.setProperty(processAttributes, element.getBind(), component.getValue()); } } } };
@Override public Class<?> getType() { return propertyDataSource.getType(); }
public void commit() throws Buffered.SourceException, InvalidValueException { if (dataSource != null && !dataSource.isReadOnly()) { if ((isInvalidCommitted() || isValid())) { final Object newValue = getValue(); dataSource.setValue(newValue);
/** * Sets the Property's read-only mode to the specified status. * * @param newStatus * the new read-only status of the Property. */ public void setReadOnly(boolean newStatus) { if (dataSource != null) { dataSource.setReadOnly(newStatus); } }
/** * Reflects the read-only status of the datasource. If there is no data * source, returns false. */ public boolean isReadOnly() { return dataSource != null && dataSource.isReadOnly(); }
@SuppressWarnings("unchecked") private void addSourceTableData(final Long selectedId) { if (sourceTableContainer != null) { Item saveTblitem; saveTblitem = sourceTableContainer.addItem(selectedId); saveTblitem.getItemProperty(DIST_TYPE_NAME).setValue(selectedTable.getContainerDataSource() .getItem(selectedId).getItemProperty(DIST_TYPE_NAME).getValue()); saveTblitem.getItemProperty(DIST_TYPE_DESCRIPTION).setValue(selectedTable.getContainerDataSource() .getItem(selectedId).getItemProperty(DIST_TYPE_DESCRIPTION).getValue()); } }
Class<?> componentPropertyType = property.getType(); @SuppressWarnings( "unchecked" ) Converter<Object, Object> setValueConverter = (Converter<Object, Object>) getConverter( toInspectPropertyType, componentPropertyType ); boolean readOnly = property.isReadOnly(); if ( readOnly ) { property.setReadOnly( false ); property.setValue( value ); if ( readOnly ) { property.setReadOnly( true );
/** * Discards changes in the view. */ @Override public void discard() { for (final Item item : addedItems) { if (item.getItemProperty(PROPERTY_ID_ITEM_STATUS) != null) { item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(false); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setValue(QueryItemStatus.None); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(true); } } for (final Item item : modifiedItems) { if (item.getItemProperty(PROPERTY_ID_ITEM_STATUS) != null) { item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(false); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setValue(QueryItemStatus.None); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(true); } } for (final Item item : removedItems) { if (item.getItemProperty(PROPERTY_ID_ITEM_STATUS) != null) { item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(false); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setValue(QueryItemStatus.None); item.getItemProperty(PROPERTY_ID_ITEM_STATUS).setReadOnly(true); } } addedItems.clear(); modifiedItems.clear(); removedItems.clear(); }
/** * Construct a new formatter that is connected to given data source. Calls * {@link #format(Object)} which can be a problem if the formatter has not * yet been initialized. * * @param propertyDataSource * to connect this property to. */ public PropertyConverter(Property propertyDataSource) { setPropertyDataSource(propertyDataSource); propertyClass = (Class<? extends PC>) propertyDataSource.getType(); }//new
@Override public void setReadOnly(boolean newStatus) { propertyDataSource.setReadOnly(newStatus); } };
@Override public boolean isReadOnly() { return propertyDataSource.isReadOnly(); }
protected void populateTableList() { TreeMap<String, Long> tables = new TreeMap<String, Long>(managementService.getTableCount()); // treemap because we want to sort it on name for (String tableName : tables.keySet()) { Item item = table.addItem(tableName); item.getItemProperty("icon").setValue(determineTableIcon(tableName)); item.getItemProperty("tableName").setValue(tableName + " (" + tables.get(tableName) + ")"); } }