~ubuntu-branches/ubuntu/utopic/eclipse-linuxtools/utopic

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/c/CConfiguration.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2014-05-12 18:11:40 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140512181140-w237r3vsah1tmybz
Tags: 2.2.1-1
* New upstream release.
* Refreshed d/patches.
* Removed eclipse-cdt-valgrind-remote package, all its functionality
  is now provided by eclipse-cdt-profiling-framework-remote.
* Added remove-license-feature.patch.
* Bump Standards-Version to 3.9.5.
* Enable eclipse-changelog package.
* Enable eclipse-rpm-editor package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 * Copyright (c) 2006 IBM Corporation.
3
 
 * All rights reserved. This program and the accompanying materials
4
 
 * are made available under the terms of the Eclipse Public License v1.0
5
 
 * which accompanies this distribution, and is available at
6
 
 * http://www.eclipse.org/legal/epl-v10.html
7
 
 *
8
 
 * Contributors:
9
 
 *     IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
10
 
 *******************************************************************************/
11
 
 
12
 
package org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.c;
13
 
 
14
 
import org.eclipse.jface.preference.IPreferenceStore;
15
 
import org.eclipse.jface.preference.PreferenceConverter;
16
 
import org.eclipse.jface.text.IDocument;
17
 
import org.eclipse.jface.text.ITextDoubleClickStrategy;
18
 
import org.eclipse.jface.text.TextAttribute;
19
 
import org.eclipse.jface.text.presentation.IPresentationReconciler;
20
 
import org.eclipse.jface.text.presentation.PresentationReconciler;
21
 
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
22
 
import org.eclipse.jface.text.source.ISourceViewer;
23
 
import org.eclipse.jface.text.source.SourceViewerConfiguration;
24
 
import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
25
 
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
26
 
import org.eclipse.linuxtools.systemtap.ui.editor.ColorManager;
27
 
import org.eclipse.linuxtools.systemtap.ui.editor.DoubleClickStrategy;
28
 
import org.eclipse.linuxtools.systemtap.ui.editor.NonRuleBasedDamagerRepairer;
29
 
import org.eclipse.linuxtools.systemtap.ui.logging.LogManager;
30
 
import org.eclipse.swt.graphics.RGB;
31
 
 
32
 
 
33
 
 
34
 
/**
35
 
 * Configures an instance of <code>CEditor</code>. This class is responsible for starting
36
 
 * the Syntax highlighting system.
37
 
 * @author Henry Hughes
38
 
 * @author Ryan Morse
39
 
 */
40
 
public class CConfiguration extends SourceViewerConfiguration {
41
 
        private DoubleClickStrategy doubleClickStrategy;
42
 
        private CScanner scanner;
43
 
        private ColorManager colorManager;
44
 
 
45
 
        /**
46
 
         * The constructor for the <code>CConfiguration</code> class. Takes as its only parameter
47
 
         * the ColorManager to use for syntax highlighting.
48
 
         * @param colorManager  the <code>ColorManager</code> to use for text highlighting
49
 
         */
50
 
        public CConfiguration(ColorManager colorManager) {
51
 
                LogManager.logDebug("Start/End CConfiguration: colorManager-" + colorManager, this); //$NON-NLS-1$
52
 
                this.colorManager = colorManager;
53
 
        }
54
 
        @Override
55
 
        public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
56
 
                LogManager.logDebug("Start/End getConfiguredContentTypes: sourceViewer-" + sourceViewer, this); //$NON-NLS-1$
57
 
                return new String[] {
58
 
                        IDocument.DEFAULT_CONTENT_TYPE,
59
 
                        CPartitionScanner.C_COMMENT};
60
 
        }
61
 
        @Override
62
 
        public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
63
 
                LogManager.logDebug("Start getDoubleClickStrategy: sourceViewer-" + sourceViewer + ", contentType-" + contentType, this); //$NON-NLS-1$ //$NON-NLS-2$
64
 
                if (doubleClickStrategy == null)
65
 
                        doubleClickStrategy = new DoubleClickStrategy();
66
 
                LogManager.logDebug("End getDoubleClickStrategy: returnVal-" + doubleClickStrategy, this); //$NON-NLS-1$
67
 
                return doubleClickStrategy;
68
 
        }
69
 
 
70
 
        /**
71
 
         * An accessor method for the <code>CScanner</code> associated with this editor. This method is used
72
 
         * in order to dispatch notifications to the <code>CScanner</code> when the color preferences have
73
 
         * been changed. The <code>CEditor</code> class calls this method to get the <code>CScanner</code>
74
 
         * associated with it, and then it reinitializes that <code>CScanner</code> using the
75
 
         * <code>CScanner.initializeScanner</code> method.
76
 
         * @return      the instance of the CScanner associated with this instance
77
 
         */
78
 
        protected CScanner getCScanner() {
79
 
                LogManager.logDebug("Start getCScanner:", this); //$NON-NLS-1$
80
 
                if (scanner == null) {
81
 
                        scanner = new CScanner(colorManager);
82
 
                }
83
 
                LogManager.logDebug("End getCScanner: returnVal-" + scanner, this); //$NON-NLS-1$
84
 
                return scanner;
85
 
        }
86
 
 
87
 
        @Override
88
 
        public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
89
 
                LogManager.logDebug("Start getPresentationReconciler: sourceViewer-" + sourceViewer, this); //$NON-NLS-1$
90
 
                PresentationReconciler reconciler = new PresentationReconciler();
91
 
                
92
 
                DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getCScanner());
93
 
                reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
94
 
                reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
95
 
                IPreferenceStore store = IDEPlugin.getDefault().getPreferenceStore();
96
 
                RGB comment = PreferenceConverter.getColor(store, IDEPreferenceConstants.P_C_COMMENT_COLOR);
97
 
                NonRuleBasedDamagerRepairer ndr =
98
 
                        new NonRuleBasedDamagerRepairer(
99
 
                                new TextAttribute(colorManager.getColor(comment)));
100
 
                reconciler.setDamager(ndr, CPartitionScanner.C_COMMENT);
101
 
                reconciler.setRepairer(ndr, CPartitionScanner.C_COMMENT);
102
 
        
103
 
                LogManager.logDebug("End getPresentationReconciler: returnVal-" + reconciler, this); //$NON-NLS-1$
104
 
                return reconciler;
105
 
        }
106
 
}