/** * Returns the layer of the given annotation type. * * @param annotationType the annotation type * @return the layer */ private int getAnnotationTypeLayer(Object annotationType) { AnnotationPreference info= fAnnotationTypeKeyMap.get(annotationType); if (info != null) return info.getPresentationLayer(); return 0; }
private ListItem[] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) { ArrayList listModelItems= new ArrayList(); Iterator e= preferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { AnnotationPreference info= (AnnotationPreference) e.next(); if (isLinkedModeAnnotation(info)) { String label= info.getPreferenceLabel(); List styles= getStyles(info.getAnnotationType()); listModelItems.add(new ListItem(label, null, info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(), info.getTextStylePreferenceKey(), styles)); } } ListItem[] items= new ListItem[listModelItems.size()]; listModelItems.toArray(items); return items; }
/** * Clones the given annotation preference. * * @param annotationPreference the annotation preference to clone * @return the cloned annotation preference * @since 3.1 */ private AnnotationPreference clone(AnnotationPreference annotationPreference) { if (annotationPreference == null) return null; AnnotationPreference clone= new AnnotationPreference(); if (annotationPreference.getAnnotationType() != null) { clone.setAnnotationType(annotationPreference.getAnnotationType()); clone.merge(annotationPreference); } return clone; }
/** * Checks if <code>spec</code> has all the attributes previously required * by the marker annotation preference extension point. These are: color, text * and overview ruler preference keys. * * @param spec the <code>AnnotationPreference</code> to check * @return <code>true</code> if <code>spec</code> is complete, <code>false</code> otherwise * @since 3.0 */ private static boolean isComplete(AnnotationPreference spec) { return spec.getColorPreferenceKey() != null && spec.getColorPreferenceValue() != null && spec.getTextPreferenceKey() != null && spec.getOverviewRulerPreferenceKey() != null; }
/** * Merges the values of the given preference into this preference. Existing * values will not be overwritten. Subclasses may extend. * * @param preference the preference to merge into this preference * @since 3.0 */ public void merge(AnnotationPreference preference) { if (!getAnnotationType().equals(preference.getAnnotationType())) return; for (int i= 0; i < ATTRIBUTES.length; i++) { if (!hasValue(ATTRIBUTES[i])) setValue(ATTRIBUTES[i], preference.getValue(ATTRIBUTES[i])); } if (fAnnotationImageProvider == null) fAnnotationImageProvider= preference.fAnnotationImageProvider; if (fConfigurationElement == null) fConfigurationElement= preference.fConfigurationElement; if (fAnnotationImageProviderAttribute == null) fAnnotationImageProviderAttribute= preference.fAnnotationImageProviderAttribute; }
if (!(info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange") //$NON-NLS-1$ || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$ || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion")) //$NON-NLS-1$ )) continue; store.setToDefault(info.getTextPreferenceKey()); store.setToDefault(info.getOverviewRulerPreferenceKey()); if (info.getVerticalRulerPreferenceKey() != null) store.setToDefault(info.getVerticalRulerPreferenceKey()); store.setToDefault(info.getColorPreferenceKey()); if (info.getShowInNextPrevDropdownToolbarActionKey() != null) store.setToDefault(info.getShowInNextPrevDropdownToolbarActionKey()); if (info.getIsGoToNextNavigationTargetKey() != null) store.setToDefault(info.getIsGoToNextNavigationTargetKey()); if (info.getIsGoToPreviousNavigationTargetKey() != null) store.setToDefault(info.getIsGoToPreviousNavigationTargetKey()); if (info.getHighlightPreferenceKey() != null) store.setToDefault(info.getHighlightPreferenceKey()); if (info.getTextStylePreferenceKey() != null) store.setToDefault(info.getTextStylePreferenceKey());
AnnotationPreference info= (AnnotationPreference) e.next(); if (ignoreAnnotationsPrefPage && info.isIncludeOnPreferencePage() && isComplete(info)) continue; if (ignoreQuickDiffPrefPage && (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange") //$NON-NLS-1$ || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$ || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion")) //$NON-NLS-1$ )) continue; store.setDefault(info.getTextPreferenceKey(), info.getTextPreferenceValue()); store.setDefault(info.getOverviewRulerPreferenceKey(), info.getOverviewRulerPreferenceValue()); if (info.getVerticalRulerPreferenceKey() != null) store.setDefault(info.getVerticalRulerPreferenceKey(), info.getVerticalRulerPreferenceValue()); PreferenceConverter.setDefault(store, info.getColorPreferenceKey(), info.getColorPreferenceValue()); if (info.getShowInNextPrevDropdownToolbarActionKey() != null) store.setDefault(info.getShowInNextPrevDropdownToolbarActionKey(), info.isShowInNextPrevDropdownToolbarAction()); if (info.getIsGoToNextNavigationTargetKey() != null) store.setDefault(info.getIsGoToNextNavigationTargetKey(), info.isGoToNextNavigationTarget()); if (info.getIsGoToPreviousNavigationTargetKey() != null) store.setDefault(info.getIsGoToPreviousNavigationTargetKey(), info.isGoToPreviousNavigationTarget()); if (info.getHighlightPreferenceKey() != null) store.setDefault(info.getHighlightPreferenceKey(), info.getHighlightPreferenceValue()); if (info.getTextStylePreferenceKey() != null) store.setDefault(info.getTextStylePreferenceKey(), info.getTextStyleValue());
/** * Determines whether the preference change encoded by the given event * changes the override indication. * * @param event the event to be investigated * @return <code>true</code> if event causes a change * @since 3.0 */ protected boolean affectsOverrideIndicatorAnnotations(PropertyChangeEvent event) { String key= event.getProperty(); AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE); if (key == null || preference == null) return false; return key.equals(preference.getHighlightPreferenceKey()) || key.equals(preference.getVerticalRulerPreferenceKey()) || key.equals(preference.getOverviewRulerPreferenceKey()) || key.equals(preference.getTextPreferenceKey()); }
if (info.getColorPreferenceKey().equals(p)) { Color color= getColor(info.getColorPreferenceKey()); if (fAnnotationPainter != null) { fAnnotationPainter.setAnnotationTypeColor(info.getAnnotationType(), color); fAnnotationPainter.paint(IPainter.CONFIGURATION); setAnnotationOverviewColor(info.getAnnotationType(), color); return; if (info.getTextPreferenceKey().equals(p) || info.getTextStylePreferenceKey() != null && info.getTextStylePreferenceKey().equals(p)) { Object style= getAnnotationDecorationType(info.getAnnotationType()); if (AnnotationPreference.STYLE_NONE != style) showAnnotations(info.getAnnotationType(), false, true); else hideAnnotations(info.getAnnotationType(), false, true); return; if (info.getHighlightPreferenceKey() != null && info.getHighlightPreferenceKey().equals(p)) { if (areAnnotationsHighlighted(info.getAnnotationType())) showAnnotations(info.getAnnotationType(), true, true); else hideAnnotations(info.getAnnotationType(), true, true); return; Object style= getAnnotationDecorationType(info.getAnnotationType()); if (style != AnnotationPreference.STYLE_NONE) showAnnotations(info.getAnnotationType(), false, false); else hideAnnotations(info.getAnnotationType(), false, false);
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) { ArrayList overlayKeys= new ArrayList(); Iterator e= preferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { AnnotationPreference info= (AnnotationPreference) e.next(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey())); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey())); if (info.getHighlightPreferenceKey() != null) overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey())); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey())); if (info.getVerticalRulerPreferenceKey() != null) overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey())); if (info.getTextStylePreferenceKey() != null) overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey())); } OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; overlayKeys.toArray(keys); return keys; }
private ListItem[] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) { ArrayList<ListItem> listModelItems= new ArrayList<>(); Iterator<AnnotationPreference> e= preferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { AnnotationPreference info= e.next(); if (isLinkedModeAnnotation(info)) { String label= info.getPreferenceLabel(); List<String[]> styles= getStyles(info.getAnnotationType()); listModelItems.add(new ListItem(label, info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getHighlightPreferenceKey(), info.getTextStylePreferenceKey(), styles)); } } ListItem[] items= new ListItem[listModelItems.size()]; listModelItems.toArray(items); return items; }
private String[][] createQuickDiffModel(MarkerAnnotationPreferences preferences) { String[][] items= new String[3][]; Iterator e= preferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { AnnotationPreference info= (AnnotationPreference) e.next(); if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange")) //$NON-NLS-1$ items[0]= new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.QuickDiffConfigurationBlock_changeColor }; else if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$ items[1]= new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.QuickDiffConfigurationBlock_additionColor }; else if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion")) //$NON-NLS-1$ items[2]= new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.QuickDiffConfigurationBlock_deletionColor }; } return items; }
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) { ArrayList overlayKeys= new ArrayList(); Iterator e= preferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { AnnotationPreference info= (AnnotationPreference) e.next(); if (isLinkedModeAnnotation(info)) { overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey())); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey())); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey())); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey())); } } OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; overlayKeys.toArray(keys); return keys; }
protected boolean isShownInText(Annotation annotation) { AnnotationPreference preference= getAnnotationPreference(annotation); if (preference == null) return false; String key= preference.getTextPreferenceKey(); if (key != null) { if (!fPreferenceStore.getBoolean(key)) return false; } else { key= preference.getHighlightPreferenceKey(); if (key == null || !fPreferenceStore.getBoolean(key)) return false; } return true; }
@Override public void propertyChange(PropertyChangeEvent event) { String property= event.getProperty(); AnnotationPreference annotationPreference= getVerticalRulerAnnotationPreference(property); if (annotationPreference != null && property.equals(annotationPreference.getVerticalRulerPreferenceKey())) { Object type= annotationPreference.getAnnotationType(); if (getPreferenceStore().getBoolean(property)) column.addAnnotationType(type); else column.removeAnnotationType(type); column.redraw(); } } };
/** * Sets the preference info for the annotation painter. * @param info the preference info to be set */ public void setAnnotationPreference(AnnotationPreference info) { fAnnotationTypeKeyMap.put(info.getAnnotationType(), info); }
/** * Tells whether annotation overview is enabled for the given type. * * @param annotationType the annotation type * @return <code>true</code> if the annotation overview is shown */ private boolean isAnnotationOverviewShown(Object annotationType) { if (fPreferenceStore != null && fOverviewRuler != null) { AnnotationPreference info= fAnnotationTypeKeyMap.get(annotationType); if (info != null) return fPreferenceStore.getBoolean(info.getOverviewRulerPreferenceKey()); } return false; }
/** * Returns the image descriptor for the image to be drawn in the vertical ruler. The provided * image is only used, if <code>getAnnotationImageProvider</code> returns <code>null</code>. * * @return the image descriptor or <code>null</code> * @since 3.0 */ public ImageDescriptor getImageDescriptor() { return (ImageDescriptor) getValue(IMAGE_DESCRIPTOR); }
/** * Returns the annotation preference for which the given * preference matches a vertical ruler preference key. * * @param preferenceKey the preference key string * @return the annotation preference or <code>null</code> if none */ private AnnotationPreference getVerticalRulerAnnotationPreference(String preferenceKey) { if (preferenceKey == null) return null; Iterator<AnnotationPreference> e= fAnnotationPreferences.getAnnotationPreferences().iterator(); while (e.hasNext()) { AnnotationPreference info= e.next(); if (info != null && preferenceKey.equals(info.getVerticalRulerPreferenceKey())) return info; } return null; }
/** * Tells whether annotations are highlighted in the source viewer for the given type. * * @param annotationType the annotation type * @return <code>true</code> if the annotations are highlighted * @since 3.0 */ private boolean areAnnotationsHighlighted(Object annotationType) { if (fPreferenceStore != null) { AnnotationPreference info= fAnnotationTypeKeyMap.get(annotationType); if (info != null) return info.getHighlightPreferenceKey() != null && fPreferenceStore.getBoolean(info.getHighlightPreferenceKey()); } return false; }