Changes between Version 3 and Version 4 of Entry_MS_Migration


Ignore:
Timestamp:
11/10/2016 10:20:47 PM (4 years ago)
Author:
sena
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Entry_MS_Migration

    v3 v4  
    4040       }
    4141}}}
     42
     43== Updating the pages ===
     44One important aspect of the multi-page editor is to react to the changes in any of the pages (tabs) so that the editor gets marked dirty. In order to handle this behavior, the MassSpecMultiPageViewer needs to subscribe to the changes in the tabs. This is done by publishing EntryEditorPart.EVENT_TOPIC_CONTENT_MODIFIED event every time a page gets dirty as shown below:
     45
     46{{{
     47public abstract class EntryEditorPart implements IEntryEditorPart {
     48       
     49        public static final String EVENT_TOPIC_CONTENT_MODIFIED = "content_modified_in_a_tab";
     50       
     51        protected Entry entry = null;
     52        protected Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
     53        protected String errMsg = null;
     54       
     55        boolean dirty = false;
     56        @Inject protected IEclipseContext context;
     57        @Inject IEventBroker eventBroker;
     58       
     59        public IEclipseContext getContext() {
     60                return context;
     61        }
     62       
     63        @Override
     64        public Entry getEntry() {
     65                return entry;
     66        }
     67
     68        @Override
     69        public void setEntry(Entry entry) {
     70                this.entry = entry;
     71        }
     72       
     73        @Override
     74        public void setDirty(boolean d) {
     75                this.dirty = d;
     76                eventBroker.post(EVENT_TOPIC_CONTENT_MODIFIED, this);
     77        }
     78...
     79}}}
     80
     81The multi-page editor then listens to this event.
     82
     83{{{
     84public class MassSpecMultiPageViewer extends CancelableMultiPageEditor implements IPropertyChangeListener {
     85
     86     ...
     87
     88        /**
     89         * this method is called whenever a page (tab) is updated
     90         * However we have to check to make sure the modified page is one of the pages of this
     91         * multi-page editor
     92         * 
     93         * @param the part that gets dirty
     94         */
     95        @Optional @Inject
     96        public void tabContentModified (@UIEventTopic
     97                        (EntryEditorPart.EVENT_TOPIC_CONTENT_MODIFIED) IEntryEditorPart part) {
     98                if (part.equals(propertyView) || part.equals(scansView) || this.alPeaksViews.contains(part))
     99                        setDirty(part.isDirty());
     100        }
     101    ...
     102}
     103}}}