65 | | The above code is from MassSpecMultiPageViewer class. This multi-page editor needs to update its table's column visibility whenever MassSpecViewerPreference gets updated. |
| 65 | 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. |
| 66 | |
| 67 | Similarly, MSAnnotationMultiPageViewer (entry.ms.annotation plugin) needs to listen to the changes in MSAnnotationViewerPreference as shown below: |
| 68 | |
| 69 | {{{ |
| 70 | @Optional @Inject |
| 71 | public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED) |
| 72 | String preferenceName) |
| 73 | { |
| 74 | if(preferenceName != null && preferenceName.startsWith(MSAnnotationViewerPreference.class.getName())) { |
| 75 | PreferenceEntity preferenceEntity; |
| 76 | try { |
| 77 | preferenceEntity = gritsPreferenceStore.getPreferenceEntity(preferenceName); |
| 78 | |
| 79 | MSAnnotationViewerPreference updatePref = (MSAnnotationViewerPreference) TableViewerPreference.getTableViewerPreference(preferenceEntity, MSAnnotationViewerPreference.class); |
| 80 | this.updateColumnVisibility(updatePref); |
| 81 | } catch (UnsupportedVersionException e) { |
| 82 | logger.error("Error updating column visibility", e); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | }}} |
| 87 | |
| 88 | |
| 89 | MSGlycanAnnotationMultiPageViewer (entry.ms.annotation.glycan) needs to listen to the changes for two types (MSGlycanAnnotationViewerPreference and MSGlycanAnnotationSummaryViewerPreference) of preferences. |
| 90 | |
| 91 | {{{ |
| 92 | @Optional @Inject |
| 93 | public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED) |
| 94 | String preferenceName) |
| 95 | { |
| 96 | if(preferenceName != null && preferenceName.startsWith(MSGlycanAnnotationViewerPreference.class.getName())) { |
| 97 | PreferenceEntity preferenceEntity; |
| 98 | try { |
| 99 | preferenceEntity = gritsPreferenceStore.getPreferenceEntity(preferenceName); |
| 100 | |
| 101 | MSGlycanAnnotationViewerPreference updatePref = (MSGlycanAnnotationViewerPreference) TableViewerPreference.getTableViewerPreference(preferenceEntity, MSGlycanAnnotationViewerPreference.class); |
| 102 | this.updateColumnVisibility(updatePref); |
| 103 | } catch (UnsupportedVersionException e) { |
| 104 | logger.error("Error updating column visibility", e); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | if(preferenceName != null && preferenceName.startsWith(MSGlycanAnnotationSummaryViewerPreference.class.getName())) { |
| 109 | PreferenceEntity preferenceEntity; |
| 110 | try { |
| 111 | preferenceEntity = gritsPreferenceStore.getPreferenceEntity(preferenceName); |
| 112 | |
| 113 | MSGlycanAnnotationSummaryViewerPreference updatePref = (MSGlycanAnnotationSummaryViewerPreference) TableViewerPreference.getTableViewerPreference(preferenceEntity, MSGlycanAnnotationSummaryViewerPreference.class); |
| 114 | this.updateColumnVisibility(updatePref); |
| 115 | } catch (UnsupportedVersionException e) { |
| 116 | logger.error("Error updating column visibility", e); |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | }}} |
| 121 | |
| 122 | The tables in this multi-page editor also need to be updated with cartoon options changes (MSGlycanAnnotationCartoonPreferences). |
| 123 | |
| 124 | This is handled in MSGlycanAnnotationPeakView as shown below: |
| 125 | |
| 126 | {{{ |
| 127 | /** |
| 128 | * This method is called whenever a preference change occurs |
| 129 | * We need to act upon cartoon preference changes for this view |
| 130 | * |
| 131 | * @param preferenceName |
| 132 | */ |
| 133 | @Optional @Inject |
| 134 | public void updatePreferences(@UIEventTopic(IGritsPreferenceStore.EVENT_TOPIC_PREF_VALUE_CHANGED) |
| 135 | String preferenceName) |
| 136 | { |
| 137 | if (MSGlycanAnnotationCartoonPreferences.getPreferenceID().equals(preferenceName)) { |
| 138 | try { |
| 139 | MSGlycanAnnotationSelectionView sv = (MSGlycanAnnotationSelectionView) this.getCurrentSelectionView(); |
| 140 | if( sv != null && sv.getSubTable() != null ) { |
| 141 | ((MSGlycanAnnotationTable) sv.getSubTable()).refreshTableImages(); |
| 142 | } |
| 143 | } catch( Exception e ) { |
| 144 | logger.error("Could not refresh subtable images", e); |
| 145 | } |
| 146 | |
| 147 | try { |
| 148 | MassSpecTableBase viewBase = (MassSpecTableBase) ( (IMSPeaksViewer) this ).getViewBase(); |
| 149 | ((MSGlycanAnnotationTable) viewBase.getNatTable()).refreshTableImages(); |
| 150 | } catch( Exception e ) { |
| 151 | logger.error("Could not refresh table images", e); |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | }}} |
| 156 | |
| 157 | |
| 158 | |