diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java index a49cee4651c..d7889628654 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java @@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings; */ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { - private static final boolean PRINT_POSITIONS= false; + private static final boolean PRINT_POSITIONS= true; private static final Class THIS= SemanticHighlightingTest.class; @@ -66,10 +66,16 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { setUpSemanticHighlighting(SemanticHighlightings.FIELD); Position[] actual= getSemanticHighlightingPositions(); Position[] expected= new Position[] { + createPosition(23, 15, 14), createPosition(24, 14, 13), + createPosition(25, 21, 19), createPosition(26, 8, 8), + createPosition(42, 21, 20), + createPosition(43, 15, 15), createPosition(44, 15, 14), createPosition(45, 8, 9), + createPosition(57, 21, 20), + createPosition(58, 15, 15), createPosition(59, 15, 14), createPosition(60, 8, 9), createPosition(75, 7, 5), @@ -82,6 +88,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { createPosition(110, 11, 8), createPosition(115, 8, 11), createPosition(117, 7, 10), + createPosition(118, 20, 15), createPosition(121, 11, 10), createPosition(121, 28, 11), }; @@ -111,9 +118,22 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { assertEqualPositions(expected, actual); } - public void testMethodInvocationHighlighting() throws Exception { - setUpSemanticHighlighting(SemanticHighlightings.METHOD_INVOCATION); + public void testMethodHighlighting() throws Exception { + setUpSemanticHighlighting(SemanticHighlightings.METHOD); Position[] expected= new Position[] { + createPosition(28, 15, 15), + createPosition(33, 8, 9), + createPosition(47, 15, 16), + createPosition(48, 8, 10), + createPosition(62, 15, 16), + createPosition(63, 8, 10), + createPosition(77, 4, 13), + createPosition(104, 4, 26), + createPosition(104, 20, 10), + createPosition(108, 4, 25), + createPosition(108, 20, 9), + createPosition(113, 4, 32), + createPosition(113, 20, 16), createPosition(114, 23, 9), createPosition(118, 4, 15), }; @@ -166,7 +186,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { assertEqualPositions(expected, actual); } - public void testLocalVariableHighlighting() throws Exception { + public void testLocalVariableReferencesHighlighting() throws Exception { setUpSemanticHighlighting(SemanticHighlightings.LOCAL_VARIABLE); Position[] expected= new Position[] { createPosition(110, 22, 8), @@ -286,12 +306,16 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { assertEqualPositions(expected, actual); } - public void testFunctionInvocationHighlighting() throws Exception { - setUpSemanticHighlighting(SemanticHighlightings.FUNCTION_INVOCATION); + public void testFunctionHighlighting() throws Exception { + setUpSemanticHighlighting(SemanticHighlightings.FUNCTION); Position[] actual= getSemanticHighlightingPositions(); Position[] expected= new Position[] { + createPosition(11, 5, 10), + createPosition(12, 12, 16), + createPosition(19, 16, 10), createPosition(30, 8, 10), - createPosition(99, 1, 16) + createPosition(98, 8, 13), + createPosition(99, 1, 16), }; if (PRINT_POSITIONS) System.out.println(toString(actual)); assertEqualPositions(expected, actual); diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index 4a442119bde..74e86944d53 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -60,6 +60,7 @@ Require-Bundle: org.eclipse.ui.ide, org.eclipse.ui.workbench.texteditor, org.eclipse.ui.editors, org.eclipse.ui, + org.eclipse.ui.forms, org.eclipse.core.resources, org.eclipse.search, org.eclipse.compare, diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 281f167f3fb..d415b20c7c6 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -134,6 +134,7 @@ CPluginBuildConsolePreferencePage.name=Build Console CPluginFileTypesPreferencePage.name=File Types CodeFormatterPreferencePage.name=Code Formatter CodeAssistPreferencePage.name=Content Assist +ColoringPreferencePage.name=Syntax Coloring todoPageName=C/C++ Task Tags todoTaskPrefName=Task Tags @@ -357,4 +358,4 @@ Dummy.label = dummy navigatorContent.name = CDT Elements OpenCallHierarchy.label = Open Call Hierarchy -OpenCallHierarchy.tooltip = Open Call Hierarchy \ No newline at end of file +OpenCallHierarchy.tooltip = Open Call Hierarchy diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index f360c8e4493..96b38b7e9cc 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -572,6 +572,11 @@ class="org.eclipse.cdt.internal.ui.preferences.CodeAssistPreferencePage" id="org.eclipse.cdt.ui.preferences.CodeAssistPreferencePage"> + null if there is no such information available. + * + * @param store the store to read from + * @param key the key used for the lookup in the preference store + * @param display the display used create the color + * @return the created color according to the specification in the preference store + */ + private Color createColor(IPreferenceStore store, String key, Display display) { + + RGB rgb= null; + + if (store.contains(key)) { + + if (store.isDefault(key)) + rgb= PreferenceConverter.getDefaultColor(store, key); + else + rgb= PreferenceConverter.getColor(store, key); + + if (rgb != null) + return new Color(display, rgb); + } + + return null; } /** @@ -142,9 +307,60 @@ public class CSourceViewer extends ProjectionViewer implements ITextViewerExtens fOutlinePresenter.uninstall(); fOutlinePresenter= null; } - super.unconfigure(); + if (fForegroundColor != null) { + fForegroundColor.dispose(); + fForegroundColor= null; + } + if (fBackgroundColor != null) { + fBackgroundColor.dispose(); + fBackgroundColor= null; + } + + if (fPreferenceStore != null) + fPreferenceStore.removePropertyChangeListener(this); + + super.unconfigure(); + + fIsConfigured= false; } - + + /* + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + String property = event.getProperty(); + if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) + || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) + || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) + || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) + || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR.equals(property) + || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR.equals(property) + || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR.equals(property) + || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR.equals(property)) + { + initializeViewerColors(); + } + } + + /** + * Sets the preference store on this viewer. + * + * @param store the preference store + * + * @since 4.0 + */ + public void setPreferenceStore(IPreferenceStore store) { + if (fIsConfigured && fPreferenceStore != null) + fPreferenceStore.removePropertyChangeListener(this); + + fPreferenceStore= store; + + if (fIsConfigured && fPreferenceStore != null) { + fPreferenceStore.addPropertyChangeListener(this); + initializeViewerColors(); + } + } + /** * @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int) */ @@ -212,19 +428,6 @@ public class CSourceViewer extends ProjectionViewer implements ITextViewerExtens } } - /* (non-Javadoc) - * @see org.eclipse.jface.text.source.ISourceViewer#setRangeIndication(int, int, boolean) - */ - public void setRangeIndication(int offset, int length, boolean moveCursor) { - // Fixin a bug in the ProjectViewer implemenation - // PR: https://bugs.eclipse.org/bugs/show_bug.cgi?id=72914 - if (isProjectionMode()) { - super.setRangeIndication(offset, length, moveCursor); - } else { - super.setRangeIndication(offset, length, false); - } - } - /** * Prepend given listener to the list of presentation listeners * diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java index c9966905671..0297c5402a0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java @@ -47,7 +47,7 @@ import org.eclipse.cdt.ui.PreferenceConstants; /** * Semantic highlightings. - * Cloned from JDT. + * Derived from JDT. * * @since 4.0 */ @@ -96,9 +96,9 @@ public class SemanticHighlightings { public static final String FUNCTION_DECLARATION="functionDeclaration"; //$NON-NLS-1$ /** - * A named preference part that controls the highlighting of static method invocations. + * A named preference part that controls the highlighting of functions. */ - public static final String FUNCTION_INVOCATION="functionInvocation"; //$NON-NLS-1$ + public static final String FUNCTION="function"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of local variables. @@ -106,7 +106,7 @@ public class SemanticHighlightings { public static final String LOCAL_VARIABLE_DECLARATION="localVariableDeclaration"; //$NON-NLS-1$ /** - * A named preference part that controls the highlighting of local variables. + * A named preference part that controls the highlighting of local variable references. */ public static final String LOCAL_VARIABLE="localVariable"; //$NON-NLS-1$ @@ -126,9 +126,9 @@ public class SemanticHighlightings { public static final String TEMPLATE_PARAMETER="templateParameter"; //$NON-NLS-1$ /** - * A named preference part that controls the highlighting of method invocations. + * A named preference part that controls the highlighting of methods. */ - public static final String METHOD_INVOCATION="method"; //$NON-NLS-1$ + public static final String METHOD="method"; //$NON-NLS-1$ /** * A named preference part that controls the highlighting of classes. @@ -374,13 +374,6 @@ public class SemanticHighlightings { public boolean consumes(SemanticToken token) { IBinding binding= token.getBinding(); if (binding instanceof IField && !(binding instanceof IProblemBinding)) { - try { - return !((IField)binding).isStatic(); - } catch (DOMException exc) { - CUIPlugin.getDefault().log(exc.getStatus()); - } catch (Error e) /* PDOMNotImplementedError */ { - // ignore - } return true; } return false; @@ -424,7 +417,7 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ public boolean isEnabledByDefault() { - return false; + return true; } /* @@ -649,15 +642,15 @@ public class SemanticHighlightings { // } /** - * Semantic highlighting for method invocations. + * Semantic highlighting for methods. */ - private static final class MethodInvocationHighlighting extends SemanticHighlighting { + private static final class MethodHighlighting extends SemanticHighlighting { /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ public String getPreferenceKey() { - return METHOD_INVOCATION; + return METHOD; } /* @@ -701,12 +694,9 @@ public class SemanticHighlightings { public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; - if (name.isReference()) { - IBinding binding= token.getBinding(); - if (binding instanceof ICPPMethod && !(binding instanceof IProblemBinding)) { - return true; - } + IBinding binding= token.getBinding(); + if (binding instanceof ICPPMethod && !(binding instanceof IProblemBinding)) { + return true; } } return false; @@ -795,7 +785,7 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ public boolean isEnabledByDefault() { - return false; + return true; } /* @@ -826,15 +816,15 @@ public class SemanticHighlightings { } /** - * Semantic highlighting for function invocations. + * Semantic highlighting for functions. */ - private static final class FunctionInvocationHighlighting extends SemanticHighlighting { + private static final class FunctionHighlighting extends SemanticHighlighting { /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ public String getPreferenceKey() { - return FUNCTION_INVOCATION; + return FUNCTION; } /* @@ -869,7 +859,7 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ public String getDisplayName() { - return CEditorMessages.getString("SemanticHighlighting_functionInvocation"); //$NON-NLS-1$ + return CEditorMessages.getString("SemanticHighlighting_function"); //$NON-NLS-1$ } /* @@ -878,14 +868,11 @@ public class SemanticHighlightings { public boolean consumes(SemanticToken token) { IASTNode node= token.getNode(); if (node instanceof IASTName) { - IASTName name= (IASTName)node; - if (name.isReference()) { - IBinding binding= token.getBinding(); - if (binding instanceof IFunction - && !(binding instanceof ICPPMethod) - && !(binding instanceof IProblemBinding)) { - return true; - } + IBinding binding= token.getBinding(); + if (binding instanceof IFunction + && !(binding instanceof ICPPMethod) + && !(binding instanceof IProblemBinding)) { + return true; } } return false; @@ -1298,7 +1285,7 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ public boolean isEnabledByDefault() { - return false; + return true; } /* @@ -1611,7 +1598,7 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ public boolean isEnabledByDefault() { - return false; + return true; } /* @@ -1767,7 +1754,7 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() */ public RGB getDefaultTextColor() { - return RGB_BLACK; + return new RGB(0, 0, 192); } /* @@ -1781,14 +1768,14 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ public boolean isItalicByDefault() { - return false; + return true; } /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ public boolean isEnabledByDefault() { - return false; + return true; } /* @@ -1840,7 +1827,7 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isStrikethroughByDefault() */ public boolean isStrikethroughByDefault() { - return true; + return false; } /* @@ -1854,7 +1841,7 @@ public class SemanticHighlightings { * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ public boolean isEnabledByDefault() { - return DEBUG; + return false; } /* @@ -1960,14 +1947,14 @@ public class SemanticHighlightings { new GlobalVariableHighlighting(), // TLETODO [semanticHighlighting] Template parameter highlighting new TemplateParameterHighlighting(), // before template arguments! - new MethodInvocationHighlighting(), // before types to get ctors + new MethodHighlighting(), // before types to get ctors // TLETODO [semanticHighlighting] Template argument highlighting // new TemplateArgumentHighlighting(), // before other types new EnumHighlighting(), // TLETODO [semanticHighlighting] Macro definition highlighting // new MacroDefinitionHighlighting(), new FunctionDeclarationHighlighting(), - new FunctionInvocationHighlighting(), + new FunctionHighlighting(), new TypedefHighlighting(), new NamespaceHighlighting(), new LabelHighlighting(), diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java new file mode 100644 index 00000000000..99ab7c82053 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java @@ -0,0 +1,474 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.preferences; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.IStatus; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.resource.JFaceResources; + +import org.eclipse.jface.text.Assert; + +import org.eclipse.ui.forms.events.ExpansionAdapter; +import org.eclipse.ui.forms.events.ExpansionEvent; +import org.eclipse.ui.forms.widgets.ExpandableComposite; + +import org.eclipse.cdt.internal.ui.util.Messages; + +import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; +import org.eclipse.cdt.internal.ui.util.PixelConverter; + +/** + * Abstract implementation of a generic {@link IPreferenceConfigurationBlock}. + * + * @since 4.0 + */ +abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlock { + + /** + * Use as follows: + * + *
+	 * SectionManager manager= new SectionManager();
+	 * Composite composite= manager.createSectionComposite(parent);
+	 * 
+	 * Composite xSection= manager.createSection("section X"));
+	 * xSection.setLayout(new FillLayout());
+	 * new Button(xSection, SWT.PUSH); // add controls to section..
+	 * 
+	 * [...]
+	 * 
+	 * return composite; // return main composite
+	 * 
+ */ + protected final class SectionManager { + /** The preference setting for keeping no section open. */ + private static final String __NONE= "__none"; //$NON-NLS-1$ + private Set fSections= new HashSet(); + private boolean fIsBeingManaged= false; + private ExpansionAdapter fListener= new ExpansionAdapter() { + public void expansionStateChanged(ExpansionEvent e) { + ExpandableComposite source= (ExpandableComposite) e.getSource(); + updateSectionStyle(source); + if (fIsBeingManaged) + return; + if (e.getState()) { + try { + fIsBeingManaged= true; + for (Iterator iter= fSections.iterator(); iter.hasNext();) { + ExpandableComposite composite= (ExpandableComposite) iter.next(); + if (composite != source) + composite.setExpanded(false); + } + } finally { + fIsBeingManaged= false; + } + if (fLastOpenKey != null && fDialogSettingsStore != null) + fDialogSettingsStore.setValue(fLastOpenKey, source.getText()); + } else { + if (!fIsBeingManaged && fLastOpenKey != null && fDialogSettingsStore != null) + fDialogSettingsStore.setValue(fLastOpenKey, __NONE); + } + ExpandableComposite exComp= getParentExpandableComposite(source); + if (exComp != null) + exComp.layout(true, true); + ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(source); + if (parentScrolledComposite != null) { + parentScrolledComposite.reflow(true); + } + } + }; + private Composite fBody; + private final String fLastOpenKey; + private final IPreferenceStore fDialogSettingsStore; + private ExpandableComposite fFirstChild= null; + /** + * Creates a new section manager. + */ + public SectionManager() { + this(null, null); + } + /** + * Creates a new section manager. + */ + public SectionManager(IPreferenceStore dialogSettingsStore, String lastOpenKey) { + fDialogSettingsStore= dialogSettingsStore; + fLastOpenKey= lastOpenKey; + } + private void manage(ExpandableComposite section) { + if (section == null) + throw new NullPointerException(); + if (fSections.add(section)) + section.addExpansionListener(fListener); + makeScrollableCompositeAware(section); + } + + /** + * Creates a new composite that can contain a set of expandable + * sections. A ScrolledPageComposite is created and a new + * composite within that, to ensure that expanding the sections will + * always have enough space, unless there already is a + * ScrolledComposite along the parent chain of + * parent, in which case a normal Composite + * is created. + *

+ * The receiver keeps a reference to the inner body composite, so that + * new sections can be added via createSection. + *

+ * + * @param parent the parent composite + * @return the newly created composite + */ + public Composite createSectionComposite(Composite parent) { + Assert.isTrue(fBody == null); + boolean isNested= isNestedInScrolledComposite(parent); + Composite composite; + if (isNested) { + composite= new Composite(parent, SWT.NONE); + fBody= composite; + } else { + composite= new ScrolledPageContent(parent); + fBody= ((ScrolledPageContent) composite).getBody(); + } + + fBody.setLayout(new GridLayout()); + + return composite; + } + + /** + * Creates an expandable section within the parent created previously by + * calling createSectionComposite. Controls can be added + * directly to the returned composite, which has no layout initially. + * + * @param label the display name of the section + * @return a composite within the expandable section + */ + public Composite createSection(String label) { + Assert.isNotNull(fBody); + final ExpandableComposite excomposite= new ExpandableComposite(fBody, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT); + if (fFirstChild == null) + fFirstChild= excomposite; + excomposite.setText(label); + String last= null; + if (fLastOpenKey != null && fDialogSettingsStore != null) + last= fDialogSettingsStore.getString(fLastOpenKey); + + if (fFirstChild == excomposite && !__NONE.equals(last) || label.equals(last)) { + excomposite.setExpanded(true); + if (fFirstChild != excomposite) + fFirstChild.setExpanded(false); + } else { + excomposite.setExpanded(false); + } + excomposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false)); + + updateSectionStyle(excomposite); + manage(excomposite); + + Composite contents= new Composite(excomposite, SWT.NONE); + excomposite.setClient(contents); + + return contents; + } + } + + protected static final int INDENT= 20; + private OverlayPreferenceStore fStore; + + private Map fCheckBoxes= new HashMap(); + private SelectionListener fCheckBoxListener= new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + } + public void widgetSelected(SelectionEvent e) { + Button button= (Button) e.widget; + fStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); + } + }; + + + private Map fTextFields= new HashMap(); + private ModifyListener fTextFieldListener= new ModifyListener() { + public void modifyText(ModifyEvent e) { + Text text= (Text) e.widget; + fStore.setValue((String) fTextFields.get(text), text.getText()); + } + }; + + private ArrayList fNumberFields= new ArrayList(); + private ModifyListener fNumberFieldListener= new ModifyListener() { + public void modifyText(ModifyEvent e) { + numberFieldChanged((Text) e.widget); + } + }; + + /** + * List of master/slave listeners when there's a dependency. + * + * @see #createDependency(Button, Control) + * @since 3.0 + */ + private ArrayList fMasterSlaveListeners= new ArrayList(); + + private StatusInfo fStatus; + private final PreferencePage fMainPage; + + public AbstractConfigurationBlock(OverlayPreferenceStore store) { + Assert.isNotNull(store); + fStore= store; + fMainPage= null; + } + + public AbstractConfigurationBlock(OverlayPreferenceStore store, PreferencePage mainPreferencePage) { + Assert.isNotNull(store); + Assert.isNotNull(mainPreferencePage); + fStore= store; + fMainPage= mainPreferencePage; + } + + protected final ScrolledPageContent getParentScrolledComposite(Control control) { + Control parent= control.getParent(); + while (!(parent instanceof ScrolledPageContent) && parent != null) { + parent= parent.getParent(); + } + if (parent instanceof ScrolledPageContent) { + return (ScrolledPageContent) parent; + } + return null; + } + + private final ExpandableComposite getParentExpandableComposite(Control control) { + Control parent= control.getParent(); + while (!(parent instanceof ExpandableComposite) && parent != null) { + parent= parent.getParent(); + } + if (parent instanceof ExpandableComposite) { + return (ExpandableComposite) parent; + } + return null; + } + + protected void updateSectionStyle(ExpandableComposite excomposite) { + excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); + } + + private void makeScrollableCompositeAware(Control control) { + ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control); + if (parentScrolledComposite != null) { + parentScrolledComposite.adaptChild(control); + } + } + + private boolean isNestedInScrolledComposite(Composite parent) { + return getParentScrolledComposite(parent) != null; + } + + protected Button addCheckBox(Composite parent, String label, String key, int indentation) { + Button checkBox= new Button(parent, SWT.CHECK); + checkBox.setText(label); + + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= indentation; + gd.horizontalSpan= 2; + checkBox.setLayoutData(gd); + checkBox.addSelectionListener(fCheckBoxListener); + makeScrollableCompositeAware(checkBox); + + fCheckBoxes.put(checkBox, key); + + return checkBox; + } + + /** + * Returns an array of size 2: + * - first element is of type Label + * - second element is of type Text + * Use getLabelControl and getTextControl to get the 2 controls. + * + * @param composite the parent composite + * @param label the text field's label + * @param key the preference key + * @param textLimit the text limit + * @param indentation the field's indentation + * @param isNumber true iff this text field is used to e4dit a number + * @return the controls added + */ + protected Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) { + + PixelConverter pixelConverter= new PixelConverter(composite); + + Label labelControl= new Label(composite, SWT.NONE); + labelControl.setText(label); + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= indentation; + labelControl.setLayoutData(gd); + + Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE); + gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.widthHint= pixelConverter.convertWidthInCharsToPixels(textLimit + 1); + textControl.setLayoutData(gd); + textControl.setTextLimit(textLimit); + fTextFields.put(textControl, key); + if (isNumber) { + fNumberFields.add(textControl); + textControl.addModifyListener(fNumberFieldListener); + } else { + textControl.addModifyListener(fTextFieldListener); + } + + return new Control[]{labelControl, textControl}; + } + + protected void createDependency(final Button master, final Control slave) { + createDependency(master, new Control[] {slave}); + } + + protected void createDependency(final Button master, final Control[] slaves) { + Assert.isTrue(slaves.length > 0); + indent(slaves[0]); + SelectionListener listener= new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + boolean state= master.getSelection(); + for (int i= 0; i < slaves.length; i++) { + slaves[i].setEnabled(state); + } + } + + public void widgetDefaultSelected(SelectionEvent e) {} + }; + master.addSelectionListener(listener); + fMasterSlaveListeners.add(listener); + } + + protected static void indent(Control control) { + ((GridData) control.getLayoutData()).horizontalIndent+= INDENT; + } + + public void initialize() { + initializeFields(); + } + + private void initializeFields() { + + Iterator iter= fCheckBoxes.keySet().iterator(); + while (iter.hasNext()) { + Button b= (Button) iter.next(); + String key= (String) fCheckBoxes.get(b); + b.setSelection(fStore.getBoolean(key)); + } + + iter= fTextFields.keySet().iterator(); + while (iter.hasNext()) { + Text t= (Text) iter.next(); + String key= (String) fTextFields.get(t); + t.setText(fStore.getString(key)); + } + + // Update slaves + iter= fMasterSlaveListeners.iterator(); + while (iter.hasNext()) { + SelectionListener listener= (SelectionListener)iter.next(); + listener.widgetSelected(null); + } + + updateStatus(new StatusInfo()); + } + + public void performOk() { + } + + public void performDefaults() { + initializeFields(); + } + + IStatus getStatus() { + if (fStatus == null) + fStatus= new StatusInfo(); + return fStatus; + } + + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose() + */ + public void dispose() { + } + + private void numberFieldChanged(Text textControl) { + String number= textControl.getText(); + IStatus status= validatePositiveNumber(number); + if (!status.matches(IStatus.ERROR)) + fStore.setValue((String) fTextFields.get(textControl), number); + updateStatus(status); + } + + private IStatus validatePositiveNumber(String number) { + StatusInfo status= new StatusInfo(); + if (number.length() == 0) { + status.setError(PreferencesMessages.CEditorPreferencePage_empty_input); + } else { + try { + int value= Integer.parseInt(number); + if (value < 0) + status.setError(Messages.format(PreferencesMessages.CEditorPreferencePage_invalid_input, number)); + } catch (NumberFormatException e) { + status.setError(Messages.format(PreferencesMessages.CEditorPreferencePage_invalid_input, number)); + } + } + return status; + } + + protected void updateStatus(IStatus status) { + if (fMainPage == null) + return; + fMainPage.setValid(status.isOK()); + StatusUtil.applyToStatusLine(fMainPage, status); + } + + protected final OverlayPreferenceStore getPreferenceStore() { + return fStore; + } + + protected Composite createSubsection(Composite parent, SectionManager manager, String label) { + if (manager != null) { + return manager.createSection(label); + } else { + Group group= new Group(parent, SWT.SHADOW_NONE); + group.setText(label); + GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false); + group.setLayoutData(data); + return group; + } + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java new file mode 100644 index 00000000000..544b56afcfd --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.preferences; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.preference.PreferencePage; + +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.PlatformUI; + +import org.eclipse.cdt.ui.CUIPlugin; + +/** + * Abstract preference page which is used to wrap a + * {@link org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock}. + * + * @since 4.0 + */ +public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + + private IPreferenceConfigurationBlock fConfigurationBlock; + private OverlayPreferenceStore fOverlayStore; + + + /** + * Creates a new preference page. + */ + public AbstractConfigurationBlockPreferencePage() { + setDescription(); + setPreferenceStore(); + fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {}); + fConfigurationBlock= createConfigurationBlock(fOverlayStore); + } + + protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore); + protected abstract String getHelpId(); + protected abstract void setDescription(); + protected abstract void setPreferenceStore(); + + /* + * @see IWorkbenchPreferencePage#init() + */ + public void init(IWorkbench workbench) { + } + + /* + * @see PreferencePage#createControl(Composite) + */ + public void createControl(Composite parent) { + super.createControl(parent); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId()); + } + + /* + * @see PreferencePage#createContents(Composite) + */ + protected Control createContents(Composite parent) { + + fOverlayStore.load(); + fOverlayStore.start(); + + Control content= fConfigurationBlock.createControl(parent); + + initialize(); + + Dialog.applyDialogFont(content); + return content; + } + + private void initialize() { + fConfigurationBlock.initialize(); + } + + /* + * @see PreferencePage#performOk() + */ + public boolean performOk() { + + fConfigurationBlock.performOk(); + + fOverlayStore.propagate(); + + CUIPlugin.getDefault().savePluginPreferences(); + + return true; + } + + /* + * @see PreferencePage#performDefaults() + */ + public void performDefaults() { + + fOverlayStore.loadDefaults(); + fConfigurationBlock.performDefaults(); + + super.performDefaults(); + } + + /* + * @see DialogPage#dispose() + */ + public void dispose() { + + fConfigurationBlock.dispose(); + + if (fOverlayStore != null) { + fOverlayStore.stop(); + fOverlayStore= null; + } + + super.dispose(); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java index b1741a3c289..e4790dae34f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java @@ -224,14 +224,14 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I private IStatus validatePositiveNumber(String number) { StatusInfo status = new StatusInfo(); if (number.length() == 0) { - status.setError(PreferencesMessages.getString("CEditorPreferencePage.empty_input")); //$NON-NLS-1$ + status.setError(PreferencesMessages.CEditorPreferencePage_empty_input); } else { try { int value = Integer.parseInt(number); if (value < 0) - status.setError(PreferencesMessages.getString("CEditorPreferencePage.invalid_input")); //$NON-NLS-1$ + status.setError(PreferencesMessages.CEditorPreferencePage_invalid_input); } catch (NumberFormatException e) { - status.setError(PreferencesMessages.getString("CEditorPreferencePage.invalid_input")); //$NON-NLS-1$ + status.setError(PreferencesMessages.CEditorPreferencePage_invalid_input); } } return status; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java index 4ff8e11b67d..da7be5a8e16 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java @@ -53,7 +53,7 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben public AppearancePreferencePage() { setPreferenceStore(PreferenceConstants.getPreferenceStore()); - setDescription(PreferencesMessages.getString("AppearancePreferencePage.description")); //$NON-NLS-1$ + setDescription(PreferencesMessages.AppearancePreferencePage_description); IDialogFieldListener listener= new IDialogFieldListener() { public void dialogFieldChanged(DialogField field) { @@ -63,19 +63,19 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben fShowTUChildren= new SelectionButtonDialogField(SWT.CHECK); fShowTUChildren.setDialogFieldListener(listener); - fShowTUChildren.setLabelText(PreferencesMessages.getString("AppearancePreferencePage.showTUChildren.label")); //$NON-NLS-1$ + fShowTUChildren.setLabelText(PreferencesMessages.AppearancePreferencePage_showTUChildren_label); fOutlineGroupIncludes= new SelectionButtonDialogField(SWT.CHECK); fOutlineGroupIncludes.setDialogFieldListener(listener); - fOutlineGroupIncludes.setLabelText(PreferencesMessages.getString("AppearancePreferencePage.outlineGroupIncludes.label")); //$NON-NLS-1$ + fOutlineGroupIncludes.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupIncludes_label); fOutlineGroupNamespaces= new SelectionButtonDialogField(SWT.CHECK); fOutlineGroupNamespaces.setDialogFieldListener(listener); - fOutlineGroupNamespaces.setLabelText(PreferencesMessages.getString("AppearancePreferencePage.outlineGroupNamespaces.label")); //$NON-NLS-1$ + fOutlineGroupNamespaces.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupNamespaces_label); fCViewGroupIncludes= new SelectionButtonDialogField(SWT.CHECK); fCViewGroupIncludes.setDialogFieldListener(listener); - fCViewGroupIncludes.setLabelText(PreferencesMessages.getString("AppearancePreferencePage.cviewGroupIncludes.label")); //$NON-NLS-1$ + fCViewGroupIncludes.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewGroupIncludes_label); } @@ -119,8 +119,8 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben new Separator().doFillIntoGrid(result, nColumns); - String noteTitle= PreferencesMessages.getString("AppearancePreferencePage.note"); //$NON-NLS-1$ - String noteMessage= PreferencesMessages.getString("AppearancePreferencePage.preferenceOnlyEffectiveForNewPerspectives"); //$NON-NLS-1$ + String noteTitle= PreferencesMessages.AppearancePreferencePage_note; + String noteMessage= PreferencesMessages.AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives; Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java new file mode 100644 index 00000000000..9bae89108cb --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -0,0 +1,897 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Anton Leherbauer (Wind River Systems) + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.preferences; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Iterator; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.preference.ColorSelector; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontMetrics; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.ScrollBar; +import org.eclipse.swt.widgets.Scrollable; +import org.eclipse.ui.dialogs.PreferencesUtil; +import org.eclipse.ui.editors.text.EditorsUI; +import org.eclipse.ui.texteditor.ChainedPreferenceStore; + +import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage; +import org.eclipse.cdt.core.model.ILanguage; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.ICPartitions; + +import org.eclipse.cdt.internal.ui.editor.CSourceViewer; +import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting; +import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager; +import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings; +import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedRange; +import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; +import org.eclipse.cdt.internal.ui.text.CTextTools; +import org.eclipse.cdt.internal.ui.text.IColorManager; +import org.eclipse.cdt.internal.ui.text.util.CColorManager; +import org.eclipse.cdt.internal.ui.util.PixelConverter; + +/** + * Configures C/C++ Editor code coloring preferences. + * + * @since 4.0 + */ +class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { + + /** + * Item in the highlighting color list. + */ + private static class HighlightingColorListItem { + /** Display name */ + private String fDisplayName; + /** Color preference key */ + private String fColorKey; + /** Bold preference key */ + private String fBoldKey; + /** Italic preference key */ + private String fItalicKey; + /** Strikethrough preference key */ + private String fStrikethroughKey; + /** Underline preference key */ + private String fUnderlineKey; + + /** + * Initialize the item with the given values. + * @param displayName the display name + * @param colorKey the color preference key + * @param boldKey the bold preference key + * @param italicKey the italic preference key + * @param strikethroughKey the strikethrough preference key + * @param underlineKey the underline preference key + */ + public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { + fDisplayName= displayName; + fColorKey= colorKey; + fBoldKey= boldKey; + fItalicKey= italicKey; + fStrikethroughKey= strikethroughKey; + fUnderlineKey= underlineKey; + } + + /** + * @return the bold preference key + */ + public String getBoldKey() { + return fBoldKey; + } + + /** + * @return the bold preference key + */ + public String getItalicKey() { + return fItalicKey; + } + + /** + * @return the strikethrough preference key + */ + public String getStrikethroughKey() { + return fStrikethroughKey; + } + + /** + * @return the underline preference key + */ + public String getUnderlineKey() { + return fUnderlineKey; + } + + /** + * @return the color preference key + */ + public String getColorKey() { + return fColorKey; + } + + /** + * @return the display name + */ + public String getDisplayName() { + return fDisplayName; + } + } + + private static class SemanticHighlightingColorListItem extends HighlightingColorListItem { + + /** Enablement preference key */ + private final String fEnableKey; + + /** + * Initialize the item with the given values. + * @param displayName the display name + * @param colorKey the color preference key + * @param boldKey the bold preference key + * @param italicKey the italic preference key + * @param strikethroughKey the strikethroughKey preference key + * @param underlineKey the underlineKey preference key + * @param enableKey the enable preference key + */ + public SemanticHighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey, String enableKey) { + super(displayName, colorKey, boldKey, italicKey, strikethroughKey, underlineKey); + fEnableKey= enableKey; + } + + /** + * @return the enablement preference key + */ + public String getEnableKey() { + return fEnableKey; + } + } + + /** + * Color list label provider. + */ + private class ColorListLabelProvider extends LabelProvider { + /* + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + */ + public String getText(Object element) { + if (element instanceof String) + return (String) element; + return ((HighlightingColorListItem)element).getDisplayName(); + } + } + + /** + * Color list content provider. + */ + private class ColorListContentProvider implements ITreeContentProvider { + + /* + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object inputElement) { + return new String[] {fCodeCategory, fCommentsCategory}; + } + + /* + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + } + + /* + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + + public Object[] getChildren(Object parentElement) { + if (parentElement instanceof String) { + String entry= (String) parentElement; + if (fCodeCategory.equals(entry)) + return fListModel.subList(3, fListModel.size()).toArray(); + if (fCommentsCategory.equals(entry)) + return fListModel.subList(0, 3).toArray(); + } + return new Object[0]; + } + + public Object getParent(Object element) { + if (element instanceof String) + return null; + int index= fListModel.indexOf(element); + if (index >= 3) + return fCodeCategory; + return fCommentsCategory; + } + + public boolean hasChildren(Object element) { + return element instanceof String; + } + } + + /** + * Preference key suffix for bold preferences. + */ + private static final String BOLD= PreferenceConstants.EDITOR_BOLD_SUFFIX; + /** + * Preference key suffix for italic preferences. + */ + private static final String ITALIC= PreferenceConstants.EDITOR_ITALIC_SUFFIX; + /** + * Preference key suffix for strikethrough preferences. + */ + private static final String STRIKETHROUGH= PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX; + /** + * Preference key suffix for underline preferences. + */ + private static final String UNDERLINE= PreferenceConstants.EDITOR_UNDERLINE_SUFFIX; + + /** + * The keys of the overlay store. + */ + private final String[][] fSyntaxColorListModel= new String[][] { + { PreferencesMessages.CEditorColoringConfigurationBlock_MultiLine, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_singleLine, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_cCommentTaskTags, PreferenceConstants.EDITOR_TASK_TAG_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_keywords, PreferenceConstants.EDITOR_C_KEYWORD_COLOR }, +// { PreferencesMessages.CEditorColoringConfigurationBlock_returnKeyword, PreferenceConstants.EDITOR_C_KEYWORD_RETURN_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_builtInTypes, PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_operators, PreferenceConstants.EDITOR_C_OPERATOR_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_strings, PreferenceConstants.EDITOR_C_STRING_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_braces, PreferenceConstants.EDITOR_C_BRACES_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_numbers, PreferenceConstants.EDITOR_C_NUMBER_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_headers, PreferenceConstants.EDITOR_C_HEADER_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_others, PreferenceConstants.EDITOR_C_DEFAULT_COLOR }, + }; + + private final String fCodeCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_code; + private final String fCommentsCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_comments; + + private ColorSelector fSyntaxForegroundColorEditor; + private Label fColorEditorLabel; + private Button fBoldCheckBox; + private Button fEnableCheckbox; + /** + * Check box for italic preference. + */ + private Button fItalicCheckBox; + /** + * Check box for strikethrough preference. + */ + private Button fStrikethroughCheckBox; + /** + * Check box for underline preference. + */ + private Button fUnderlineCheckBox; + /** + * Highlighting color list + */ + private final java.util.List fListModel= new ArrayList(); + /** + * Highlighting color list viewer + */ + private StructuredViewer fListViewer; + /** + * Semantic highlighting manager + */ + private SemanticHighlightingManager fSemanticHighlightingManager; + /** + * The previewer. + */ + private CSourceViewer fPreviewViewer; + /** + * The color manager. + */ + private IColorManager fColorManager; + /** + * The font metrics. + */ + private FontMetrics fFontMetrics; + private CTextTools fTextTools; + + public CEditorColoringConfigurationBlock(OverlayPreferenceStore store) { + super(store); + + fColorManager= new CColorManager(false); + + for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++) + fListModel.add(new HighlightingColorListItem ( + fSyntaxColorListModel[i][0], + fSyntaxColorListModel[i][1], + fSyntaxColorListModel[i][1] + BOLD, + fSyntaxColorListModel[i][1] + ITALIC, + fSyntaxColorListModel[i][1] + STRIKETHROUGH, + fSyntaxColorListModel[i][1] + UNDERLINE)); + + SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings(); + for (int i= 0, n= semanticHighlightings.length; i < n; i++) + fListModel.add( + new SemanticHighlightingColorListItem( + semanticHighlightings[i].getDisplayName(), + SemanticHighlightings.getColorPreferenceKey(semanticHighlightings[i]), + SemanticHighlightings.getBoldPreferenceKey(semanticHighlightings[i]), + SemanticHighlightings.getItalicPreferenceKey(semanticHighlightings[i]), + SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlightings[i]), + SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlightings[i]), + SemanticHighlightings.getEnabledPreferenceKey(semanticHighlightings[i]) + )); + + store.addKeys(createOverlayStoreKeys()); + } + + private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { + + ArrayList overlayKeys= new ArrayList(); + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)); + + for (int i= 0, n= fListModel.size(); i < n; i++) { + HighlightingColorListItem item= (HighlightingColorListItem) fListModel.get(i); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, item.getColorKey())); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getBoldKey())); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getItalicKey())); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getStrikethroughKey())); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getUnderlineKey())); + + if (item instanceof SemanticHighlightingColorListItem) + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ((SemanticHighlightingColorListItem) item).getEnableKey())); + } + + OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; + overlayKeys.toArray(keys); + return keys; + } + + /** + * Creates page for hover preferences. + * + * @param parent the parent composite + * @return the control for the preference page + */ + public Control createControl(Composite parent) { + initializeDialogUnits(parent); + return createSyntaxPage(parent); + } + + /** + * Returns the number of pixels corresponding to the width of the given + * number of characters. + *

+ * This method may only be called after initializeDialogUnits + * has been called. + *

+ *

+ * Clients may call this framework method, but should not override it. + *

+ * + * @param chars + * the number of characters + * @return the number of pixels + */ + private int convertWidthInCharsToPixels(int chars) { + // test for failure to initialize for backward compatibility + if (fFontMetrics == null) + return 0; + return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars); + } + + /** + * Returns the number of pixels corresponding to the height of the given + * number of characters. + *

+ * This method may only be called after initializeDialogUnits + * has been called. + *

+ *

+ * Clients may call this framework method, but should not override it. + *

+ * + * @param chars + * the number of characters + * @return the number of pixels + */ + private int convertHeightInCharsToPixels(int chars) { + // test for failure to initialize for backward compatibility + if (fFontMetrics == null) + return 0; + return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars); + } + + public void initialize() { + super.initialize(); + + fListViewer.setInput(fListModel); + fListViewer.setSelection(new StructuredSelection(fCodeCategory)); + } + + public void performDefaults() { + super.performDefaults(); + + handleSyntaxColorListSelection(); + + uninstallSemanticHighlighting(); + installSemanticHighlighting(); + + fPreviewViewer.invalidateTextPresentation(); + } + + /* + * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose() + */ + public void dispose() { + uninstallSemanticHighlighting(); + fColorManager.dispose(); + if (fTextTools != null) { + fTextTools.dispose(); + fTextTools= null; + } + + super.dispose(); + } + + private void handleSyntaxColorListSelection() { + HighlightingColorListItem item= getHighlightingColorListItem(); + if (item == null) { + fEnableCheckbox.setEnabled(false); + fSyntaxForegroundColorEditor.getButton().setEnabled(false); + fColorEditorLabel.setEnabled(false); + fBoldCheckBox.setEnabled(false); + fItalicCheckBox.setEnabled(false); + fStrikethroughCheckBox.setEnabled(false); + fUnderlineCheckBox.setEnabled(false); + return; + } + RGB rgb= PreferenceConverter.getColor(getPreferenceStore(), item.getColorKey()); + fSyntaxForegroundColorEditor.setColorValue(rgb); + fBoldCheckBox.setSelection(getPreferenceStore().getBoolean(item.getBoldKey())); + fItalicCheckBox.setSelection(getPreferenceStore().getBoolean(item.getItalicKey())); + fStrikethroughCheckBox.setSelection(getPreferenceStore().getBoolean(item.getStrikethroughKey())); + fUnderlineCheckBox.setSelection(getPreferenceStore().getBoolean(item.getUnderlineKey())); + if (item instanceof SemanticHighlightingColorListItem) { + fEnableCheckbox.setEnabled(true); + boolean enable= getPreferenceStore().getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey()); + fEnableCheckbox.setSelection(enable); + fSyntaxForegroundColorEditor.getButton().setEnabled(enable); + fColorEditorLabel.setEnabled(enable); + fBoldCheckBox.setEnabled(enable); + fItalicCheckBox.setEnabled(enable); + fStrikethroughCheckBox.setEnabled(enable); + fUnderlineCheckBox.setEnabled(enable); + } else { + fSyntaxForegroundColorEditor.getButton().setEnabled(true); + fColorEditorLabel.setEnabled(true); + fBoldCheckBox.setEnabled(true); + fItalicCheckBox.setEnabled(true); + fStrikethroughCheckBox.setEnabled(true); + fUnderlineCheckBox.setEnabled(true); + fEnableCheckbox.setEnabled(false); + fEnableCheckbox.setSelection(true); + } + } + + private Control createSyntaxPage(final Composite parent) { + + Composite colorComposite= new Composite(parent, SWT.NONE); + GridLayout layout= new GridLayout(); + layout.marginHeight= 0; + layout.marginWidth= 0; + colorComposite.setLayout(layout); + + Link link= new Link(colorComposite, SWT.NONE); + link.setText(PreferencesMessages.CEditorColoringConfigurationBlock_link); + link.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null); + } + }); + // TODO replace by link-specific tooltips when + // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed +// link.setToolTipText(PreferencesMessages.CEditorColoringConfigurationBlock_link_tooltip); + + GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false); + gridData.widthHint= 150; // only expand further if anyone else requires it + gridData.horizontalSpan= 2; + link.setLayoutData(gridData); + + addFiller(colorComposite, 1); + + Label label; + label= new Label(colorComposite, SWT.LEFT); + label.setText(PreferencesMessages.CEditorColoringConfigurationBlock_coloring_element); + label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Composite editorComposite= new Composite(colorComposite, SWT.NONE); + layout= new GridLayout(); + layout.numColumns= 2; + layout.marginHeight= 0; + layout.marginWidth= 0; + editorComposite.setLayout(layout); + GridData gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false); + editorComposite.setLayoutData(gd); + + fListViewer= new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER); + fListViewer.setLabelProvider(new ColorListLabelProvider()); + fListViewer.setContentProvider(new ColorListContentProvider()); + fListViewer.setSorter(new ViewerSorter() { + public int category(Object element) { + // don't sort the top level categories + if (fCodeCategory.equals(element)) + return 0; + if (fCommentsCategory.equals(element)) + return 2; + // to sort semantic settings after partition based ones: +// if (element instanceof SemanticHighlightingColorListItem) +// return 1; + return 0; + } + }); + gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true); + gd.heightHint= convertHeightInCharsToPixels(9); + int maxWidth= 0; + for (Iterator it= fListModel.iterator(); it.hasNext();) { + HighlightingColorListItem item= (HighlightingColorListItem) it.next(); + maxWidth= Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length())); + } + ScrollBar vBar= ((Scrollable) fListViewer.getControl()).getVerticalBar(); + if (vBar != null) + maxWidth += vBar.getSize().x * 3; // scrollbars and tree indentation guess + gd.widthHint= maxWidth; + + fListViewer.getControl().setLayoutData(gd); + + Composite stylesComposite= new Composite(editorComposite, SWT.NONE); + layout= new GridLayout(); + layout.marginHeight= 0; + layout.marginWidth= 0; + layout.numColumns= 2; + stylesComposite.setLayout(layout); + stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + fEnableCheckbox= new Button(stylesComposite, SWT.CHECK); + fEnableCheckbox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_enable); + gd= new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment= GridData.BEGINNING; + gd.horizontalSpan= 2; + fEnableCheckbox.setLayoutData(gd); + + fColorEditorLabel= new Label(stylesComposite, SWT.LEFT); + fColorEditorLabel.setText(PreferencesMessages.CEditorColoringConfigurationBlock_color); + gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= 20; + fColorEditorLabel.setLayoutData(gd); + + fSyntaxForegroundColorEditor= new ColorSelector(stylesComposite); + Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton(); + gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + foregroundColorButton.setLayoutData(gd); + + fBoldCheckBox= new Button(stylesComposite, SWT.CHECK); + fBoldCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_bold); + gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= 20; + gd.horizontalSpan= 2; + fBoldCheckBox.setLayoutData(gd); + + fItalicCheckBox= new Button(stylesComposite, SWT.CHECK); + fItalicCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_italic); + gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= 20; + gd.horizontalSpan= 2; + fItalicCheckBox.setLayoutData(gd); + + fStrikethroughCheckBox= new Button(stylesComposite, SWT.CHECK); + fStrikethroughCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_strikethrough); + gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= 20; + gd.horizontalSpan= 2; + fStrikethroughCheckBox.setLayoutData(gd); + + fUnderlineCheckBox= new Button(stylesComposite, SWT.CHECK); + fUnderlineCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_underline); + gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= 20; + gd.horizontalSpan= 2; + fUnderlineCheckBox.setLayoutData(gd); + + label= new Label(colorComposite, SWT.LEFT); + label.setText(PreferencesMessages.CEditorColoringConfigurationBlock_preview); + label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Control previewer= createPreviewer(colorComposite); + gd= new GridData(GridData.FILL_BOTH); + gd.widthHint= convertWidthInCharsToPixels(20); + gd.heightHint= convertHeightInCharsToPixels(5); + previewer.setLayoutData(gd); + + fListViewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + handleSyntaxColorListSelection(); + } + }); + + foregroundColorButton.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + HighlightingColorListItem item= getHighlightingColorListItem(); + PreferenceConverter.setValue(getPreferenceStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue()); + } + }); + + fBoldCheckBox.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + HighlightingColorListItem item= getHighlightingColorListItem(); + getPreferenceStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection()); + } + }); + + fItalicCheckBox.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + HighlightingColorListItem item= getHighlightingColorListItem(); + getPreferenceStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection()); + } + }); + fStrikethroughCheckBox.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + HighlightingColorListItem item= getHighlightingColorListItem(); + getPreferenceStore().setValue(item.getStrikethroughKey(), fStrikethroughCheckBox.getSelection()); + } + }); + + fUnderlineCheckBox.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + HighlightingColorListItem item= getHighlightingColorListItem(); + getPreferenceStore().setValue(item.getUnderlineKey(), fUnderlineCheckBox.getSelection()); + } + }); + + fEnableCheckbox.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + HighlightingColorListItem item= getHighlightingColorListItem(); + if (item instanceof SemanticHighlightingColorListItem) { + boolean enable= fEnableCheckbox.getSelection(); + getPreferenceStore().setValue(((SemanticHighlightingColorListItem) item).getEnableKey(), enable); + fEnableCheckbox.setSelection(enable); + fSyntaxForegroundColorEditor.getButton().setEnabled(enable); + fColorEditorLabel.setEnabled(enable); + fBoldCheckBox.setEnabled(enable); + fItalicCheckBox.setEnabled(enable); + fStrikethroughCheckBox.setEnabled(enable); + fUnderlineCheckBox.setEnabled(enable); + uninstallSemanticHighlighting(); + installSemanticHighlighting(); + } + } + }); + + colorComposite.layout(false); + + return colorComposite; + } + + private void addFiller(Composite composite, int horizontalSpan) { + PixelConverter pixelConverter= new PixelConverter(composite); + Label filler= new Label(composite, SWT.LEFT ); + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gd.horizontalSpan= horizontalSpan; + gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2; + filler.setLayoutData(gd); + } + + private Control createPreviewer(Composite parent) { + + IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore(); + IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), generalTextStore }); + fTextTools= new CTextTools(store, null, false); + fPreviewViewer = new CSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store) { + public ILanguage getLanguage() { + return GPPLanguage.getDefault(); + } + }; + fPreviewViewer.setPreferenceStore(store); + CSourceViewerConfiguration configuration = new CSourceViewerConfiguration(fTextTools, null); + fPreviewViewer.configure(configuration); + Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); + fPreviewViewer.getTextWidget().setFont(font); + CSourcePreviewerUpdater.registerPreviewer(fPreviewViewer, configuration, store); + fPreviewViewer.setEditable(false); + + String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$ + IDocument document= new Document(content); + fTextTools.setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING); + fPreviewViewer.setDocument(document); + + installSemanticHighlighting(); + + return fPreviewViewer.getControl(); + } + + private String loadPreviewContentFromFile(String filename) { + String line; + String separator= System.getProperty("line.separator"); //$NON-NLS-1$ + StringBuffer buffer= new StringBuffer(512); + BufferedReader reader= null; + try { + reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename))); + while ((line= reader.readLine()) != null) { + buffer.append(line); + buffer.append(separator); + } + } catch (IOException io) { + CUIPlugin.getDefault().log(io); + } finally { + if (reader != null) { + try { reader.close(); } catch (IOException e) {} + } + } + return buffer.toString(); + } + + /** + * Install Semantic Highlighting on the previewer + */ + private void installSemanticHighlighting() { + if (fSemanticHighlightingManager == null) { + fSemanticHighlightingManager= new SemanticHighlightingManager(); + fSemanticHighlightingManager.install(fPreviewViewer, fColorManager, getPreferenceStore(), createPreviewerRanges()); + } + } + + /** + * Uninstall Semantic Highlighting from the previewer + */ + private void uninstallSemanticHighlighting() { + if (fSemanticHighlightingManager != null) { + fSemanticHighlightingManager.uninstall(); + fSemanticHighlightingManager= null; + } + } + + /** + * Create the hard coded previewer ranges + * + * @return the hard coded previewer ranges + */ + private SemanticHighlightingManager.HighlightedRange[][] createPreviewerRanges() { + return new SemanticHighlightingManager.HighlightedRange[][] { + { createHighlightedRange(13, 14, 11, SemanticHighlightings.STATIC_FIELD), createHighlightedRange(13, 14, 11, SemanticHighlightings.FIELD) }, + { createHighlightedRange(14, 6, 5, SemanticHighlightings.FIELD) }, + { createHighlightedRange(15, 10, 7, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(15, 7, 7, SemanticHighlightings.METHOD) }, + { createHighlightedRange(16, 7, 6, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(16, 7, 6, SemanticHighlightings.METHOD) }, + { createHighlightedRange(19, 4, 7, SemanticHighlightings.METHOD) }, + { createHighlightedRange(17, 8, 5, SemanticHighlightings.LOCAL_VARIABLE_DECLARATION) }, + { createHighlightedRange(18, 14, 5, SemanticHighlightings.LOCAL_VARIABLE) }, + { createHighlightedRange( 6, 23, 9, SemanticHighlightings.PARAMETER_VARIABLE) }, + { createHighlightedRange( 7, 6, 9, SemanticHighlightings.PARAMETER_VARIABLE) }, + { createHighlightedRange( 8, 9, 9, SemanticHighlightings.PARAMETER_VARIABLE) }, + { createHighlightedRange(16, 21, 1, SemanticHighlightings.PARAMETER_VARIABLE) }, + { createHighlightedRange(17, 20, 1, SemanticHighlightings.PARAMETER_VARIABLE) }, + { createHighlightedRange(12, 7, 6, SemanticHighlightings.ENUM) }, + { createHighlightedRange(15, 10, 6, SemanticHighlightings.ENUM) }, + { createHighlightedRange(16, 14, 6, SemanticHighlightings.ENUM) }, + { createHighlightedRange(10, 6, 7, SemanticHighlightings.CLASS) }, + { createHighlightedRange( 6, 11, 6, SemanticHighlightings.FUNCTION_DECLARATION), createHighlightedRange( 6, 11, 6, SemanticHighlightings.FUNCTION) }, + { createHighlightedRange(18, 7, 6, SemanticHighlightings.FUNCTION) }, + { createHighlightedRange(18, 21, 11, SemanticHighlightings.MACRO_SUBSTITUTION) }, + { createHighlightedRange( 5, 21, 4, SemanticHighlightings.TYPEDEF) }, + { createHighlightedRange( 6, 18, 4, SemanticHighlightings.TYPEDEF) }, + { createHighlightedRange( 3, 16, 3, SemanticHighlightings.NAMESPACE) }, + { createHighlightedRange( 7, 25, 3, SemanticHighlightings.GLOBAL_VARIABLE) }, + { createHighlightedRange( 7, 39, 4, SemanticHighlightings.GLOBAL_VARIABLE) }, + { createHighlightedRange(18, 0, 5, SemanticHighlightings.LABEL) }, + { createHighlightedRange(12, 16, 4, SemanticHighlightings.ENUMERATOR) }, + { createHighlightedRange(12, 22, 3, SemanticHighlightings.ENUMERATOR) }, + { createHighlightedRange(12, 27, 3, SemanticHighlightings.ENUMERATOR) }, + { createHighlightedRange(20, 4, 7, SemanticHighlightings.PROBLEM) }, + }; + } + + /** + * Create a highlighted range on the previewers document with the given line, column, length and key. + * + * @param line the line + * @param column the column + * @param length the length + * @param key the key + * @return the highlighted range + */ + private HighlightedRange createHighlightedRange(int line, int column, int length, String key) { + try { + IDocument document= fPreviewViewer.getDocument(); + int offset= document.getLineOffset(line) + column; + return new HighlightedRange(offset, length, key); + } catch (BadLocationException x) { + CUIPlugin.getDefault().log(x); + } + return null; + } + + /** + * Returns the current highlighting color list item. + * + * @return the current highlighting color list item + */ + private HighlightingColorListItem getHighlightingColorListItem() { + IStructuredSelection selection= (IStructuredSelection) fListViewer.getSelection(); + Object element= selection.getFirstElement(); + if (element instanceof String) + return null; + return (HighlightingColorListItem) element; + } + + /** + * Initializes the computation of horizontal and vertical dialog units based + * on the size of current font. + *

+ * This method must be called before any of the dialog unit based conversion + * methods are called. + *

+ * + * @param testControl + * a control from which to obtain the current font + */ + private void initializeDialogUnits(Control testControl) { + // Compute and store a font metric + GC gc = new GC(testControl); + gc.setFont(JFaceResources.getDialogFont()); + fFontMetrics = gc.getFontMetrics(); + gc.dispose(); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java new file mode 100644 index 00000000000..65dab2b4554 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Anton Leherbauer (Wind River Systems) + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.preferences; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.ICHelpContextIds; + + + +/** + * Code coloring preference page. + *

+ * Note: Must be public since it is referenced from plugin.xml + *

+ * + * @since 4.0 + */ +public class CEditorColoringPreferencePage extends AbstractConfigurationBlockPreferencePage { + + /* + * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId() + */ + protected String getHelpId() { + return ICHelpContextIds.C_EDITOR_COLORS_PREF_PAGE; + } + + /* + * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription() + */ + protected void setDescription() { + String description= PreferencesMessages.CEditorPreferencePage_colors; + setDescription(description); + } + + + protected Label createDescriptionLabel(Composite parent) { + return null; + } + + /* + * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore() + */ + protected void setPreferenceStore() { + setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); + } + + /* + * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore) + */ + protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) { + return new CEditorColoringConfigurationBlock(overlayPreferenceStore); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java index e2662391141..ae2cec7b7eb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java @@ -38,6 +38,7 @@ import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; @@ -63,7 +64,7 @@ import org.eclipse.ui.PlatformUI; * CEditorHoverConfigurationBlock */ public class CEditorHoverConfigurationBlock { - static final String DELIMITER= PreferencesMessages.getString("CEditorHoverConfigurationBlock.delimiter"); //$NON-NLS-1$ + static final String DELIMITER= PreferencesMessages.CEditorHoverConfigurationBlock_delimiter; private static final int ENABLED_PROP= 0; private static final int MODIFIER_PROP= 1; @@ -204,7 +205,7 @@ public class CEditorHoverConfigurationBlock { // Disable/enable editor problem annotaion checkbox fShowEditorAnnotationCheckbox = new Button(hoverComposite, SWT.CHECK); - fShowEditorAnnotationCheckbox.setText(PreferencesMessages.getString("CEditorPreferencePage.behaviourPage.EnableEditorProblemAnnotation")); //$NON-NLS-1$ + fShowEditorAnnotationCheckbox.setText(PreferencesMessages.CEditorPreferencePage_behaviourPage_EnableEditorProblemAnnotation); gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent= 0; gd.horizontalSpan= 2; @@ -213,7 +214,7 @@ public class CEditorHoverConfigurationBlock { addFiller(hoverComposite); Label label= new Label(hoverComposite, SWT.NONE); - label.setText(PreferencesMessages.getString("CEditorHoverConfigurationBlock.hoverPreferences")); //$NON-NLS-1$ + label.setText(PreferencesMessages.CEditorHoverConfigurationBlock_hoverPreferences); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; @@ -245,11 +246,11 @@ public class CEditorHoverConfigurationBlock { fHoverTable.setLayout(tableLayout); fNameColumn= new TableColumn(fHoverTable, SWT.NONE); - fNameColumn.setText(PreferencesMessages.getString("CEditorHoverConfigurationBlock.nameColumnTitle")); //$NON-NLS-1$ + fNameColumn.setText(PreferencesMessages.CEditorHoverConfigurationBlock_nameColumnTitle); fNameColumn.setResizable(true); fModifierColumn= new TableColumn(fHoverTable, SWT.NONE); - fModifierColumn.setText(PreferencesMessages.getString("CEditorHoverConfigurationBlock.modifierColumnTitle")); //$NON-NLS-1$ + fModifierColumn.setText(PreferencesMessages.CEditorHoverConfigurationBlock_modifierColumnTitle); fModifierColumn.setResizable(true); fHoverTableViewer= new CheckboxTableViewer(fHoverTable); @@ -283,7 +284,7 @@ public class CEditorHoverConfigurationBlock { // Text field for modifier string label= new Label(hoverComposite, SWT.LEFT); - label.setText(PreferencesMessages.getString("CEditorHoverConfigurationBlock.keyModifier")); //$NON-NLS-1$ + label.setText(PreferencesMessages.CEditorHoverConfigurationBlock_keyModifier); fModifierEditor= new Text(hoverComposite, SWT.BORDER); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); fModifierEditor.setLayoutData(gd); @@ -313,11 +314,11 @@ public class CEditorHoverConfigurationBlock { String insertString; if (needsPrefixDelimiter && needsPostfixDelimiter) - insertString= PreferencesMessages.getFormattedString("CEditorHoverConfigurationBlock.insertDelimiterAndModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$ + insertString= NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter, new String[] {Action.findModifierString(e.stateMask)}); else if (needsPrefixDelimiter) - insertString= PreferencesMessages.getFormattedString("CEditorHoverConfigurationBlock.insertDelimiterAndModifier", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$ + insertString= NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_insertDelimiterAndModifier, new String[] {Action.findModifierString(e.stateMask)}); else if (needsPostfixDelimiter) - insertString= PreferencesMessages.getFormattedString("CEditorHoverConfigurationBlock.insertModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$ + insertString= NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_insertModifierAndDelimiter, new String[] {Action.findModifierString(e.stateMask)}); else insertString= Action.findModifierString(e.stateMask); @@ -335,7 +336,7 @@ public class CEditorHoverConfigurationBlock { // Description Label descriptionLabel= new Label(hoverComposite, SWT.LEFT); - descriptionLabel.setText(PreferencesMessages.getString("CEditorHoverConfigurationBlock.description")); //$NON-NLS-1$ + descriptionLabel.setText(PreferencesMessages.CEditorHoverConfigurationBlock_description); gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.horizontalSpan= 2; descriptionLabel.setLayoutData(gd); @@ -496,7 +497,7 @@ public class CEditorHoverConfigurationBlock { fHoverConfigs[i].fModifierString= modifiers; fHoverConfigs[i].fStateMask= CEditorTextHoverDescriptor.computeStateMask(modifiers); if (fHoverConfigs[i].fIsEnabled && fHoverConfigs[i].fStateMask == -1) - fStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getFormattedString("CEditorHoverConfigurationBlock.modifierIsNotValid", fHoverConfigs[i].fModifierString)); //$NON-NLS-1$ + fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValid, fHoverConfigs[i].fModifierString)); else fStatus= new StatusInfo(); @@ -532,7 +533,7 @@ public class CEditorHoverConfigurationBlock { void updateStatus(HoverConfig hoverConfig) { if (hoverConfig != null && hoverConfig.fIsEnabled && hoverConfig.fStateMask == -1) - fStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getFormattedString("CEditorHoverConfigurationBlock.modifierIsNotValid", hoverConfig.fModifierString)); //$NON-NLS-1$ + fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValid, hoverConfig.fModifierString)); else fStatus= new StatusInfo(); @@ -543,9 +544,9 @@ public class CEditorHoverConfigurationBlock { String label= getContributedHovers()[i].getLabel(); Integer stateMask= new Integer(fHoverConfigs[i].fStateMask); if (fHoverConfigs[i].fStateMask == -1) - fStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getFormattedString("CEditorHoverConfigurationBlock.modifierIsNotValidForHover", new String[] {fHoverConfigs[i].fModifierString, label})); //$NON-NLS-1$ + fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValidForHover, new String[] {fHoverConfigs[i].fModifierString, label})); else if (stateMasks.containsKey(stateMask)) - fStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getFormattedString("CEditorHoverConfigurationBlock.duplicateModifier", new String[] {label, (String)stateMasks.get(stateMask)})); //$NON-NLS-1$ + fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, (String)stateMasks.get(stateMask)})); else stateMasks.put(stateMask, label); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java index b7929c269f8..0143a7a7738 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java @@ -12,17 +12,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; import java.util.ArrayList; import org.eclipse.jface.preference.ColorSelector; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -51,39 +45,20 @@ import org.eclipse.cdt.utils.ui.controls.TabFolderLayout; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.editor.CEditor; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; -import org.eclipse.cdt.internal.ui.text.CTextTools; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; /* * The page for setting the editor options. */ public class CEditorPreferencePage extends AbstractPreferencePage implements IWorkbenchPreferencePage { - protected final String[][] fListModel = new String[][] { { PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.MultiLine"), ICColorConstants.C_MULTI_LINE_COMMENT }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.singleLine"), ICColorConstants.C_SINGLE_LINE_COMMENT }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.keywords"), ICColorConstants.C_KEYWORD }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.builtInTypes"), ICColorConstants.C_TYPE }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.strings"), ICColorConstants.C_STRING }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.operators"), ICColorConstants.C_OPERATOR }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.braces"), ICColorConstants.C_BRACES }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.numbers"), ICColorConstants.C_NUMBER }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.headers"), ICColorConstants.C_HEADER }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.others"), ICColorConstants.C_DEFAULT }, { //$NON-NLS-1$ - PreferencesMessages.getString("CEditorPreferencePage.syntaxPage.cCommentTaskTags"), PreferenceConstants.EDITOR_TASK_TAG_COLOR } //$NON-NLS-1$ - }; - protected final String[][] fAppearanceColorListModel = new String[][] { - {PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.matchingBracketColor"), CEditor.MATCHING_BRACKETS_COLOR, null }, //$NON-NLS-1$ - {PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.inactiveCodeColor"), CEditor.INACTIVE_CODE_COLOR, null }, //$NON-NLS-1$ + {PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor, CEditor.MATCHING_BRACKETS_COLOR, null }, + {PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCodeColor, CEditor.INACTIVE_CODE_COLOR, null }, }; - private CTextTools fCTextTools; - protected List fList; protected ColorSelector fForegroundColorEditor; protected Button fBoldCheckBox; - protected PreviewSourceViewer fPreviewViewer; private CEditorHoverConfigurationBlock fCEditorHoverConfigurationBlock; private FoldingConfigurationBlock fFoldingConfigurationBlock; @@ -103,38 +78,12 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { ArrayList overlayKeys = new ArrayList(); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_MULTI_LINE_COMMENT)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_MULTI_LINE_COMMENT + "_bold")); //$NON-NLS-1$ - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_SINGLE_LINE_COMMENT)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_SINGLE_LINE_COMMENT + "_bold")); //$NON-NLS-1$ - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_KEYWORD)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_KEYWORD + "_bold")); //$NON-NLS-1$ - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_TYPE)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_TYPE + "_bold")); //$NON-NLS-1$ - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_STRING)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_STRING + "_bold")); //$NON-NLS-1$ - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_DEFAULT)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_DEFAULT + "_bold")); //$NON-NLS-1$ - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_BRACES)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_BRACES + "_bold")); //$NON-NLS-1$ - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_NUMBER)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_NUMBER + "_bold")); //$NON-NLS-1$ - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_OPERATOR)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_OPERATOR + "_bold")); //$NON-NLS-1$ - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_HEADER)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_HEADER + "_bold")); //$NON-NLS-1$ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SUB_WORD_NAVIGATION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.MATCHING_BRACKETS_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.INACTIVE_CODE_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.INACTIVE_CODE_ENABLE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SPACES_FOR_TABS)); - - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.ENSURE_NEWLINE_AT_EOF)); OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; @@ -164,36 +113,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo store.setDefault(CEditor.SPACES_FOR_TABS, false); - PreferenceConverter.setDefault(store, ICColorConstants.C_MULTI_LINE_COMMENT, new RGB(63, 127, 95)); - store.setDefault(ICColorConstants.C_MULTI_LINE_COMMENT + "_bold", false); //$NON-NLS-1$ - - PreferenceConverter.setDefault(store, ICColorConstants.C_SINGLE_LINE_COMMENT, new RGB(63, 125, 95)); - store.setDefault(ICColorConstants.C_SINGLE_LINE_COMMENT + "_bold", false); //$NON-NLS-1$ - - PreferenceConverter.setDefault(store, ICColorConstants.C_KEYWORD, new RGB(127, 0, 85)); - store.setDefault(ICColorConstants.C_KEYWORD + "_bold", true); //$NON-NLS-1$ - - PreferenceConverter.setDefault(store, ICColorConstants.C_TYPE, new RGB(127, 0, 85)); - store.setDefault(ICColorConstants.C_TYPE + "_bold", true); //$NON-NLS-1$ - - PreferenceConverter.setDefault(store, ICColorConstants.C_STRING, new RGB(42, 0, 255)); - store.setDefault(ICColorConstants.C_STRING + "_bold", false); //$NON-NLS-1$ - - PreferenceConverter.setDefault(store, ICColorConstants.C_DEFAULT, new RGB(0, 0, 0)); - store.setDefault(ICColorConstants.C_DEFAULT + "_bold", false); //$NON-NLS-1$ - - PreferenceConverter.setDefault(store, ICColorConstants.C_OPERATOR, new RGB(0, 0, 0)); - store.setDefault(ICColorConstants.C_OPERATOR + "_bold", false); //$NON-NLS-1$ - - PreferenceConverter.setDefault(store, ICColorConstants.C_BRACES, new RGB(0, 0, 0)); - store.setDefault(ICColorConstants.C_BRACES + "_bold", false); //$NON-NLS-1$ - - PreferenceConverter.setDefault(store, ICColorConstants.C_HEADER, new RGB(42, 0, 255)); - store.setDefault(ICColorConstants.C_HEADER + "_bold", false); //$NON-NLS-1$ - - PreferenceConverter.setDefault(store, ICColorConstants.C_NUMBER, new RGB(0, 0, 0)); - store.setDefault(ICColorConstants.C_NUMBER + "_bold", false); //$NON-NLS-1$ - } /* @@ -204,131 +123,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_EDITOR_PREF_PAGE); } - protected void handleListSelection() { - int i = fList.getSelectionIndex(); - String key = fListModel[i][1]; - RGB rgb = PreferenceConverter.getColor(fOverlayStore, key); - fForegroundColorEditor.setColorValue(rgb); - fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + "_bold")); //$NON-NLS-1$ - } - - private Control createSyntaxPage(Composite parent) { - - Composite colorComposite = new Composite(parent, SWT.NULL); - colorComposite.setLayout(new GridLayout()); - - Label label = new Label(colorComposite, SWT.LEFT); - label.setText(PreferencesMessages.getString("CEditorPreferencePage.colorPage.foreground")); //$NON-NLS-1$ - label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite editorComposite = new Composite(colorComposite, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginWidth = 0; - editorComposite.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - editorComposite.setLayoutData(gd); - - fList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); - gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = convertHeightInCharsToPixels(5); - fList.setLayoutData(gd); - - Composite stylesComposite = new Composite(editorComposite, SWT.NULL); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.numColumns = 2; - stylesComposite.setLayout(layout); - stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - label = new Label(stylesComposite, SWT.LEFT); - label.setText(PreferencesMessages.getString("CEditorPreferencePage.colorPage.color")); //$NON-NLS-1$ - gd = new GridData(); - gd.horizontalAlignment = GridData.BEGINNING; - label.setLayoutData(gd); - - fForegroundColorEditor = new ColorSelector(stylesComposite); - Button foregroundColorButton = fForegroundColorEditor.getButton(); - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalAlignment = GridData.BEGINNING; - foregroundColorButton.setLayoutData(gd); - - fBoldCheckBox = new Button(stylesComposite, SWT.CHECK); - fBoldCheckBox.setText(PreferencesMessages.getString("CEditorPreferencePage.colorPage.bold")); //$NON-NLS-1$ - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan=2; - gd.horizontalAlignment = GridData.BEGINNING; - fBoldCheckBox.setLayoutData(gd); - - label = new Label(colorComposite, SWT.LEFT); - label.setText(PreferencesMessages.getString("CEditorPreferencePage.colorPage.preview")); //$NON-NLS-1$ - label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Control previewer = createPreviewer(colorComposite); - gd = new GridData(GridData.FILL_BOTH); - gd.widthHint = convertWidthInCharsToPixels(80); - gd.heightHint = convertHeightInCharsToPixels(15); - previewer.setLayoutData(gd); - - fList.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing - } - public void widgetSelected(SelectionEvent e) { - handleListSelection(); - } - }); - - foregroundColorButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing - } - public void widgetSelected(SelectionEvent e) { - int i = fList.getSelectionIndex(); - String key = fListModel[i][1]; - - PreferenceConverter.setValue(fOverlayStore, key, fForegroundColorEditor.getColorValue()); - } - }); - - fBoldCheckBox.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing - } - public void widgetSelected(SelectionEvent e) { - int i = fList.getSelectionIndex(); - String key = fListModel[i][1]; - fOverlayStore.setValue(key + "_bold", fBoldCheckBox.getSelection()); //$NON-NLS-1$ - } - }); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(colorComposite, ICHelpContextIds.C_EDITOR_COLORS_PREF_PAGE); - - return colorComposite; - } - - private Control createPreviewer(Composite parent) { - - fCTextTools = CUIPlugin.getDefault().getTextTools(); - CSourceViewerConfiguration configuration = new CSourceViewerConfiguration(fCTextTools, null); - fPreviewViewer = new PreviewSourceViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); - fPreviewViewer.setPreferenceStore(CUIPlugin.getDefault().getCombinedPreferenceStore()); - fPreviewViewer.configure(configuration); - fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); - fPreviewViewer.setEditable(false); - - String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$ - IDocument document = new Document(content); - fCTextTools.setupCDocument(document); - - fPreviewViewer.setDocument(document); - - CSourcePreviewerUpdater.registerPreviewer(fPreviewViewer, configuration, fOverlayStore); - return fPreviewViewer.getControl(); - } - // sets enabled flag for a control and all its sub-tree protected static void setEnabled(Control control, boolean enable) { control.setEnabled(enable); @@ -347,19 +141,19 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo layout.numColumns = 2; behaviorComposite.setLayout(layout); - String label= PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.subWordNavigation"); //$NON-NLS-1$; + String label= PreferencesMessages.CEditorPreferencePage_behaviorPage_subWordNavigation; addCheckBox(behaviorComposite, label, CEditor.SUB_WORD_NAVIGATION, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.matchingBrackets"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBrackets; addCheckBox(behaviorComposite, label, CEditor.MATCHING_BRACKETS, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.inactiveCode"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCode; addCheckBox(behaviorComposite, label, CEditor.INACTIVE_CODE_ENABLE, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.tabSpace"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_behaviorPage_tabSpace; addCheckBox(behaviorComposite, label, CEditor.SPACES_FOR_TABS, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.ensureNewline"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_behaviorPage_ensureNewline; addCheckBox(behaviorComposite, label, PreferenceConstants.ENSURE_NEWLINE_AT_EOF, 0); Label l = new Label(behaviorComposite, SWT.LEFT); @@ -369,7 +163,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo l.setLayoutData(gd); l = new Label(behaviorComposite, SWT.LEFT); - l.setText(PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.appearanceColorOptions")); //$NON-NLS-1$ + l.setText(PreferencesMessages.CEditorPreferencePage_behaviorPage_appearanceColorOptions); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 2; l.setLayoutData(gd); @@ -398,7 +192,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); l = new Label(stylesComposite, SWT.LEFT); - l.setText(PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.Color")); //$NON-NLS-1$ + l.setText(PreferencesMessages.CEditorPreferencePage_behaviorPage_Color); gd = new GridData(); gd.horizontalAlignment = GridData.BEGINNING; l.setLayoutData(gd); @@ -422,7 +216,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo }; fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK); - fAppearanceColorDefault.setText(PreferencesMessages.getString("CEditorPreferencePage.colorPage.systemDefault")); //$NON-NLS-1$ + fAppearanceColorDefault.setText(PreferencesMessages.CEditorPreferencePage_colorPage_systemDefault); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; @@ -468,7 +262,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo } private Control createHeader(Composite parent) { - String text = PreferencesMessages.getString("CEditorPreferencePage.link"); //$NON-NLS-1$ + String text = PreferencesMessages.CEditorPreferencePage_link; Link link = new Link(parent, SWT.NONE); link.setText(text); link.addListener (SWT.Selection, new Listener () { @@ -502,19 +296,15 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo folder.setLayoutData(new GridData(GridData.FILL_BOTH)); TabItem item = new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.getString("CEditorPreferencePage.generalTabTitle")); //$NON-NLS-1$ + item.setText(PreferencesMessages.CEditorPreferencePage_generalTabTitle); item.setControl(createAppearancePage(folder)); - item = new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.getString("CEditorPreferencePage.colorsTabTitle")); //$NON-NLS-1$ - item.setControl(createSyntaxPage(folder)); - item= new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.getString("CEditorPreferencePage.hoverTab.title")); //$NON-NLS-1$ + item.setText(PreferencesMessages.CEditorPreferencePage_hoverTab_title); item.setControl(fCEditorHoverConfigurationBlock.createControl(folder)); item= new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.getString("CEditorPreferencePage.folding.title")); //$NON-NLS-1$ + item.setText(PreferencesMessages.CEditorPreferencePage_folding_title); item.setControl(fFoldingConfigurationBlock.createControl(folder)); initialize(); @@ -536,16 +326,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo } }); - for (int i = 0; i < fListModel.length; i++) { - fList.add(fListModel[i][0]); - } - fList.getDisplay().asyncExec(new Runnable() { - public void run() { - fList.select(0); - handleListSelection(); - } - }); - fFoldingConfigurationBlock.initialize(); } @@ -567,12 +347,10 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo super.performDefaults(); handleAppearanceColorListSelection(); - handleListSelection(); fCEditorHoverConfigurationBlock.performDefaults(); fFoldingConfigurationBlock.performDefaults(); - fPreviewViewer.invalidateTextPresentation(); } /* @@ -582,10 +360,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo fFoldingConfigurationBlock.dispose(); - if (fCTextTools != null) { - fCTextTools = null; - } - if (fOverlayStore != null) { fOverlayStore.stop(); fOverlayStore = null; @@ -594,29 +368,4 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo super.dispose(); } - - private String loadPreviewContentFromFile(String filename) { - String line; - String separator = System.getProperty("line.separator"); //$NON-NLS-1$ - StringBuffer buffer = new StringBuffer(512); - BufferedReader reader = null; - try { - reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename))); - while ((line = reader.readLine()) != null) { - buffer.append(line); - buffer.append(separator); - } - } catch (IOException io) { - CUIPlugin.getDefault().log(io); - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - } - } - } - return buffer.toString(); - } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java index e02d7b62fda..c14d88dc916 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java @@ -45,7 +45,7 @@ public class CFileTypeDialog extends Dialog { protected void configureShell(Shell newShell) { super.configureShell(newShell); - newShell.setText(PreferencesMessages.getString("CFileTypeDialog.title")); //$NON-NLS-1$ + newShell.setText(PreferencesMessages.CFileTypeDialog_title); } protected void createButtonsForButtonBar(Composite parent) { @@ -63,7 +63,7 @@ public class CFileTypeDialog extends Dialog { Label pattern = new Label(composite, SWT.NONE); - pattern.setText(PreferencesMessages.getString("CFileTypeDialog.patternLabel")); //$NON-NLS-1$ + pattern.setText(PreferencesMessages.CFileTypeDialog_patternLabel); fTextPattern = new Text(composite, SWT.BORDER | SWT.SINGLE); @@ -83,7 +83,7 @@ public class CFileTypeDialog extends Dialog { Label type = new Label(composite, SWT.NONE); - type.setText(PreferencesMessages.getString("CFileTypeDialog.typeLabel")); //$NON-NLS-1$ + type.setText(PreferencesMessages.CFileTypeDialog_typeLabel); fComboType = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.SINGLE); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java index 4b4eda19567..e4e243889d4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java @@ -132,9 +132,9 @@ public class CFileTypesPreferenceBlock { case COL_STATUS: if (assoc.isUserDefined()) { - return PreferencesMessages.getString("CFileTypesPreferencePage.userDefined"); //$NON-NLS-1$ + return PreferencesMessages.CFileTypesPreferencePage_userDefined; } else if (assoc.isPredefined()) { - return PreferencesMessages.getString("CFileTypesPreferencePage.preDefined"); //$NON-NLS-1$ + return PreferencesMessages.CFileTypesPreferencePage_preDefined; } return new String(); } @@ -223,13 +223,13 @@ public class CFileTypesPreferenceBlock { table.setLinesVisible(true); col = new TableColumn(table, SWT.LEFT); - col.setText(PreferencesMessages.getString("CFileTypesPreferencePage.colTitlePattern")); //$NON-NLS-1$ + col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitlePattern); col = new TableColumn(table, SWT.LEFT); - col.setText(PreferencesMessages.getString("CFileTypesPreferencePage.colTitleDescription")); //$NON-NLS-1$ + col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitleDescription); col = new TableColumn(table, SWT.LEFT); - col.setText(PreferencesMessages.getString("CFileTypesPreferencePage.colTitleStatus")); //$NON-NLS-1$ + col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitleStatus); // Create the button pane @@ -245,7 +245,7 @@ public class CFileTypesPreferenceBlock { // New button fBtnNew = new Button(buttonPane, SWT.PUSH); - fBtnNew.setText(PreferencesMessages.getString("CFileTypesPreferenceBlock.New...")); //$NON-NLS-1$ + fBtnNew.setText(PreferencesMessages.CFileTypesPreferenceBlock_New___); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnNew); @@ -260,7 +260,7 @@ public class CFileTypesPreferenceBlock { // Remove button fBtnRemove = new Button(buttonPane, SWT.PUSH); - fBtnRemove.setText(PreferencesMessages.getString("CFileTypesPreferenceBlock.Remove")); //$NON-NLS-1$ + fBtnRemove.setText(PreferencesMessages.CFileTypesPreferenceBlock_Remove); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnRemove); @@ -508,7 +508,7 @@ public class CFileTypesPreferenceBlock { settings= assoc.getContentType().getSettings(new ProjectScope(fInput)); } catch (CoreException e) { ErrorDialog.openError(fBtnNew.getParent().getShell(), - PreferencesMessages.getString("CFileTypesPreferenceBlock.addAssociationError.title"), //$NON-NLS-1$ + PreferencesMessages.CFileTypesPreferenceBlock_addAssociationError_title, null, e.getStatus()); return false; } @@ -538,8 +538,8 @@ public class CFileTypesPreferenceBlock { private void reportDuplicateAssociation(CFileTypeAssociation assoc) { MessageDialog.openError(fBtnNew.getParent().getShell(), - PreferencesMessages.getString("CFileTypesPreferenceBlock.addAssociationError.title"), //$NON-NLS-1$ - Messages.format(PreferencesMessages.getString("CFileTypesPreferenceBlock.addAssociationErrorMessage"), //$NON-NLS-1$ + PreferencesMessages.CFileTypesPreferenceBlock_addAssociationError_title, + Messages.format(PreferencesMessages.CFileTypesPreferenceBlock_addAssociationErrorMessage, assoc.getPattern(), assoc.getContentType().getName())); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java index ec6615632ab..d3d44318d87 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java @@ -33,7 +33,7 @@ public class CFileTypesPreferencePage extends PreferencePage implements IWorkben private CFileTypesPreferenceBlock fPrefsBlock; public CFileTypesPreferencePage() { - setDescription(PreferencesMessages.getString("CFileTypesPreferencePage.description")); //$NON-NLS-1$ + setDescription(PreferencesMessages.CFileTypesPreferencePage_description); noDefaultAndApplyButton(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java index dd7a5faf5da..8ec0365b6f0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java @@ -121,7 +121,7 @@ public class CFileTypesPropertyPage extends PropertyPage { radioPane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fUseWorkspace = new Button(radioPane, SWT.RADIO); - fUseWorkspace.setText(PreferencesMessages.getString("CFileTypesPropertyPage.useWorkspaceSettings")); //$NON-NLS-1$ + fUseWorkspace.setText(PreferencesMessages.CFileTypesPropertyPage_useWorkspaceSettings); fUseWorkspace.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { if (fUseWorkspace.getSelection()) { @@ -135,7 +135,7 @@ public class CFileTypesPropertyPage extends PropertyPage { boolean custom = CCorePlugin.usesProjectSpecificContentTypes(project); fUseProject = new Button(radioPane, SWT.RADIO); - fUseProject.setText(PreferencesMessages.getString("CFileTypesPropertyPage.useProjectSettings")); //$NON-NLS-1$ + fUseProject.setText(PreferencesMessages.CFileTypesPropertyPage_useProjectSettings); fUseProject.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { if (fUseProject.getSelection()) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java index 712b8ce28dc..1ee098e9930 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java @@ -76,9 +76,9 @@ public class CParserPreferencePage extends PreferencePage implements Group bufferGroup= new Group(result, SWT.NONE); bufferGroup.setLayout(new GridLayout()); bufferGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - bufferGroup.setText(PreferencesMessages.getString("CBufferPreferences.CodeReaderBuffer.CodeReaderBufferGroup")); //$NON-NLS-1$ + bufferGroup.setText(PreferencesMessages.CBufferPreferences_CodeReaderBuffer_CodeReaderBufferGroup); - bufferTextControl = (Text) addTextField( bufferGroup, PreferencesMessages.getString("CBufferPreferences.CodeReaderBuffer.Size"),6,0); //$NON-NLS-1$ + bufferTextControl = (Text) addTextField( bufferGroup, PreferencesMessages.CBufferPreferences_CodeReaderBuffer_Size,6,0); initialize(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java index 3a8eb4e6ba5..f61bf381e00 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 QNX Software Systems and others. + * Copyright (c) 2000, 2006 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,11 +7,11 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.source.SourceViewer; @@ -22,13 +22,17 @@ import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Font; +import org.eclipse.cdt.ui.PreferenceConstants; + +import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; + public class CSourcePreviewerUpdater { private CSourcePreviewerUpdater() { } /** - * Creates a Java source preview updater for the given viewer, configuration and preference store. + * Creates a source preview updater for the given viewer, configuration and preference store. * * @param viewer the viewer * @param configuration the configuration @@ -43,8 +47,8 @@ public class CSourcePreviewerUpdater { * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(JFaceResources.TEXT_FONT)) { - Font font= JFaceResources.getTextFont(); + if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) { + Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java index d309fe57cb0..71c6476ed41 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java @@ -12,11 +12,7 @@ package org.eclipse.cdt.internal.ui.preferences; -import org.eclipse.cdt.internal.ui.ICHelpContextIds; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; -import org.eclipse.cdt.internal.ui.text.CTextTools; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; @@ -31,6 +27,14 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.templates.TemplatePreferencePage; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; + +import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.editor.CSourceViewer; +import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; +import org.eclipse.cdt.internal.ui.text.CTextTools; + /** * CTemplatePreferencePage */ @@ -70,8 +74,8 @@ public class CTemplatePreferencePage extends TemplatePreferencePage { * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createViewer(org.eclipse.swt.widgets.Composite) */ protected SourceViewer createViewer(Composite parent) { - PreviewSourceViewer viewer= new PreviewSourceViewer(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - viewer.setPreferenceStore(CUIPlugin.getDefault().getCombinedPreferenceStore()); + IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore(); + CSourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); CTextTools tools= CUIPlugin.getDefault().getTextTools(); CSourceViewerConfiguration configuration = new CSourceViewerConfiguration(tools, null); IDocument document = new Document(); @@ -90,7 +94,7 @@ public class CTemplatePreferencePage extends TemplatePreferencePage { control.getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { - e.result = PreferencesMessages.getString("TemplatePreferencePage.preview"); //$NON-NLS-1$ + e.result = PreferencesMessages.TemplatePreferencePage_Viewer_preview; }}); CSourcePreviewerUpdater.registerPreviewer(viewer, configuration, CUIPlugin.getDefault().getCombinedPreferenceStore()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java index 861a54c24b5..b285235c1e2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java @@ -80,54 +80,54 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage { //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // The following three radio buttons are grouped together - String label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupTitle"); //$NON-NLS-1$ + String label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupTitle; Group searchGroup = addGroupBox(contentAssistComposite, label, 2); - label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentFileOption"); //$NON-NLS-1$ + label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption; addRadioButton(searchGroup, label, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, 0); - label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectOption"); //$NON-NLS-1$ + label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption; addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_SEARCH_SCOPE, 0); //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertionGroupTitle"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertionGroupTitle; Group insertionGroup = addGroupBox(contentAssistComposite, label, 2); - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically; addCheckBox(insertionGroup, label, ContentAssistPreference.AUTOINSERT, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertCommonProposalAutomatically"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically; addCheckBox(insertionGroup, label, ContentAssistPreference.CODEASSIST_PREFIX_COMPLETION, 0); - label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder"); //$NON-NLS-1$ + label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder; addCheckBox(insertionGroup, label, ContentAssistPreference.ORDER_PROPOSALS, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.timeoutDelay"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_timeoutDelay; addTextField(insertionGroup, label, ContentAssistPreference.TIMEOUT_DELAY, 6, 0, true); //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // The following items are grouped for Auto Activation - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle; Group enableGroup = addGroupBox(contentAssistComposite, label, 2); - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot; addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow; addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationEnableDoubleColon"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon; addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationDelay"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationDelay; addTextField(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true); //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalBackgroundColor"); //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor; addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_BACKGROUND, 0); - label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.completionProposalForegroundColor"); //$NON-NLS-1$ + label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor; addColorButton(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_FOREGROUND, 0); // label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterBackgroundColor"); @@ -136,7 +136,7 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage { // label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.parameterForegroundColor"); // addColorButton(contentAssistComposite, label, ContentAssistPreference.PARAMETERS_FOREGROUND, 0); - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.proposalFilterSelect") ; //$NON-NLS-1$ + label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_proposalFilterSelect ; addComboBox(contentAssistComposite, label, ContentAssistPreference.PROPOSALS_FILTER, 20, 0); initializeFields(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java index 6cafb71fe8a..39fb0b2f9dc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java @@ -37,7 +37,7 @@ public class CodeFormatterPreferencePage extends PreferencePage implements IWork public CodeFormatterPreferencePage() { setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); // only used when page is shown programatically - setTitle(PreferencesMessages.getString("CodeFormatterPreferencePage.title")); //$NON-NLS-1$ + setTitle(PreferencesMessages.CodeFormatterPreferencePage_title); //setDescription(PreferencesMessages.getString("CodeFormatterPreferencePage.description")); //$NON-NLS-1$ fCodeFormatterBlock= new CodeFormatterBlock(CUIPlugin.getDefault().getPluginPreferences()); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt index 1a7e359c3dc..87c1bb354bb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt @@ -1,10 +1,23 @@ -/* - * This is sample C code - */ -#include -unsigned static myfunc(int a, char b,) { - /* This comment may span multiple lines. */ - int integer= 0; - // This comment may span only this line - if(integer == 0) printf("zero"); -} \ No newline at end of file +/* This is sample C++ code */ +#include +#define MACRO(x) x +using namespace std; +// This comment may span only this line +typedef unsigned int uint; +int static myfunc(uint parameter) { + if (parameter == 0) out << "zero" << endl; + return parameter - 1; +} +class MyClass { +public: + enum Number { ZERO, ONE, TWO }; + static char staticField; + int field; + virtual Number vmethod(); + void method(Number n) const { + int local= (int)n; +label: myfunc(local, MACRO('\0')); + vmethod(); + problem(); + } +}; \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java index f530b2dbd6a..f3373d06036 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java @@ -156,7 +156,7 @@ class FoldingConfigurationBlock { /* check box for new editors */ fFoldingCheckbox= new Button(composite, SWT.CHECK); - fFoldingCheckbox.setText(PreferencesMessages.getString("FoldingConfigurationBlock.enable")); //$NON-NLS-1$ + fFoldingCheckbox.setText(PreferencesMessages.FoldingConfigurationBlock_enable); gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fFoldingCheckbox.setLayoutData(gd); fFoldingCheckbox.addSelectionListener(new SelectionListener() { @@ -184,7 +184,7 @@ class FoldingConfigurationBlock { Label comboLabel= new Label(comboComp, SWT.CENTER); gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER); comboLabel.setLayoutData(gd); - comboLabel.setText(PreferencesMessages.getString("FoldingConfigurationBlock.combo_caption")); //$NON-NLS-1$ + comboLabel.setText(PreferencesMessages.FoldingConfigurationBlock_combo_caption); label= new Label(composite, SWT.CENTER); gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); @@ -273,7 +273,7 @@ class FoldingConfigurationBlock { if (desc == null) { // safety in case there is no such descriptor - String message= PreferencesMessages.getString("FoldingConfigurationBlock.error.not_exist"); //$NON-NLS-1$ + String message= PreferencesMessages.FoldingConfigurationBlock_error_not_exist; CUIPlugin.getDefault().log(new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null)); prefs= new ErrorPreferences(message); } else { @@ -293,7 +293,7 @@ class FoldingConfigurationBlock { if (control == null) { control= prefs.createControl(fGroup); if (control == null) { - String message= PreferencesMessages.getString("FoldingConfigurationBlock.info.no_preferences"); //$NON-NLS-1$ + String message= PreferencesMessages.FoldingConfigurationBlock_info_no_preferences; control= new ErrorPreferences(message).createControl(fGroup); } else { fProviderControls.put(id, control); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java new file mode 100644 index 00000000000..ce6608d8661 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.preferences; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + + +/** + * Interface for preference configuration blocks which can either be + * wrapped by a {@link org.eclipse.cdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage} + * or be included some preference page. + *

+ * Clients may implement this interface. + *

+ * + * @since 4.0 + */ +public interface IPreferenceConfigurationBlock { + + /** + * Creates the preference control. + * + * @param parent the parent composite to which to add the preferences control + * @return the control that was added to parent + */ + Control createControl(Composite parent); + + /** + * Called after creating the control. Implementations should load the + * preferences values and update the controls accordingly. + */ + void initialize(); + + /** + * Called when the OK button is pressed on the preference + * page. Implementations should commit the configured preference settings + * into their form of preference storage. + */ + void performOk(); + + /** + * Called when the Defaults button is pressed on the + * preference page. Implementation should reset any preference settings to + * their default values and adjust the controls accordingly. + */ + void performDefaults(); + + /** + * Called when the preference page is being disposed. Implementations should + * free any resources they are holding on to. + */ + void dispose(); +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java index 336fc67bf8c..c3a8b5d25d9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java @@ -41,7 +41,7 @@ public class IndexerPreferencePage extends PreferencePage implements public IndexerPreferencePage(){ setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); - setDescription(PreferencesMessages.getString("IndexerPrefs.description")); //$NON-NLS-1$ + setDescription(PreferencesMessages.IndexerPrefs_description); fOptionBlock = new IndexerBlock(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java index 8dbeb93d4d6..94ad696cec3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java @@ -25,6 +25,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -353,10 +354,10 @@ public abstract class OptionsConfigurationBlock { monitor.beginTask("", 1); //$NON-NLS-1$ try { if (fProject != null) { - monitor.setTaskName(PreferencesMessages.getFormattedString("OptionsConfigurationBlock.buildproject.taskname", fProject.getElementName())); //$NON-NLS-1$ + monitor.setTaskName(NLS.bind(PreferencesMessages.OptionsConfigurationBlock_buildproject_taskname, fProject.getElementName())); fProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor,1)); } else { - monitor.setTaskName(PreferencesMessages.getString("OptionsConfigurationBlock.buildall.taskname")); //$NON-NLS-1$ + monitor.setTaskName(PreferencesMessages.OptionsConfigurationBlock_buildall_taskname); CUIPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new SubProgressMonitor(monitor,1)); } } catch (CoreException e) { @@ -369,8 +370,8 @@ public abstract class OptionsConfigurationBlock { } catch (InterruptedException e) { // cancelled by user } catch (InvocationTargetException e) { - String title= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.title"); //$NON-NLS-1$ - String message= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.message"); //$NON-NLS-1$ + String title= PreferencesMessages.OptionsConfigurationBlock_builderror_title; + String message= PreferencesMessages.OptionsConfigurationBlock_builderror_message; ExceptionHandler.handle(e, getShell(), title, message); } } @@ -383,10 +384,10 @@ public abstract class OptionsConfigurationBlock { monitor.beginTask("", 1); //$NON-NLS-1$ if (fProject != null) { - monitor.setTaskName(PreferencesMessages.getFormattedString("OptionsConfigurationBlock.parseproject.taskname", fProject.getElementName())); //$NON-NLS-1$ + monitor.setTaskName(NLS.bind(PreferencesMessages.OptionsConfigurationBlock_parseproject_taskname, fProject.getElementName())); reParseHierarchy(fProject.getResource(), monitor); } else { - monitor.setTaskName(PreferencesMessages.getString("OptionsConfigurationBlock.parseall.taskname")); //$NON-NLS-1$ + monitor.setTaskName(PreferencesMessages.OptionsConfigurationBlock_parseall_taskname); reParseHierarchy(CUIPlugin.getWorkspace().getRoot(), monitor); } @@ -396,8 +397,8 @@ public abstract class OptionsConfigurationBlock { } catch (InterruptedException e) { // cancelled by user } catch (InvocationTargetException e) { - String title= PreferencesMessages.getString("OptionsConfigurationBlock.parseerror.title"); //$NON-NLS-1$ - String message= PreferencesMessages.getString("OptionsConfigurationBlock.parseerror.message"); //$NON-NLS-1$ + String title= PreferencesMessages.OptionsConfigurationBlock_parseerror_title; + String message= PreferencesMessages.OptionsConfigurationBlock_parseerror_message; ExceptionHandler.handle(e, getShell(), title, message); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java index c4d8c145b48..f237f2b28c7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java @@ -159,11 +159,9 @@ public class PathEntryVariableDialog extends TitleAreaDialog { this.namesInUse = namesInUse; if (newVariable) - this.standardMessage = PreferencesMessages - .getString("PathEntryVariableDialog.message.newVariable"); //$NON-NLS-1$ + this.standardMessage = PreferencesMessages.PathEntryVariableDialog_message_newVariable; else - this.standardMessage = PreferencesMessages - .getString("PathEntryVariableDialog.message.existingVariable"); //$NON-NLS-1$ + this.standardMessage = PreferencesMessages.PathEntryVariableDialog_message_existingVariable; } /** @@ -174,12 +172,10 @@ public class PathEntryVariableDialog extends TitleAreaDialog { protected void configureShell(Shell shell) { super.configureShell(shell); if (newVariable) - shell.setText(PreferencesMessages - .getString("PathEntryVariableDialog.shellTitle.newVariable")); //$NON-NLS-1$ + shell.setText(PreferencesMessages.PathEntryVariableDialog_shellTitle_newVariable); else shell - .setText(PreferencesMessages - .getString("PathEntryVariableDialog.shellTitle.existingVariable")); //$NON-NLS-1$ + .setText(PreferencesMessages.PathEntryVariableDialog_shellTitle_existingVariable); } /** @@ -225,11 +221,9 @@ public class PathEntryVariableDialog extends TitleAreaDialog { contents.setFont(parentComposite.getFont()); if (newVariable) - setTitle(PreferencesMessages - .getString("PathEntryVariableDialog.dialogTitle.newVariable")); //$NON-NLS-1$ + setTitle(PreferencesMessages.PathEntryVariableDialog_dialogTitle_newVariable); else - setTitle(PreferencesMessages - .getString("PathEntryVariableDialog.dialogTitle.existingVariable")); //$NON-NLS-1$ + setTitle(PreferencesMessages.PathEntryVariableDialog_dialogTitle_existingVariable); setMessage(standardMessage); return contents; } @@ -243,10 +237,8 @@ public class PathEntryVariableDialog extends TitleAreaDialog { private void createWidgets(Composite contents, Font font) { FormData data; - String nameLabelText = PreferencesMessages - .getString("PathEntryVariableDialog.variableName"); //$NON-NLS-1$ - String valueLabelText = PreferencesMessages - .getString("PathEntryVariableDialog.variableValue"); //$NON-NLS-1$ + String nameLabelText = PreferencesMessages.PathEntryVariableDialog_variableName; + String valueLabelText = PreferencesMessages.PathEntryVariableDialog_variableValue; // variable name label variableNameLabel = new Label(contents, SWT.LEFT); @@ -309,8 +301,7 @@ public class PathEntryVariableDialog extends TitleAreaDialog { // select file path button fileButton = new Button(contents, SWT.PUSH); - fileButton.setText(PreferencesMessages - .getString("PathEntryVariableDialog.file")); //$NON-NLS-1$ + fileButton.setText(PreferencesMessages.PathEntryVariableDialog_file); if ((variableType & IResource.FILE) == 0) fileButton.setEnabled(false); @@ -331,8 +322,7 @@ public class PathEntryVariableDialog extends TitleAreaDialog { // select folder path button folderButton = new Button(contents, SWT.PUSH); - folderButton.setText(PreferencesMessages - .getString("PathEntryVariableDialog.folder")); //$NON-NLS-1$ + folderButton.setText(PreferencesMessages.PathEntryVariableDialog_folder); if ((variableType & IResource.FOLDER) == 0) folderButton.setEnabled(false); @@ -399,10 +389,8 @@ public class PathEntryVariableDialog extends TitleAreaDialog { */ protected void selectFolder() { DirectoryDialog dialog = new DirectoryDialog(getShell()); - dialog.setText(PreferencesMessages - .getString("PathEntryVariableDialog.selectFolderTitle")); //$NON-NLS-1$ - dialog.setMessage(PreferencesMessages - .getString("PathEntryVariableDialog.selectFolderMessage")); //$NON-NLS-1$ + dialog.setText(PreferencesMessages.PathEntryVariableDialog_selectFolderTitle); + dialog.setMessage(PreferencesMessages.PathEntryVariableDialog_selectFolderMessage); dialog.setFilterPath(variableValue); String res = dialog.open(); if (res != null) { @@ -416,8 +404,7 @@ public class PathEntryVariableDialog extends TitleAreaDialog { */ protected void selectFile() { FileDialog dialog = new FileDialog(getShell()); - dialog.setText(PreferencesMessages - .getString("PathEntryVariableDialog.selectFileTitle")); //$NON-NLS-1$ + dialog.setText(PreferencesMessages.PathEntryVariableDialog_selectFileTitle); dialog.setFilterPath(variableValue); String res = dialog.open(); if (res != null) { @@ -461,15 +448,13 @@ public class PathEntryVariableDialog extends TitleAreaDialog { if (nameEntered) { // a name was entered before and is now empty newValidationStatus = IMessageProvider.ERROR; - message = PreferencesMessages - .getString("PathEntryVariableDialog.variableNameEmptyMessage"); //$NON-NLS-1$ + message = PreferencesMessages.PathEntryVariableDialog_variableNameEmptyMessage; } } else { if (namesInUse.contains(variableName) && !variableName.equals(originalName)) { // the variable name is already in use - message = PreferencesMessages - .getString("PathEntryVariableDialog.variableAlreadyExistsMessage"); //$NON-NLS-1$ + message = PreferencesMessages.PathEntryVariableDialog_variableAlreadyExistsMessage; newValidationStatus = IMessageProvider.ERROR; } else { allowFinish = true; @@ -511,23 +496,19 @@ public class PathEntryVariableDialog extends TitleAreaDialog { if (locationEntered) { // a location value was entered before and is now empty newValidationStatus = IMessageProvider.ERROR; - message = PreferencesMessages - .getString("PathEntryVariableDialog.variableValueEmptyMessage"); //$NON-NLS-1$ + message = PreferencesMessages.PathEntryVariableDialog_variableValueEmptyMessage; } } else if (!Path.EMPTY.isValidPath(variableValue)) { // the variable value is an invalid path - message = PreferencesMessages - .getString("PathEntryVariableDialog.variableValueInvalidMessage"); //$NON-NLS-1$ + message = PreferencesMessages.PathEntryVariableDialog_variableValueInvalidMessage; newValidationStatus = IMessageProvider.ERROR; } else if (!new Path(variableValue).isAbsolute()) { // the variable value is a relative path - message = PreferencesMessages - .getString("PathEntryVariableDialog.pathIsRelativeMessage"); //$NON-NLS-1$ + message = PreferencesMessages.PathEntryVariableDialog_pathIsRelativeMessage; newValidationStatus = IMessageProvider.ERROR; } else if (!new File(variableValue).exists()) { // the path does not exist (warning) - message = PreferencesMessages - .getString("PathEntryVariableDialog.pathDoesNotExistMessage"); //$NON-NLS-1$ + message = PreferencesMessages.PathEntryVariableDialog_pathDoesNotExistMessage; newValidationStatus = IMessageProvider.WARNING; allowFinish = true; } else { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablePreferencePage.java index 62fb8980c71..410d92ee52a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablePreferencePage.java @@ -67,7 +67,7 @@ implements IWorkbenchPreferencePage { topLabel = new Label(pageComponent, SWT.NONE); - topLabel.setText(PreferencesMessages.getString("PathEntryVariablePreference.explanation")); //$NON-NLS-1$ + topLabel.setText(PreferencesMessages.PathEntryVariablePreference_explanation); data = new GridData(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java index 45be8a46d5e..8f68ea4e1e0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java @@ -200,8 +200,7 @@ public class PathEntryVariablesGroup { // layout the table & its buttons variableLabel = new Label(pageComponent, SWT.LEFT); - variableLabel.setText(PreferencesMessages - .getString("PathEntryVariablesBlock.variablesLabel")); //$NON-NLS-1$ + variableLabel.setText(PreferencesMessages.PathEntryVariablesBlock_variablesLabel); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; @@ -336,8 +335,7 @@ public class PathEntryVariablesGroup { groupComponent.setFont(font); addButton = new Button(groupComponent, SWT.PUSH); - addButton.setText(PreferencesMessages - .getString("PathEntryVariablesBlock.addVariableButton")); //$NON-NLS-1$ + addButton.setText(PreferencesMessages.PathEntryVariablesBlock_addVariableButton); addButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addNewVariable(); @@ -347,8 +345,7 @@ public class PathEntryVariablesGroup { setButtonLayoutData(addButton); editButton = new Button(groupComponent, SWT.PUSH); - editButton.setText(PreferencesMessages - .getString("PathEntryVariablesBlock.editVariableButton")); //$NON-NLS-1$ + editButton.setText(PreferencesMessages.PathEntryVariablesBlock_editVariableButton); editButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editSelectedVariable(); @@ -358,8 +355,7 @@ public class PathEntryVariablesGroup { setButtonLayoutData(editButton); removeButton = new Button(groupComponent, SWT.PUSH); - removeButton.setText(PreferencesMessages - .getString("PathEntryVariablesBlock.removeVariableButton")); //$NON-NLS-1$ + removeButton.setText(PreferencesMessages.PathEntryVariablesBlock_removeVariableButton); removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeSelectedVariables(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java index d3d26354817..46d00a76dfa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java @@ -10,41 +10,187 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; +import org.eclipse.osgi.util.NLS; -public class PreferencesMessages { +public final class PreferencesMessages extends NLS { - private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.ui.preferences.PreferencesMessages";//$NON-NLS-1$ - - private static ResourceBundle fgResourceBundle; - static { - try { - fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE); - } catch (MissingResourceException x) { - fgResourceBundle = null; - } - } + private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.preferences.PreferencesMessages";//$NON-NLS-1$ private PreferencesMessages() { + // Do not instantiate } - public static String getString(String key) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } catch (NullPointerException e) { - return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } + public static String OptionsConfigurationBlock_builderror_title; + public static String OptionsConfigurationBlock_builderror_message; + public static String OptionsConfigurationBlock_buildall_taskname; + public static String OptionsConfigurationBlock_buildproject_taskname; + public static String OptionsConfigurationBlock_parseerror_title; + public static String OptionsConfigurationBlock_parseerror_message; + public static String OptionsConfigurationBlock_parseall_taskname; + public static String OptionsConfigurationBlock_parseproject_taskname; + public static String TodoTaskPreferencePage_title; + public static String TodoTaskPropertyPage_useworkspacesettings_label; + public static String TodoTaskPropertyPage_useworkspacesettings_change; + public static String TodoTaskPropertyPage_useprojectsettings_label; + public static String TodoTaskConfigurationBlock_markers_tasks_high_priority; + public static String TodoTaskConfigurationBlock_markers_tasks_normal_priority; + public static String TodoTaskConfigurationBlock_markers_tasks_low_priority; + public static String TodoTaskConfigurationBlock_markers_tasks_label; + public static String TodoTaskConfigurationBlock_markers_tasks_add_button; + public static String TodoTaskConfigurationBlock_markers_tasks_remove_button; + public static String TodoTaskConfigurationBlock_markers_tasks_edit_button; + public static String TodoTaskConfigurationBlock_markers_tasks_name_column; + public static String TodoTaskConfigurationBlock_markers_tasks_priority_column; + public static String TodoTaskConfigurationBlock_needsbuild_title; + public static String TodoTaskConfigurationBlock_needsfullbuild_message; + public static String TodoTaskConfigurationBlock_needsprojectbuild_message; + public static String TodoTaskConfigurationBlock_needsparse_title; + public static String TodoTaskConfigurationBlock_needsfullparse_message; + public static String TodoTaskConfigurationBlock_needsprojectparse_message; + public static String TodoTaskInputDialog_new_title; + public static String TodoTaskInputDialog_edit_title; + public static String TodoTaskInputDialog_name_label; + public static String TodoTaskInputDialog_priority_label; + public static String TodoTaskInputDialog_priority_high; + public static String TodoTaskInputDialog_priority_normal; + public static String TodoTaskInputDialog_priority_low; + public static String TodoTaskInputDialog_error_enterName; + public static String TodoTaskInputDialog_error_comma; + public static String TodoTaskInputDialog_error_entryExists; + public static String TodoTaskInputDialog_error_noSpace; + public static String CEditorPreferencePage_link; + public static String CEditorPreferencePage_generalTabTitle; + public static String CEditorPreferencePage_colors; + public static String CEditorPreferencePage_invalid_input; + public static String CEditorPreferencePage_empty_input; + public static String CEditorPreferencePage_ContentAssistPage_searchGroupTitle; + public static String CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption; + public static String CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption; + public static String CEditorPreferencePage_ContentAssistPage_insertionGroupTitle; + public static String CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically; + public static String CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically; + public static String CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder; + public static String CEditorPreferencePage_ContentAssistPage_timeoutDelay; + public static String CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle; + public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot; + public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow; + public static String CEditorPreferencePage_ContentAssistPage_autoActivationDelay; + public static String CEditorPreferencePage_ContentAssistPage_proposalFilterSelect; + public static String CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor; + public static String CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor; + public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon; + public static String CEditorColoringConfigurationBlock_MultiLine; + public static String CEditorColoringConfigurationBlock_singleLine; + public static String CEditorColoringConfigurationBlock_keywords; +// public static String CEditorColoringConfigurationBlock_returnKeyword; + public static String CEditorColoringConfigurationBlock_builtInTypes; + public static String CEditorColoringConfigurationBlock_strings; + public static String CEditorColoringConfigurationBlock_operators; + public static String CEditorColoringConfigurationBlock_braces; + public static String CEditorColoringConfigurationBlock_numbers; + public static String CEditorColoringConfigurationBlock_headers; + public static String CEditorColoringConfigurationBlock_others; + public static String CEditorColoringConfigurationBlock_cCommentTaskTags; + public static String CEditorColoringConfigurationBlock_coloring_category_code; + public static String CEditorColoringConfigurationBlock_coloring_category_comments; + public static String CEditorColoringConfigurationBlock_coloring_element; + public static String CEditorColoringConfigurationBlock_link; + public static String CEditorColoringConfigurationBlock_enable; + public static String CEditorColoringConfigurationBlock_preview; + public static String CEditorColoringConfigurationBlock_color; + public static String CEditorColoringConfigurationBlock_bold; + public static String CEditorColoringConfigurationBlock_italic; + public static String CEditorColoringConfigurationBlock_underline; + public static String CEditorColoringConfigurationBlock_strikethrough; + public static String CEditorPreferencePage_colorPage_systemDefault; + public static String CEditorPreferencePage_colorPage_foreground; + public static String CEditorPreferencePage_colorPage_color; + public static String CEditorPreferencePage_colorPage_bold; + public static String CEditorPreferencePage_colorPage_preview; + public static String CEditorPreferencePage_behaviorPage_tabSpace; + public static String CEditorPreferencePage_behaviorPage_ensureNewline; + public static String CEditorPreferencePage_behaviorPage_matchingBrackets; + public static String CEditorPreferencePage_behaviorPage_subWordNavigation; + public static String CEditorPreferencePage_behaviorPage_inactiveCode; + public static String CEditorPreferencePage_behaviorPage_appearanceColorOptions; + public static String CEditorPreferencePage_behaviorPage_matchingBracketColor; + public static String CEditorPreferencePage_behaviorPage_inactiveCodeColor; + public static String CEditorPreferencePage_behaviorPage_Color; + public static String TemplatePreferencePage_Viewer_preview; + public static String CFileTypesPreferencePage_description; + public static String CFileTypesPreferenceBlock_New___; + public static String CFileTypesPreferenceBlock_Remove; + public static String CFileTypesPreferencePage_colTitlePattern; + public static String CFileTypesPreferencePage_colTitleDescription; + public static String CFileTypesPreferenceBlock_addAssociationError_title; + public static String CFileTypesPreferenceBlock_addAssociationErrorMessage; + public static String CFileTypesPreferencePage_colTitleStatus; + public static String CFileTypesPreferencePage_userDefined; + public static String CFileTypesPreferencePage_preDefined; + public static String CFileTypesPropertyPage_useWorkspaceSettings; + public static String CFileTypesPropertyPage_useProjectSettings; + public static String CFileTypeDialog_title; + public static String CFileTypeDialog_patternLabel; + public static String CFileTypeDialog_typeLabel; + public static String CEditorPreferencePage_hoverTab_title; + public static String CEditorHoverConfigurationBlock_hoverPreferences; + public static String CEditorHoverConfigurationBlock_keyModifier; + public static String CEditorHoverConfigurationBlock_description; + public static String CEditorHoverConfigurationBlock_modifierIsNotValid; + public static String CEditorHoverConfigurationBlock_modifierIsNotValidForHover; + public static String CEditorHoverConfigurationBlock_duplicateModifier; + public static String CEditorHoverConfigurationBlock_nameColumnTitle; + public static String CEditorHoverConfigurationBlock_modifierColumnTitle; + public static String CEditorHoverConfigurationBlock_delimiter; + public static String CEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter; + public static String CEditorHoverConfigurationBlock_insertModifierAndDelimiter; + public static String CEditorHoverConfigurationBlock_insertDelimiterAndModifier; + public static String CBufferPreferences_CodeReaderBuffer_CodeReaderBufferGroup; + public static String CBufferPreferences_CodeReaderBuffer_Size; + public static String CEditorPreferencePage_behaviourPage_EnableEditorProblemAnnotation; + public static String AppearancePreferencePage_description; + public static String AppearancePreferencePage_showTUChildren_label; + public static String AppearancePreferencePage_cviewGroupIncludes_label; + public static String AppearancePreferencePage_outlineGroupIncludes_label; + public static String AppearancePreferencePage_outlineGroupNamespaces_label; + public static String AppearancePreferencePage_note; + public static String AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives; + public static String CEditorPreferencePage_folding_title; + public static String FoldingConfigurationBlock_enable; + public static String FoldingConfigurationBlock_combo_caption; + public static String FoldingConfigurationBlock_info_no_preferences; + public static String FoldingConfigurationBlock_error_not_exist; + public static String CodeFormatterPreferencePage_title; + public static String CodeFormatterPreferencePage_selectionName; + public static String CodeFormatterPreferencePage_emptyName; + public static String PathEntryVariablePreference_explanation; + public static String PathEntryVariableDialog_shellTitle_newVariable; + public static String PathEntryVariableDialog_shellTitle_existingVariable; + public static String PathEntryVariableDialog_dialogTitle_newVariable; + public static String PathEntryVariableDialog_dialogTitle_existingVariable; + public static String PathEntryVariableDialog_message_newVariable; + public static String PathEntryVariableDialog_message_existingVariable; + public static String PathEntryVariableDialog_variableName; + public static String PathEntryVariableDialog_variableValue; + public static String PathEntryVariableDialog_variableNameEmptyMessage; + public static String PathEntryVariableDialog_variableValueEmptyMessage; + public static String PathEntryVariableDialog_variableValueInvalidMessage; + public static String PathEntryVariableDialog_file; + public static String PathEntryVariableDialog_folder; + public static String PathEntryVariableDialog_selectFileTitle; + public static String PathEntryVariableDialog_selectFolderTitle; + public static String PathEntryVariableDialog_selectFolderMessage; + public static String PathEntryVariableDialog_variableAlreadyExistsMessage; + public static String PathEntryVariableDialog_pathIsRelativeMessage; + public static String PathEntryVariableDialog_pathDoesNotExistMessage; + public static String PathEntryVariablesBlock_variablesLabel; + public static String PathEntryVariablesBlock_addVariableButton; + public static String PathEntryVariablesBlock_editVariableButton; + public static String PathEntryVariablesBlock_removeVariableButton; + public static String IndexerPrefs_description; + public static String ProposalFilterPreferencesUtil_defaultFilterName; - public static String getFormattedString(String key, String arg) { - return getFormattedString(key, new String[] { arg }); + static { + NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class); } - - public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getString(key), args); - } -} +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties index 4ca345aa3d5..aacfc2cd4f4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties @@ -9,239 +9,222 @@ # IBM Corporation - initial API and implementation ############################################################################### -OptionsConfigurationBlock.builderror.title=Preference Changes -OptionsConfigurationBlock.builderror.message=Problem while building. Check log for details. +OptionsConfigurationBlock_builderror_title=Preference Changes +OptionsConfigurationBlock_builderror_message=Problem while building. Check log for details. -OptionsConfigurationBlock.buildall.taskname=Build all... -OptionsConfigurationBlock.buildproject.taskname=Build project ''{0}''... +OptionsConfigurationBlock_buildall_taskname=Build all... +OptionsConfigurationBlock_buildproject_taskname=Build project ''{0}''... -OptionsConfigurationBlock.parseerror.title=Preference Changes -OptionsConfigurationBlock.parseerror.message=Problem while parsing. Check log for details. +OptionsConfigurationBlock_parseerror_title=Preference Changes +OptionsConfigurationBlock_parseerror_message=Problem while parsing. Check log for details. -OptionsConfigurationBlock.parseall.taskname=Parse all... -OptionsConfigurationBlock.parseproject.taskname=Parse project ''{0}''... +OptionsConfigurationBlock_parseall_taskname=Parse all... +OptionsConfigurationBlock_parseproject_taskname=Parse project ''{0}''... -TodoTaskPreferencePage.title=Task Tags +TodoTaskPreferencePage_title=Task Tags -TodoTaskPropertyPage.useworkspacesettings.label=Use &workspace settings -TodoTaskPropertyPage.useworkspacesettings.change=&Configure Workspace Settings... -TodoTaskPropertyPage.useprojectsettings.label=Use pr&oject settings +TodoTaskPropertyPage_useworkspacesettings_label=Use &workspace settings +TodoTaskPropertyPage_useworkspacesettings_change=&Configure Workspace Settings... +TodoTaskPropertyPage_useprojectsettings_label=Use pr&oject settings -TodoTaskConfigurationBlock.markers.tasks.high.priority=High -TodoTaskConfigurationBlock.markers.tasks.normal.priority=Normal -TodoTaskConfigurationBlock.markers.tasks.low.priority=Low -TodoTaskConfigurationBlock.markers.tasks.label=&Strings indicating tasks in Java comments: -TodoTaskConfigurationBlock.markers.tasks.add.button=Ne&w... -TodoTaskConfigurationBlock.markers.tasks.remove.button=Remo&ve -TodoTaskConfigurationBlock.markers.tasks.edit.button=Edi&t... -TodoTaskConfigurationBlock.markers.tasks.name.column=Tag -TodoTaskConfigurationBlock.markers.tasks.priority.column=Priority +TodoTaskConfigurationBlock_markers_tasks_high_priority=High +TodoTaskConfigurationBlock_markers_tasks_normal_priority=Normal +TodoTaskConfigurationBlock_markers_tasks_low_priority=Low +TodoTaskConfigurationBlock_markers_tasks_label=&Strings indicating tasks in Java comments: +TodoTaskConfigurationBlock_markers_tasks_add_button=Ne&w... +TodoTaskConfigurationBlock_markers_tasks_remove_button=Remo&ve +TodoTaskConfigurationBlock_markers_tasks_edit_button=Edi&t... +TodoTaskConfigurationBlock_markers_tasks_name_column=Tag +TodoTaskConfigurationBlock_markers_tasks_priority_column=Priority -TodoTaskConfigurationBlock.needsbuild.title=Task Tags Settings Changed -TodoTaskConfigurationBlock.needsfullbuild.message=The task tags settings have changed. A full rebuild is required to make changes effective. Do the full build now? -TodoTaskConfigurationBlock.needsprojectbuild.message=The task tags settings have changed. A rebuild of the project is required to make changes effective. Do the project build now? +TodoTaskConfigurationBlock_needsbuild_title=Task Tags Settings Changed +TodoTaskConfigurationBlock_needsfullbuild_message=The task tags settings have changed. A full rebuild is required to make changes effective. Do the full build now? +TodoTaskConfigurationBlock_needsprojectbuild_message=The task tags settings have changed. A rebuild of the project is required to make changes effective. Do the project build now? -TodoTaskConfigurationBlock.needsparse.title=Task Tags Settings Changed -TodoTaskConfigurationBlock.needsfullparse.message=The task tags settings have changed. A full re-parse is required to make changes effective. Do the full re-parse now? -TodoTaskConfigurationBlock.needsprojectparse.message=The task tags settings have changed. Re-parsing of the project is required to make changes effective. Do the project re-parse now? +TodoTaskConfigurationBlock_needsparse_title=Task Tags Settings Changed +TodoTaskConfigurationBlock_needsfullparse_message=The task tags settings have changed. A full re-parse is required to make changes effective. Do the full re-parse now? +TodoTaskConfigurationBlock_needsprojectparse_message=The task tags settings have changed. Re-parsing of the project is required to make changes effective. Do the project re-parse now? -TodoTaskInputDialog.new.title=New Task Tag -TodoTaskInputDialog.edit.title=Edit Task Tag -TodoTaskInputDialog.name.label=T&ag: -TodoTaskInputDialog.priority.label=&Priority: -TodoTaskInputDialog.priority.high=High -TodoTaskInputDialog.priority.normal=Normal -TodoTaskInputDialog.priority.low=Low -TodoTaskInputDialog.error.enterName=Enter task tag name. -TodoTaskInputDialog.error.comma=Name cannot contain a comma. -TodoTaskInputDialog.error.entryExists=Entry with the same name already exists. -TodoTaskInputDialog.error.noSpace=Name can not start or end with a whitespace. +TodoTaskInputDialog_new_title=New Task Tag +TodoTaskInputDialog_edit_title=Edit Task Tag +TodoTaskInputDialog_name_label=T&ag: +TodoTaskInputDialog_priority_label=&Priority: +TodoTaskInputDialog_priority_high=High +TodoTaskInputDialog_priority_normal=Normal +TodoTaskInputDialog_priority_low=Low +TodoTaskInputDialog_error_enterName=Enter task tag name. +TodoTaskInputDialog_error_comma=Name cannot contain a comma. +TodoTaskInputDialog_error_entryExists=Entry with the same name already exists. +TodoTaskInputDialog_error_noSpace=Name can not start or end with a whitespace. -CEditorPreferencePage.link=Note that some preferences may be set on the Text Editors preference page. -CEditorPreferencePage.generalTabTitle=Appeara&nce -CEditorPreferencePage.annotationTabTitle= &Annotations -CEditorPreferencePage.colorsTabTitle=Synta&x -CEditorPreferencePage.contentAssistTabTitle=Content A&ssist +CEditorPreferencePage_link=Note that some preferences may be set on the Text Editors preference page. +CEditorPreferencePage_generalTabTitle=Appeara&nce +CEditorPreferencePage_colors=Synta&x -CEditorPreferencePage.invalid_input=Invalid input. -CEditorPreferencePage.empty_input=Empty input +CEditorPreferencePage_invalid_input=Invalid input. +CEditorPreferencePage_empty_input=Empty input -CodeAssistPreferencePage.name=Content Assist -CodeAssistPreferencePage.description=Content Assist -CEditorPreferencePage.ContentAssistPage.searchGroupTitle=Search scope for completion proposals: -CEditorPreferencePage.ContentAssistPage.searchGroupCurrentFileOption=S&earch current file and included files -CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectOption=Search current &project -CEditorPreferencePage.ContentAssistPage.insertionGroupTitle=Insertion -CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically=&Insert single proposals automatically -CEditorPreferencePage.ContentAssistPage.insertCommonProposalAutomatically=Insert common prefixes automatically -CEditorPreferencePage.ContentAssistPage.showOnlyProposalsWithCorrectVisibility=Show only proposals visible in the invocation conte&xt -CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order -CEditorPreferencePage.ContentAssistPage.timeoutDelay=Content Assist parsing &timeout (ms) -CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle=Auto activation: -CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot=Enable "." as trigger -CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow=Enable "->" as trigger -CEditorPreferencePage.ContentAssistPage.autoActivationDelay=dela&y (ms) -CEditorPreferencePage.ContentAssistPage.proposalFilterSelect=Completion Proposal Filter: -CEditorPreferencePage.ContentAssistPage.completionProposalBackgroundColor=&Background for completion proposals: -CEditorPreferencePage.ContentAssistPage.completionProposalForegroundColor=&Foreground for completion proposals: -CEditorPreferencePage.ContentAssistPage.parameterBackgroundColor=Bac&kground for method parameters: -CEditorPreferencePage.ContentAssistPage.parameterForegroundColor=Fo®round for method parameters: -CEditorPreferencePage.ContentAssistPage.autoActivationEnableDoubleColon=Enable "::" as trigger -CEditorPreferencePage.syntaxPage.MultiLine=Multi-line comment -CEditorPreferencePage.syntaxPage.singleLine=Single-line comment -CEditorPreferencePage.syntaxPage.keywords=Keywords -CEditorPreferencePage.syntaxPage.builtInTypes=Built-in types -CEditorPreferencePage.syntaxPage.strings=Strings -CEditorPreferencePage.syntaxPage.operators=Operators -CEditorPreferencePage.syntaxPage.braces=Braces -CEditorPreferencePage.syntaxPage.numbers=Numbers -CEditorPreferencePage.syntaxPage.headers=Headers -CEditorPreferencePage.syntaxPage.others=Others -CEditorPreferencePage.syntaxPage.cCommentTaskTags=Task Tags -CEditorPreferencePage.colorPage.backgroundColor=Bac&kground Color: -CEditorPreferencePage.colorPage.systemDefault=S&ystem Default -CEditorPreferencePage.colorPage.custom=C&ustom -CEditorPreferencePage.colorPage.foreground=Fo®round: -CEditorPreferencePage.colorPage.color=C&olor: -CEditorPreferencePage.colorPage.bold=&Bold -CEditorPreferencePage.colorPage.preview=Preview: -CEditorPreferencePage.behaviorPage.tabSpace=&Insert space for tabs -CEditorPreferencePage.behaviorPage.ensureNewline=Ensure &newline at end of file when saving -CEditorPreferencePage.behaviorPage.matchingBrackets=Highlight &matching brackets -CEditorPreferencePage.behaviorPage.subWordNavigation=Smart &caret positioning in identifiers -CEditorPreferencePage.behaviorPage.inactiveCode=Highlight &inactive code -CEditorPreferencePage.behaviorPage.appearanceColorOptions=Appearance color options: -CEditorPreferencePage.behaviorPage.matchingBracketColor=Matching brackets highlight -CEditorPreferencePage.behaviorPage.inactiveCodeColor=Inactive code highlight -CEditorPreferencePage.behaviorPage.Color=Color: -CEditorPreferencePage.textFont.changeButton=C&hange... +CEditorPreferencePage_ContentAssistPage_searchGroupTitle=Search scope for completion proposals: +CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption=S&earch current file and included files +CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption=Search current &project +CEditorPreferencePage_ContentAssistPage_insertionGroupTitle=Insertion +CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically=&Insert single proposals automatically +CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically=Insert common prefixes automatically +CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order +CEditorPreferencePage_ContentAssistPage_timeoutDelay=Content Assist parsing &timeout (ms) +CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle=Auto activation: +CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot=Enable "." as trigger +CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow=Enable "->" as trigger +CEditorPreferencePage_ContentAssistPage_autoActivationDelay=dela&y (ms) +CEditorPreferencePage_ContentAssistPage_proposalFilterSelect=Completion Proposal Filter: +CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor=&Background for completion proposals: +CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor=&Foreground for completion proposals: +CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon=Enable "::" as trigger +CEditorColoringConfigurationBlock_MultiLine=Multi-line comment +CEditorColoringConfigurationBlock_singleLine=Single-line comment +CEditorColoringConfigurationBlock_keywords=Keywords +CEditorColoringConfigurationBlock_builtInTypes=Built-in types +CEditorColoringConfigurationBlock_strings=Strings +CEditorColoringConfigurationBlock_operators=Operators +CEditorColoringConfigurationBlock_braces=Braces +CEditorColoringConfigurationBlock_numbers=Numbers +CEditorColoringConfigurationBlock_headers=Headers +CEditorColoringConfigurationBlock_others=Others +CEditorColoringConfigurationBlock_cCommentTaskTags=Task Tags +CEditorColoringConfigurationBlock_coloring_category_code=Code +CEditorColoringConfigurationBlock_coloring_category_comments=Comments +CEditorColoringConfigurationBlock_coloring_element=Element: +# DO NOT TRANSLATE "org.eclipse.ui.preferencePages.GeneralTextEditor" and "org.eclipse.ui.preferencePages.ColorsAndFonts" +CEditorColoringConfigurationBlock_link=Default colors and font can be configured on the Text Editors and on the Colors and Fonts preference page. +CEditorColoringConfigurationBlock_enable=Enab&le +CEditorColoringConfigurationBlock_preview=Previe&w: +CEditorColoringConfigurationBlock_color=C&olor: +CEditorColoringConfigurationBlock_bold=&Bold +CEditorColoringConfigurationBlock_italic=&Italic +CEditorColoringConfigurationBlock_underline=&Underline +CEditorColoringConfigurationBlock_strikethrough=&Strikethrough +CEditorPreferencePage_colorPage_systemDefault=S&ystem Default +CEditorPreferencePage_colorPage_foreground=Fo®round: +CEditorPreferencePage_colorPage_color=C&olor: +CEditorPreferencePage_colorPage_bold=&Bold +CEditorPreferencePage_colorPage_preview=Preview: +CEditorPreferencePage_behaviorPage_tabSpace=&Insert space for tabs +CEditorPreferencePage_behaviorPage_ensureNewline=Ensure &newline at end of file when saving +CEditorPreferencePage_behaviorPage_matchingBrackets=Highlight &matching brackets +CEditorPreferencePage_behaviorPage_subWordNavigation=Smart &caret positioning in identifiers +CEditorPreferencePage_behaviorPage_inactiveCode=Highlight &inactive code +CEditorPreferencePage_behaviorPage_appearanceColorOptions=Appearance color options: +CEditorPreferencePage_behaviorPage_matchingBracketColor=Matching brackets highlight +CEditorPreferencePage_behaviorPage_inactiveCodeColor=Inactive code highlight +CEditorPreferencePage_behaviorPage_Color=Color: -TemplatePreferencePage.Viewer.preview=Preview: +TemplatePreferencePage_Viewer_preview=Preview: -CFileTypesPreferencePage.description=C/C++ File Types -CFileTypesPreferenceBlock.New...=New... -CFileTypesPreferenceBlock.Remove=Remove -CFileTypesPreferencePage.colTitlePattern=Filename -CFileTypesPreferencePage.colTitleDescription=Description -CFileTypesPreferenceBlock.addAssociationError.title=Create file association -CFileTypesPreferenceBlock.addAssociationErrorMessage=The association between ''{0}'' and ''{1}'' already exists -CFileTypesPreferencePage.colTitleStatus=Status -CFileTypesPreferencePage.userDefined=User Defined -CFileTypesPreferencePage.preDefined=Locked +CFileTypesPreferencePage_description=C/C++ File Types +CFileTypesPreferenceBlock_New___=New... +CFileTypesPreferenceBlock_Remove=Remove +CFileTypesPreferencePage_colTitlePattern=Filename +CFileTypesPreferencePage_colTitleDescription=Description +CFileTypesPreferenceBlock_addAssociationError_title=Create file association +CFileTypesPreferenceBlock_addAssociationErrorMessage=The association between ''{0}'' and ''{1}'' already exists +CFileTypesPreferencePage_colTitleStatus=Status +CFileTypesPreferencePage_userDefined=User Defined +CFileTypesPreferencePage_preDefined=Locked -CFileTypesPropertyPage.useWorkspaceSettings=Use workspace settings -CFileTypesPropertyPage.useProjectSettings=Use project settings +CFileTypesPropertyPage_useWorkspaceSettings=Use workspace settings +CFileTypesPropertyPage_useProjectSettings=Use project settings -CFileTypeDialog.title=C/C++ File Type -CFileTypeDialog.patternLabel=Pattern: -CFileTypeDialog.typeLabel=Type: +CFileTypeDialog_title=C/C++ File Type +CFileTypeDialog_patternLabel=Pattern: +CFileTypeDialog_typeLabel=Type: # Hover tab -CEditorPreferencePage.hoverTab.title= Ho&vers -CEditorHoverConfigurationBlock.annotationRollover= &Enable annotation roll-over (on new editors) -CEditorHoverConfigurationBlock.hoverPreferences= Text &Hover key modifier preferences: -CEditorHoverConfigurationBlock.enabled= &Enabled -CEditorHoverConfigurationBlock.keyModifier= Pressed key &modifier while hovering: -CEditorHoverConfigurationBlock.description= Description: -CEditorHoverConfigurationBlock.modifierIsNotValid= Modifier ''{0}'' is not valid. -CEditorHoverConfigurationBlock.modifierIsNotValidForHover= Modifier ''{0}'' for ''{1}'' hover is not valid. -CEditorHoverConfigurationBlock.duplicateModifier= ''{0}'' hover uses the same modifier as ''{1}'' hover. -CEditorHoverConfigurationBlock.nameColumnTitle= Text Hover Name -CEditorHoverConfigurationBlock.modifierColumnTitle= Pressed Key Modifier While Hovering +CEditorPreferencePage_hoverTab_title= Ho&vers +CEditorHoverConfigurationBlock_hoverPreferences= Text &Hover key modifier preferences: +CEditorHoverConfigurationBlock_keyModifier= Pressed key &modifier while hovering: +CEditorHoverConfigurationBlock_description= Description: +CEditorHoverConfigurationBlock_modifierIsNotValid= Modifier ''{0}'' is not valid. +CEditorHoverConfigurationBlock_modifierIsNotValidForHover= Modifier ''{0}'' for ''{1}'' hover is not valid. +CEditorHoverConfigurationBlock_duplicateModifier= ''{0}'' hover uses the same modifier as ''{1}'' hover. +CEditorHoverConfigurationBlock_nameColumnTitle= Text Hover Name +CEditorHoverConfigurationBlock_modifierColumnTitle= Pressed Key Modifier While Hovering -CEditorHoverConfigurationBlock.delimiter= + -CEditorHoverConfigurationBlock.insertDelimiterAndModifierAndDelimiter= \ + {0} + -CEditorHoverConfigurationBlock.insertModifierAndDelimiter= \ {0} + -CEditorHoverConfigurationBlock.insertDelimiterAndModifier= \ + {0} +CEditorHoverConfigurationBlock_delimiter= + +CEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter= \ + {0} + +CEditorHoverConfigurationBlock_insertModifierAndDelimiter= \ {0} + +CEditorHoverConfigurationBlock_insertDelimiterAndModifier= \ + {0} -CEditorHoverConfigurationBlock.showAffordance= &Show affordance in hover on how to make it sticky #Search Preferences -CSearchPreferences.ExternalSearchLinks.ExternalSearchLinksGroup=External Search Links -CSearchPreferences.ExternalSearchLinks.EnableMarkerLinkType=Enable Marker Link Type -CSearchPreferences.ExternalSearchLinks.EnableMessage=Enable external search markers -CSearchPreferences.ExternalSearchLinks.Visible=Visible -CSearchPreferences.ExternalSearchLinks.Invisible=Invisible -CSearchPreferences.IndexerTimeout.IndexerTimeoutGroup=Indexer Timeout -CSearchPreferences.IndexerTimeout.Timeout=Timeout (ms) #Buffer Preferences -CBufferPreferences.CodeReaderBuffer.CodeReaderBufferGroup=CodeReader Buffer Size -CBufferPreferences.CodeReaderBuffer.Size=Size (MB) +CBufferPreferences_CodeReaderBuffer_CodeReaderBufferGroup=CodeReader Buffer Size +CBufferPreferences_CodeReaderBuffer_Size=Size (MB) #Open Type Preferences -CEditorPreferencePage.Navigation.OpenType=Open Type -CEditorPreferencePage.Navigation.CacheTypesInBackground=Cache types in background #Editor Preferences -CEditorPreferencePage.behaviourPage.EditorGroup=Editor -CEditorPreferencePage.behaviourPage.EnableEditorProblemAnnotation=Enable editor problem annotation +CEditorPreferencePage_behaviourPage_EnableEditorProblemAnnotation=Enable editor problem annotation #Appearance Preferences -AppearancePreferencePage.description= Appearance of C elements in viewers: +AppearancePreferencePage_description= Appearance of C elements in viewers: #AppearancePreferencePage.methodreturntype.label= Show &method return types -AppearancePreferencePage.showTUChildren.label= Show translation unit members -AppearancePreferencePage.cviewGroupIncludes.label= Group the includes in the C/C++ projects view -AppearancePreferencePage.outlineGroupIncludes.label= Group the includes in the outliner -AppearancePreferencePage.outlineGroupNamespaces.label= Group the namespaces in the outliner -AppearancePreferencePage.note=Note: -AppearancePreferencePage.preferenceOnlyEffectiveForNewPerspectives=This preference may only take effect on new perspectives +AppearancePreferencePage_showTUChildren_label= Show translation unit members +AppearancePreferencePage_cviewGroupIncludes_label= Group the includes in the C/C++ projects view +AppearancePreferencePage_outlineGroupIncludes_label= Group the includes in the outliner +AppearancePreferencePage_outlineGroupNamespaces_label= Group the namespaces in the outliner +AppearancePreferencePage_note=Note: +AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives=This preference may only take effect on new perspectives #Folding -CEditorPreferencePage.folding.title= &Folding +CEditorPreferencePage_folding_title= &Folding -FoldingConfigurationBlock.enable= Enable folding when &opening a new editor -FoldingConfigurationBlock.combo_caption= Select folding to &use: -FoldingConfigurationBlock.info.no_preferences= The selected folding provider did not provide a preference control -FoldingConfigurationBlock.error.not_exist= The selected folding provider does not exist +FoldingConfigurationBlock_enable= Enable folding when &opening a new editor +FoldingConfigurationBlock_combo_caption= Select folding to &use: +FoldingConfigurationBlock_info_no_preferences= The selected folding provider did not provide a preference control +FoldingConfigurationBlock_error_not_exist= The selected folding provider does not exist #Code Formatting -CodeFormatterPreferencePage.title=Code Formatter -CodeFormatterPreferencePage.selectionName=Formatters: -CodeFormatterPreferencePage.emptyName=(NONE) -CodeFormatterPreferencePage.description=Code Formatter +CodeFormatterPreferencePage_title=Code Formatter +CodeFormatterPreferencePage_selectionName=Formatters: +CodeFormatterPreferencePage_emptyName=(NONE) # --- Linked Resources --- -PathEntryVariablePreference.explanation = PathEntry variables. -PathEntryVariablePreference.enableLinkedResources = &Enable linked resources -PathEntryVariablePreference.linkedResourcesWarningTitle = Enabled Linked Resources -PathEntryVariablePreference.linkedResourcesWarningMessage = You have enabled a feature which may give rise to incompatibilities if projects are shared by users of different versions of the workbench. Please consult the documentation for further details. +PathEntryVariablePreference_explanation = PathEntry variables. # The following six keys are marked as unused by the NLS search, but they are indirectly used # and should be removed. -PathEntryVariableDialog.shellTitle.newVariable = New PathEntry Variable -PathEntryVariableDialog.shellTitle.existingVariable = Edit PathEntry Variable -PathEntryVariableDialog.dialogTitle.newVariable = Define a New PathEntry Variable -PathEntryVariableDialog.dialogTitle.existingVariable = Edit an Existing PathEntry Variable -PathEntryVariableDialog.message.newVariable = Enter a new PathEntry variable name and its associated location. -PathEntryVariableDialog.message.existingVariable = Edit PathEntry variable's name and path value. +PathEntryVariableDialog_shellTitle_newVariable = New PathEntry Variable +PathEntryVariableDialog_shellTitle_existingVariable = Edit PathEntry Variable +PathEntryVariableDialog_dialogTitle_newVariable = Define a New PathEntry Variable +PathEntryVariableDialog_dialogTitle_existingVariable = Edit an Existing PathEntry Variable +PathEntryVariableDialog_message_newVariable = Enter a new PathEntry variable name and its associated location. +PathEntryVariableDialog_message_existingVariable = Edit PathEntry variable's name and path value. -PathEntryVariableDialog.variableName = &Name: -PathEntryVariableDialog.variableValue = &Location: -PathEntryVariableDialog.variableNameEmptyMessage = You must provide a variable name. -PathEntryVariableDialog.variableValueEmptyMessage = You must provide a file or folder path as variable value. -PathEntryVariableDialog.variableValueInvalidMessage = The provided value is not a valid path. -PathEntryVariableDialog.file = &File... -PathEntryVariableDialog.folder = F&older... -PathEntryVariableDialog.selectFileTitle = File selection -PathEntryVariableDialog.selectFolderTitle = Folder selection -PathEntryVariableDialog.selectFolderMessage = Specify the folder to be represented by the variable. -PathEntryVariableDialog.variableAlreadyExistsMessage = This variable name is already in use. -PathEntryVariableDialog.pathIsRelativeMessage = Path must be absolute. -PathEntryVariableDialog.pathDoesNotExistMessage = Path does not exist. +PathEntryVariableDialog_variableName = &Name: +PathEntryVariableDialog_variableValue = &Location: +PathEntryVariableDialog_variableNameEmptyMessage = You must provide a variable name. +PathEntryVariableDialog_variableValueEmptyMessage = You must provide a file or folder path as variable value. +PathEntryVariableDialog_variableValueInvalidMessage = The provided value is not a valid path. +PathEntryVariableDialog_file = &File... +PathEntryVariableDialog_folder = F&older... +PathEntryVariableDialog_selectFileTitle = File selection +PathEntryVariableDialog_selectFolderTitle = Folder selection +PathEntryVariableDialog_selectFolderMessage = Specify the folder to be represented by the variable. +PathEntryVariableDialog_variableAlreadyExistsMessage = This variable name is already in use. +PathEntryVariableDialog_pathIsRelativeMessage = Path must be absolute. +PathEntryVariableDialog_pathDoesNotExistMessage = Path does not exist. -PathEntryVariablesBlock.variablesLabel = &Defined PathEntry variables: -PathEntryVariablesBlock.addVariableButton = &New... -PathEntryVariablesBlock.editVariableButton = Edi&t... -PathEntryVariablesBlock.removeVariableButton = &Remove +PathEntryVariablesBlock_variablesLabel = &Defined PathEntry variables: +PathEntryVariablesBlock_addVariableButton = &New... +PathEntryVariablesBlock_editVariableButton = Edi&t... +PathEntryVariablesBlock_removeVariableButton = &Remove -PathEntryVariableSelectionDialog.title = Select Path Variable -PathEntryVariableSelectionDialog.extendButton = &Extend... -PathEntryVariableSelectionDialog.ExtensionDialog.title = Variable Extension -PathEntryVariableSelectionDialog.ExtensionDialog.description = Choose extension to {0} #Indexer -IndexerPrefs.description=Sets default Indexer Options for new Projects -ProposalFilterPreferencesUtil.defaultFilterName= +IndexerPrefs_description=Sets default Indexer Options for new Projects + +# Others +ProposalFilterPreferencesUtil_defaultFilterName= diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreviewSourceViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreviewSourceViewer.java index 2aef0750dd6..c582d362017 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreviewSourceViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreviewSourceViewer.java @@ -25,6 +25,9 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.AbstractTextEditor; +/** + * @deprecated Use {@link org.eclipse.cdt.internal.ui.editor.CSourceViewer} instead. + */ class PreviewSourceViewer extends SourceViewer implements IPropertyChangeListener { /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java index 568d5da1b6a..1fa51059439 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java @@ -80,7 +80,7 @@ public class ProposalFilterPreferencesUtil { */ public static String getProposalFilternamesAsString() { StringBuffer filterNames = new StringBuffer("0;"); //$NON-NLS-1$ - filterNames.append(""); // TODO: NP externalize this! //$NON-NLS-1$ + filterNames.append(PreferencesMessages.ProposalFilterPreferencesUtil_defaultFilterName); String[] names = getProposalFilterNames(); for (int i = 0; i < names.length; i++) { String name = names[i]; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java new file mode 100644 index 00000000000..c738333cc98 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.preferences; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +import org.eclipse.ui.forms.FormColors; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.SharedScrolledComposite; + + +public class ScrolledPageContent extends SharedScrolledComposite { + + private FormToolkit fToolkit; + + public ScrolledPageContent(Composite parent) { + this(parent, SWT.V_SCROLL | SWT.H_SCROLL); + } + + public ScrolledPageContent(Composite parent, int style) { + super(parent, style); + + setFont(parent.getFont()); + + FormColors colors= new FormColors(parent.getDisplay()); + colors.setBackground(null); + colors.setForeground(null); + + fToolkit= new FormToolkit(colors); + + setExpandHorizontal(true); + setExpandVertical(true); + + Composite body= new Composite(this, SWT.NONE); + body.setFont(parent.getFont()); + setContent(body); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Widget#dispose() + */ + public void dispose() { + fToolkit.dispose(); + super.dispose(); + } + + public void adaptChild(Control childControl) { + fToolkit.adapt(childControl, true, true); + } + + public Composite getBody() { + return (Composite) getContent(); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java index b8ba0479161..731f781e985 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java @@ -85,11 +85,11 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { return task.name; } if (PRIORITY_HIGH.equals(task.priority)) { - return PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.high.priority"); //$NON-NLS-1$ + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority; } else if (PRIORITY_NORMAL.equals(task.priority)) { - return PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.normal.priority"); //$NON-NLS-1$ + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority; } else if (PRIORITY_LOW.equals(task.priority)) { - return PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.low.priority"); //$NON-NLS-1$ + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority; } return ""; //$NON-NLS-1$ } @@ -104,19 +104,19 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { TaskTagAdapter adapter= new TaskTagAdapter(); String[] buttons= new String[] { - /* 0 */ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.add.button"), //$NON-NLS-1$ - /* 1 */ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.remove.button"), //$NON-NLS-1$ + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button, + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button, null, - /* 3 */ PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.edit.button"), //$NON-NLS-1$ + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button, }; fTodoTasksList= new ListDialogField(adapter, buttons, new TodoTaskLabelProvider()); fTodoTasksList.setDialogFieldListener(adapter); - fTodoTasksList.setLabelText(PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.label")); //$NON-NLS-1$ + fTodoTasksList.setLabelText(PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_label); fTodoTasksList.setRemoveButtonIndex(1); String[] columnsHeaders= new String[] { - PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.name.column"), //$NON-NLS-1$ - PreferencesMessages.getString("TodoTaskConfigurationBlock.markers.tasks.priority.column"), //$NON-NLS-1$ + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column, + PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column, }; fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true)); @@ -222,23 +222,23 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { protected String[] getFullBuildDialogStrings(boolean workspaceSettings) { - String title= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsbuild.title"); //$NON-NLS-1$ + String title= PreferencesMessages.TodoTaskConfigurationBlock_needsbuild_title; String message; if (fProject == null) { - message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsfullbuild.message"); //$NON-NLS-1$ + message= PreferencesMessages.TodoTaskConfigurationBlock_needsfullbuild_message; } else { - message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$ + message= PreferencesMessages.TodoTaskConfigurationBlock_needsprojectbuild_message; } return new String[] { title, message }; } protected String[] getFullReParseDialogStrings(boolean workspaceSettings) { - String title= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsparse.title"); //$NON-NLS-1$ + String title= PreferencesMessages.TodoTaskConfigurationBlock_needsparse_title; String message; if (fProject == null) { - message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsfullparse.message"); //$NON-NLS-1$ + message= PreferencesMessages.TodoTaskConfigurationBlock_needsfullparse_message; } else { - message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsprojectparse.message"); //$NON-NLS-1$ + message= PreferencesMessages.TodoTaskConfigurationBlock_needsprojectparse_message; } return new String[] { title, message }; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java index f57b94553ef..04cd5771e31 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java @@ -61,27 +61,27 @@ public class TodoTaskInputDialog extends StatusDialog { } if (task == null) { - setTitle(PreferencesMessages.getString("TodoTaskInputDialog.new.title")); //$NON-NLS-1$ + setTitle(PreferencesMessages.TodoTaskInputDialog_new_title); } else { - setTitle(PreferencesMessages.getString("TodoTaskInputDialog.edit.title")); //$NON-NLS-1$ + setTitle(PreferencesMessages.TodoTaskInputDialog_edit_title); } CompilerTodoTaskInputAdapter adapter= new CompilerTodoTaskInputAdapter(); fNameDialogField= new StringDialogField(); - fNameDialogField.setLabelText(PreferencesMessages.getString("TodoTaskInputDialog.name.label")); //$NON-NLS-1$ + fNameDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_name_label); fNameDialogField.setDialogFieldListener(adapter); fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$ String[] items= new String[] { - PreferencesMessages.getString("TodoTaskInputDialog.priority.high"), //$NON-NLS-1$ - PreferencesMessages.getString("TodoTaskInputDialog.priority.normal"), //$NON-NLS-1$ - PreferencesMessages.getString("TodoTaskInputDialog.priority.low") //$NON-NLS-1$ + PreferencesMessages.TodoTaskInputDialog_priority_high, + PreferencesMessages.TodoTaskInputDialog_priority_normal, + PreferencesMessages.TodoTaskInputDialog_priority_low }; fPriorityDialogField= new ComboDialogField(SWT.READ_ONLY); - fPriorityDialogField.setLabelText(PreferencesMessages.getString("TodoTaskInputDialog.priority.label")); //$NON-NLS-1$ + fPriorityDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_priority_label); fPriorityDialogField.setItems(items); if (task != null) { if (CCorePlugin.TRANSLATION_TASK_PRIORITY_HIGH.equals(task.priority)) { @@ -139,14 +139,14 @@ public class TodoTaskInputDialog extends StatusDialog { StatusInfo status= new StatusInfo(); String newText= fNameDialogField.getText(); if (newText.length() == 0) { - status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.enterName")); //$NON-NLS-1$ + status.setError(PreferencesMessages.TodoTaskInputDialog_error_enterName); } else { if (newText.indexOf(',') != -1) { - status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.comma")); //$NON-NLS-1$ + status.setError(PreferencesMessages.TodoTaskInputDialog_error_comma); } else if (fExistingNames.contains(newText)) { - status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.entryExists")); //$NON-NLS-1$ + status.setError(PreferencesMessages.TodoTaskInputDialog_error_entryExists); } else if (Character.isWhitespace(newText.charAt(0)) || Character.isWhitespace(newText.charAt(newText.length() - 1))) { - status.setError(PreferencesMessages.getString("TodoTaskInputDialog.error.noSpace")); //$NON-NLS-1$ + status.setError(PreferencesMessages.TodoTaskInputDialog_error_noSpace); } } updateStatus(status); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java index 4203520e74c..722dcc91eda 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java @@ -41,7 +41,7 @@ public class TodoTaskPreferencePage extends PreferencePage implements IWorkbench //setDescription(PreferencesMessages.getString("TodoTaskPreferencePage.description")); //$NON-NLS-1$ // only used when page is shown programatically - setTitle(PreferencesMessages.getString("TodoTaskPreferencePage.title")); //$NON-NLS-1$ + setTitle(PreferencesMessages.TodoTaskPreferencePage_title); fConfigurationBlock= new TodoTaskConfigurationBlock(this, null); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPropertyPage.java index 0e5d09bdb3a..79f008fe8c9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPropertyPage.java @@ -69,17 +69,17 @@ public class TodoTaskPropertyPage extends PropertyPage { fUseWorkspaceSettings= new SelectionButtonDialogField(SWT.RADIO); fUseWorkspaceSettings.setDialogFieldListener(listener); - fUseWorkspaceSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useworkspacesettings.label")); //$NON-NLS-1$ + fUseWorkspaceSettings.setLabelText(PreferencesMessages.TodoTaskPropertyPage_useworkspacesettings_label); fChangeWorkspaceSettings= new SelectionButtonDialogField(SWT.PUSH); - fChangeWorkspaceSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useworkspacesettings.change")); //$NON-NLS-1$ + fChangeWorkspaceSettings.setLabelText(PreferencesMessages.TodoTaskPropertyPage_useworkspacesettings_change); fChangeWorkspaceSettings.setDialogFieldListener(listener); fUseWorkspaceSettings.attachDialogField(fChangeWorkspaceSettings); fUseProjectSettings= new SelectionButtonDialogField(SWT.RADIO); fUseProjectSettings.setDialogFieldListener(listener); - fUseProjectSettings.setLabelText(PreferencesMessages.getString("TodoTaskPropertyPage.useprojectsettings.label")); //$NON-NLS-1$ + fUseProjectSettings.setLabelText(PreferencesMessages.TodoTaskPropertyPage_useprojectsettings_label); } /* diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java index bd74ba71660..cf8795db61b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000 2005 IBM Corporation and others. + * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,13 +11,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.text; + import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.RGB; - import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.StringConverter; @@ -27,40 +25,111 @@ import org.eclipse.jface.text.rules.IRule; import org.eclipse.jface.text.rules.IToken; import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; + +import org.eclipse.cdt.ui.PreferenceConstants; /** * Initialized with a color manager and a preference store, its subclasses are - * only responsible for providing a list of preference keys based on which tokens + * only responsible for providing a list of preference keys for based on which tokens * are generated and to use this tokens to define the rules controlling this scanner. + *

+ * This scanner stores the color defined by the color preference key into + * the color manager under the same key. + *

+ *

+ * Preference color key + {@link PreferenceConstants#EDITOR_BOLD_SUFFIX} are used + * to retrieve whether the token is rendered in bold. + *

+ *

+ * Preference color key + {@link PreferenceConstants#EDITOR_ITALIC_SUFFIX} are used + * to retrieve whether the token is rendered in italic. + *

+ *

+ * Preference color key + {@link PreferenceConstants#EDITOR_STRIKETHROUGH_SUFFIX} are used + * to retrieve whether the token is rendered in strikethrough. + *

+ *

+ * Preference color key + {@link PreferenceConstants#EDITOR_UNDERLINE_SUFFIX} are used + * to retrieve whether the token is rendered in underline. + *

*/ public abstract class AbstractCScanner extends BufferedRuleBasedScanner { - - + + private IColorManager fColorManager; private IPreferenceStore fPreferenceStore; - + private Map fTokenMap= new HashMap(); private String[] fPropertyNamesColor; - private String[] fPropertyNamesStyle; - - private IToken fDefaultToken; - - - /** - * Returns the list of preference keys which define the tokens + /** + * Preference keys for boolean preferences which are true, + * iff the corresponding token should be rendered bold. + */ + private String[] fPropertyNamesBold; + /** + * Preference keys for boolean preferences which are true, + * iff the corresponding token should be rendered italic. + * + * @since 4.0 + */ + private String[] fPropertyNamesItalic; + /** + * Preference keys for boolean preferences which are true, + * iff the corresponding token should be rendered strikethrough. + * + * @since 4.0 + */ + private String[] fPropertyNamesStrikethrough; + /** + * Preference keys for boolean preferences which are true, + * iff the corresponding token should be rendered underline. + * + * @since 4.0 + */ + private String[] fPropertyNamesUnderline; + + + private boolean fNeedsLazyColorLoading; + + /** + * Returns an array of preference keys which define the tokens * used in the rules of this scanner. + *

+ * The preference key is used access the color in the preference + * store and in the color manager. + *

+ *

+ * Preference key + {@link PreferenceConstants#EDITOR_BOLD_SUFFIX} is used + * to retrieve whether the token is rendered in bold. + *

+ *

+ * Preference key + {@link PreferenceConstants#EDITOR_ITALIC_SUFFIX} is used + * to retrieve whether the token is rendered in italic. + *

+ *

+ * Preference key + {@link PreferenceConstants#EDITOR_UNDERLINE_SUFFIX} is used + * to retrieve whether the token is rendered underlined. + *

+ *

+ * Preference key + {@link PreferenceConstants#EDITOR_STRIKETHROUGH_SUFFIX} is used + * to retrieve whether the token is rendered stricken out. + *

*/ abstract protected String[] getTokenProperties(); - + /** * Creates the list of rules controlling this scanner. */ abstract protected List createRules(); - - + + /** - * Creates an abstract Java scanner. + * Creates an abstract C scanner. */ public AbstractCScanner(IColorManager manager, IPreferenceStore store) { super(); @@ -69,45 +138,133 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner { } /** - * Creates an abstract Java scanner. + * Creates an abstract C scanner. */ public AbstractCScanner(IColorManager manager, IPreferenceStore store, int bufsize) { super(bufsize); fColorManager= manager; fPreferenceStore= store; - } + } + /** * Must be called after the constructor has been called. */ public final void initialize() { - + fPropertyNamesColor= getTokenProperties(); int length= fPropertyNamesColor.length; - fPropertyNamesStyle= new String[length]; + fPropertyNamesBold= new String[length]; + fPropertyNamesItalic= new String[length]; + fPropertyNamesStrikethrough= new String[length]; + fPropertyNamesUnderline= new String[length]; + for (int i= 0; i < length; i++) { - fPropertyNamesStyle[i]= fPropertyNamesColor[i] + "_bold"; //$NON-NLS-1$ - addToken(fPropertyNamesColor[i], fPropertyNamesStyle[i]); + fPropertyNamesBold[i]= getBoldKey(fPropertyNamesColor[i]); + fPropertyNamesItalic[i]= getItalicKey(fPropertyNamesColor[i]); + fPropertyNamesStrikethrough[i]= getStrikethroughKey(fPropertyNamesColor[i]); + fPropertyNamesUnderline[i]= getUnderlineKey(fPropertyNamesColor[i]); } + fNeedsLazyColorLoading= Display.getCurrent() == null; + for (int i= 0; i < length; i++) { + if (fNeedsLazyColorLoading) + addTokenWithProxyAttribute(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]); + else + addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]); + } + initializeRules(); } - - private void addToken(String colorKey, String styleKey) { - RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey); - if (fColorManager instanceof IColorManagerExtension) { - IColorManagerExtension ext= (IColorManagerExtension) fColorManager; - ext.unbindColor(colorKey); - ext.bindColor(colorKey, rgb); - } - - boolean bold= fPreferenceStore.getBoolean(styleKey); - fTokenMap.put(colorKey, new Token(new TextAttribute(fColorManager.getColor(colorKey), null, bold ? SWT.BOLD : SWT.NORMAL))); + + protected String getBoldKey(String colorKey) { + return colorKey + PreferenceConstants.EDITOR_BOLD_SUFFIX; + } + + protected String getItalicKey(String colorKey) { + return colorKey + PreferenceConstants.EDITOR_ITALIC_SUFFIX; } + protected String getStrikethroughKey(String colorKey) { + return colorKey + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX; + } + + protected String getUnderlineKey(String colorKey) { + return colorKey + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX; + } + + public IToken nextToken() { + if (fNeedsLazyColorLoading) + resolveProxyAttributes(); + return super.nextToken(); + } + + private void resolveProxyAttributes() { + if (fNeedsLazyColorLoading && Display.getCurrent() != null) { + for (int i= 0; i < fPropertyNamesColor.length; i++) { + addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]); + } + fNeedsLazyColorLoading= false; + } + } + + private void addTokenWithProxyAttribute(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { + fTokenMap.put(colorKey, new Token(createTextAttribute(null, boldKey, italicKey, strikethroughKey, underlineKey))); + } + + private void addToken(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { + if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) { + RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey); + if (fColorManager instanceof IColorManagerExtension) { + IColorManagerExtension ext= (IColorManagerExtension) fColorManager; + ext.unbindColor(colorKey); + ext.bindColor(colorKey, rgb); + } + } + + if (!fNeedsLazyColorLoading) + fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey))); + else { + Token token= ((Token)fTokenMap.get(colorKey)); + if (token != null) + token.setData(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey)); + } + } + + /** + * Create a text attribute based on the given color, bold, italic, strikethrough and underline preference keys. + * + * @param colorKey the color preference key + * @param boldKey the bold preference key + * @param italicKey the italic preference key + * @param strikethroughKey the strikethrough preference key + * @param underlineKey the italic preference key + * @return the created text attribute + * @since 3.0 + */ + private TextAttribute createTextAttribute(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { + Color color= null; + if (colorKey != null) + color= fColorManager.getColor(colorKey); + + int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL; + if (fPreferenceStore.getBoolean(italicKey)) + style |= SWT.ITALIC; + + if (fPreferenceStore.getBoolean(strikethroughKey)) + style |= TextAttribute.STRIKETHROUGH; + + if (fPreferenceStore.getBoolean(underlineKey)) + style |= TextAttribute.UNDERLINE; + + return new TextAttribute(color, null, style); + } + protected Token getToken(String key) { + if (fNeedsLazyColorLoading) + resolveProxyAttributes(); return (Token) fTokenMap.get(key); } - + private void initializeRules() { List rules= createRules(); if (rules != null) { @@ -116,109 +273,93 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner { setRules(result); } } - + private int indexOf(String property) { if (property != null) { int length= fPropertyNamesColor.length; for (int i= 0; i < length; i++) { - if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesStyle[i])) + if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBold[i]) || property.equals(fPropertyNamesItalic[i]) || property.equals(fPropertyNamesStrikethrough[i]) || property.equals(fPropertyNamesUnderline[i])) return i; } } return -1; } - + public boolean affectsBehavior(PropertyChangeEvent event) { return indexOf(event.getProperty()) >= 0; } - + public void adaptToPreferenceChange(PropertyChangeEvent event) { String p= event.getProperty(); int index= indexOf(p); - Token token = getToken(fPropertyNamesColor[index]); + Token token= getToken(fPropertyNamesColor[index]); if (fPropertyNamesColor[index].equals(p)) adaptToColorChange(token, event); - else - adaptToStyleChange(token, event); + else if (fPropertyNamesBold[index].equals(p)) + adaptToStyleChange(token, event, SWT.BOLD); + else if (fPropertyNamesItalic[index].equals(p)) + adaptToStyleChange(token, event, SWT.ITALIC); + else if (fPropertyNamesStrikethrough[index].equals(p)) + adaptToStyleChange(token, event, TextAttribute.STRIKETHROUGH); + else if (fPropertyNamesUnderline[index].equals(p)) + adaptToStyleChange(token, event, TextAttribute.UNDERLINE); } - + private void adaptToColorChange(Token token, PropertyChangeEvent event) { RGB rgb= null; - + Object value= event.getNewValue(); if (value instanceof RGB) rgb= (RGB) value; - else if (value instanceof String) { + else if (value instanceof String) rgb= StringConverter.asRGB((String) value); - } - + if (rgb != null) { - + String property= event.getProperty(); - - if (fColorManager instanceof IColorManagerExtension) { + Color color= fColorManager.getColor(property); + + if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; - ext.unbindColor(property); - ext.bindColor(property, rgb); + + ext.unbindColor(property); + ext.bindColor(property, rgb); + + color= fColorManager.getColor(property); } - + Object data= token.getData(); if (data instanceof TextAttribute) { TextAttribute oldAttr= (TextAttribute) data; - token.setData(new TextAttribute(fColorManager.getColor(property), oldAttr.getBackground(), oldAttr.getStyle())); + token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle())); } } } - - private void adaptToStyleChange(Token token, PropertyChangeEvent event) { - boolean bold= false; + + private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) { + boolean eventValue= false; Object value= event.getNewValue(); if (value instanceof Boolean) - bold= ((Boolean) value).booleanValue(); - else if (value instanceof String) { - String s= (String) value; - if (IPreferenceStore.TRUE.equals(s)) - bold= true; - else if (IPreferenceStore.FALSE.equals(s)) - bold= false; - } - + eventValue= ((Boolean) value).booleanValue(); + else if (IPreferenceStore.TRUE.equals(value)) + eventValue= true; + Object data= token.getData(); if (data instanceof TextAttribute) { TextAttribute oldAttr= (TextAttribute) data; - boolean isBold= (oldAttr.getStyle() == SWT.BOLD); - if (isBold != bold) - token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), bold ? SWT.BOLD : SWT.NORMAL)); + boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute; + if (activeValue != eventValue) + token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute)); } } - /** - * Returns the next token in the document. + * Returns the preference store. * - * @return the next token in the document + * @return the preference store. + * + * @since 3.0 */ - public IToken nextToken() { - - IToken token; - - while (true) { - - fTokenOffset= fOffset; - fColumn= UNDEFINED; - - for (int i= 0; i < fRules.length; i++) { - token= (fRules[i].evaluate(this)); - if (!token.isUndefined()) - return token; - } - if (read() == EOF) - return Token.EOF; - return fDefaultToken; - } - } - - public void setDefaultReturnToken(IToken token) { - fDefaultToken = token; + protected IPreferenceStore getPreferenceStore() { + return fPreferenceStore; } } - diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java index 56d432e64dd..f6baedc107f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java @@ -72,18 +72,26 @@ public class CTextTools { * and initializes all members of this collection. */ public CTextTools(IPreferenceStore store) { - this(store, null); + this(store, null, true); + } + + /** + * Creates a new C text tools collection and eagerly creates + * and initializes all members of this collection. + */ + public CTextTools(IPreferenceStore store, Preferences coreStore) { + this(store, coreStore, true); } /** * Creates a new C text tools collection and eagerly creates * and initializes all members of this collection. */ - public CTextTools(IPreferenceStore store, Preferences coreStore) { + public CTextTools(IPreferenceStore store, Preferences coreStore, boolean autoDisposeOnDisplayDispose) { if(store == null) { store = CUIPlugin.getDefault().getPreferenceStore(); } - fColorManager= new CColorManager(); + fColorManager= new CColorManager(autoDisposeOnDisplayDispose); fCodeScanner= new CCodeScanner(fColorManager, store); fCppCodeScanner= new CppCodeScanner(fColorManager, store); fPartitionScanner= new FastCPartitionScanner(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java index 284cb03bbbb..74ebdde95a8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000 2005 IBM Corporation and others. + * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * QNX Software System + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.text.util; @@ -22,17 +23,41 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; /** - * Java color manager. + * CDT color manager. */ public class CColorManager implements IColorManager, IColorManagerExtension { protected Map fKeyTable= new HashMap(10); protected Map fDisplayTable= new HashMap(2); - + /** + * Flag which tells if the colors are automatically disposed when + * the current display gets disposed. + */ + private boolean fAutoDisposeOnDisplayDispose; + + /** + * Creates a new CDT color manager which automatically + * disposes the allocated colors when the current display + * gets disposed. + */ public CColorManager() { + this(true); } - + + /** + * Creates a new CDT color manager. + * + * @param autoDisposeOnDisplayDispose if true the color manager + * automatically disposes all managed colors when the current display gets disposed + * and all calls to {@link org.eclipse.jface.text.source.ISharedTextColors#dispose()} are ignored. + * + * @since 4.0 + */ + public CColorManager(boolean autoDisposeOnDisplayDispose) { + fAutoDisposeOnDisplayDispose= autoDisposeOnDisplayDispose; + } + protected void dispose(Display display) { Map colorTable= (Map) fDisplayTable.get(display); if (colorTable != null) { @@ -55,11 +80,13 @@ public class CColorManager implements IColorManager, IColorManagerExtension { if (colorTable == null) { colorTable= new HashMap(10); fDisplayTable.put(display, colorTable); - display.disposeExec(new Runnable() { - public void run() { - dispose(display); - } - }); + if (fAutoDisposeOnDisplayDispose) { + display.disposeExec(new Runnable() { + public void run() { + dispose(display); + } + }); + } } Color color= (Color) colorTable.get(rgb); @@ -75,9 +102,10 @@ public class CColorManager implements IColorManager, IColorManagerExtension { * @see IColorManager#dispose */ public void dispose() { - dispose(Display.getCurrent()); + if (!fAutoDisposeOnDisplayDispose) + dispose(Display.getCurrent()); } - + /* * @see IColorManager#getColor(String) */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java index b96fc576d80..cba76ad143e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java @@ -12,14 +12,14 @@ *******************************************************************************/ package org.eclipse.cdt.ui; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; - import org.eclipse.jface.action.Action; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.RGB; +import org.eclipse.cdt.internal.ui.text.ICColorConstants; + /** * Preference constants used in the CDT-UI preference store. Clients should only read the * CDT-UI preference store using these values. Clients are not allowed to modify the @@ -33,21 +33,376 @@ public class PreferenceConstants { private PreferenceConstants() { } - /** - * Preference key suffix for bold text style preference keys. - */ - public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$ + /** + * Preference key suffix for bold text style preference keys. + * + * @since 4.0 + */ + public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$ /** - * A named preference that controls if comment stubs will be added - * automatically to newly created types and methods. + * Preference key suffix for italic text style preference keys. + * + * @since 4.0 + */ + public static final String EDITOR_ITALIC_SUFFIX= "_italic"; //$NON-NLS-1$ + + /** + * Preference key suffix for strikethrough text style preference keys. + * + * @since 4.0 + */ + public static final String EDITOR_STRIKETHROUGH_SUFFIX= "_strikethrough"; //$NON-NLS-1$ + + /** + * Preference key suffix for underline text style preference keys. + * + * @since 4.0 + */ + public static final String EDITOR_UNDERLINE_SUFFIX= "_underline"; //$NON-NLS-1$ + + /** + * A named preference that holds the color used to render multi-line comments. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_MULTI_LINE_COMMENT_COLOR= ICColorConstants.C_MULTI_LINE_COMMENT; + + /** + * A named preference that controls whether multi-line comments are rendered in bold. + *

+ * Value is of type Boolean. If true multi-line comments are rendered + * in bold. If false the are rendered using no font style attribute. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_MULTI_LINE_COMMENT_BOLD= ICColorConstants.C_MULTI_LINE_COMMENT + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether multi-line comments are rendered in italic. + *

+ * Value is of type Boolean. If true multi-line comments are rendered + * in italic. If false the are rendered using no italic font style attribute. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_MULTI_LINE_COMMENT_ITALIC= ICColorConstants.C_MULTI_LINE_COMMENT + EDITOR_ITALIC_SUFFIX; + + /** + * A named preference that holds the color used to render single line comments. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_SINGLE_LINE_COMMENT_COLOR= ICColorConstants.C_SINGLE_LINE_COMMENT; + + /** + * A named preference that controls whether single line comments are rendered in bold. + *

+ * Value is of type Boolean. If true single line comments are rendered + * in bold. If false the are rendered using no font style attribute. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD= ICColorConstants.C_SINGLE_LINE_COMMENT + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether single line comments are rendered in italic. + *

+ * Value is of type Boolean. If true single line comments are rendered + * in italic. If false the are rendered using no italic font style attribute. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_SINGLE_LINE_COMMENT_ITALIC= ICColorConstants.C_SINGLE_LINE_COMMENT + EDITOR_ITALIC_SUFFIX; + + /** + * A named preference that holds the color used to render C/C++ keywords. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_C_KEYWORD_COLOR= ICColorConstants.C_KEYWORD; + + /** + * A named preference that controls whether keywords are rendered in bold. *

* Value is of type Boolean. *

- * @since 2.1 + * + * @since 4.0 */ - public static final String CODEGEN_ADD_COMMENTS= "org.eclipse.cdt.ui.javadoc"; //$NON-NLS-1$ + public final static String EDITOR_C_KEYWORD_BOLD= ICColorConstants.C_KEYWORD + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether keywords are rendered in italic. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_KEYWORD_ITALIC= ICColorConstants.C_KEYWORD + EDITOR_ITALIC_SUFFIX; + /** + * A named preference that holds the color used to render builtin types. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_C_BUILTIN_TYPE_COLOR= ICColorConstants.C_TYPE; + + /** + * A named preference that controls whether builtin types are rendered in bold. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_BUILTIN_TYPE_BOLD= ICColorConstants.C_TYPE + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether builtin types are rendered in italic. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_BUILTIN_TYPE_ITALIC= ICColorConstants.C_TYPE + EDITOR_ITALIC_SUFFIX; + + /** + * A named preference that holds the color used to render string constants. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_C_STRING_COLOR= ICColorConstants.C_STRING; + + /** + * A named preference that controls whether string constants are rendered in bold. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_STRING_BOLD= ICColorConstants.C_STRING + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether string constants are rendered in italic. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_STRING_ITALIC= ICColorConstants.C_STRING + EDITOR_ITALIC_SUFFIX; + + /** + * A named preference that holds the color used to render operators. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_C_OPERATOR_COLOR= ICColorConstants.C_OPERATOR; + + /** + * A named preference that controls whether operators are rendered in bold. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_OPERATOR_BOLD= ICColorConstants.C_OPERATOR + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether operators are rendered in italic. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_OPERATOR_ITALIC= ICColorConstants.C_OPERATOR + EDITOR_ITALIC_SUFFIX; + + /** + * A named preference that holds the color used to render numbers. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_C_NUMBER_COLOR= ICColorConstants.C_NUMBER; + + /** + * A named preference that controls whether number are rendered in bold. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_NUMBER_BOLD= ICColorConstants.C_NUMBER + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether number are rendered in italic. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_NUMBER_ITALIC= ICColorConstants.C_NUMBER + EDITOR_ITALIC_SUFFIX; + + /** + * A named preference that holds the color used to render headers. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_C_HEADER_COLOR= ICColorConstants.C_HEADER; + + /** + * A named preference that controls whether headers are rendered in bold. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_HEADER_BOLD= ICColorConstants.C_HEADER + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether number are rendered in italic. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_HEADER_ITALIC= ICColorConstants.C_HEADER + EDITOR_ITALIC_SUFFIX; + + /** + * A named preference that holds the color used to render braces. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_C_BRACES_COLOR= ICColorConstants.C_BRACES; + + /** + * A named preference that controls whether braces are rendered in bold. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_BRACES_BOLD= ICColorConstants.C_BRACES + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether braces are rendered in italic. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_BRACES_ITALIC= ICColorConstants.C_BRACES + EDITOR_ITALIC_SUFFIX; + + /** + * A named preference that holds the color used to render C/C++ default text. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 4.0 + */ + public final static String EDITOR_C_DEFAULT_COLOR= ICColorConstants.C_DEFAULT; + + /** + * A named preference that controls whether C/C++ default text is rendered in bold. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_DEFAULT_BOLD= ICColorConstants.C_DEFAULT + EDITOR_BOLD_SUFFIX; + + /** + * A named preference that controls whether C/C++ default text is rendered in italic. + *

+ * Value is of type Boolean. + *

+ * + * @since 4.0 + */ + public final static String EDITOR_C_DEFAULT_ITALIC= ICColorConstants.C_DEFAULT + EDITOR_ITALIC_SUFFIX; + + /** + * The symbolic font name for the C/C++ editor text font + * (value "org.eclipse.cdt.ui.editors.textfont"). + * + * @since 4.0 + */ + public final static String EDITOR_TEXT_FONT= "org.eclipse.cdt.ui.editors.textfont"; //$NON-NLS-1$ + /** * A named preference that controls whether the cview's selection is linked to the active editor. *

@@ -99,39 +454,16 @@ public class PreferenceConstants { *

*/ public final static String EDITOR_TASK_TAG_BOLD= ICColorConstants.TASK_TAG + EDITOR_BOLD_SUFFIX; - + /** - * A named preference that controls whether the editor shows task indicators in text (squiggly lines). + * A named preference that controls whether task tags are rendered in italic. *

* Value is of type Boolean. *

*/ - public final static String EDITOR_TASK_INDICATION= "taskIndication"; //$NON-NLS-1$ + public final static String EDITOR_TASK_TAG_ITALIC= ICColorConstants.TASK_TAG + EDITOR_ITALIC_SUFFIX; /** - * A named preference that holds the color used to render task indicators. - *

- * Value is of type String. A RGB color value encoded as a string - * using class PreferenceConverter - *

- * - * @see #EDITOR_TASK_INDICATION - * @see org.eclipse.jface.resource.StringConverter - * @see org.eclipse.jface.preference.PreferenceConverter - */ - public final static String EDITOR_TASK_INDICATION_COLOR= "taskIndicationColor"; //$NON-NLS-1$ - - /** - * A named preference that controls whether the overview ruler shows task - * indicators. - *

- * Value is of type Boolean. - *

- * @since 2.1 - */ - public final static String EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER= "taskIndicationInOverviewRuler"; //$NON-NLS-1$ - - /** * A named preference that controls if correction indicators are shown in the UI. *

* Value is of type Boolean. @@ -209,7 +541,7 @@ public class PreferenceConstants { /** * The id of the best match hover contributed for extension point - * javaEditorTextHovers. + * org.eclipse.cdt.ui.textHovers. * * @since 2.1 */ @@ -571,12 +903,6 @@ public class PreferenceConstants { * @param store the preference store to be initialized */ public static void initializeDefaultValues(IPreferenceStore store) { - store.setDefault(PreferenceConstants.EDITOR_TASK_INDICATION, false); - PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR, new RGB(0, 128, 255)); - store.setDefault(PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER, true); - - PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191)); - store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_BOLD, true); store.setDefault(PreferenceConstants.EDITOR_CORRECTION_INDICATION, false); @@ -589,6 +915,51 @@ public class PreferenceConstants { store.setDefault(PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true); + // coloring + PreferenceConverter.setDefault(store, EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95)); + store.setDefault(EDITOR_MULTI_LINE_COMMENT_BOLD, false); + store.setDefault(EDITOR_MULTI_LINE_COMMENT_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 125, 95)); + store.setDefault(EDITOR_SINGLE_LINE_COMMENT_BOLD, false); + store.setDefault(EDITOR_SINGLE_LINE_COMMENT_ITALIC, false); + + PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191)); + store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_BOLD, true); + store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_C_KEYWORD_COLOR, new RGB(127, 0, 85)); + store.setDefault(EDITOR_C_KEYWORD_BOLD, true); + store.setDefault(EDITOR_C_KEYWORD_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_C_BUILTIN_TYPE_COLOR, new RGB(127, 0, 85)); + store.setDefault(EDITOR_C_BUILTIN_TYPE_BOLD, true); + store.setDefault(EDITOR_C_BUILTIN_TYPE_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_C_STRING_COLOR, new RGB(42, 0, 255)); + store.setDefault(EDITOR_C_STRING_BOLD, false); + store.setDefault(EDITOR_C_STRING_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_C_DEFAULT_COLOR, new RGB(0, 0, 0)); + store.setDefault(EDITOR_C_DEFAULT_BOLD, false); + store.setDefault(EDITOR_C_DEFAULT_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_C_OPERATOR_COLOR, new RGB(0, 0, 0)); + store.setDefault(EDITOR_C_OPERATOR_BOLD, false); + store.setDefault(EDITOR_C_OPERATOR_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_C_BRACES_COLOR, new RGB(0, 0, 0)); + store.setDefault(EDITOR_C_BRACES_BOLD, false); + store.setDefault(EDITOR_C_BRACES_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_C_NUMBER_COLOR, new RGB(0, 0, 0)); + store.setDefault(EDITOR_C_NUMBER_BOLD, false); + store.setDefault(EDITOR_C_NUMBER_ITALIC, false); + + PreferenceConverter.setDefault(store, EDITOR_C_HEADER_COLOR, new RGB(42, 0, 255)); + store.setDefault(EDITOR_C_HEADER_BOLD, false); + store.setDefault(EDITOR_C_HEADER_ITALIC, false); + // folding store.setDefault(PreferenceConstants.EDITOR_FOLDING_ENABLED, false); store.setDefault(PreferenceConstants.EDITOR_FOLDING_PROVIDER, "org.eclipse.cdt.ui.text.defaultFoldingProvider"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CodeFormatterBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CodeFormatterBlock.java index 4faad5919b6..2c164148d23 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CodeFormatterBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CodeFormatterBlock.java @@ -50,7 +50,7 @@ public class CodeFormatterBlock { private static final String ATTR_ID="id"; //$NON-NLS-1$ // This is a hack until we have a default Formatter. // For now it is comment out in the plugin.xml - private static final String NONE=PreferencesMessages.getString("CodeFormatterPreferencePage.emptyName"); //$NON-NLS-1$ + private static final String NONE=PreferencesMessages.CodeFormatterPreferencePage_emptyName; public CodeFormatterBlock(Preferences prefs) { @@ -105,7 +105,7 @@ public class CodeFormatterBlock { ControlFactory.createEmptySpace(control, 2); - Label label = ControlFactory.createLabel(control, PreferencesMessages.getString("CodeFormatterPreferencePage.selectionName")); //$NON-NLS-1$ + Label label = ControlFactory.createLabel(control, PreferencesMessages.CodeFormatterPreferencePage_selectionName); label.setLayoutData(new GridData()); fFormatterCombo = new Combo(control, SWT.DROP_DOWN | SWT.READ_ONLY); GridData gd = new GridData(GridData.GRAB_HORIZONTAL);