mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cleanup CSourceViewer: remove obsolete constructor and duplicate methods
This commit is contained in:
parent
9b75c68712
commit
39fd51b72a
3 changed files with 34 additions and 89 deletions
|
@ -16,10 +16,8 @@ package org.eclipse.cdt.internal.ui.editor;
|
|||
|
||||
|
||||
import java.text.CharacterIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Stack;
|
||||
|
@ -215,12 +213,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IR
|
|||
|
||||
class AdaptedSourceViewer extends CSourceViewer {
|
||||
|
||||
private List fTextConverters;
|
||||
private boolean fIgnoreTextConverters= false;
|
||||
|
||||
public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
|
||||
boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
|
||||
super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
|
||||
super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles, store);
|
||||
}
|
||||
|
||||
public IContentAssistant getContentAssistant() {
|
||||
|
@ -253,52 +248,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IR
|
|||
msg= fQuickAssistAssistant.showPossibleQuickAssists();
|
||||
setStatusLineErrorMessage(msg);
|
||||
return;
|
||||
case UNDO:
|
||||
fIgnoreTextConverters= true;
|
||||
super.doOperation(operation);
|
||||
fIgnoreTextConverters= false;
|
||||
return;
|
||||
case REDO:
|
||||
fIgnoreTextConverters= true;
|
||||
super.doOperation(operation);
|
||||
fIgnoreTextConverters= false;
|
||||
return;
|
||||
}
|
||||
|
||||
super.doOperation(operation);
|
||||
}
|
||||
|
||||
public void insertTextConverter(ITextConverter textConverter, int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void addTextConverter(ITextConverter textConverter) {
|
||||
if (fTextConverters == null) {
|
||||
fTextConverters= new ArrayList(1);
|
||||
fTextConverters.add(textConverter);
|
||||
} else if (!fTextConverters.contains(textConverter))
|
||||
fTextConverters.add(textConverter);
|
||||
}
|
||||
|
||||
public void removeTextConverter(ITextConverter textConverter) {
|
||||
if (fTextConverters != null) {
|
||||
fTextConverters.remove(textConverter);
|
||||
if (fTextConverters.size() == 0)
|
||||
fTextConverters= null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see TextViewer#customizeDocumentCommand(DocumentCommand)
|
||||
*/
|
||||
protected void customizeDocumentCommand(DocumentCommand command) {
|
||||
super.customizeDocumentCommand(command);
|
||||
if (!fIgnoreTextConverters && fTextConverters != null) {
|
||||
for (Iterator e = fTextConverters.iterator(); e.hasNext();)
|
||||
((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateIndentationPrefixes() {
|
||||
SourceViewerConfiguration configuration= getSourceViewerConfiguration();
|
||||
String[] types= configuration.getConfiguredContentTypes(this);
|
||||
|
@ -1836,6 +1790,13 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IR
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.texteditor.AbstractTextEditor#initializeViewerColors(org.eclipse.jface.text.source.ISourceViewer)
|
||||
*/
|
||||
protected void initializeViewerColors(ISourceViewer viewer) {
|
||||
// is handled by CSourceViewer
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the hovering behavior depending on the preferences.
|
||||
*/
|
||||
|
@ -2874,7 +2835,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IR
|
|||
* @see org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant#reconciled()
|
||||
*/
|
||||
public void reconciled(boolean somethingHasChanged) {
|
||||
if (getSourceViewer() == null) {
|
||||
if (getSourceViewer() == null || getSourceViewer().getTextWidget() == null) {
|
||||
return;
|
||||
}
|
||||
// this method must be called in a background thread
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Sergey Prigogin, Google
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
|
@ -15,9 +16,9 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
import org.eclipse.jface.text.Assert;
|
||||
import org.eclipse.jface.text.DocumentCommand;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
|
@ -52,12 +53,11 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
/** Show outline operation id. */
|
||||
public static final int SHOW_OUTLINE = 101;
|
||||
|
||||
/** Editor. */
|
||||
private CEditor editor;
|
||||
/** Presents outline. */
|
||||
private IInformationPresenter fOutlinePresenter;
|
||||
|
||||
private List fTextConverters;
|
||||
private boolean fIgnoreTextConverters= false;
|
||||
|
||||
/**
|
||||
* This viewer's foreground color.
|
||||
|
@ -104,19 +104,6 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
|
||||
/**
|
||||
* Creates new source viewer.
|
||||
* @param parent
|
||||
* @param ruler
|
||||
* @param fOverviewRuler
|
||||
* @param isOverviewRulerShowing
|
||||
* @param styles
|
||||
*/
|
||||
public CSourceViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler fOverviewRuler, boolean isOverviewRulerShowing,
|
||||
int styles) {
|
||||
super(parent, ruler, fOverviewRuler, isOverviewRulerShowing, styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new source viewer.
|
||||
* @param parent
|
||||
* @param ruler
|
||||
* @param overviewRuler
|
||||
|
@ -132,7 +119,6 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
int styles,
|
||||
IPreferenceStore store) {
|
||||
super(parent, ruler, overviewRuler, isOverviewRulerShowing, styles);
|
||||
this.editor= null;
|
||||
setPreferenceStore(store);
|
||||
}
|
||||
|
||||
|
@ -161,7 +147,6 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
fOutlinePresenter= cConfiguration.getOutlinePresenter(this);
|
||||
if (fOutlinePresenter != null)
|
||||
fOutlinePresenter.install(this);
|
||||
editor = (CEditor) cConfiguration.getEditor();
|
||||
}
|
||||
if (fPreferenceStore != null) {
|
||||
fPreferenceStore.addPropertyChangeListener(this);
|
||||
|
@ -178,8 +163,8 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
|
||||
// ----------- foreground color --------------------
|
||||
Color color= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
|
||||
? null
|
||||
: createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
|
||||
? null
|
||||
: createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
|
||||
styledText.setForeground(color);
|
||||
|
||||
if (fForegroundColor != null)
|
||||
|
@ -189,8 +174,8 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
|
||||
// ---------- background color ----------------------
|
||||
color= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
|
||||
? null
|
||||
: createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
|
||||
? null
|
||||
: createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
|
||||
styledText.setBackground(color);
|
||||
|
||||
if (fBackgroundColor != null)
|
||||
|
@ -249,7 +234,7 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* @see org.eclipse.jface.text.source.SourceViewer#unconfigure()
|
||||
*/
|
||||
public void unconfigure() {
|
||||
|
@ -311,7 +296,7 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int)
|
||||
*/
|
||||
public void doOperation(int operation) {
|
||||
|
@ -320,22 +305,24 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
return;
|
||||
}
|
||||
switch (operation) {
|
||||
case CONTENTASSIST_PROPOSALS:
|
||||
{
|
||||
String msg= fContentAssistant.showPossibleCompletions();
|
||||
editor.setStatusLineErrorMessage(msg);
|
||||
return;
|
||||
}
|
||||
case SHOW_OUTLINE:
|
||||
{
|
||||
fOutlinePresenter.showInformation();
|
||||
return;
|
||||
}
|
||||
case UNDO:
|
||||
fIgnoreTextConverters= true;
|
||||
super.doOperation(operation);
|
||||
fIgnoreTextConverters= false;
|
||||
return;
|
||||
case REDO:
|
||||
fIgnoreTextConverters= true;
|
||||
super.doOperation(operation);
|
||||
fIgnoreTextConverters= false;
|
||||
return;
|
||||
}
|
||||
super.doOperation(operation);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* @see org.eclipse.jface.text.source.projection.ProjectionViewer#canDoOperation(int)
|
||||
*/
|
||||
public boolean canDoOperation(int operation) {
|
||||
|
@ -345,10 +332,6 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
return super.canDoOperation(operation);
|
||||
}
|
||||
|
||||
public void insertTextConverter(ITextConverter textConverter, int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void addTextConverter(ITextConverter textConverter) {
|
||||
if (fTextConverters == null) {
|
||||
fTextConverters = new ArrayList(1);
|
||||
|
@ -370,9 +353,9 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
*/
|
||||
protected void customizeDocumentCommand(DocumentCommand command) {
|
||||
super.customizeDocumentCommand(command);
|
||||
if (fTextConverters != null) {
|
||||
if (!fIgnoreTextConverters && fTextConverters != null) {
|
||||
for (Iterator e = fTextConverters.iterator(); e.hasNext();)
|
||||
((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
|
||||
((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* Sergey Prigogin, Google
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
||||
|
||||
|
@ -114,7 +115,7 @@ public abstract class CPreview {
|
|||
|
||||
IPreferenceStore[] chain= { prioritizedSettings, CUIPlugin.getDefault().getCombinedPreferenceStore() };
|
||||
fPreferenceStore= new ChainedPreferenceStore(chain);
|
||||
fSourceViewer= new CSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
|
||||
fSourceViewer= new CSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore);
|
||||
fViewerConfiguration= new SimpleCSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, ICPartitions.C_PARTITIONING, true);
|
||||
fSourceViewer.configure(fViewerConfiguration);
|
||||
fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
|
||||
|
|
Loading…
Add table
Reference in a new issue