Page History
...
- The
DirectoryNotifierViewerContribution
class requires three class-level private attributes. These attributes store notification data, which is the composite on which any options are placed, as well as thefolderField
, which is used to enter a file directory address.private INotifierData notificationData;
private Composite body;
private Text folderField; - The
createFormContent
attribute creates a new composite and provides a layout template for options and entry fields. The code below adds a label and a text field to the interface:public Composite createFormContent (Composite parent, FormToolkit toolkit) body = toolkit.createComposite (parent);
The code does the following:
body.setLayout (new GridLayout ());
toolkit.createLabel (parent, "Target Directory:");
String folder = notificationData == null ? " " " : notificationData.getNotificationProperties().get (DirectoryNotifierConstants.TARGET_DIRECTORY);
folderField = toolkit.createText (parent, folder, SWT.SINGLE | SWT.BORDER);
folderField.setLayoutData (new GridData (SWT.FILL, SWT.CENTER, true, false));
folderField.addModifyListener (new ModifyListener () {
public void modifyText (ModifyEvent e)
{
notificationData.setNotificationPropert (DirectoryNotifierConstants.TARGET_DIRECTORY, folderField.getText().trim() );
}
});
return body;- Creates a new composite body, and sets it to have a grid layout.
- Creates a label for the target directory field.
- Retrieves the folder from the job, if the job is new or unsaved, or defaults to an empty string if the result is null.
- Initializes the
folderField
text element and sets it to justify. - Adds a listener for changes on the
folderField
element that updates thenotificationData
, thus enabling save actions. - Returns the body to be added to the DB Change Manager job editor to which this class applies.
- Add the
setData
method using the following code, which is called to update the user interface with job information. This method accepts and stores the new instance ofINotifierData
containing job-specific data for the notifier. If thefolderField
has already had something entered, the notification properties are initialized and store the value that was previously entered.public void setData (INotifierData notificationData)
this.notificationData = notificationData;
if (folderField !=null && !folderField.isDisposed() && folderField.getText().trim().length() > 0))
if (notificationData !=null) Map<String, String> propMap notificationData.getNotificationProperties();
if (propMap == null)
{
notificationData.setNotificationProperties(new HashMap<String, String>());
propMap = notificationData.getNotificationProperties();
}
notificationData.setNotificationProperty (DirectoryNotifierConstants.TARGET_DIRECTORY, folderField.getText());
}
}
}
Register the extensions
Once you have coded the plugin and implemented the notifier and user interface, you include definitions that explain how DB Change Manager should interact with the plugin.
You register the extensions that define the Notifier
and NotifierViewerContribution
to DB Change Manager. When the plugin is added to DB Change Manager, the extensions are registered and DB Change Manager understands the purpose of the plugin.
- Open the
MANIFEST.MF
file. - Navigate to the plugin.xml tab and display the source.
- Add the following code:
<extension point="com.idera.change.notifications.notifier">
notifier
id="org.acme.directorynotifier" name="Directory Notifier"
notifier="org.acme.directorynotifier.DirectoryNotifier"
viewContribution="org.acme.directorynotifier.DirectoryNotifierViewerContribution">
</notifier>
</extension> - Save the file by pressing Ctrl+S or by clicking File > Save.
When org.acme.directorynotifier
is found, the notification extension point is registered. The notifier
and viewContribution
attributes are the class names for two implementations and Eclipse reflectively registers these objects for use in DB Change Manager.