Objectpooleditor

ObjectPool Editor #

This page contains the following content:

The ObjectPool Editor allows the viewing, editing, adding, deletion and filtering of objects in an object pool. Alterations made to the pool or its objects can be written to the Java object of the pool. Additionally, the pool can be exported to an XML file. Editing and viewing of the contained objects is facilitated by providing embedded access to the DataObjectEditor and the NESTWorkflowEditor.

⚠️ The editor creates a copy of the ObjectPool provided as a parameter during instantiation and applies the modifications made by the user to this copy. To transfer the modifications to the original ObjectPool, the Save action from the File menu has to be used

Starting the Editor #

To open the editor, an instance of the class ObjectPoolEditor needs to be created with the desired WriteableObjectPool as a parameter. The given pool is deeply copied on editor instantiation so changes made with the editor are only applied to the copy at first. Invoking the Save Action writes the changes to the original pool.

GUI Overview #

gui_overview

Pool view #

The pool view provides access to the objects in the pool. Each object is represented by a node which might be expanded to access its nested elements (attributes in AggregateObjects or nodes and edges for NESTWorkflowObjects). Arbitrarily nested objects are supported. Selecting a node in the pool view loads the corresponding object in a suitable editor in the editor area on the right.

Additionally, the path display is updated when the selection in the pool view is changed. The elements of the path display can be clicked, which causes the selection of the pool view to be set to the corresponding node.

Right Click Menu #

Right clicking a node in the pool view opens a popup menu offering several actions (depending on the type of node that was clicked):

  • Export to XML: Serializes the selected object to XML and saves the XML to a file chosen by the user.
  • Replace by XML import: Prompts for an XML file containing a DataObject definition which then is deserialized into an object and placed at the selected position (possibly overwriting an already existing object).
  • Copy: Copies the selected object to the global clipboard spanning all editor instances.
  • Replace by clipboard object: Copies the object present in the global clipboard and places it at the selected position (possibly overwriting an already existing object).
  • Set ID: Prompts for an ID to be set as the internal ID of the selected DataObject.
  • For collection types and pool:
    • Add from XML import: Prompts for an XML file containing a DataObject definition which then is deserialized into an object and added to the selected collection / the pool.
    • Add clipboard object: Copies the object present in the global clipboard and adds it to the selected collection / the pool.
  • Delete (only for pool elements): Removes the selected element from the pool.

Configuring Labels #

The representation of aggregate object nodes in the pool view can be configured in the composition.xml file in the cake.utils.objectpooleditor.LabelProviderFactory factory section. The editor uses the implementation class cake.utils.objectpooleditor.ObjectPoolEditorLabelProvider for generating labels for the tree view nodes that represent an aggregate object. Parameters can be defined to specify which attribute values of an aggregate of a specific class should be incorporated into the label. Multiple attributes for labels are supported by separating them by a comma in the parameter value.

Example:

<Factory name="label_provider" class="cake.utils.objectpooleditor.LabelProviderFactory">
    <Implementation class="cake.utils.objectpooleditor.ObjectPoolEditorLabelProvider">
        <Parameter name="Cars" value="manufacturer,make,year"/>
        <Parameter name="AmountType" value="value,unit"/>
    </Implementation>
</Factory>

This causes the editor to look for the attributes named manufacturer, make and year whenever it encounters an aggregate object of the type Cars.

When these options to customize the editor labels do not suffice (e.g. when the pool consists of NESTWorkflowObjects instead of AggregateObjects), the ObjectPoolEditor class offers the possibility to overwrite the getTreeNodeLabel methods responsible for label generation and to provide a custom implementation.

Example:

new ObjectPoolEditor<>(pool) {
    @Override
    protected String getTreeNodeLabel(NESTWorkflowObject nestWorkflowObject) {
        return nestWorkflowObject.getWorkflowNode().getSemanticDescriptorStringValue("source");
    }
};

This extracts the attribute named source from the semantic descriptor of the workflow node of the NESTWorkflowObjects in the pool to display as the label of the tree nodes. The getTreeNodeLabel method exists for the following parameter types:

  • AtomicObject
  • AggregateObject
  • NESTWorkflowObject
  • Map.Entry (Attribute name and value)
  • CollectionObject
  • NESTEdgeObject
  • NESTNodeObject
  • ReadableObjectPool
  • DataObject

Filtering the Pool #

The top section of the editor offers filtering of the pool elements by means of a filter expression. The filter input needs to be a predicate in the form of java code. Pressing Enter or clicking the Filter button after entering a filter expression checks the expression against each element of the pool and hides it in the pool view when it evaluates to false. To remove the filtering, delete the filter input and press Enter / click Filter.

Only the filtering of AggregateObjects is supported. Attributes can be accessed by their names and attributes containing atomic values can be used in conjunction with the usual operators to build a filter expression, e.g.: year > 1999 && price <= 5000 && manufacturer.equals("opel").

Multiple Editor Instances #

It is possible to open additional editor instances via the View -> Open new editor window which are initialized with the pool object of the parent editor. Multiple editor instances facilitate the possibility to easily compare multiple elements of the pool by arranging the windows side by side. The feature can also be used to open multiple different pools simultaneously and then use the global clipboard to transfer elements of one pool to another.

Persisting changes #

Changes made to the pool or its elements can be persisted by executing File -> Save or File -> Export to XML. Saving writes the changes to the Java object the editor was initially instanced with. Exporting serializes the pool to XML and prompts for a file the XML should be written to.