| 26 | |
| 27 | == Preference Handling == |
| 28 | |
| 29 | 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. |
| 30 | |
| 31 | === Table Header/Cartoon option related preferences === |
| 32 | Whenever these preferences change, any open viewer needs to reflect the changes in their tables. |
| 33 | |
| 34 | - MassSpecViewerPreference |
| 35 | - MSAnnotationViewerPreference |
| 36 | - MSGlycanAnnotationViewerPreference |
| 37 | - MSGlycanAnnotationSummaryViewerPreference |
| 38 | - MSGlycanAnnotationCartoonPreferences |
| 39 | - MSGlycanAnnotationReportViewerPreference |
| 40 | |
| 41 | In order to reflect preference changes, the parts (multi-page editors or specific pages (tabs) within the editor) |
| 42 | needs to subscribe to the changes on the specific preference that they are interested in. |
| 43 | |
| 44 | An example subscription code is shown below: |
| 45 | |
| 46 | {{{ |
| 47 | @Optional @Inject |
| 48 | public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED) |
| 49 | String preferenceName) |
| 50 | { |
| 51 | if(MassSpecViewerPreference.getPreferenceID().equals(preferenceName)) { |
| 52 | PreferenceEntity preferenceEntity; |
| 53 | try { |
| 54 | preferenceEntity = gritsPreferenceStore.getPreferenceEntity(preferenceName); |
| 55 | |
| 56 | MassSpecViewerPreference updatePref = (MassSpecViewerPreference) TableViewerPreference.getTableViewerPreference(preferenceEntity, MassSpecViewerPreference.class); |
| 57 | this.updateColumnVisibility(updatePref); |
| 58 | } catch (UnsupportedVersionException e) { |
| 59 | logger.error("Error updating column visibility", e); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | }}} |
| 64 | |
| 65 | The above code is from MassSpecMultiPageViewer class. This multi-page editor needs to update its table's column visibility whenever MassSpecViewerPreference gets updated. |