Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. 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 the folderField, which is used to enter a file directory address.
         private INotifierData notificationData;
         private Composite body;
         private Text folderField;
  2. 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);
         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;
    The code does the following:
    • 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 the notificationData, thus enabling save actions.
    • Returns the body to be added to the DB Change Manager job editor to which this class applies.
  3. 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 of INotifierData containing job-specific data for the notifier. If the folderField 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.

  1. Open the MANIFEST.MF file.
  2. Navigate to the plugin.xml tab and display the source.
  3. 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>
  4. 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.

Deploy the Notifier plugin


Scroll Ignore
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmltrue
Newtabfooter
aliasIDERA
urlhttp://www.idera.com
 | 
Newtabfooter
aliasProducts
urlhttps://www.idera.com/productssolutions/sqlserver
 
Newtabfooter
aliasPurchase
urlhttps://www.idera.com/buynow/onlinestore
 | 
Newtabfooter
aliasSupport
urlhttps://idera.secure.force.com/
 | 
Newtabfooter
aliasCommunity
urlhttp://community.idera.com
 
|
 
Newtabfooter
aliasResources
urlhttp://www.idera.com/resourcecentral
 | 
Newtabfooter
aliasAbout Us
urlhttp://www.idera.com/about/aboutus
 
Newtabfooter
aliasLegal
urlhttps://www.idera.com/legal/termsofuse