Skip to content

Post It Plugin Development

Paolo Ciccarese edited this page Jul 26, 2013 · 4 revisions

The Post It is a simple plugin that allows to create an annotation whose body is composed by a type (Comment, Errata, Free text tag...) and a textual content.

1. Plugin Linkage

In order to link a plugin to the GWT codebase it is necessary to add in the Domeo.gwt.xml file a line specifying the inheritance. The name of the module to inherit has to contain the full package name:

<inherits name="org.mindinformatics.gwt.domeo.plugins.annotation.postit.PostIt"/>

In order for this directive to work, the plugin project needs to include in the root a .gwt.xml file. In the above case (PostIt plugin), the file would be in the directory and would be named 'PostIt.gwt.xml':

src>org>mindinformatics>gwt>domeo>plugins>annotation>postit>PostIt.gwt.xml

The file contains the dependencies and specifies the sub-directories that will contain the GWT code of the plugin. For example, the file PostIt.gwt.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='domeo'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>

  <!-- Inherit the default GWT style sheet.  You can change       -->
  <!-- the theme of your GWT application by uncommenting          -->
  <!-- any one of the following lines.                            -->
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>
  <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

  <!-- Specify the paths for translatable code                    -->
  <source path='info'/>
  <source path='model'/>
  <source path='search'/>
  <source path='ui'/>
</module>

This basically means that the sub-directories named: info, model, search and ui are all be considered as source directories. This directories structures correspond more or less to the structure of every plugin. However, this is a convention and not a strict requirement.

In other words, by looking at the source directories we can understand that the hierarchy of the plugin code will look something like this:

../postit/PostIt.gwt.xml
../postit/info/..
../postit/model/..
../postit/search/..
../postit/ui/..

Note: While developing the plugin it does not matter if the directories have not been created yet. Declaring them in the descriptor and not having the real directories present does not cause any exception.

2. Plugin Creation

When developing a plugin, normally, by convention (as detailed in PostIt.gwt.xml) we create the following directories:

3. Plugin Registration

The final step consists in registering the plugin in Domeo. That is now happening in the Domeo.java main file.

 // Post It
 // Registers the plugin
 pluginsManager.registerPlugin(PostitPlugin.getInstance(), true);

 // Registers the UI annotation creation form
 annotationFormsManager.registerAnnotationForm(MPostItAnnotation.class.getName(), new PostItFormProvider(this));
 // Registers the UI tile component
 annotationTailsManager.registerAnnotationTile(MPostItAnnotation.class.getName(), new PostItTileProvider(this));
 // Registers the UI card component
 annotationCardsManager.registerAnnotationCard(MPostItAnnotation.class.getName(), new PostItCardProvider(this));
 // Registers the UI search component
 searchComponentsManager.registerAnnotationCard(MPostItAnnotation.class.getName(), new PostItSearchComponent(this));

As Domeo supports profiles (see note below), it is possible to modify the code so that the annotation creator form gets loaded only if that plugin is enabled. To do so, it is sufficient to modify the form registration line above with:

 if(_profileManager.getUserCurrentProfile().isPluginEnabled(PostitPlugin.getInstance().getPluginName())) {
      annotationFormsManager.registerAnnotationForm(MPostItAnnotation.class.getName(), new PostItFormProvider(this));
 }

The conditional statement will make sure the plugin is active for the current profile before registering the annotation creation form. All the other UI components are currently always active (don't belong to the conditional block) to make sure that when an annotation is loaded it always have a proper set of UI components that could render it.

Note: Domeo provides ways for defining profiles. Every profile details which plugins are activated or disactivated. This will be addressed elsewhere in the wiki.