wiki:Migration_of_MSPlugins

General migration notes

Here is the check-list of items for migrating the plugins to E4:

  • no plugin should contain a dependency to org.eclipse.ui package: removal of this dependency sometimes requires the addition of org.eclipse.jface dependency
  • all editors/views/commands (part of GUI - originally in plugin.xml) should become a POJO
  • Activators that extend AbstractUIPlugin (which is part of eclipse.ui) should be converted to implement BundleActivator instead
  • All gui related items should be defined in fragment.4xmi instead of plugin.xml, propertyreader extension should still be in plugin.xml
  • Since only the parts/objects that are created through the context can use injected variables/objects/services, these classes should be defined in fragment.4xmi or created by ContextInjectionFactory.make(...) in any part of the code. "AddOn" can be used to inject utility classes (which require access to injected variables like workspace_location for example) into the context at startup

List of MS plugins migrated

  • org.grits.toolbox.display.control.table - removed reference to PartInitException and changed the Activator (do not extend AbstractUIPlugin)
  • org.grits.toolbox.display.control.spectrum - changed the Activator (do not extend AbstractUIPlugin)
  • org.grits.toolbox.datamodel.ms - no changes
  • org.grits.toolbox.datamodel.ms.annotation - no changes
  • org.grits.toolbox.datamodel.ms.annotation.glycan - no changes
  • org.grits.toolbox.datamodel.ms.annotation.glycan.report - no changes
  • org.grits.toolbox.importer.ms - migrated commands/handlers to E4 (moved from plugin.xml -> fragment.4xmi)
    • an essential step: before you open the part for the newly created entry, the selection needs to be set to the newly created entry
          // post may not work because of synchronization 
          // the selection needs to change before we try to open the part!
          eventBroker.send(IGritsDataModelService.EVENT_SELECT_ENTRY, newMSEntry);
          gritsUIService.openEntryInPart(newMSEntry);
      
  • org.grits.toolbox.importer.ms.annotation.glycan.simiansearch - migrated commands/handlers to E4 (moved from plugin.xml -> fragment.4xmi)
  • org.grits.toolbox.io.ms.annotation - changed the Activator (do not extend AbstractUIPlugin)
  • org.grits.toolbox.io.ms.annotation.glycan - no changes
  • org.grits.toolbox.io.ms.annotation.glycan.report - no changes
  • org.grits.toolbox.widgets - moved editor package to core plugin and migrated the editor implementation to E4
  • org.grits.toolbox.entry.ms - see this page for general migration changes for this plugin. Since this plugin's classes are extended by the other plugins (namely, entry.ms.annotation, entry.ms.annotation.glycan and entry.ms.annotation.glycan.report), the changes explained for this plugin are not repeated again for the aforementioned plugins.
  • org.grits.toolbox.entry.ms.annotation - see this page for the migration notes for this plugin
  • org.grits.toolbox.entry.ms.annotation.glycan - see this page for the migration notes for this plugin
  • org.grits.toolbox.entry.ms.annotation.glycan.report - migrated the multi-page viewer and the pages (tabs), migrated command/handlers

Preference Handling

There are several preferences used in MS plugins. One important distinction is that some require changes to be propagated to the active viewers/table and the others are only retrieved when creating new experiment entries.

Table Header/Cartoon option related preferences

Whenever these preferences change, any open viewer needs to reflect the changes in their tables.

  • MassSpecViewerPreference
  • MSAnnotationViewerPreference
  • MSGlycanAnnotationViewerPreference
  • MSGlycanAnnotationSummaryViewerPreference
  • MSGlycanAnnotationCartoonPreferences
  • MSGlycanAnnotationReportViewerPreference

In order to reflect preference changes, the parts (multi-page editors or specific pages (tabs) within the editor) needs to subscribe to the changes on the specific preference that they are interested in.

An example subscription code is shown below:

        @Optional @Inject
	public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED)
	 					String preferenceName)
	{
		if(MassSpecViewerPreference.getPreferenceID().equals(preferenceName)) {
	 		PreferenceEntity preferenceEntity;
			try {
				preferenceEntity = gritsPreferenceStore.getPreferenceEntity(preferenceName);
			
				MassSpecViewerPreference updatePref = (MassSpecViewerPreference) 
                                              TableViewerPreference.getTableViewerPreference(preferenceEntity, MassSpecViewerPreference.class);
				this.updateColumnVisibility(updatePref);
			} catch (UnsupportedVersionException e) {
				logger.error("Error updating column visibility", e);
			}
		}
	}

The above code is from MassSpecMultiPageViewer class (entry.ms plugin). This multi-page editor needs to update its table's column visibility whenever MassSpecViewerPreference gets updated.

Similarly, MSAnnotationMultiPageViewer (entry.ms.annotation plugin) needs to listen to the changes in MSAnnotationViewerPreference as shown below:

        @Optional @Inject
	public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED)
	 					String preferenceName)
	{
		if(preferenceName != null && preferenceName.startsWith(MSAnnotationViewerPreference.class.getName())) {
	 		PreferenceEntity preferenceEntity;
			try {
				preferenceEntity = gritsPreferenceStore.getPreferenceEntity(preferenceName);
			
				MSAnnotationViewerPreference updatePref = (MSAnnotationViewerPreference) TableViewerPreference.getTableViewerPreference(preferenceEntity, 
                                               MSAnnotationViewerPreference.class);
				this.updateColumnVisibility(updatePref);
			} catch (UnsupportedVersionException e) {
				logger.error("Error updating column visibility", e);
			}
		}
	}

MSGlycanAnnotationMultiPageViewer (entry.ms.annotation.glycan) needs to listen to the changes for two types (MSGlycanAnnotationViewerPreference and MSGlycanAnnotationSummaryViewerPreference) of preferences.

        @Optional @Inject
	public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED)
	 					String preferenceName)
	{
		if(preferenceName != null && preferenceName.startsWith(MSGlycanAnnotationViewerPreference.class.getName())) {
	 		PreferenceEntity preferenceEntity;
			try {
				preferenceEntity = gritsPreferenceStore.getPreferenceEntity(preferenceName);
			
				MSGlycanAnnotationViewerPreference updatePref = (MSGlycanAnnotationViewerPreference) TableViewerPreference.getTableViewerPreference(preferenceEntity, 
                                          MSGlycanAnnotationViewerPreference.class);
				this.updateColumnVisibility(updatePref);
			} catch (UnsupportedVersionException e) {
				logger.error("Error updating column visibility", e);
			}
		}
		
		if(preferenceName != null && preferenceName.startsWith(MSGlycanAnnotationSummaryViewerPreference.class.getName())) {
	 		PreferenceEntity preferenceEntity;
			try {
				preferenceEntity = gritsPreferenceStore.getPreferenceEntity(preferenceName);
			
				MSGlycanAnnotationSummaryViewerPreference updatePref = (MSGlycanAnnotationSummaryViewerPreference) 
                                               TableViewerPreference.getTableViewerPreference(preferenceEntity, MSGlycanAnnotationSummaryViewerPreference.class);
				this.updateColumnVisibility(updatePref);
			} catch (UnsupportedVersionException e) {
				logger.error("Error updating column visibility", e);
			}
		}
	}

The tables in this multi-page editor (MSGlycanAnnotationMultiPageViewer) also need to be updated with cartoon options changes (MSGlycanAnnotationCartoonPreferences).

This is handled in MSGlycanAnnotationPeakView as shown below:

        /**
	 * This method is called whenever a preference change occurs
	 * We need to act upon cartoon preference changes for this view 
	 * 
	 * @param preferenceName
	 */
	@Optional @Inject
	public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED)
	 					String preferenceName)
	{
	 	if (MSGlycanAnnotationCartoonPreferences.getPreferenceID().equals(preferenceName)) {
	 		try {
				MSGlycanAnnotationSelectionView sv = (MSGlycanAnnotationSelectionView) this.getCurrentSelectionView();
				if( sv != null && sv.getSubTable() != null ) {
					((MSGlycanAnnotationTable) sv.getSubTable()).refreshTableImages();
				}
			} catch( Exception e ) {
				logger.error("Could not refresh subtable images", e);
			}
	 		
	 		try {
				MassSpecTableBase viewBase = (MassSpecTableBase) ( (IMSPeaksViewer) this ).getViewBase();
				((MSGlycanAnnotationTable) viewBase.getNatTable()).refreshTableImages();
			} catch( Exception e ) {
				logger.error("Could not refresh table images", e);
			}
	 	}
	}

Similarly, MSGlycanAnnotationDetails view should also act upon cartoon preference changes.

        /**
	 * This method is called whenever a preference change occurs
	 * We need to act upon cartoon preference changes for this view 
	 * 
	 * @param preferenceName
	 */
	@Optional @Inject
	public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED)
	 					String preferenceName)
	{
	 	if (MSGlycanAnnotationCartoonPreferences.getPreferenceID().equals(preferenceName)) {
			if( this.getPeaksViews() != null ) {
				MSGlycanAnnotationEntityScroller entityScroller = (MSGlycanAnnotationEntityScroller) this.getEntityScroller();
				entityScroller.refreshImages();
			}
	 	}
	}

Finally, MSGlycanAnnotationReportMultiPageViewer listens to the changes to MSGlycanAnnotationReportViewerPreference. One of the pages in the multi-page viewer, MSGlycanAnnotationReportResultsView should listen to the cartoon preference changes.

public class MSGlycanAnnotationReportMultiPageViewer extends CancelableMultiPageEditor {
	
        ...

        @Optional @Inject
	public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED)
	 					String preferenceName)
	{
		if(preferenceName != null && preferenceName.startsWith(MSGlycanAnnotationReportViewerPreference.class.getName())) {
	 		PreferenceEntity preferenceEntity;
			try {
				preferenceEntity = gritsPreferenceStore.getPreferenceEntity(preferenceName);
			
				MSGlycanAnnotationReportViewerPreference updatePref = (MSGlycanAnnotationReportViewerPreference) 
                                         TableViewerPreference.getTableViewerPreference(preferenceEntity, MSGlycanAnnotationReportViewerPreference.class);
				this.updateColumnVisibility(updatePref);
			} catch (UnsupportedVersionException e) {
				logger.error("Error updating column visibility", e);
			}
		}
	}

        ...
}

MSGlycanAnnotationReportResultsView's preference update (in reaction to cartoon options change) is shown below:

        /**
	 * This method is called whenever a preference change occurs
	 * We need to act upon cartoon preference changes for this view 
	 * 
	 * @param preferenceName
	 */
	@Optional @Inject
	public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED)
	 					String preferenceName)
	{
	 	if (MSGlycanAnnotationCartoonPreferences.getPreferenceID().equals(preferenceName)) {
	 		try {
				MassSpecTableBase viewBase = (MassSpecTableBase) ( (IMSPeaksViewer) this ).getViewBase();
				((MSGlycanAnnotationReportTable) viewBase.getNatTable()).refreshTableImages();
			} catch( Exception e ) {
				logger.error("Could not refresh table images", e);
			}
	 	}
	}
Last modified 5 years ago Last modified on 11/14/2016 07:53:20 PM