wiki:Entry_MS_Migration

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

--

Migrating the multi-page viewer

Each of the MS plugins have a multi-page viewer that extends from CancelableMultiPageEditor (core plugin). For this specific plugin the class is MassSpecMultiPageViewer. One of the major changes for this editor and all the pages (tabs) of the editor is the removal of the reference to ViewInput (core plugin - uses IEditorInput).

Multi-page editor requires a CTabFolder to hold the pages and each page needs to be added as a CTabItem to this folder. CancelableMultiPageEditor handles the interactions such as adding pages so MassSpecMultiPageViewer does not need to change much to handle the addition of pages (tabs). One major change is that all the pages need to be created with ContextInjectionFactory.make(...) method to be able access injected objects later. The following code shows the required changes:

        protected MassSpecScansView getNewScansView( Entry entry, MassSpecEntityProperty entityProperty) {
		MassSpecEntityProperty msProp = (MassSpecEntityProperty) entityProperty.clone();
		msProp.setParentScanNum( entityProperty.getScanNum() );
		msProp.setScanNum(null);
		getPart().getContext().set(MIN_MS_LEVEL_CONTEXT, getMinMSLevel());
		getPart().getContext().set(Property.class, msProp);
		getPart().getContext().set(Entry.class, entry);
		MassSpecScansView view = ContextInjectionFactory.make(MassSpecScansView.class, getPart().getContext());
		
		return view;
	}

Previously, MSAnnotationScansView object was being created by calling its constructor directly (see below). However, now all the necessary objects for the MassSpecScanView need to be set into the context before initializing it through ContextInjectionFactory.

       protected MassSpecScansView getNewScansView( Entry entry, MassSpecEntityProperty entityProperty) {
		MassSpecEntityProperty msProp = (MassSpecEntityProperty) entityProperty.clone();
		msProp.setParentScanNum( entityProperty.getScanNum() );
		msProp.setScanNum(null);
                return new MassSpecScansView(this.getContainer(), entry, msProp, getMinMSLevel());
       }