wiki:Migration_of_MSPlugins

Version 13 (modified by sena, 4 years ago) (diff)

--

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
  • org.grits.toolbox.entry.ms.annotation - see this page for general migration changes for this plugin
  • org.grits.toolbox.entry.ms.annotation.glycan - see this page for general migration changes for this plugin
  • org.grits.toolbox.entry.ms.annotation.glycan.report - see this? page for general migration changes for this plugin

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.

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);
			}
		}
	}

        ...
}