wiki:Entry_MS_Annotation_Migration

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

--

Propagation of checkbox changes

public class MSAnnotationTable extends MassSpecTable {

       ...

       public void finishUpdateHiddenRowsAfterEdit( boolean isDirty ) {
		updateRowVisibilityAfterRead(this.dataLayer, null);
		updateEventListForVisibility();
		reSort();
		if( parentView != null ) {
			IEclipseContext context = parentView.getParentEditor().getContext();
			IEventBroker eventBroker = context.get(IEventBroker.class);
			eventBroker.post (MSAnnotationMultiPageViewer.EVENT_PARENT_ENTRY_VALUE_MODIFIED, parentView.getEntry());
		}

		if( getCurrentRowIndex() != null ) {
			moveRowIntoViewport(getNatIndexFromSourceIndex(getCurrentRowIndex()+1));
		}
		if ( isDirty && ! parentView.isDirty() ) {
			parentView.setDirty(true);
		}		
	}

    ...

}

Before E4 migration, the above code was making a call to a static method in the multi-page viewer to find the parent viewer and make appropriate changes. We now post an event and the related pages (MSAnnotationDetails and MSAnnotationSpectraView in this case) subscribe to that event. An example (from MSAnnotationSpectraView) is shown below:

        @Optional
	@Inject
	void refreshCheckboxes(
			@UIEventTopic(MassSpecMultiPageViewer.EVENT_PARENT_ENTRY_VALUE_MODIFIED) Entry parentEntry) {
		if( getEntry().getParent() != null && 
			getEntry().getParent().equals(parentEntry) ) {
			MSAnnotationSpectraControlPanelView cp = (MSAnnotationSpectraControlPanelView) getControlPanel();
			cp.updateView();
		}
	}