Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-text-dev] Annotations

Thank you very much! This looks like it will help me along. Where can I get the full source code for the newly modified Java editor example? I have my own source viewer and that might be contributing to the problem.

Thanks again,
Mary Kroening
Amzi! inc.

At 11:13 AM 3/25/2003 +0100, you wrote:

I changed the actual version of the Java editor example to work with a custom preference store:

        /* (non-Javadoc)
         * Method declared on AbstractTextEditor
         */
        protected void initializeEditor() {
                // super.initializeEditor();
                setPreferenceStore(createPreferenceStore());
               
                JavaEditorEnvironment.connect(this);
                setSourceViewerConfiguration(new JavaSourceViewerConfiguration());
                setEditorContextMenuId("#JavaEditorContext"); //$NON-NLS-1$
                setRulerContextMenuId("#JavaRulerContext"); //$NON-NLS-1$
        }

        private IPreferenceStore createPreferenceStore() {
                IPreferenceStore store= new PreferenceStore();
                initializeAppearance(store);
                initializeAnnotations(store);
                return store;
        }

        private void initializeAppearance(IPreferenceStore store) {
                store.setDefault(TextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true);
                PreferenceConverter.setDefault(store, TextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR, new RGB(225, 235, 224));
               
                store.setDefault(TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, true);
                store.setDefault(TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80);
                PreferenceConverter.setDefault(store, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, new RGB(176, 180 , 185));
               
                store.setDefault(TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, true);
                PreferenceConverter.setDefault(store, TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, new RGB(128, 128, 128));
               
                store.setDefault(TextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, true);
               
                store.setDefault(TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION, false);
                store.setDefault(TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER, false);
                PreferenceConverter.setDefault(store, TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, new RGB(0, 0, 0));
        }
       
        private void initializeAnnotations(IPreferenceStore store) {
                MarkerAnnotationPreferences preferences= new MarkerAnnotationPreferences();
                Iterator e= preferences.getAnnotationPreferences().iterator();
                while (e.hasNext()) {
                        AnnotationPreference info= (AnnotationPreference) e.next();
                        store.setDefault(info.getTextPreferenceKey(), info.getTextPreferenceValue());
                        store.setDefault(info.getOverviewRulerPreferenceKey(), info.getOverviewRulerPreferenceValue());
                        PreferenceConverter.setDefault(store, info.getColorPreferenceKey(), info.getColorPreferenceValue());
                }
        }

Rather than inheriting the preference store from the TextEditor, the Java example editor creates and initializes its own store. The method initializeEditor differs in the first two lines from the original.

This example uses MarkerAnnotationPreferences. This way all configuration data (annotation types, their preference keys and their preference default values) comes from extensions provided for the markerAnnotationSpecification extension point. If you don't want this, you have to change initializeAnnotations accordingly. Also you have to override createSourceViewer and depending on your concrete code configureSourceViewerConfigurationSupport to be in sync with the data you use in initializeAnnotations.

Kai





Mary Kroening <mary@xxxxxxxx>
Sent by: platform-text-dev-admin@xxxxxxxxxxx

03/24/2003 11:40 PM
Please respond to
platform-text-dev@xxxxxxxxxxx


To
platform-text-dev@xxxxxxxxxxx
cc
Subject
[platform-text-dev] Annotations




I've spent the day on this problem to no avail. I have a preferences page
based on TextEditorPreferencePage2.java in org.eclipse.ui.editors. I've
walked through the code in createSourceViewer() in TextEditor.java and the
AnnotationPreferences are being added to the header for my editor. Yet
still no annotations of any type are displayed. However, line numbers,
highlighting, etc. all from the appearance tab work fine.

My editor is quite simple. It extends TextEditor. This is the constructor:

public PrologEditor() {
        super();

        // The font is loaded from the preference store
        preferenceStore = PrologUIPlugin.getDefault().getPreferenceStore();
        setPreferenceStore(preferenceStore);

        // Create the color manager
        colorManager = new ColorManager();

        sourceViewerConfig = new
PrologSourceViewerConfiguration(colorManager);
        setSourceViewerConfiguration(sourceViewerConfig);

        prologDocumentProvider = new PrologDocumentProvider(colorManager);
        setDocumentProvider(prologDocumentProvider);

        setRulerContextMenuId("#PrologRulerContext");
}

And this for my breakpoints:

protected void createActions() {

        try {
                super.createActions();

                // Breakpoint setting via the ruler menu and double-click
                BreakpointRulerEditorAction action = ""> new
BreakpointRulerEditorAction(PrologUIPlugin.getResourceBundle(),
                        "ToggleBreakpoint_", this, getVerticalRuler());
                setAction("ToggleBreakpoint", action);
                setAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK,
getAction("ToggleBreakpoint"));
        }
        catch(NullPointerException e) {
        }
}

Everything else is pretty vanilla. The first version was based on the Java
Editor example (not the full editor). I've studied TextEditor.java and
looked at JavaEditor.java, but I think the latter was written after this
feature was added. Can someone give me an idea of where to look next for
this problem? Or a working code example?

Many thanks,
Mary Kroening
Amzi! inc.




_______________________________________________
platform-text-dev mailing list
platform-text-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-text-dev

Back to the top