Java 类org.eclipse.ui.texteditor.MarkerAnnotationPreferences 实例源码

项目:PDFReporter-Studio    文件:StyledTextXtextAdapter.java   
/**
 * Creates decoration support for the sourceViewer. code is entirely copied
 * from {@link XtextEditor} and its super class
 * {@link AbstractDecoratedTextEditor}.
 * 
 */
protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
    MarkerAnnotationPreferences annotationPreferences = new MarkerAnnotationPreferences();
    @SuppressWarnings("unchecked")
    List<AnnotationPreference> prefs = annotationPreferences.getAnnotationPreferences();
    for (AnnotationPreference annotationPreference : prefs) {
        support.setAnnotationPreference(annotationPreference);
    }

    support.setCharacterPairMatcher(characterPairMatcher);
    support.setMatchingCharacterPainterPreferenceKeys(BracketMatchingPreferencesInitializer.IS_ACTIVE_KEY,
            BracketMatchingPreferencesInitializer.COLOR_KEY);

    support.install(preferenceStoreAccess.getPreferenceStore());

}
项目:mesfavoris    文件:SpellcheckableMessageArea.java   
private SourceViewerDecorationSupport configureAnnotationPreferences() {
    ISharedTextColors textColors = EditorsUI.getSharedTextColors();
    IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
    final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(
            sourceViewer, null, annotationAccess, textColors);

    List annotationPreferences = new MarkerAnnotationPreferences()
    .getAnnotationPreferences();
    Iterator e = annotationPreferences.iterator();
    while (e.hasNext())
        support.setAnnotationPreference((AnnotationPreference) e.next());

    support.install(EditorsUI.getPreferenceStore());
    return support;
}
项目:statecharts    文件:StyledTextXtextAdapter.java   
/**
 * Creates decoration support for the sourceViewer. code is entirely copied from
 * {@link XtextEditor} and its super class {@link AbstractDecoratedTextEditor}.
 * 
 */
protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
    MarkerAnnotationPreferences annotationPreferences = new MarkerAnnotationPreferences();
    List<AnnotationPreference> prefs = annotationPreferences.getAnnotationPreferences();
    for (AnnotationPreference annotationPreference : prefs) {
        support.setAnnotationPreference(annotationPreference);
    }

    support.setCharacterPairMatcher(getCharacterPairMatcher());
    support.setMatchingCharacterPainterPreferenceKeys(BracketMatchingPreferencesInitializer.IS_ACTIVE_KEY,
            BracketMatchingPreferencesInitializer.COLOR_KEY);

    support.install(getPreferenceStoreAccess().getPreferenceStore());
}
项目:APICloud-Studio    文件:ThemeManager.java   
private void setAnnotationColorsToMatchTheme(Theme theme)
{
    IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode("org.eclipse.ui.editors"); //$NON-NLS-1$
    if (!theme.hasEntry("override.searchResultIndication")) //$NON-NLS-1$
    {
        prefs.put("searchResultIndicationColor", toString(theme.getSearchResultColor())); //$NON-NLS-1$
    }
    // TODO Use markup.changed bg color for "decoration color" in Prefs>General>Appearance>Colors and Fonts

    // TODO Move this stuff over to theme change listeners in the XML/HTML/Ruby editor plugins?
    if (!theme.hasEntry("override.xmlTagPairOccurrenceIndication")) //$NON-NLS-1$
    {
        prefs.putBoolean("xmlTagPairOccurrenceIndicationHighlighting", false); //$NON-NLS-1$
        prefs.putBoolean("xmlTagPairOccurrenceIndication", true); //$NON-NLS-1$
        prefs.put("xmlTagPairOccurrenceIndicationColor", toString(theme.getOccurenceHighlightColor())); //$NON-NLS-1$
        prefs.put("xmlTagPairOccurrenceIndicationTextStyle", AnnotationPreference.STYLE_BOX); //$NON-NLS-1$
    }
    if (!theme.hasEntry("override.htmlTagPairOccurrenceIndication")) //$NON-NLS-1$
    {
        prefs.putBoolean("htmlTagPairOccurrenceIndicationHighlighting", false); //$NON-NLS-1$
        prefs.putBoolean("htmlTagPairOccurrenceIndication", true); //$NON-NLS-1$
        prefs.put("htmlTagPairOccurrenceIndicationColor", toString(theme.getOccurenceHighlightColor())); //$NON-NLS-1$
        prefs.put("htmlTagPairOccurrenceIndicationTextStyle", AnnotationPreference.STYLE_BOX); //$NON-NLS-1$
    }
    if (!theme.hasEntry("override.rubyBlockPairOccurrenceIndication")) //$NON-NLS-1$
    {
        prefs.putBoolean("rubyBlockPairOccurrenceIndicationHighlighting", false); //$NON-NLS-1$
        prefs.putBoolean("rubyBlockPairOccurrenceIndication", true); //$NON-NLS-1$
        prefs.put("rubyBlockPairOccurrenceIndicationColor", toString(theme.getOccurenceHighlightColor())); //$NON-NLS-1$
        prefs.put("rubyBlockPairOccurrenceIndicationTextStyle", AnnotationPreference.STYLE_BOX); //$NON-NLS-1$
    }
    // PyDev Occurrences (com.python.pydev.occurrences)
    // Override them if pydev is set to use our themes
    if (Platform.getPreferencesService().getBoolean("org.python.pydev.red_core", "PYDEV_USE_APTANA_THEMES", true, //$NON-NLS-1$ //$NON-NLS-2$
            null))
    {
        if (!theme.hasEntry("override.pydevOccurrenceIndication")) //$NON-NLS-1$
        {
            MarkerAnnotationPreferences preferences = new MarkerAnnotationPreferences();
            AnnotationPreference pydevOccurPref = null;
            for (Object obj : preferences.getAnnotationPreferences())
            {
                AnnotationPreference pref = (AnnotationPreference) obj;
                Object type = pref.getAnnotationType();
                if ("com.python.pydev.occurrences".equals(type)) //$NON-NLS-1$
                {
                    pydevOccurPref = pref;
                }
            }
            if (pydevOccurPref != null)
            {
                if (pydevOccurPref.getTextStylePreferenceKey() != null)
                {
                    // Now that pydev supports text style, use the box style and don't highlight.
                    prefs.putBoolean("pydevOccurrenceHighlighting", false); //$NON-NLS-1$
                    prefs.putBoolean("pydevOccurrenceIndication", true); //$NON-NLS-1$
                    prefs.put("pydevOccurrenceIndicationColor", toString(theme.getOccurenceHighlightColor())); //$NON-NLS-1$
                    prefs.put("pydevOccurrenceIndicationTextStyle", AnnotationPreference.STYLE_BOX); //$NON-NLS-1$
                }
                else
                {
                    // Must use highlighting, since we're against older pydev that had no text style
                    prefs.putBoolean("pydevOccurrenceHighlighting", true); //$NON-NLS-1$
                    prefs.putBoolean("pydevOccurrenceIndication", true); //$NON-NLS-1$
                    prefs.put("pydevOccurrenceIndicationColor", toString(theme.getSearchResultColor())); //$NON-NLS-1$
                }
            }
        }
    }

    try
    {
        prefs.flush();
    }
    catch (BackingStoreException e)
    {
        IdeLog.logError(ThemePlugin.getDefault(), e);
    }
}
项目:SPLevo    文件:UnifiedDiffHighlighter.java   
/**
 * Highlights the differences within the unified difference editor.
 * 
 * @return the color to unified lines mapping.
 */
@SuppressWarnings({ "unchecked" })
public Map<Integer, Color> highlightLines() {
    // initialize local variables
    UnifiedDiffConnectorModel diffModel = editorInput.getDiffConnectorModel();
    Map<Integer, Color> colorToUnifiedLinesMapping = new HashMap<Integer, Color>();
    MarkerAnnotationPreferences maPrefs = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
    List<AnnotationPreference> aPrefs = (List<AnnotationPreference>) (List<?>) maPrefs.getAnnotationPreferences();
    IFile ressource = (IFile) editorInput.getAdapter(IFile.class);

    // add new markers from connector content
    int offset = 0;
    int lineCount = editor.getViewer().getTextWidget().getLineCount();
    int lineTextLength = 0;
    String lineText = "";
    for (int line = 0; line < lineCount - 1; line++) {
        lineText = editor.getViewer().getTextWidget().getLine(line);
        lineTextLength = lineText.length();

        // create marker according to type
        MarkerType markerType = diffModel.getMarkerTypeFor(line);
        if (markerType != MarkerType.NONE) {
            try {
                IMarker marker = ressource.createMarker(UIConstants.UNIFIED_DIFF_MARKERTYPE);
                TextSelection selection = new TextSelection(offset, lineTextLength);
                createAnnotation(marker, selection, this.editor, markerType);

            } catch (CoreException exception) {
                LOGGER.error("An error occurred while creating a marker or setting an attribute for said marker!",
                        exception);
            }

            // get and add color to mapping
            IGetMarkerColor getMarkerColor = markerTypeToGetMarkerColor.get(markerType);
            colorToUnifiedLinesMapping.put(line, getMarkerColor.get(aPrefs)); 
        }

        offset += lineTextLength + 1;
    }

    return colorToUnifiedLinesMapping;
}