Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2005-07-09 23:44:55 -0400
committerAlain Magloire2005-07-09 23:44:55 -0400
commite7a70d2d22fb66cece3a6a01b610b3e00bafd5f9 (patch)
tree8454eacd3bb6840ebc202c66b88e3f6948e786cc
parent07d3cbbf01043e6d5ff4dd4714a6b5a0a52aa60d (diff)
downloadorg.eclipse.cdt-e7a70d2d22fb66cece3a6a01b610b3e00bafd5f9.tar.gz
org.eclipse.cdt-e7a70d2d22fb66cece3a6a01b610b3e00bafd5f9.tar.xz
org.eclipse.cdt-e7a70d2d22fb66cece3a6a01b610b3e00bafd5f9.zip
2005-07-09 Alain Magloire
Fix PR 90419 * src/org/eclipse/cdt/internal/coreext/util/CodeFormatterUtil.java * src/org/eclipse/cdt/internal/ui/editor/CEditor.java * src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java * src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
-rw-r--r--core/org.eclipse.cdt.ui/ChangeLog7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java14
5 files changed, 25 insertions, 35 deletions
diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index 7858e991a3..381f9be753 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,3 +1,10 @@
+2005-07-09 Alain Magloire
+ Fix PR 90419
+ * src/org/eclipse/cdt/internal/coreext/util/CodeFormatterUtil.java
+ * src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+ * src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
+ * src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
+
2005-07-08 Alain Magloire
Fix for the CFileType UI
* src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
index f8fa310f33..c9bef6808f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
@@ -15,7 +15,6 @@ import java.util.Map;
import org.eclipse.cdt.core.ToolFactory;
import org.eclipse.cdt.core.formatter.CodeFormatter;
import org.eclipse.cdt.internal.corext.Assert;
-import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.text.BadLocationException;
@@ -24,6 +23,7 @@ import org.eclipse.jface.text.DefaultPositionUpdater;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.Position;
import org.eclipse.text.edits.TextEdit;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
public class CodeFormatterUtil {
@@ -136,7 +136,7 @@ public class CodeFormatterUtil {
public static int getTabWidth() {
Preferences preferences= CUIPlugin.getDefault().getPluginPreferences();
- return preferences.getInt(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH);
+ return preferences.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
index d007bc9aeb..9b5cc662dc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
@@ -98,6 +98,7 @@ import org.eclipse.ui.part.EditorActionBarContributor;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.IDocumentProvider;
@@ -335,24 +336,18 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
String property = event.getProperty();
- if (CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH.equals(property)) {
+ if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
String[] types = configuration.getConfiguredContentTypes(asv);
- for (int i = 0; i < types.length; i++)
+ for (int i = 0; i < types.length; i++) {
asv.setIndentPrefixes(configuration.getIndentPrefixes(asv, types[i]), types[i]);
+ }
- if (fTabConverter != null)
- fTabConverter.setNumberOfSpacesPerTab(
- getPreferenceStore().getInt(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH));
-
- Object value = event.getNewValue();
-
- if (value instanceof Integer) {
- asv.getTextWidget().setTabs(((Integer) value).intValue());
-
- } else if (value instanceof String) {
- asv.getTextWidget().setTabs(Integer.parseInt((String) value));
+ if (fTabConverter != null) {
+ fTabConverter.setNumberOfSpacesPerTab(configuration.getTabWidth(asv));
}
+ // the super class handles the reset of the tabsize.
+ return;
}
if (SPACES_FOR_TABS.equals(property)) {
@@ -371,8 +366,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
}
if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
- if (fProjectionModelUpdater != null)
+ if (fProjectionModelUpdater != null) {
fProjectionModelUpdater.uninstall();
+ }
// either freshly enabled or provider changed
fProjectionModelUpdater= CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
if (fProjectionModelUpdater != null) {
@@ -382,8 +378,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
}
IContentAssistant c= asv.getContentAssistant();
- if (c instanceof ContentAssistant)
+ if (c instanceof ContentAssistant) {
ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
+ }
}
} finally {
@@ -1145,10 +1142,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
private void startTabConversion() {
if (fTabConverter == null) {
+ CSourceViewer asv = (CSourceViewer) getSourceViewer();
+ SourceViewerConfiguration configuration = getSourceViewerConfiguration();
fTabConverter = new TabConverter();
configureTabConverter();
- fTabConverter.setNumberOfSpacesPerTab(getPreferenceStore().getInt(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH));
- CSourceViewer asv = (CSourceViewer) getSourceViewer();
+ fTabConverter.setNumberOfSpacesPerTab(configuration.getTabWidth(asv));
asv.addTextConverter(fTabConverter);
}
}
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 b96dd01852..36af4918da 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
@@ -86,7 +86,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
ArrayList overlayKeys = new ArrayList();
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH));
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));
@@ -126,8 +125,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
store.setDefault(CEditor.MATCHING_BRACKETS, true);
PreferenceConverter.setDefault(store, CEditor.MATCHING_BRACKETS_COLOR, new RGB(170,170,170));
- store.setDefault(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH, 4);
-
store.setDefault(CEditor.SPACES_FOR_TABS, false);
PreferenceConverter.setDefault(store, ICColorConstants.C_MULTI_LINE_COMMENT, new RGB(63, 127, 95));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
index aacf5884fa..56eb9e3b70 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
@@ -57,9 +57,6 @@ import org.eclipse.ui.texteditor.ITextEditor;
*/
public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
- /** Key used to look up display tab width */
- public final static String PREFERENCE_TAB_WIDTH= "org.eclipse.cdt.editor.tab.width"; //$NON-NLS-1$
-
private CTextTools fTextTools;
private CEditor fEditor;
@@ -282,7 +279,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
Vector vector= new Vector();
// prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
- int tabWidth= getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
+ int tabWidth= getTabWidth(sourceViewer);
boolean useSpaces= getPreferenceStore().getBoolean(CEditor.SPACES_FOR_TABS); //$NON-NLS-1$
for (int i= 0; i <= tabWidth; i++) {
@@ -310,15 +307,6 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
return (String[]) vector.toArray(new String[vector.size()]);
}
-
- /**
- * @see SourceViewerConfiguration#getTabWidth(ISourceViewer)
- */
- public int getTabWidth(ISourceViewer sourceViewer) {
- return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
- }
-
-
/**
* @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
*/

Back to the top