1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

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
This commit is contained in:
Alain Magloire 2005-07-10 03:44:55 +00:00
parent 07d3cbbf01
commit e7a70d2d22
5 changed files with 26 additions and 36 deletions

View file

@ -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 2005-07-08 Alain Magloire
Fix for the CFileType UI Fix for the CFileType UI
* src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java * src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java

View file

@ -15,7 +15,6 @@ import java.util.Map;
import org.eclipse.cdt.core.ToolFactory; import org.eclipse.cdt.core.ToolFactory;
import org.eclipse.cdt.core.formatter.CodeFormatter; import org.eclipse.cdt.core.formatter.CodeFormatter;
import org.eclipse.cdt.internal.corext.Assert; import org.eclipse.cdt.internal.corext.Assert;
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.text.BadLocationException; 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.Document;
import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Position;
import org.eclipse.text.edits.TextEdit; import org.eclipse.text.edits.TextEdit;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
public class CodeFormatterUtil { public class CodeFormatterUtil {
@ -136,7 +136,7 @@ public class CodeFormatterUtil {
public static int getTabWidth() { public static int getTabWidth() {
Preferences preferences= CUIPlugin.getDefault().getPluginPreferences(); Preferences preferences= CUIPlugin.getDefault().getPluginPreferences();
return preferences.getInt(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH); return preferences.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
} }
} }

View file

@ -98,6 +98,7 @@ import org.eclipse.ui.part.EditorActionBarContributor;
import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTargetList; import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.ContentAssistAction; import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.IDocumentProvider;
@ -335,24 +336,18 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
String property = event.getProperty(); String property = event.getProperty();
if (CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH.equals(property)) { if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
SourceViewerConfiguration configuration = getSourceViewerConfiguration(); SourceViewerConfiguration configuration = getSourceViewerConfiguration();
String[] types = configuration.getConfiguredContentTypes(asv); 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]); 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)) { 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 (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
if (fProjectionModelUpdater != null) if (fProjectionModelUpdater != null) {
fProjectionModelUpdater.uninstall(); fProjectionModelUpdater.uninstall();
}
// either freshly enabled or provider changed // either freshly enabled or provider changed
fProjectionModelUpdater= CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider(); fProjectionModelUpdater= CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
if (fProjectionModelUpdater != null) { if (fProjectionModelUpdater != null) {
@ -382,8 +378,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
} }
IContentAssistant c= asv.getContentAssistant(); IContentAssistant c= asv.getContentAssistant();
if (c instanceof ContentAssistant) if (c instanceof ContentAssistant) {
ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event); ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
}
} }
} finally { } finally {
@ -1145,10 +1142,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
private void startTabConversion() { private void startTabConversion() {
if (fTabConverter == null) { if (fTabConverter == null) {
CSourceViewer asv = (CSourceViewer) getSourceViewer();
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
fTabConverter = new TabConverter(); fTabConverter = new TabConverter();
configureTabConverter(); configureTabConverter();
fTabConverter.setNumberOfSpacesPerTab(getPreferenceStore().getInt(CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH)); fTabConverter.setNumberOfSpacesPerTab(configuration.getTabWidth(asv));
CSourceViewer asv = (CSourceViewer) getSourceViewer();
asv.addTextConverter(fTabConverter); asv.addTextConverter(fTabConverter);
} }
} }

View file

@ -86,7 +86,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
ArrayList overlayKeys = new ArrayList(); 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.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.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.STRING, ICColorConstants.C_SINGLE_LINE_COMMENT));
@ -126,8 +125,6 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
store.setDefault(CEditor.MATCHING_BRACKETS, true); store.setDefault(CEditor.MATCHING_BRACKETS, true);
PreferenceConverter.setDefault(store, CEditor.MATCHING_BRACKETS_COLOR, new RGB(170,170,170)); 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); store.setDefault(CEditor.SPACES_FOR_TABS, false);
PreferenceConverter.setDefault(store, ICColorConstants.C_MULTI_LINE_COMMENT, new RGB(63, 127, 95)); PreferenceConverter.setDefault(store, ICColorConstants.C_MULTI_LINE_COMMENT, new RGB(63, 127, 95));

View file

@ -57,9 +57,6 @@ import org.eclipse.ui.texteditor.ITextEditor;
*/ */
public class CSourceViewerConfiguration extends TextSourceViewerConfiguration { 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 CTextTools fTextTools;
private CEditor fEditor; private CEditor fEditor;
@ -282,7 +279,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
Vector vector= new Vector(); Vector vector= new Vector();
// prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces // 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$ boolean useSpaces= getPreferenceStore().getBoolean(CEditor.SPACES_FOR_TABS); //$NON-NLS-1$
for (int i= 0; i <= tabWidth; i++) { for (int i= 0; i <= tabWidth; i++) {
@ -310,15 +307,6 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
return (String[]) vector.toArray(new String[vector.size()]); 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) * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
*/ */