This section describes an initial version of a Data Framework.

At the core of the Data Framework is the concept of Data Handlers. A Data Handler wraps an instance of a particular kind of data and usually knows how to read, save etc. this particular kind of data.

To integrate with the Docking Framework a Data Handler needs to implement at least UniqueKeyProvider. The unique key can be e.g. the unique business key of the data instance or the path to the file for file based Data Handlers or any other kind of key which allows the Docking Framework to detect if there’s already an editor open for this data instance. The unique key can be null for newly created data instances but must be non-null after it has been saved and must not change afterwards.

1. Data Handlers for Business Objects

To register a Data Handler for a business object, which e.g. has been obtained from a web service call, use the @BusinessObjectHandler annotation:

@BusinessObjectHandler(icon = "bar.png")
public class BarHandler extends AbstractDataHandler<String> {

The @BusinessObjectHandler properties:

Property Value

icon

The icon name pattern to resolve the icons to be used for this file type handler. Note that this only specifies the name pattern. Drombler ACP Docking Framework looks for <icon-base-name>16.<icon-extension> (expected to be 16x16 pixels). So if icon is "test.png", the Drombler ACP Docking Framework would look for test16.png.

As the code sample shows, the easiest way to implement a Data Handler for a business object is to extend AbstractDataHandler.

2. Data Handlers for Documents

To register a Data Handler for a document use the @DocumentHandler annotation:

@DocumentHandler(mimeType = "text/foo", icon = "foo.png")
public class FooHandler extends AbstractDocumentHandler {

The @DocumentHandler properties:

Property Value

mimeType

The MIME type of the document.

icon

The icon name pattern to resolve the icons to be used for this file type handler. Note that this only specifies the name pattern. Drombler ACP looks for <icon-base-name>16.<icon-extension> for data types (expected to be 16x16 pixels). So if icon is "test.png", Drombler ACP would look for test16.png.

As the code sample shows, the easiest way to implement a Data Handler for a file based document is to extend AbstractDocumentHandler.

2.1. File Extension

To associate some file extensions with a MIME type you can register the file extensions using the @FileExtension annotation:

@FileExtension(displayName = "%fooFileExtension.displayName", mimeType = "text/foo", fileExtensions = "foo", position = 10)
package tutorial.data;

The @FileExtension properties:

Property Value

displayName

The text to be displayed, e.g. as the text for filters in file dialogs. If the value starts with '%' the rest of the value is interpreted as a property key and the value gets looked-up in the Bundle.properties file (or a locale specific derivation of this file), which has to be in the same package as the annotated data type.

mimeType

The MIME type for the specified file extensions.

fileExtensions

The file extensions for the specified MIME type.

position

The position, e.g. to order the file extensions in filters of file dialogs. It’s a best practice to leave out some positions between entries to allow other bundles to register entries between some existing ones.

2.2. Standard File Actions

The org.drombler.acp:drombler-acp-core-standard-action-data-file Maven module registers the following file based action:

Open Files:

@Action(id = "open", category = "core", displayName = "%displayName", accelerator = "Shortcut+O")
@MenuEntry(path = "File", position = 1010)

The Open Files action provides a generic open file dialog and tries to open the selected files by calling FileUtils.openFile.

2.3. File Path Arguments Support

The Data Framework registers an implementation of AdditionalArgumentsProvider, which tries to open unnamed file path arguments passed to the application on application start by calling FileUtils.openFile.