mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
update ceditor to 2.0/2.1
This commit is contained in:
parent
e6ecdc51cd
commit
445d0d51ee
15 changed files with 1150 additions and 3492 deletions
|
@ -1,3 +1,23 @@
|
||||||
|
2003-04-21 David Inglis
|
||||||
|
|
||||||
|
Update CEditor to be 2.0/2.1 compliant.
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/CEditor.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/BracketPainter.java (removed)
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/IPainter.java (removed)
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/LinePainter.java (removed)
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/OverviewRuler.java (removed)
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/PaintManager.java (removed)
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/PrintMarginPainter.java (removed)
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/ProblemPainter.java (removed)
|
||||||
|
* src/org/eclipse/cdt/internal/ui/preferences/CLaunchingPropertyPage.java (removed)
|
||||||
|
* src/org/eclipse/cdt/internal/ui/util/CoreUtility.java (removed)
|
||||||
|
|
||||||
2003-04-17 Alain Magloire
|
2003-04-17 Alain Magloire
|
||||||
|
|
||||||
Bug 36584
|
Bug 36584
|
||||||
|
|
|
@ -1,169 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.eclipse.swt.custom.StyledText;
|
|
||||||
import org.eclipse.swt.events.PaintEvent;
|
|
||||||
import org.eclipse.swt.events.PaintListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.text.CPairMatcher;
|
|
||||||
import org.eclipse.jface.text.IRegion;
|
|
||||||
import org.eclipse.jface.text.Position;
|
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public final class BracketPainter implements IPainter, PaintListener {
|
|
||||||
|
|
||||||
private CPairMatcher fMatcher= new CPairMatcher(new char[] { '{', '}', '(', ')', '[', ']' });
|
|
||||||
private Position fBracketPosition= new Position(0, 0);
|
|
||||||
private int fAnchor;
|
|
||||||
|
|
||||||
private boolean fIsActive= false;
|
|
||||||
private ISourceViewer fSourceViewer;
|
|
||||||
private StyledText fTextWidget;
|
|
||||||
private Color fColor;
|
|
||||||
private boolean fNoBox;
|
|
||||||
|
|
||||||
private IPositionManager fPositionManager;
|
|
||||||
|
|
||||||
|
|
||||||
public BracketPainter(ISourceViewer sourceViewer) {
|
|
||||||
fSourceViewer= sourceViewer;
|
|
||||||
fTextWidget= sourceViewer.getTextWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHighlightColor(Color color) {
|
|
||||||
fColor= color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHighlightStyle(boolean nobox) {
|
|
||||||
fNoBox = nobox;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose() {
|
|
||||||
if (fMatcher != null) {
|
|
||||||
fMatcher.dispose();
|
|
||||||
fMatcher= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
fColor= null;
|
|
||||||
fTextWidget= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deactivate(boolean redraw) {
|
|
||||||
if (fIsActive) {
|
|
||||||
fIsActive= false;
|
|
||||||
fTextWidget.removePaintListener(this);
|
|
||||||
if (fPositionManager != null)
|
|
||||||
fPositionManager.removeManagedPosition(fBracketPosition);
|
|
||||||
if (redraw)
|
|
||||||
handleDrawRequest(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void paintControl(PaintEvent event) {
|
|
||||||
if (fTextWidget != null)
|
|
||||||
handleDrawRequest(event.gc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleDrawRequest(GC gc) {
|
|
||||||
|
|
||||||
if (fBracketPosition.isDeleted)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int length= fBracketPosition.getLength();
|
|
||||||
if (length < 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int offset= fBracketPosition.getOffset();
|
|
||||||
IRegion region= fSourceViewer.getVisibleRegion();
|
|
||||||
|
|
||||||
if (region.getOffset() <= offset && region.getOffset() + region.getLength() >= offset + length) {
|
|
||||||
offset -= region.getOffset();
|
|
||||||
if (CPairMatcher.RIGHT == fAnchor)
|
|
||||||
draw(gc, offset, 1);
|
|
||||||
else
|
|
||||||
draw(gc, offset + length -1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void draw(GC gc, int offset, int length) {
|
|
||||||
if (gc != null) {
|
|
||||||
Point left= fTextWidget.getLocationAtOffset(offset);
|
|
||||||
Point right= fTextWidget.getLocationAtOffset(offset + length);
|
|
||||||
|
|
||||||
gc.setForeground(fColor);
|
|
||||||
if(fNoBox) {
|
|
||||||
gc.drawString(fTextWidget.getTextRange(offset, 1), left.x, left.y, true);
|
|
||||||
} else {
|
|
||||||
gc.drawRectangle(left.x, left.y, right.x - left.x - 1, gc.getFontMetrics().getHeight() - 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fTextWidget.redrawRange(offset, length, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#paint(int)
|
|
||||||
*/
|
|
||||||
public void paint(int reason) {
|
|
||||||
Point selection= fSourceViewer.getSelectedRange();
|
|
||||||
if (selection.y > 0) {
|
|
||||||
deactivate(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IRegion pair= fMatcher.match(fSourceViewer.getDocument(), selection.x);
|
|
||||||
if (pair == null) {
|
|
||||||
deactivate(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fIsActive) {
|
|
||||||
// only if different
|
|
||||||
if (pair.getOffset() != fBracketPosition.getOffset() ||
|
|
||||||
pair.getLength() != fBracketPosition.getLength() ||
|
|
||||||
fMatcher.getAnchor() != fAnchor) {
|
|
||||||
|
|
||||||
// remove old highlighting
|
|
||||||
handleDrawRequest(null);
|
|
||||||
// update position
|
|
||||||
fBracketPosition.isDeleted= false;
|
|
||||||
fBracketPosition.offset= pair.getOffset();
|
|
||||||
fBracketPosition.length= pair.getLength();
|
|
||||||
fAnchor= fMatcher.getAnchor();
|
|
||||||
// apply new highlighting
|
|
||||||
handleDrawRequest(null);
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
fIsActive= true;
|
|
||||||
|
|
||||||
fBracketPosition.isDeleted= false;
|
|
||||||
fBracketPosition.offset= pair.getOffset();
|
|
||||||
fBracketPosition.length= pair.getLength();
|
|
||||||
fAnchor= fMatcher.getAnchor();
|
|
||||||
|
|
||||||
fTextWidget.addPaintListener(this);
|
|
||||||
fPositionManager.addManagedPosition(fBracketPosition);
|
|
||||||
handleDrawRequest(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#setPositionManager(IPositionManager)
|
|
||||||
*/
|
|
||||||
public void setPositionManager(IPositionManager manager) {
|
|
||||||
fPositionManager= manager;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,12 +19,9 @@ ClassFileMarkerAnnotationModel.error.isAcceptable=ClassFileMarkerAnnotationModel
|
||||||
ClassFileMarkerAnnotationModel.error.isAffected=ClassFileMarkerAnnotationModel.isAffected
|
ClassFileMarkerAnnotationModel.error.isAffected=ClassFileMarkerAnnotationModel.isAffected
|
||||||
ClassFileMarkerAnnotationModel.error.resourceChanged=ClassFileMarkerAnnotationModel.resourceChanged
|
ClassFileMarkerAnnotationModel.error.resourceChanged=ClassFileMarkerAnnotationModel.resourceChanged
|
||||||
|
|
||||||
CEditor.error.saving.message1=File has been deleted.
|
CEditor.error.saving.message=Save could not be completed. {0}
|
||||||
CEditor.error.saving.message2=Could not save file.
|
CEditor.error.saving.title=Problems During Save As...
|
||||||
CEditor.error.saving.message3=Could not save file.
|
|
||||||
CEditor.error.saving.title1=Cannot Save
|
|
||||||
CEditor.error.saving.title2=Save Problems
|
|
||||||
CEditor.error.saving.title3=Save Problems
|
|
||||||
CEditorPreferencePage.description= C Editor Preferences
|
CEditorPreferencePage.description= C Editor Preferences
|
||||||
|
|
||||||
DeleteISourceManipulations.description=Delete the selected element in the editor
|
DeleteISourceManipulations.description=Delete the selected element in the editor
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface IPainter {
|
|
||||||
|
|
||||||
/** Paint reasons */
|
|
||||||
int SELECTION= 0;
|
|
||||||
int TEXT_CHANGE= 1;
|
|
||||||
int KEY_STROKE= 2;
|
|
||||||
int MOUSE_BUTTON= 4;
|
|
||||||
int INTERNAL= 8;
|
|
||||||
|
|
||||||
|
|
||||||
void dispose();
|
|
||||||
|
|
||||||
void paint(int reason);
|
|
||||||
|
|
||||||
void deactivate(boolean redraw);
|
|
||||||
|
|
||||||
void setPositionManager(IPositionManager manager);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,141 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.eclipse.swt.custom.LineBackgroundEvent;
|
|
||||||
import org.eclipse.swt.custom.LineBackgroundListener;
|
|
||||||
import org.eclipse.swt.custom.StyledText;
|
|
||||||
import org.eclipse.swt.custom.StyledTextContent;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
|
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
|
||||||
|
|
||||||
|
|
||||||
public class LinePainter implements IPainter, LineBackgroundListener {
|
|
||||||
|
|
||||||
private StyledText fTextWidget;
|
|
||||||
private Color fHighlightColor;
|
|
||||||
private int[] fLine= { -1, -1 };
|
|
||||||
private boolean fIsActive= false;
|
|
||||||
|
|
||||||
|
|
||||||
public LinePainter(ISourceViewer sourceViewer) {
|
|
||||||
fTextWidget= sourceViewer.getTextWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHighlightColor(Color highlightColor) {
|
|
||||||
fHighlightColor= highlightColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see LineBackgroundListener#lineGetBackground(LineBackgroundEvent)
|
|
||||||
*/
|
|
||||||
public void lineGetBackground(LineBackgroundEvent event) {
|
|
||||||
/* Don't use cached line information because of batched redrawing events. */
|
|
||||||
|
|
||||||
if (fTextWidget != null) {
|
|
||||||
|
|
||||||
|
|
||||||
int caret= fTextWidget.getCaretOffset();
|
|
||||||
int length= event.lineText.length();
|
|
||||||
|
|
||||||
if (event.lineOffset <= caret && caret <= event.lineOffset + length && fIsActive) {
|
|
||||||
StyledTextContent content= fTextWidget.getContent();
|
|
||||||
Point p= fTextWidget.getSelectionRange();
|
|
||||||
if(content.getLineAtOffset(caret) == content.getLineAtOffset(p.x)) {
|
|
||||||
event.lineBackground= fHighlightColor;
|
|
||||||
} else {
|
|
||||||
event.lineBackground= fTextWidget.getBackground();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
event.lineBackground= fTextWidget.getBackground();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateHighlightLine() {
|
|
||||||
StyledTextContent content= fTextWidget.getContent();
|
|
||||||
|
|
||||||
|
|
||||||
int offset= fTextWidget.getCaretOffset();
|
|
||||||
int length= content.getCharCount();
|
|
||||||
if (offset > length)
|
|
||||||
offset= length;
|
|
||||||
|
|
||||||
int lineNumber= content.getLineAtOffset(offset);
|
|
||||||
fLine[0]= content.getOffsetAtLine(lineNumber);
|
|
||||||
|
|
||||||
try {
|
|
||||||
fLine[1]= content.getOffsetAtLine(lineNumber + 1);
|
|
||||||
} catch (IllegalArgumentException x) {
|
|
||||||
fLine[1]= -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearHighlightLine() {
|
|
||||||
if (fLine[0] <= fTextWidget.getCharCount())
|
|
||||||
drawHighlightLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawHighlightLine() {
|
|
||||||
if (fLine[1] >= fTextWidget.getCharCount())
|
|
||||||
fLine[1]= -1;
|
|
||||||
|
|
||||||
if (fLine[1] == -1) {
|
|
||||||
|
|
||||||
Point upperLeft= fTextWidget.getLocationAtOffset(fLine[0]);
|
|
||||||
int width= fTextWidget.getClientArea().width;
|
|
||||||
int height= fTextWidget.getLineHeight();
|
|
||||||
fTextWidget.redraw(upperLeft.x, upperLeft.y, width, height, false);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
fTextWidget.redrawRange(fLine[0], fLine[1] - fLine[0], true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#deactivate(boolean)
|
|
||||||
*/
|
|
||||||
public void deactivate(boolean redraw) {
|
|
||||||
if (fIsActive) {
|
|
||||||
fIsActive= false;
|
|
||||||
fTextWidget.removeLineBackgroundListener(this);
|
|
||||||
if (redraw)
|
|
||||||
drawHighlightLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#dispose()
|
|
||||||
*/
|
|
||||||
public void dispose() {
|
|
||||||
fTextWidget= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#paint(int)
|
|
||||||
*/
|
|
||||||
public void paint(int reason) {
|
|
||||||
if (!fIsActive) {
|
|
||||||
fIsActive= true;
|
|
||||||
fTextWidget.addLineBackgroundListener(this);
|
|
||||||
} else if (fLine[0] != -1) {
|
|
||||||
clearHighlightLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateHighlightLine();
|
|
||||||
|
|
||||||
drawHighlightLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#setPositionManager(IPositionManager)
|
|
||||||
*/
|
|
||||||
public void setPositionManager(IPositionManager manager) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,498 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.custom.StyledText;
|
|
||||||
import org.eclipse.swt.events.DisposeEvent;
|
|
||||||
import org.eclipse.swt.events.DisposeListener;
|
|
||||||
import org.eclipse.swt.events.MouseAdapter;
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.events.MouseMoveListener;
|
|
||||||
import org.eclipse.swt.events.PaintEvent;
|
|
||||||
import org.eclipse.swt.events.PaintListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.Cursor;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
|
||||||
import org.eclipse.swt.widgets.Canvas;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
|
||||||
import org.eclipse.jface.text.IDocument;
|
|
||||||
import org.eclipse.jface.text.IRegion;
|
|
||||||
import org.eclipse.jface.text.ITextListener;
|
|
||||||
import org.eclipse.jface.text.ITextViewer;
|
|
||||||
import org.eclipse.jface.text.Position;
|
|
||||||
import org.eclipse.jface.text.TextEvent;
|
|
||||||
import org.eclipse.jface.text.source.Annotation;
|
|
||||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
|
||||||
import org.eclipse.jface.text.source.IAnnotationModelListener;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class OverviewRuler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal listener class.
|
|
||||||
*/
|
|
||||||
class InternalListener implements ITextListener, IAnnotationModelListener {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see ITextListener#textChanged
|
|
||||||
*/
|
|
||||||
public void textChanged(TextEvent e) {
|
|
||||||
if (fTextViewer != null && e.getDocumentEvent() == null && e.getViewerRedrawState()) {
|
|
||||||
// handle only changes of visible document
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IAnnotationModelListener#modelChanged(IAnnotationModel)
|
|
||||||
*/
|
|
||||||
public void modelChanged(IAnnotationModel model) {
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters problems based on their types.
|
|
||||||
*/
|
|
||||||
class FilterIterator implements Iterator {
|
|
||||||
|
|
||||||
private Iterator fIterator;
|
|
||||||
private int fType;
|
|
||||||
private Annotation fNext;
|
|
||||||
|
|
||||||
public FilterIterator(int type) {
|
|
||||||
fType= type;
|
|
||||||
if (fModel != null) {
|
|
||||||
fIterator= fModel.getAnnotationIterator();
|
|
||||||
skip();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void skip() {
|
|
||||||
while (fIterator.hasNext()) {
|
|
||||||
fNext= (Annotation) fIterator.next();
|
|
||||||
int type= getType(fNext);
|
|
||||||
if ((fType == ALL && type != UNKNOWN) || fType == type)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fNext= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see Iterator#hasNext()
|
|
||||||
*/
|
|
||||||
public boolean hasNext() {
|
|
||||||
return fNext != null;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* @see Iterator#next()
|
|
||||||
*/
|
|
||||||
public Object next() {
|
|
||||||
try {
|
|
||||||
return fNext;
|
|
||||||
} finally {
|
|
||||||
if (fModel != null)
|
|
||||||
skip();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* @see Iterator#remove()
|
|
||||||
*/
|
|
||||||
public void remove() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Problem types */
|
|
||||||
private static final int ALL= -1;
|
|
||||||
private static final int COMPILE_WARNING= 0;
|
|
||||||
private static final int COMPILE_ERROR= 1;
|
|
||||||
private static final int TEMPORARY= 2;
|
|
||||||
private static final int UNKNOWN= 4;
|
|
||||||
|
|
||||||
/** Color table */
|
|
||||||
private static final RGB[][] COLORS= new RGB[][] {
|
|
||||||
/* fill */ /* stroke */
|
|
||||||
/* warning */ { new RGB(248, 218, 114), new RGB(139, 109, 7) },
|
|
||||||
/* error */ { new RGB(255, 140, 140), new RGB(255, 0 ,0) },
|
|
||||||
/* temp */ { new RGB(240, 230, 230), new RGB(200, 100, 100) }
|
|
||||||
};
|
|
||||||
|
|
||||||
/** drawing layers */
|
|
||||||
private static final int[] LAYERS= new int[] { COMPILE_WARNING, TEMPORARY, COMPILE_ERROR };
|
|
||||||
|
|
||||||
private static final int INSET= 2;
|
|
||||||
private static final int PROBLEM_HEIGHT_MIN= 4;
|
|
||||||
private static boolean PROBLEM_HEIGHT_SCALABLE= false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** The model of the overview ruler */
|
|
||||||
protected IAnnotationModel fModel;
|
|
||||||
/** The view to which this ruler is connected */
|
|
||||||
protected ITextViewer fTextViewer;
|
|
||||||
/** The ruler's canvas */
|
|
||||||
private Canvas fCanvas;
|
|
||||||
/** The drawable for double buffering */
|
|
||||||
private Image fBuffer;
|
|
||||||
/** The internal listener */
|
|
||||||
private InternalListener fInternalListener= new InternalListener();
|
|
||||||
/** The width of this vertical ruler */
|
|
||||||
private int fWidth;
|
|
||||||
/** The hit detection cursor */
|
|
||||||
private Cursor fHitDetectionCursor;
|
|
||||||
/** The last cursor */
|
|
||||||
private Cursor fLastCursor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a vertical ruler with the given width.
|
|
||||||
*
|
|
||||||
* @param width the width of the vertical ruler
|
|
||||||
*/
|
|
||||||
public OverviewRuler(int width) {
|
|
||||||
fWidth= width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Control getControl() {
|
|
||||||
return fCanvas;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return fWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getType(Annotation annotation) {
|
|
||||||
if (annotation instanceof IProblemAnnotation) {
|
|
||||||
IProblemAnnotation pa= (IProblemAnnotation) annotation;
|
|
||||||
//if (!pa.isRelevant())
|
|
||||||
// return UNKNOWN;
|
|
||||||
if (pa.isTemporaryProblem())
|
|
||||||
return TEMPORARY;
|
|
||||||
if (pa.isError())
|
|
||||||
return COMPILE_ERROR;
|
|
||||||
if (pa.isWarning())
|
|
||||||
return COMPILE_WARNING;
|
|
||||||
}
|
|
||||||
|
|
||||||
return UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModel(IAnnotationModel model) {
|
|
||||||
if (model != fModel || model != null) {
|
|
||||||
|
|
||||||
if (fModel != null)
|
|
||||||
fModel.removeAnnotationModelListener(fInternalListener);
|
|
||||||
|
|
||||||
fModel= model;
|
|
||||||
|
|
||||||
if (fModel != null)
|
|
||||||
fModel.addAnnotationModelListener(fInternalListener);
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Control createControl(Composite parent, ITextViewer textViewer) {
|
|
||||||
|
|
||||||
fTextViewer= textViewer;
|
|
||||||
|
|
||||||
fHitDetectionCursor= new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
|
|
||||||
fCanvas= new Canvas(parent, SWT.NO_BACKGROUND);
|
|
||||||
|
|
||||||
fCanvas.addPaintListener(new PaintListener() {
|
|
||||||
public void paintControl(PaintEvent event) {
|
|
||||||
if (fTextViewer != null)
|
|
||||||
doubleBufferPaint(event.gc);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fCanvas.addDisposeListener(new DisposeListener() {
|
|
||||||
public void widgetDisposed(DisposeEvent event) {
|
|
||||||
handleDispose();
|
|
||||||
fTextViewer= null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fCanvas.addMouseListener(new MouseAdapter() {
|
|
||||||
public void mouseDown(MouseEvent event) {
|
|
||||||
handleMouseDown(event);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fCanvas.addMouseMoveListener(new MouseMoveListener() {
|
|
||||||
public void mouseMove(MouseEvent event) {
|
|
||||||
handleMouseMove(event);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (fTextViewer != null)
|
|
||||||
fTextViewer.addTextListener(fInternalListener);
|
|
||||||
|
|
||||||
return fCanvas;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disposes the ruler's resources.
|
|
||||||
*/
|
|
||||||
protected void handleDispose() {
|
|
||||||
|
|
||||||
if (fTextViewer != null) {
|
|
||||||
fTextViewer.removeTextListener(fInternalListener);
|
|
||||||
fTextViewer= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fModel != null)
|
|
||||||
fModel.removeAnnotationModelListener(fInternalListener);
|
|
||||||
|
|
||||||
if (fBuffer != null) {
|
|
||||||
fBuffer.dispose();
|
|
||||||
fBuffer= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fHitDetectionCursor != null) {
|
|
||||||
fHitDetectionCursor.dispose();
|
|
||||||
fHitDetectionCursor= null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Double buffer drawing.
|
|
||||||
*/
|
|
||||||
protected void doubleBufferPaint(GC dest) {
|
|
||||||
|
|
||||||
Point size= fCanvas.getSize();
|
|
||||||
|
|
||||||
if (size.x <= 0 || size.y <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (fBuffer != null) {
|
|
||||||
Rectangle r= fBuffer.getBounds();
|
|
||||||
if (r.width != size.x || r.height != size.y) {
|
|
||||||
fBuffer.dispose();
|
|
||||||
fBuffer= null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fBuffer == null)
|
|
||||||
fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y);
|
|
||||||
|
|
||||||
GC gc= new GC(fBuffer);
|
|
||||||
try {
|
|
||||||
gc.setBackground(fCanvas.getBackground());
|
|
||||||
gc.fillRectangle(0, 0, size.x, size.y);
|
|
||||||
doPaint(gc);
|
|
||||||
} finally {
|
|
||||||
gc.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
dest.drawImage(fBuffer, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Color getColor(RGB rgb) {
|
|
||||||
CTextTools textTools= CUIPlugin.getDefault().getTextTools();
|
|
||||||
return textTools.getColorManager().getColor(rgb);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doPaint(GC gc) {
|
|
||||||
|
|
||||||
if (fTextViewer == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Rectangle r= new Rectangle(0, 0, 0, 0);
|
|
||||||
int yy, hh= PROBLEM_HEIGHT_MIN;
|
|
||||||
|
|
||||||
|
|
||||||
IDocument document= fTextViewer.getDocument();
|
|
||||||
IRegion visible= fTextViewer.getVisibleRegion();
|
|
||||||
|
|
||||||
StyledText textWidget= fTextViewer.getTextWidget();
|
|
||||||
int maxLines= textWidget.getLineCount();
|
|
||||||
|
|
||||||
Point size= fCanvas.getSize();
|
|
||||||
int writable= maxLines * textWidget.getLineHeight();
|
|
||||||
if (size.y > writable)
|
|
||||||
size.y= writable;
|
|
||||||
|
|
||||||
for (int l= 0 ; l < LAYERS.length; l++) {
|
|
||||||
|
|
||||||
Iterator e= new FilterIterator(LAYERS[l]);
|
|
||||||
Color fill= getColor(COLORS[LAYERS[l]][0]);
|
|
||||||
Color stroke= getColor(COLORS[LAYERS[l]][1]);
|
|
||||||
|
|
||||||
for (int i= 0; e.hasNext(); i++) {
|
|
||||||
|
|
||||||
Annotation a= (Annotation) e.next();
|
|
||||||
Position p= fModel.getPosition(a);
|
|
||||||
|
|
||||||
if (!p.overlapsWith(visible.getOffset(), visible.getLength()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int problemOffset= Math.max(p.getOffset(), visible.getOffset());
|
|
||||||
int problemEnd= Math.min(p.getOffset() + p.getLength(), visible.getOffset() + visible.getLength());
|
|
||||||
int problemLength= problemEnd - problemOffset;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
int startLine= textWidget.getLineAtOffset(problemOffset - visible.getOffset());
|
|
||||||
yy= (startLine * size.y) / maxLines;
|
|
||||||
|
|
||||||
if (PROBLEM_HEIGHT_SCALABLE) {
|
|
||||||
int numbersOfLines= document.getNumberOfLines(problemOffset, problemLength);
|
|
||||||
hh= (numbersOfLines * size.y) / maxLines;
|
|
||||||
if (hh < PROBLEM_HEIGHT_MIN)
|
|
||||||
hh= PROBLEM_HEIGHT_MIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fill != null) {
|
|
||||||
gc.setBackground(fill);
|
|
||||||
gc.fillRectangle(INSET, yy, size.x-(2*INSET), hh);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stroke != null) {
|
|
||||||
gc.setForeground(stroke);
|
|
||||||
r.x= INSET;
|
|
||||||
r.y= yy;
|
|
||||||
r.width= size.x - (2 * INSET) - 1;
|
|
||||||
r.height= hh;
|
|
||||||
gc.setLineWidth(1);
|
|
||||||
gc.drawRectangle(r);
|
|
||||||
}
|
|
||||||
} catch (BadLocationException x) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Thread-safe implementation.
|
|
||||||
* Can be called from any thread.
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
if (fCanvas != null && !fCanvas.isDisposed()) {
|
|
||||||
Display d= fCanvas.getDisplay();
|
|
||||||
if (d != null) {
|
|
||||||
d.asyncExec(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Redraws the overview ruler.
|
|
||||||
*/
|
|
||||||
protected void redraw() {
|
|
||||||
if (fCanvas != null && !fCanvas.isDisposed()) {
|
|
||||||
GC gc= new GC(fCanvas);
|
|
||||||
doubleBufferPaint(gc);
|
|
||||||
gc.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int[] toLineNumbers(int y_coordinate) {
|
|
||||||
|
|
||||||
IRegion visible= fTextViewer.getVisibleRegion();
|
|
||||||
int lineNumber= 0;
|
|
||||||
try {
|
|
||||||
lineNumber= fTextViewer.getDocument().getLineOfOffset(visible.getOffset());
|
|
||||||
} catch (BadLocationException x) {
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText textWidget= fTextViewer.getTextWidget();
|
|
||||||
int maxLines= textWidget.getContent().getLineCount();
|
|
||||||
|
|
||||||
Point size= fCanvas.getSize();
|
|
||||||
int writable= maxLines * textWidget.getLineHeight();
|
|
||||||
if (size.y > writable)
|
|
||||||
size.y= writable;
|
|
||||||
|
|
||||||
int[] lines= new int[2];
|
|
||||||
|
|
||||||
int pixel= Math.max(y_coordinate - 1, 0);
|
|
||||||
lines[0]= lineNumber + (pixel * maxLines) / size.y;
|
|
||||||
|
|
||||||
pixel= Math.min(size.y, y_coordinate + 1);
|
|
||||||
lines[1]= lineNumber + (pixel * maxLines) / size.y;
|
|
||||||
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Position getProblemPositionAt(int[] lineNumbers) {
|
|
||||||
|
|
||||||
Position found= null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
IDocument d= fTextViewer.getDocument();
|
|
||||||
IRegion line= d.getLineInformation(lineNumbers[0]);
|
|
||||||
int start= line.getOffset();
|
|
||||||
|
|
||||||
line= d.getLineInformation(lineNumbers[lineNumbers.length - 1]);
|
|
||||||
int end= line.getOffset() + line.getLength();
|
|
||||||
|
|
||||||
Iterator e= new FilterIterator(ALL);
|
|
||||||
while (e.hasNext()) {
|
|
||||||
Annotation a= (Annotation) e.next();
|
|
||||||
Position p= fModel.getPosition(a);
|
|
||||||
if (start <= p.getOffset() && p.getOffset() < end) {
|
|
||||||
if (found == null || p.getOffset() < found.getOffset())
|
|
||||||
found= p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handleMouseDown(MouseEvent event) {
|
|
||||||
if (fTextViewer != null) {
|
|
||||||
int[] lines= toLineNumbers(event.y);
|
|
||||||
Position p= getProblemPositionAt(lines);
|
|
||||||
if (p != null) {
|
|
||||||
fTextViewer.revealRange(p.getOffset(), p.getLength());
|
|
||||||
fTextViewer.setSelectedRange(p.getOffset(), p.getLength());
|
|
||||||
}
|
|
||||||
fTextViewer.getTextWidget().setFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handleMouseMove(MouseEvent event) {
|
|
||||||
if (fTextViewer != null) {
|
|
||||||
int[] lines= toLineNumbers(event.y);
|
|
||||||
Position p= getProblemPositionAt(lines);
|
|
||||||
Cursor cursor= (p != null ? fHitDetectionCursor : null);
|
|
||||||
if (cursor != fLastCursor) {
|
|
||||||
fCanvas.setCursor(cursor);
|
|
||||||
fLastCursor= cursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,257 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.swt.custom.StyledText;
|
|
||||||
import org.eclipse.swt.events.KeyEvent;
|
|
||||||
import org.eclipse.swt.events.KeyListener;
|
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
|
||||||
import org.eclipse.swt.events.MouseListener;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
|
||||||
import org.eclipse.jface.text.BadPositionCategoryException;
|
|
||||||
import org.eclipse.jface.text.DefaultPositionUpdater;
|
|
||||||
import org.eclipse.jface.text.IDocument;
|
|
||||||
import org.eclipse.jface.text.IPositionUpdater;
|
|
||||||
import org.eclipse.jface.text.ITextInputListener;
|
|
||||||
import org.eclipse.jface.text.ITextListener;
|
|
||||||
import org.eclipse.jface.text.Position;
|
|
||||||
import org.eclipse.jface.text.TextEvent;
|
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
||||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
|
||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
||||||
|
|
||||||
|
|
||||||
public final class PaintManager implements KeyListener, MouseListener, ISelectionChangedListener, ITextListener, ITextInputListener {
|
|
||||||
|
|
||||||
static class PositionManager implements IPositionManager {
|
|
||||||
|
|
||||||
private IDocument fDocument;
|
|
||||||
private IPositionUpdater fPositionUpdater;
|
|
||||||
private String fCategory;
|
|
||||||
|
|
||||||
public PositionManager() {
|
|
||||||
fCategory= getClass().getName() + hashCode();
|
|
||||||
fPositionUpdater= new DefaultPositionUpdater(fCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void install(IDocument document) {
|
|
||||||
fDocument= document;
|
|
||||||
fDocument.addPositionCategory(fCategory);
|
|
||||||
fDocument.addPositionUpdater(fPositionUpdater);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose() {
|
|
||||||
uninstall(fDocument);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void uninstall(IDocument document) {
|
|
||||||
if (document == fDocument && document != null) {
|
|
||||||
try {
|
|
||||||
fDocument.removePositionUpdater(fPositionUpdater);
|
|
||||||
fDocument.removePositionCategory(fCategory);
|
|
||||||
} catch (BadPositionCategoryException x) {
|
|
||||||
// should not happen
|
|
||||||
}
|
|
||||||
fDocument= null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPositionManager#addManagedPosition(Position)
|
|
||||||
*/
|
|
||||||
public void addManagedPosition(Position position) {
|
|
||||||
try {
|
|
||||||
fDocument.addPosition(fCategory, position);
|
|
||||||
} catch (BadPositionCategoryException x) {
|
|
||||||
// should not happen
|
|
||||||
} catch (BadLocationException x) {
|
|
||||||
// should not happen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPositionManager#removeManagedPosition(Position)
|
|
||||||
*/
|
|
||||||
public void removeManagedPosition(Position position) {
|
|
||||||
try {
|
|
||||||
fDocument.removePosition(fCategory, position);
|
|
||||||
} catch (BadPositionCategoryException x) {
|
|
||||||
// should not happen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
private List fPainters= new ArrayList(2);
|
|
||||||
private PositionManager fManager;
|
|
||||||
protected ISourceViewer fSourceViewer;
|
|
||||||
protected boolean fTextChanged= false;
|
|
||||||
private boolean fAutoRepeat= false;
|
|
||||||
|
|
||||||
|
|
||||||
public PaintManager(ISourceViewer sourceViewer) {
|
|
||||||
fSourceViewer= sourceViewer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPainter(IPainter painter) {
|
|
||||||
if (!fPainters.contains(painter)) {
|
|
||||||
fPainters.add(painter);
|
|
||||||
if (fPainters.size() == 1)
|
|
||||||
install();
|
|
||||||
painter.setPositionManager(fManager);
|
|
||||||
painter.paint(IPainter.INTERNAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removePainter(IPainter painter) {
|
|
||||||
if (fPainters.remove(painter))
|
|
||||||
painter.setPositionManager(null);
|
|
||||||
if (fPainters.size() == 0)
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void install() {
|
|
||||||
|
|
||||||
fManager= new PositionManager();
|
|
||||||
fManager.install(fSourceViewer.getDocument());
|
|
||||||
|
|
||||||
fSourceViewer.addTextInputListener(this);
|
|
||||||
|
|
||||||
ISelectionProvider provider= fSourceViewer.getSelectionProvider();
|
|
||||||
provider.addSelectionChangedListener(this);
|
|
||||||
|
|
||||||
fSourceViewer.addTextListener(this);
|
|
||||||
|
|
||||||
StyledText text= fSourceViewer.getTextWidget();
|
|
||||||
text.addKeyListener(this);
|
|
||||||
text.addMouseListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose() {
|
|
||||||
|
|
||||||
if (fManager != null) {
|
|
||||||
fManager.dispose();
|
|
||||||
fManager= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Iterator e = fPainters.iterator(); e.hasNext();)
|
|
||||||
((IPainter) e.next()).dispose();
|
|
||||||
fPainters.clear();
|
|
||||||
|
|
||||||
fSourceViewer.removeTextInputListener(this);
|
|
||||||
|
|
||||||
ISelectionProvider provider= fSourceViewer.getSelectionProvider();
|
|
||||||
if (provider != null)
|
|
||||||
provider.removeSelectionChangedListener(this);
|
|
||||||
|
|
||||||
fSourceViewer.removeTextListener(this);
|
|
||||||
|
|
||||||
StyledText text= fSourceViewer.getTextWidget();
|
|
||||||
if (text != null && !text.isDisposed()) {
|
|
||||||
text.removeKeyListener(this);
|
|
||||||
text.removeMouseListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void paint(int reason) {
|
|
||||||
for (Iterator e = fPainters.iterator(); e.hasNext();)
|
|
||||||
((IPainter) e.next()).paint(reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see KeyListener#keyPressed(KeyEvent)
|
|
||||||
*/
|
|
||||||
public void keyPressed(KeyEvent e) {
|
|
||||||
// This leaves artifacts when scrolling
|
|
||||||
//if (fAutoRepeat)
|
|
||||||
paint(IPainter.KEY_STROKE);
|
|
||||||
|
|
||||||
fTextChanged= false;
|
|
||||||
fAutoRepeat= true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see KeyListener#keyReleased(KeyEvent)
|
|
||||||
*/
|
|
||||||
public void keyReleased(KeyEvent e) {
|
|
||||||
fAutoRepeat= false;
|
|
||||||
if (!fTextChanged)
|
|
||||||
paint(IPainter.KEY_STROKE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see MouseListener#mouseDoubleClick(MouseEvent)
|
|
||||||
*/
|
|
||||||
public void mouseDoubleClick(MouseEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see MouseListener#mouseDown(MouseEvent)
|
|
||||||
*/
|
|
||||||
public void mouseDown(MouseEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see MouseListener#mouseUp(MouseEvent)
|
|
||||||
*/
|
|
||||||
public void mouseUp(MouseEvent e) {
|
|
||||||
paint(IPainter.MOUSE_BUTTON);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
|
|
||||||
*/
|
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
|
||||||
paint(IPainter.SELECTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see ITextListener#textChanged(TextEvent)
|
|
||||||
*/
|
|
||||||
public void textChanged(TextEvent event) {
|
|
||||||
fTextChanged= true;
|
|
||||||
Control control= fSourceViewer.getTextWidget();
|
|
||||||
if (control != null) {
|
|
||||||
control.getDisplay().asyncExec(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (fTextChanged && fSourceViewer != null)
|
|
||||||
paint(IPainter.TEXT_CHANGE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument)
|
|
||||||
*/
|
|
||||||
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
|
|
||||||
if (oldInput != null) {
|
|
||||||
for (Iterator e = fPainters.iterator(); e.hasNext();)
|
|
||||||
((IPainter) e.next()).deactivate(false);
|
|
||||||
fManager.uninstall(oldInput);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see ITextInputListener#inputDocumentChanged(IDocument, IDocument)
|
|
||||||
*/
|
|
||||||
public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
|
|
||||||
if (newInput != null) {
|
|
||||||
fManager.install(newInput);
|
|
||||||
paint(IPainter.TEXT_CHANGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.custom.StyledText;
|
|
||||||
import org.eclipse.swt.events.PaintEvent;
|
|
||||||
import org.eclipse.swt.events.PaintListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
|
||||||
|
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class PrintMarginPainter implements IPainter, PaintListener {
|
|
||||||
|
|
||||||
|
|
||||||
private StyledText fTextWidget;
|
|
||||||
|
|
||||||
private int fMarginWidth= 80;
|
|
||||||
private Color fColor;
|
|
||||||
private int fLineStyle= SWT.LINE_SOLID;
|
|
||||||
private int fLineWidth= 1;
|
|
||||||
|
|
||||||
private int fCachedWidgetX= -1;
|
|
||||||
private boolean fIsActive= false;
|
|
||||||
|
|
||||||
public PrintMarginPainter(ISourceViewer sourceViewer) {
|
|
||||||
fTextWidget= sourceViewer.getTextWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMarginRulerColumn(int width) {
|
|
||||||
fMarginWidth= width;
|
|
||||||
intialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMarginRulerStyle(int lineStyle) {
|
|
||||||
fLineStyle= lineStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMarginRulerWidth(int lineWidth) {
|
|
||||||
fLineWidth= lineWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be called before <code>paint</code> is called the first time.
|
|
||||||
*/
|
|
||||||
public void setMarginRulerColor(Color color) {
|
|
||||||
fColor= color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be called explicitly when font of text widget changes.
|
|
||||||
*/
|
|
||||||
public void intialize() {
|
|
||||||
computeWidgetX();
|
|
||||||
fTextWidget.redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void computeWidgetX() {
|
|
||||||
GC gc= new GC(fTextWidget);
|
|
||||||
int pixels= gc.getFontMetrics().getAverageCharWidth();
|
|
||||||
gc.dispose();
|
|
||||||
|
|
||||||
fCachedWidgetX= pixels * fMarginWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#deactivate(boolean)
|
|
||||||
*/
|
|
||||||
public void deactivate(boolean redraw) {
|
|
||||||
if (fIsActive) {
|
|
||||||
fIsActive= false;
|
|
||||||
fTextWidget.removePaintListener(this);
|
|
||||||
if (redraw)
|
|
||||||
fTextWidget.redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#dispose()
|
|
||||||
*/
|
|
||||||
public void dispose() {
|
|
||||||
fTextWidget= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#paint(int)
|
|
||||||
*/
|
|
||||||
public void paint(int reason) {
|
|
||||||
if (!fIsActive) {
|
|
||||||
fIsActive= true;
|
|
||||||
fTextWidget.addPaintListener(this);
|
|
||||||
if (fCachedWidgetX == -1)
|
|
||||||
computeWidgetX();
|
|
||||||
fTextWidget.redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#setPositionManager(IPositionManager)
|
|
||||||
*/
|
|
||||||
public void setPositionManager(IPositionManager manager) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see PaintListener#paintControl(PaintEvent)
|
|
||||||
*/
|
|
||||||
public void paintControl(PaintEvent e) {
|
|
||||||
if (fTextWidget != null) {
|
|
||||||
int x= fCachedWidgetX - fTextWidget.getHorizontalPixel();
|
|
||||||
if (x >= 0) {
|
|
||||||
Rectangle area= fTextWidget.getClientArea();
|
|
||||||
e.gc.setForeground(fColor);
|
|
||||||
e.gc.setLineStyle(fLineStyle);
|
|
||||||
e.gc.setLineWidth(fLineWidth);
|
|
||||||
e.gc.drawLine(x, 0, x, area.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,248 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.swt.custom.StyledText;
|
|
||||||
import org.eclipse.swt.events.PaintEvent;
|
|
||||||
import org.eclipse.swt.events.PaintListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.GC;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
import org.eclipse.jface.text.IRegion;
|
|
||||||
import org.eclipse.jface.text.Position;
|
|
||||||
import org.eclipse.jface.text.source.Annotation;
|
|
||||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
|
||||||
import org.eclipse.jface.text.source.IAnnotationModelListener;
|
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
|
||||||
|
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
|
||||||
|
|
||||||
//import org.eclipse.jdt.core.compiler.IProblem;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Highlights the temporary problems.
|
|
||||||
*/
|
|
||||||
public class ProblemPainter implements IPainter, PaintListener, IAnnotationModelListener {
|
|
||||||
|
|
||||||
private boolean fIsActive= false;
|
|
||||||
private boolean fIsPainting= false;
|
|
||||||
protected boolean fIsModelChanging= false;
|
|
||||||
|
|
||||||
private Color fColor;
|
|
||||||
private ITextEditor fTextEditor;
|
|
||||||
private ISourceViewer fSourceViewer;
|
|
||||||
private StyledText fTextWidget;
|
|
||||||
private IAnnotationModel fModel;
|
|
||||||
private List fProblemPositions= new ArrayList();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ProblemPainter(ITextEditor textEditor, ISourceViewer sourceViewer) {
|
|
||||||
fTextEditor= textEditor;
|
|
||||||
fSourceViewer= sourceViewer;
|
|
||||||
fTextWidget= sourceViewer.getTextWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasProblems() {
|
|
||||||
if (fProblemPositions != null) {
|
|
||||||
return !fProblemPositions.isEmpty();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void enablePainting() {
|
|
||||||
if (!fIsPainting && hasProblems()) {
|
|
||||||
fIsPainting= true;
|
|
||||||
fTextWidget.addPaintListener(this);
|
|
||||||
handleDrawRequest(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void disablePainting(boolean redraw) {
|
|
||||||
if (fIsPainting) {
|
|
||||||
fIsPainting= false;
|
|
||||||
fTextWidget.removePaintListener(this);
|
|
||||||
if (redraw && hasProblems())
|
|
||||||
handleDrawRequest(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setModel(IAnnotationModel model) {
|
|
||||||
|
|
||||||
if (fModel != model) {
|
|
||||||
if (fModel != null)
|
|
||||||
fModel.removeAnnotationModelListener(this);
|
|
||||||
fModel= model;
|
|
||||||
if (fModel != null)
|
|
||||||
fModel.addAnnotationModelListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fProblemPositions != null) {
|
|
||||||
fProblemPositions.clear();
|
|
||||||
if (fModel != null) {
|
|
||||||
Iterator e= new ProblemAnnotationIterator(fModel);
|
|
||||||
while (e.hasNext()) {
|
|
||||||
IProblemAnnotation pa= (IProblemAnnotation) e.next();
|
|
||||||
if (pa.isProblem()) {
|
|
||||||
Annotation a= (Annotation) pa;
|
|
||||||
Position p= fModel.getPosition(a);
|
|
||||||
fProblemPositions.add(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IAnnotationModelListener#modelChanged(IAnnotationModel)
|
|
||||||
*/
|
|
||||||
public void modelChanged(final IAnnotationModel model) {
|
|
||||||
if (fTextWidget != null && !fTextWidget.isDisposed() && !fIsModelChanging) {
|
|
||||||
Display d= fTextWidget.getDisplay();
|
|
||||||
if (d != null) {
|
|
||||||
d.asyncExec(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
disablePainting(true);
|
|
||||||
try {
|
|
||||||
fIsModelChanging= true;
|
|
||||||
setModel(model);
|
|
||||||
} finally {
|
|
||||||
fIsModelChanging= false;
|
|
||||||
}
|
|
||||||
enablePainting();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHighlightColor(Color color) {
|
|
||||||
fColor= color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#dispose()
|
|
||||||
*/
|
|
||||||
public void dispose() {
|
|
||||||
fColor= null;
|
|
||||||
fTextWidget= null;
|
|
||||||
fModel= null;
|
|
||||||
fProblemPositions= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see PaintListener#paintControl(PaintEvent)
|
|
||||||
*/
|
|
||||||
public void paintControl(PaintEvent event) {
|
|
||||||
if (fTextWidget != null)
|
|
||||||
handleDrawRequest(event.gc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleDrawRequest(GC gc) {
|
|
||||||
|
|
||||||
IRegion region= fSourceViewer.getVisibleRegion();
|
|
||||||
int offset= region.getOffset();
|
|
||||||
int length= region.getLength();
|
|
||||||
|
|
||||||
for (Iterator e = fProblemPositions.iterator(); e.hasNext();) {
|
|
||||||
Position p = (Position) e.next();
|
|
||||||
if (p.overlapsWith(offset, length)) {
|
|
||||||
int p1= Math.max(offset, p.getOffset());
|
|
||||||
int p2= Math.min(offset + length, p.getOffset() + p.getLength());
|
|
||||||
draw(gc, p1 - offset, p2 - p1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int[] computePolyline(Point left, Point right, int height) {
|
|
||||||
|
|
||||||
final int WIDTH= 4; // must be even
|
|
||||||
final int HEIGHT= 2; // can be any number
|
|
||||||
|
|
||||||
int leftX= left.x;
|
|
||||||
int peeks= (right.x - left.x) / WIDTH;
|
|
||||||
|
|
||||||
// compute (number of point) * 2
|
|
||||||
int length= ((2 * peeks) + 1) * 2;
|
|
||||||
if (length < 0)
|
|
||||||
return new int[0];
|
|
||||||
|
|
||||||
int[] coordinates= new int[length];
|
|
||||||
|
|
||||||
// cache peeks' y-coordinates
|
|
||||||
int bottom= left.y + height - 1;
|
|
||||||
int top= bottom - HEIGHT;
|
|
||||||
|
|
||||||
// populate array with peek coordinates
|
|
||||||
for (int i= 0; i < peeks; i++) {
|
|
||||||
int index= 4 * i;
|
|
||||||
coordinates[index]= leftX + (WIDTH * i);
|
|
||||||
coordinates[index+1]= bottom;
|
|
||||||
coordinates[index+2]= coordinates[index] + WIDTH/2;
|
|
||||||
coordinates[index+3]= top;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the last down flank is missing
|
|
||||||
coordinates[length-2]= left.x + (WIDTH * peeks);
|
|
||||||
coordinates[length-1]= bottom;
|
|
||||||
|
|
||||||
return coordinates;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void draw(GC gc, int offset, int length) {
|
|
||||||
if (gc != null) {
|
|
||||||
|
|
||||||
Point left= fTextWidget.getLocationAtOffset(offset);
|
|
||||||
Point right= fTextWidget.getLocationAtOffset(offset + length);
|
|
||||||
|
|
||||||
gc.setForeground(fColor);
|
|
||||||
int[] polyline= computePolyline(left, right, gc.getFontMetrics().getHeight());
|
|
||||||
gc.drawPolyline(polyline);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
fTextWidget.redrawRange(offset, length, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#deactivate(boolean)
|
|
||||||
*/
|
|
||||||
public void deactivate(boolean redraw) {
|
|
||||||
if (fIsActive) {
|
|
||||||
fIsActive= false;
|
|
||||||
disablePainting(redraw);
|
|
||||||
setModel(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#paint(int)
|
|
||||||
*/
|
|
||||||
public void paint(int reason) {
|
|
||||||
if (!fIsActive) {
|
|
||||||
fIsActive= true;
|
|
||||||
IDocumentProvider provider= fTextEditor.getDocumentProvider();
|
|
||||||
setModel(provider.getAnnotationModel(fTextEditor.getEditorInput()));
|
|
||||||
enablePainting();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IPainter#setPositionManager(IPositionManager)
|
|
||||||
*/
|
|
||||||
public void setPositionManager(IPositionManager manager) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,8 @@ public class AsmTextEditor extends StatusTextEditor {
|
||||||
} catch (InterruptedException x) {
|
} catch (InterruptedException x) {
|
||||||
} catch (InvocationTargetException x) {
|
} catch (InvocationTargetException x) {
|
||||||
// Shared with C editor
|
// Shared with C editor
|
||||||
String title= CEditorMessages.getString("CEditor.error.save.title"); //$NON-NLS-1$
|
String title= CEditorMessages.getString("CEditor.error.saving.title"); //$NON-NLS-1$
|
||||||
String msg= MessageFormat.format(CEditorMessages.getString("CEditor.error.save.message"), new Object[] { x.getTargetException().getMessage() }); //$NON-NLS-1$
|
String msg= MessageFormat.format(CEditorMessages.getString("CEditor.error.saving.message"), new Object[] { x.getTargetException().getMessage() }); //$NON-NLS-1$
|
||||||
MessageDialog.openError(shell, title, msg);
|
MessageDialog.openError(shell, title, msg);
|
||||||
} finally {
|
} finally {
|
||||||
getDocumentProvider().changed(newInput);
|
getDocumentProvider().changed(newInput);
|
||||||
|
|
|
@ -13,6 +13,17 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||||
|
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
||||||
|
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.ContentAssistPreference;
|
||||||
|
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.preference.PreferenceConverter;
|
import org.eclipse.jface.preference.PreferenceConverter;
|
||||||
import org.eclipse.jface.preference.PreferencePage;
|
import org.eclipse.jface.preference.PreferencePage;
|
||||||
|
@ -45,109 +56,33 @@ import org.eclipse.swt.widgets.TabItem;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.ui.IWorkbench;
|
import org.eclipse.ui.IWorkbench;
|
||||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
|
||||||
|
import org.eclipse.ui.texteditor.AnnotationPreference;
|
||||||
|
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
|
||||||
import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
|
import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
|
||||||
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.ContentAssistPreference;
|
|
||||||
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The page for setting the editor options.
|
* The page for setting the editor options.
|
||||||
*/
|
*/
|
||||||
public class CEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
public class CEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
||||||
|
|
||||||
public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
|
protected final String[][] fListModel = new String[][] { { "Multi-line comment", ICColorConstants.C_MULTI_LINE_COMMENT }, {
|
||||||
|
"Single-line comment", ICColorConstants.C_SINGLE_LINE_COMMENT }, {
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.PREFERENCE_COLOR_FOREGROUND),
|
"Keywords", ICColorConstants.C_KEYWORD }, {
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT),
|
"Built-in types", ICColorConstants.C_TYPE }, {
|
||||||
|
"Strings", ICColorConstants.C_STRING }, {
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.PREFERENCE_COLOR_BACKGROUND),
|
"Others", ICColorConstants.C_DEFAULT }
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_MULTI_LINE_COMMENT),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_MULTI_LINE_COMMENT + "_bold"),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_SINGLE_LINE_COMMENT),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_SINGLE_LINE_COMMENT + "_bold"),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_KEYWORD),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_KEYWORD + "_bold"),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_TYPE),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_TYPE + "_bold"),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_STRING),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_STRING + "_bold"),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_DEFAULT),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_DEFAULT + "_bold"),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.MATCHING_BRACKETS_COLOR),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS_NOBOX),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.CURRENT_LINE_COLOR),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.CURRENT_LINE),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.PROBLEM_INDICATION_COLOR),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.PROBLEM_INDICATION),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SPACES_FOR_TABS),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.PRINT_MARGIN_COLOR),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, CEditor.PRINT_MARGIN_COLUMN),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.PRINT_MARGIN),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.LINKED_POSITION_COLOR),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.LINE_NUMBER_COLOR),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.LINE_NUMBER_RULER),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.OVERVIEW_RULER),
|
|
||||||
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOACTIVATION),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND),
|
|
||||||
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND),
|
|
||||||
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND),
|
|
||||||
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_C),
|
|
||||||
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CASE_SENSITIVITY),
|
|
||||||
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE)
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected final String[][] fListModel= new String[][] {
|
protected final String[][] fAppearanceColorListModel = new String[][] { { "Line number color", TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR }, //$NON-NLS-1$
|
||||||
{ "Multi-line comment", ICColorConstants.C_MULTI_LINE_COMMENT },
|
{
|
||||||
{ "Single-line comment", ICColorConstants.C_SINGLE_LINE_COMMENT },
|
"Matching bracket color", CEditor.MATCHING_BRACKETS_COLOR }, //$NON-NLS-1$
|
||||||
{ "Keywords", ICColorConstants.C_KEYWORD },
|
{
|
||||||
{ "Built-in types", ICColorConstants.C_TYPE },
|
"Current line highlight color", TextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR }, //$NON-NLS-1$
|
||||||
{ "Strings", ICColorConstants.C_STRING },
|
{
|
||||||
{ "Others", ICColorConstants.C_DEFAULT }
|
"Print margin color", TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR }, //$NON-NLS-1$
|
||||||
};
|
{
|
||||||
|
"Linked position color", CEditor.LINKED_POSITION_COLOR }, //$NON-NLS-1$
|
||||||
protected final String[][] fAppearanceColorListModel= new String[][] {
|
|
||||||
{"Line number color", CEditor.LINE_NUMBER_COLOR}, //$NON-NLS-1$
|
|
||||||
{"Matching bracket color", CEditor.MATCHING_BRACKETS_COLOR}, //$NON-NLS-1$
|
|
||||||
{"Current line highlight color", CEditor.CURRENT_LINE_COLOR}, //$NON-NLS-1$
|
|
||||||
{"Problem indicator color", CEditor.PROBLEM_INDICATION_COLOR}, //$NON-NLS-1$
|
|
||||||
{"Print margin color", CEditor.PRINT_MARGIN_COLOR}, //$NON-NLS-1$
|
|
||||||
{"Linked position color", CEditor.LINKED_POSITION_COLOR}, //$NON-NLS-1$
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected OverlayPreferenceStore fOverlayStore;
|
protected OverlayPreferenceStore fOverlayStore;
|
||||||
|
@ -192,13 +127,128 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
protected SourceViewer fPreviewViewer;
|
protected SourceViewer fPreviewViewer;
|
||||||
|
|
||||||
protected List fAppearanceColorList;
|
protected List fAppearanceColorList;
|
||||||
private ColorEditor fSyntaxForegroundColorEditor;
|
|
||||||
protected ColorEditor fAppearanceForegroundColorEditor;
|
protected ColorEditor fAppearanceForegroundColorEditor;
|
||||||
|
|
||||||
|
private final String[][] fAnnotationColorListModel;
|
||||||
|
private ColorEditor fAnnotationForegroundColorEditor;
|
||||||
|
private List fAnnotationList;
|
||||||
|
private Button fShowInOverviewRulerCheckBox;
|
||||||
|
private Button fShowInTextCheckBox;
|
||||||
|
|
||||||
public CEditorPreferencePage() {
|
public CEditorPreferencePage() {
|
||||||
setDescription(CUIPlugin.getResourceString("CEditorPreferencePage.description"));
|
setDescription(CUIPlugin.getResourceString("CEditorPreferencePage.description"));
|
||||||
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
|
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
|
||||||
fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys);
|
MarkerAnnotationPreferences preferences = new MarkerAnnotationPreferences();
|
||||||
|
fAnnotationColorListModel = createAnnotationTypeListModel(preferences);
|
||||||
|
fOverlayStore = createOverlayStore(preferences);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OverlayPreferenceStore createOverlayStore(MarkerAnnotationPreferences preferences) {
|
||||||
|
ArrayList overlayKeys = new ArrayList();
|
||||||
|
Iterator e = preferences.getAnnotationPreferences().iterator();
|
||||||
|
while (e.hasNext()) {
|
||||||
|
AnnotationPreference info = (AnnotationPreference) e.next();
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
|
||||||
|
}
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.PREFERENCE_COLOR_FOREGROUND));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.BOOLEAN,
|
||||||
|
CEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.PREFERENCE_COLOR_BACKGROUND));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.BOOLEAN,
|
||||||
|
CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT));
|
||||||
|
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"));
|
||||||
|
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"));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_KEYWORD));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_KEYWORD + "_bold"));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_TYPE));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_TYPE + "_bold"));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_STRING));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_STRING + "_bold"));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICColorConstants.C_DEFAULT));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ICColorConstants.C_DEFAULT + "_bold"));
|
||||||
|
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,
|
||||||
|
TextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.BOOLEAN,
|
||||||
|
TextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SPACES_FOR_TABS));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.STRING,
|
||||||
|
TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.INT,
|
||||||
|
TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.BOOLEAN,
|
||||||
|
TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.LINKED_POSITION_COLOR));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.STRING,
|
||||||
|
TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.BOOLEAN,
|
||||||
|
TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.BOOLEAN,
|
||||||
|
TextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOACTIVATION));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.STRING,
|
||||||
|
ContentAssistPreference.AUTOACTIVATION_TRIGGERS_C));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(
|
||||||
|
OverlayPreferenceStore.BOOLEAN,
|
||||||
|
ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS));
|
||||||
|
overlayKeys.add(
|
||||||
|
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CASE_SENSITIVITY));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
|
||||||
|
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND),
|
||||||
|
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND),
|
||||||
|
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND),
|
||||||
|
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC),
|
||||||
|
|
||||||
|
OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
|
||||||
|
overlayKeys.toArray(keys);
|
||||||
|
return new OverlayPreferenceStore(getPreferenceStore(), keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initDefaults(IPreferenceStore store) {
|
public static void initDefaults(IPreferenceStore store) {
|
||||||
|
@ -206,24 +256,24 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
Color color;
|
Color color;
|
||||||
Display display = Display.getDefault();
|
Display display = Display.getDefault();
|
||||||
|
|
||||||
|
MarkerAnnotationPreferences preferences = new MarkerAnnotationPreferences();
|
||||||
|
Iterator e = preferences.getAnnotationPreferences().iterator();
|
||||||
|
while (e.hasNext()) {
|
||||||
|
AnnotationPreference info = (AnnotationPreference) e.next();
|
||||||
|
store.setDefault(info.getTextPreferenceKey(), info.getTextPreferenceValue());
|
||||||
|
store.setDefault(info.getOverviewRulerPreferenceKey(), info.getOverviewRulerPreferenceValue());
|
||||||
|
PreferenceConverter.setDefault(store, info.getColorPreferenceKey(), info.getColorPreferenceValue());
|
||||||
|
}
|
||||||
store.setDefault(CEditor.MATCHING_BRACKETS, true);
|
store.setDefault(CEditor.MATCHING_BRACKETS, true);
|
||||||
store.setDefault(CEditor.MATCHING_BRACKETS_NOBOX, false);
|
|
||||||
color = display.getSystemColor(SWT.COLOR_GRAY);
|
color = display.getSystemColor(SWT.COLOR_GRAY);
|
||||||
PreferenceConverter.setDefault(store, CEditor.MATCHING_BRACKETS_COLOR, color.getRGB());
|
PreferenceConverter.setDefault(store, CEditor.MATCHING_BRACKETS_COLOR, color.getRGB());
|
||||||
|
|
||||||
store.setDefault(CEditor.CURRENT_LINE, true);
|
store.setDefault(TextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true);
|
||||||
PreferenceConverter.setDefault(store, CEditor.CURRENT_LINE_COLOR, new RGB(225, 235, 224));
|
PreferenceConverter.setDefault(store, TextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR, new RGB(225, 235, 224));
|
||||||
|
|
||||||
store.setDefault(CEditor.PRINT_MARGIN, true);
|
store.setDefault(TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, true);
|
||||||
store.setDefault(CEditor.PRINT_MARGIN_COLUMN, 80);
|
store.setDefault(TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80);
|
||||||
PreferenceConverter.setDefault(store, CEditor.PRINT_MARGIN_COLOR, new RGB(176, 180 , 185));
|
PreferenceConverter.setDefault(store, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, new RGB(176, 180, 185));
|
||||||
|
|
||||||
//PreferenceConverter.setDefault(store, CEditor.PREFERENCE_COLOR_FIND_SCOPE, new RGB(185, 176 , 180));
|
|
||||||
|
|
||||||
store.setDefault(CEditor.PROBLEM_INDICATION, true);
|
|
||||||
PreferenceConverter.setDefault(store, CEditor.PROBLEM_INDICATION_COLOR, new RGB(255, 0 , 128));
|
|
||||||
|
|
||||||
//store.setDefault(CompilationUnitEditor.OVERVIEW_RULER, false);
|
|
||||||
|
|
||||||
WorkbenchChainedTextFontFieldEditor.startPropagate(store, JFaceResources.TEXT_FONT);
|
WorkbenchChainedTextFontFieldEditor.startPropagate(store, JFaceResources.TEXT_FONT);
|
||||||
|
|
||||||
|
@ -257,13 +307,12 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
PreferenceConverter.setDefault(store, ICColorConstants.C_DEFAULT, new RGB(0, 0, 0));
|
PreferenceConverter.setDefault(store, ICColorConstants.C_DEFAULT, new RGB(0, 0, 0));
|
||||||
store.setDefault(ICColorConstants.C_DEFAULT + "_bold", false);
|
store.setDefault(ICColorConstants.C_DEFAULT + "_bold", false);
|
||||||
|
|
||||||
|
|
||||||
PreferenceConverter.setDefault(store, CEditor.LINKED_POSITION_COLOR, new RGB(0, 200, 100));
|
PreferenceConverter.setDefault(store, CEditor.LINKED_POSITION_COLOR, new RGB(0, 200, 100));
|
||||||
|
|
||||||
store.setDefault(CEditor.LINE_NUMBER_RULER, false);
|
store.setDefault(TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, false);
|
||||||
PreferenceConverter.setDefault(store, CEditor.LINE_NUMBER_COLOR, new RGB(0, 0, 0));
|
PreferenceConverter.setDefault(store, TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, new RGB(0, 0, 0));
|
||||||
|
|
||||||
store.setDefault(CEditor.OVERVIEW_RULER, true);
|
store.setDefault(TextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, true);
|
||||||
|
|
||||||
store.setDefault(ContentAssistPreference.AUTOACTIVATION, false);
|
store.setDefault(ContentAssistPreference.AUTOACTIVATION, false);
|
||||||
store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
|
store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
|
||||||
|
@ -293,7 +342,6 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
*/
|
*/
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
super.createControl(parent);
|
super.createControl(parent);
|
||||||
//WorkbenchHelp.setHelp(getControl(), ICHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleListSelection() {
|
protected void handleListSelection() {
|
||||||
|
@ -304,6 +352,147 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + "_bold"));
|
fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + "_bold"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Control createAnnotationsPage(Composite parent) {
|
||||||
|
Composite composite = new Composite(parent, SWT.NULL);
|
||||||
|
GridLayout layout = new GridLayout();
|
||||||
|
layout.numColumns = 2;
|
||||||
|
composite.setLayout(layout);
|
||||||
|
|
||||||
|
Label label = new Label(composite, SWT.LEFT);
|
||||||
|
label.setText("Annotation Presentation Options");
|
||||||
|
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
||||||
|
gd.horizontalSpan = 2;
|
||||||
|
label.setLayoutData(gd);
|
||||||
|
|
||||||
|
Composite editorComposite = new Composite(composite, SWT.NONE);
|
||||||
|
layout = new GridLayout();
|
||||||
|
layout.numColumns = 2;
|
||||||
|
layout.marginHeight = 0;
|
||||||
|
layout.marginWidth = 0;
|
||||||
|
editorComposite.setLayout(layout);
|
||||||
|
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
|
||||||
|
gd.horizontalSpan = 2;
|
||||||
|
editorComposite.setLayoutData(gd);
|
||||||
|
|
||||||
|
fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
|
||||||
|
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
|
||||||
|
gd.heightHint = convertHeightInCharsToPixels(8);
|
||||||
|
fAnnotationList.setLayoutData(gd);
|
||||||
|
|
||||||
|
Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
|
||||||
|
layout = new GridLayout();
|
||||||
|
layout.marginHeight = 0;
|
||||||
|
layout.marginWidth = 0;
|
||||||
|
layout.numColumns = 2;
|
||||||
|
optionsComposite.setLayout(layout);
|
||||||
|
optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
|
||||||
|
fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
|
||||||
|
fShowInTextCheckBox.setText("Show In Text");
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.horizontalAlignment = GridData.BEGINNING;
|
||||||
|
gd.horizontalSpan = 2;
|
||||||
|
fShowInTextCheckBox.setLayoutData(gd);
|
||||||
|
|
||||||
|
fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
|
||||||
|
fShowInOverviewRulerCheckBox.setText("Show In Overview Ruler");
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.horizontalAlignment = GridData.BEGINNING;
|
||||||
|
gd.horizontalSpan = 2;
|
||||||
|
fShowInOverviewRulerCheckBox.setLayoutData(gd);
|
||||||
|
|
||||||
|
label = new Label(optionsComposite, SWT.LEFT);
|
||||||
|
label.setText("Annotations Color");
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalAlignment = GridData.BEGINNING;
|
||||||
|
label.setLayoutData(gd);
|
||||||
|
|
||||||
|
fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite);
|
||||||
|
Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton();
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.horizontalAlignment = GridData.BEGINNING;
|
||||||
|
foregroundColorButton.setLayoutData(gd);
|
||||||
|
|
||||||
|
fAnnotationList.addSelectionListener(new SelectionListener() {
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
handleAnnotationListSelection();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
int i = fAnnotationList.getSelectionIndex();
|
||||||
|
String key = fAnnotationColorListModel[i][2];
|
||||||
|
fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
int i = fAnnotationList.getSelectionIndex();
|
||||||
|
String key = fAnnotationColorListModel[i][3];
|
||||||
|
fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foregroundColorButton.addSelectionListener(new SelectionListener() {
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
int i = fAnnotationList.getSelectionIndex();
|
||||||
|
String key = fAnnotationColorListModel[i][1];
|
||||||
|
PreferenceConverter.setValue(fOverlayStore, key, fAnnotationForegroundColorEditor.getColorValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return composite;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleAnnotationListSelection() {
|
||||||
|
int i = fAnnotationList.getSelectionIndex();
|
||||||
|
|
||||||
|
String key = fAnnotationColorListModel[i][1];
|
||||||
|
RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
|
||||||
|
fAnnotationForegroundColorEditor.setColorValue(rgb);
|
||||||
|
|
||||||
|
key = fAnnotationColorListModel[i][2];
|
||||||
|
fShowInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
|
||||||
|
|
||||||
|
key = fAnnotationColorListModel[i][3];
|
||||||
|
fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
|
||||||
|
ArrayList listModelItems = new ArrayList();
|
||||||
|
Iterator e = preferences.getAnnotationPreferences().iterator();
|
||||||
|
while (e.hasNext()) {
|
||||||
|
AnnotationPreference info = (AnnotationPreference) e.next();
|
||||||
|
listModelItems.add(
|
||||||
|
new String[] {
|
||||||
|
info.getPreferenceLabel(),
|
||||||
|
info.getColorPreferenceKey(),
|
||||||
|
info.getTextPreferenceKey(),
|
||||||
|
info.getOverviewRulerPreferenceKey()});
|
||||||
|
}
|
||||||
|
String[][] items = new String[listModelItems.size()][];
|
||||||
|
listModelItems.toArray(items);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
private Control createColorPage(Composite parent) {
|
private Control createColorPage(Composite parent) {
|
||||||
|
|
||||||
Composite colorComposite = new Composite(parent, SWT.NULL);
|
Composite colorComposite = new Composite(parent, SWT.NULL);
|
||||||
|
@ -328,7 +517,8 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
fBackgroundColorButton.setEnabled(custom);
|
fBackgroundColorButton.setEnabled(custom);
|
||||||
fOverlayStore.setValue(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, !custom);
|
fOverlayStore.setValue(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, !custom);
|
||||||
}
|
}
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {}
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
|
fBackgroundDefaultRadioButton = new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
|
||||||
|
@ -407,7 +597,6 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
gd.heightHint = convertHeightInCharsToPixels(15);
|
gd.heightHint = convertHeightInCharsToPixels(15);
|
||||||
previewer.setLayoutData(gd);
|
previewer.setLayoutData(gd);
|
||||||
|
|
||||||
|
|
||||||
fList.addSelectionListener(new SelectionListener() {
|
fList.addSelectionListener(new SelectionListener() {
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -434,7 +623,10 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
PreferenceConverter.setValue(fOverlayStore, CEditor.PREFERENCE_COLOR_BACKGROUND, fBackgroundColorEditor.getColorValue());
|
PreferenceConverter.setValue(
|
||||||
|
fOverlayStore,
|
||||||
|
CEditor.PREFERENCE_COLOR_BACKGROUND,
|
||||||
|
fBackgroundColorEditor.getColorValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -474,9 +666,8 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() {
|
fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() {
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
String p = event.getProperty();
|
String p = event.getProperty();
|
||||||
if (p.equals(CEditor.PREFERENCE_COLOR_BACKGROUND) ||
|
if (p.equals(CEditor.PREFERENCE_COLOR_BACKGROUND)
|
||||||
p.equals(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT))
|
|| p.equals(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
|
||||||
{
|
|
||||||
initializeViewerColors(fPreviewViewer);
|
initializeViewerColors(fPreviewViewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +694,8 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
StyledText styledText = viewer.getTextWidget();
|
StyledText styledText = viewer.getTextWidget();
|
||||||
|
|
||||||
// ---------- background color ----------------------
|
// ---------- background color ----------------------
|
||||||
Color color= store.getBoolean(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
|
Color color =
|
||||||
|
store.getBoolean(CEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
|
||||||
? null
|
? null
|
||||||
: createColor(store, CEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
|
: createColor(store, CEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
|
||||||
styledText.setBackground(color);
|
styledText.setBackground(color);
|
||||||
|
@ -556,14 +748,7 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
};
|
};
|
||||||
|
|
||||||
private Button fBracketHighlightButton;
|
private Button fBracketHighlightButton;
|
||||||
private Button fBracketHighlightBoxButton;
|
|
||||||
private Control fBracketHighlightColor;
|
|
||||||
private Button fLineHighlightButton;
|
private Button fLineHighlightButton;
|
||||||
private Control fLineHighlightColor;
|
|
||||||
private Button fProblemIndicationButton;
|
|
||||||
private Control fProblemIndicationColor;
|
|
||||||
private Control fFindScopeColor;
|
|
||||||
private Control fLinkedPositionColor;
|
|
||||||
|
|
||||||
protected void handleAppearanceColorListSelection() {
|
protected void handleAppearanceColorListSelection() {
|
||||||
int i = fAppearanceColorList.getSelectionIndex();
|
int i = fAppearanceColorList.getSelectionIndex();
|
||||||
|
@ -574,10 +759,10 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
private Control createBehaviorPage(Composite parent) {
|
private Control createBehaviorPage(Composite parent) {
|
||||||
|
|
||||||
Composite behaviorComposite = new Composite(parent, SWT.NULL);
|
Composite behaviorComposite = new Composite(parent, SWT.NULL);
|
||||||
GridLayout layout= new GridLayout(); layout.numColumns= 2;
|
GridLayout layout = new GridLayout();
|
||||||
|
layout.numColumns = 2;
|
||||||
behaviorComposite.setLayout(layout);
|
behaviorComposite.setLayout(layout);
|
||||||
|
|
||||||
|
|
||||||
String label = "Text &font:";
|
String label = "Text &font:";
|
||||||
addTextFontEditor(behaviorComposite, label, JFaceResources.TEXT_FONT);
|
addTextFontEditor(behaviorComposite, label, JFaceResources.TEXT_FONT);
|
||||||
|
|
||||||
|
@ -585,7 +770,7 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
addTextField(behaviorComposite, label, CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH, 2, 0, true);
|
addTextField(behaviorComposite, label, CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH, 2, 0, true);
|
||||||
|
|
||||||
label = "Print margin col&umn:";
|
label = "Print margin col&umn:";
|
||||||
addTextField(behaviorComposite, label, CEditor.PRINT_MARGIN_COLUMN, 4, 0, true);
|
addTextField(behaviorComposite, label, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 4, 0, true);
|
||||||
|
|
||||||
label = "Insert &space for tabs";
|
label = "Insert &space for tabs";
|
||||||
addCheckBox(behaviorComposite, label, CEditor.SPACES_FOR_TABS, 0);
|
addCheckBox(behaviorComposite, label, CEditor.SPACES_FOR_TABS, 0);
|
||||||
|
@ -593,23 +778,17 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
label = "Highlight &matching brackets";
|
label = "Highlight &matching brackets";
|
||||||
fBracketHighlightButton = addCheckBox(behaviorComposite, label, CEditor.MATCHING_BRACKETS, 0);
|
fBracketHighlightButton = addCheckBox(behaviorComposite, label, CEditor.MATCHING_BRACKETS, 0);
|
||||||
|
|
||||||
label= "Only c&olor bracket text";
|
|
||||||
fBracketHighlightBoxButton= addCheckBox(behaviorComposite, label, CEditor.MATCHING_BRACKETS_NOBOX, 0);
|
|
||||||
|
|
||||||
label = "Show line numbers"; //$NON-NLS-1$
|
label = "Show line numbers"; //$NON-NLS-1$
|
||||||
addCheckBox(behaviorComposite, label, CEditor.LINE_NUMBER_RULER, 0);
|
addCheckBox(behaviorComposite, label, TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
|
||||||
|
|
||||||
label = "Highlight ¤t line";
|
label = "Highlight ¤t line";
|
||||||
fLineHighlightButton= addCheckBox(behaviorComposite, label, CEditor.CURRENT_LINE, 0);
|
fLineHighlightButton = addCheckBox(behaviorComposite, label, TextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
|
||||||
|
|
||||||
label= "Highlight &problems";
|
|
||||||
fProblemIndicationButton= addCheckBox(behaviorComposite, label, CEditor.PROBLEM_INDICATION, 0);
|
|
||||||
|
|
||||||
label = "Show overview ruler"; //$NON-NLS-1$
|
label = "Show overview ruler"; //$NON-NLS-1$
|
||||||
addCheckBox(behaviorComposite, label, CEditor.OVERVIEW_RULER, 0);
|
addCheckBox(behaviorComposite, label, TextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
|
||||||
|
|
||||||
label = "Show print &margin";
|
label = "Show print &margin";
|
||||||
addCheckBox(behaviorComposite, label, CEditor.PRINT_MARGIN, 0);
|
addCheckBox(behaviorComposite, label, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
|
||||||
|
|
||||||
Label l = new Label(behaviorComposite, SWT.LEFT);
|
Label l = new Label(behaviorComposite, SWT.LEFT);
|
||||||
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
||||||
|
@ -684,7 +863,8 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
private Control createContentAssistPage(Composite parent) {
|
private Control createContentAssistPage(Composite parent) {
|
||||||
|
|
||||||
Composite contentAssistComposite = new Composite(parent, SWT.NULL);
|
Composite contentAssistComposite = new Composite(parent, SWT.NULL);
|
||||||
GridLayout layout= new GridLayout(); layout.numColumns= 2;
|
GridLayout layout = new GridLayout();
|
||||||
|
layout.numColumns = 2;
|
||||||
contentAssistComposite.setLayout(layout);
|
contentAssistComposite.setLayout(layout);
|
||||||
|
|
||||||
String label = "Insert single &proposals automatically";
|
String label = "Insert single &proposals automatically";
|
||||||
|
@ -746,6 +926,11 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
|
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
|
||||||
item.setControl(createBehaviorPage(folder));
|
item.setControl(createBehaviorPage(folder));
|
||||||
|
|
||||||
|
item = new TabItem(folder, SWT.NONE);
|
||||||
|
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
|
||||||
|
item.setText("Annotations");
|
||||||
|
item.setControl(createAnnotationsPage(folder));
|
||||||
|
|
||||||
item = new TabItem(folder, SWT.NONE);
|
item = new TabItem(folder, SWT.NONE);
|
||||||
item.setText("&Colors");
|
item.setText("&Colors");
|
||||||
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
|
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
|
||||||
|
@ -771,10 +956,6 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
|
|
||||||
for (int i = 0; i < fListModel.length; i++)
|
for (int i = 0; i < fListModel.length; i++)
|
||||||
fList.add(fListModel[i][0]);
|
fList.add(fListModel[i][0]);
|
||||||
|
|
||||||
for (int i= 0; i < fAppearanceColorListModel.length; i++)
|
|
||||||
fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
|
|
||||||
|
|
||||||
fList.getDisplay().asyncExec(new Runnable() {
|
fList.getDisplay().asyncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
fList.select(0);
|
fList.select(0);
|
||||||
|
@ -782,12 +963,25 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (int i = 0; i < fAppearanceColorListModel.length; i++)
|
||||||
|
fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
|
||||||
fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
|
fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
fAppearanceColorList.select(0);
|
fAppearanceColorList.select(0);
|
||||||
handleAppearanceColorListSelection();
|
handleAppearanceColorListSelection();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (int i = 0; i < fAnnotationColorListModel.length; i++)
|
||||||
|
fAnnotationList.add(fAnnotationColorListModel[i][0]);
|
||||||
|
fAnnotationList.getDisplay().asyncExec(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
|
||||||
|
fAnnotationList.select(0);
|
||||||
|
handleAnnotationListSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeFields() {
|
private void initializeFields() {
|
||||||
|
@ -973,7 +1167,10 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
CUIPlugin.getDefault().log(io);
|
CUIPlugin.getDefault().log(io);
|
||||||
} finally {
|
} finally {
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
try { reader.close(); } catch (IOException e) {}
|
try {
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
|
@ -1015,5 +1212,3 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
|
||||||
StatusUtil.applyToStatusLine(this, status);
|
StatusUtil.applyToStatusLine(this, status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,216 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.preferences;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
|
||||||
import org.eclipse.cdt.internal.ui.dialogs.StatusTool;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
|
|
||||||
import org.eclipse.cdt.internal.ui.wizards.swt.MGridLayout;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.ui.dialogs.PropertyPage;
|
|
||||||
import org.eclipse.ui.help.WorkbenchHelp;
|
|
||||||
public class CLaunchingPropertyPage extends PropertyPage {
|
|
||||||
|
|
||||||
private static final String PAGE_NAME= "CLaunchingPropertyPage";
|
|
||||||
private static final String ARGUMENTS= PAGE_NAME + ".arguments";
|
|
||||||
private static final String WORKINGDIR= PAGE_NAME + ".workingdir";
|
|
||||||
|
|
||||||
private static final String NO_CPROJECT= PAGE_NAME + ".nocproject.label";
|
|
||||||
|
|
||||||
private static final String ERROR_WORKINGDIR_NOTEXISTS= PAGE_NAME + ".error.WorkingDirNotExists";
|
|
||||||
|
|
||||||
private StringDialogField fArgumentField;
|
|
||||||
protected StringButtonDialogField fWorkingDirField;
|
|
||||||
|
|
||||||
private StatusInfo fWorkingDirStatus;
|
|
||||||
|
|
||||||
private QualifiedName fArgumentsPropertyName;
|
|
||||||
private QualifiedName fWorkingDirPropertyName;
|
|
||||||
|
|
||||||
private Shell fShell;
|
|
||||||
|
|
||||||
public CLaunchingPropertyPage() {
|
|
||||||
LaunchingDialogFieldsAdapter adapter= new LaunchingDialogFieldsAdapter();
|
|
||||||
|
|
||||||
fArgumentField= new StringDialogField();
|
|
||||||
fArgumentField.setLabelText(CUIPlugin.getResourceString(ARGUMENTS + ".label"));
|
|
||||||
fArgumentField.setDialogFieldListener(adapter);
|
|
||||||
|
|
||||||
fWorkingDirField= new StringButtonDialogField(adapter);
|
|
||||||
fWorkingDirField.setLabelText(CUIPlugin.getResourceString(WORKINGDIR + ".label"));
|
|
||||||
fWorkingDirField.setButtonLabel(CUIPlugin.getResourceString(WORKINGDIR + ".browse"));
|
|
||||||
fWorkingDirField.setDialogFieldListener(adapter);
|
|
||||||
|
|
||||||
fWorkingDirStatus= new StatusInfo();
|
|
||||||
|
|
||||||
fArgumentsPropertyName= new QualifiedName(CUIPlugin.PLUGIN_ID, "arguments");
|
|
||||||
fWorkingDirPropertyName= new QualifiedName(CUIPlugin.PLUGIN_ID, "workingdir");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PreferencePage#createContents(Composite)
|
|
||||||
*/
|
|
||||||
protected Control createContents(Composite parent) {
|
|
||||||
Composite composite= new Composite(parent, SWT.NONE);
|
|
||||||
fShell= parent.getShell();
|
|
||||||
|
|
||||||
MGridLayout layout= new MGridLayout();
|
|
||||||
layout.marginWidth= 0;
|
|
||||||
layout.marginHeight= 0;
|
|
||||||
layout.minimumWidth= 400;
|
|
||||||
layout.minimumHeight= 350;
|
|
||||||
layout.numColumns= 3;
|
|
||||||
composite.setLayout(layout);
|
|
||||||
|
|
||||||
boolean isCProject= false;
|
|
||||||
try {
|
|
||||||
IFile file= getInputFile();
|
|
||||||
isCProject= (file.getProject().hasNature(CProjectNature.C_NATURE_ID));
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CUIPlugin.getDefault().log(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isCProject) {
|
|
||||||
fArgumentField.doFillIntoGrid(composite, 3);
|
|
||||||
fWorkingDirField.doFillIntoGrid(composite, 3);
|
|
||||||
initialize();
|
|
||||||
} else {
|
|
||||||
DialogField labelField= new DialogField();
|
|
||||||
labelField.setLabelText(CUIPlugin.getResourceString(NO_CPROJECT));
|
|
||||||
labelField.doFillIntoGrid(composite, 3);
|
|
||||||
}
|
|
||||||
WorkbenchHelp.setHelp(parent, ICHelpContextIds.LAUNCH_PROPERTY_PAGE);
|
|
||||||
|
|
||||||
return composite;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void initialize() {
|
|
||||||
IFile file= getInputFile();
|
|
||||||
if (file != null) {
|
|
||||||
try {
|
|
||||||
String arguments= file.getPersistentProperty(fArgumentsPropertyName);
|
|
||||||
if (arguments != null) {
|
|
||||||
fArgumentField.setText(arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
String workingdir= file.getPersistentProperty(fWorkingDirPropertyName);
|
|
||||||
if (workingdir != null) {
|
|
||||||
fWorkingDirField.setText(workingdir);
|
|
||||||
} else {
|
|
||||||
fWorkingDirField.setText(file.getParent().getLocation().toOSString());
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CUIPlugin.getDefault().log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PreferencePage#performOk
|
|
||||||
*/
|
|
||||||
public boolean performOk() {
|
|
||||||
IFile file= getInputFile();
|
|
||||||
if (file != null) {
|
|
||||||
try {
|
|
||||||
file.setPersistentProperty(fArgumentsPropertyName, fArgumentField.getText());
|
|
||||||
file.setPersistentProperty(fWorkingDirPropertyName, fWorkingDirField.getText());
|
|
||||||
} catch (CoreException e) {
|
|
||||||
ErrorDialog.openError(fShell, "Error", null, e.getStatus());
|
|
||||||
CUIPlugin.getDefault().log(e.getStatus());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PreferencePage#doDefaults
|
|
||||||
*/
|
|
||||||
protected void performDefaults() {
|
|
||||||
initialize();
|
|
||||||
super.performDefaults();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LaunchingDialogFieldsAdapter implements IDialogFieldListener, IStringButtonAdapter {
|
|
||||||
|
|
||||||
public void changeControlPressed(DialogField field) {
|
|
||||||
String oldValue= fWorkingDirField.getText();
|
|
||||||
String newValue= chooseFolder(oldValue);
|
|
||||||
if (newValue != null) {
|
|
||||||
fWorkingDirField.setText(newValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dialogFieldChanged(DialogField field) {
|
|
||||||
doFieldChanged(field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void doFieldChanged(DialogField field) {
|
|
||||||
if (field == fWorkingDirField) {
|
|
||||||
updateWorkingDirStatus();
|
|
||||||
}
|
|
||||||
projectStatusChanged(fWorkingDirStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void updateWorkingDirStatus() {
|
|
||||||
String str= fWorkingDirField.getText();
|
|
||||||
if (!"".equals(str)) {
|
|
||||||
IPath path= new Path(str);
|
|
||||||
if (!path.toFile().isDirectory()) {
|
|
||||||
fWorkingDirStatus.setError(CUIPlugin.getResourceString(ERROR_WORKINGDIR_NOTEXISTS));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fWorkingDirStatus.setOK();
|
|
||||||
}
|
|
||||||
|
|
||||||
private IFile getInputFile() {
|
|
||||||
return (IFile)getElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String chooseFolder(String initPath) {
|
|
||||||
DirectoryDialog dialog= new DirectoryDialog(fShell, 0);
|
|
||||||
dialog.setFilterPath(initPath);
|
|
||||||
String res= dialog.open();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void projectStatusChanged(IStatus status) {
|
|
||||||
setValid(!status.matches(IStatus.ERROR));
|
|
||||||
StatusTool.applyToStatusLine(this, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see DialogPage#setVisible(boolean)
|
|
||||||
*/
|
|
||||||
public void setVisible(boolean visible) {
|
|
||||||
super.setVisible(visible);
|
|
||||||
if (visible && fShell != null) {
|
|
||||||
fArgumentField.postSetFocusOnDialogField(fShell.getDisplay());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,23 +7,16 @@ package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.Region;
|
import org.eclipse.jface.text.Region;
|
||||||
|
import org.eclipse.jface.text.source.ICharacterPairMatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for match pairs of characters.
|
* Helper class for match pairs of characters.
|
||||||
*/
|
*/
|
||||||
public class CPairMatcher {
|
public class CPairMatcher implements ICharacterPairMatcher {
|
||||||
|
|
||||||
|
|
||||||
public static final int LEFT= 1;
|
|
||||||
public static final int RIGHT= 2;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected char[] fPairs;
|
protected char[] fPairs;
|
||||||
protected IDocument fDocument;
|
protected IDocument fDocument;
|
||||||
|
@ -35,24 +28,19 @@ public class CPairMatcher {
|
||||||
|
|
||||||
protected CCodeReader fReader = new CCodeReader();
|
protected CCodeReader fReader = new CCodeReader();
|
||||||
|
|
||||||
|
|
||||||
public CPairMatcher(char[] pairs) {
|
public CPairMatcher(char[] pairs) {
|
||||||
fPairs = pairs;
|
fPairs = pairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRegion match(IDocument document, int offset) {
|
public IRegion match(IDocument document, int offset) {
|
||||||
|
|
||||||
|
|
||||||
fOffset = offset;
|
fOffset = offset;
|
||||||
|
|
||||||
|
|
||||||
if (fOffset < 0)
|
if (fOffset < 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
||||||
fDocument = document;
|
fDocument = document;
|
||||||
|
|
||||||
|
|
||||||
if (matchPairsAt() && fStartPos != fEndPos)
|
if (matchPairsAt() && fStartPos != fEndPos)
|
||||||
return new Region(fStartPos, fEndPos - fStartPos + 1);
|
return new Region(fStartPos, fEndPos - fStartPos + 1);
|
||||||
|
|
||||||
|
@ -63,49 +51,47 @@ public class CPairMatcher {
|
||||||
return fAnchor;
|
return fAnchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
/*
|
||||||
fDocument= null;
|
* @see org.eclipse.jface.text.source.ICharacterPairMatcher#clear()
|
||||||
|
*/
|
||||||
|
public void clear() {
|
||||||
if (fReader != null) {
|
if (fReader != null) {
|
||||||
try {
|
try {
|
||||||
fReader.close();
|
fReader.close();
|
||||||
} catch (IOException x) {
|
} catch (IOException x) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
clear();
|
||||||
|
fDocument = null;
|
||||||
fReader = null;
|
fReader = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean matchPairsAt() {
|
protected boolean matchPairsAt() {
|
||||||
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
int pairIndex1= fPairs.length;
|
int pairIndex1= fPairs.length;
|
||||||
int pairIndex2= fPairs.length;
|
int pairIndex2= fPairs.length;
|
||||||
|
|
||||||
|
|
||||||
fStartPos= -1;
|
fStartPos= -1;
|
||||||
fEndPos= -1;
|
fEndPos= -1;
|
||||||
|
|
||||||
|
|
||||||
// get the chars preceding and following the start position
|
// get the chars preceding and following the start position
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
char prevChar= fDocument.getChar(Math.max(fOffset - 1, 0));
|
||||||
/*
|
// modified behavior for http://dev.eclipse.org/bugs/show_bug.cgi?id=16879
|
||||||
A quick hack to get around the fact that we can't bracket
|
// char nextChar= fDocument.getChar(fOffset);
|
||||||
match on the very first element of a document. We make the
|
|
||||||
character to match a null character which is unlikely to match.
|
|
||||||
*/
|
|
||||||
char prevChar= (fOffset > 0) ? fDocument.getChar(fOffset - 1) : '\0';
|
|
||||||
char nextChar= fDocument.getChar(fOffset);
|
|
||||||
|
|
||||||
|
|
||||||
// search for opening peer character next to the activation point
|
// search for opening peer character next to the activation point
|
||||||
for (i= 0; i < fPairs.length; i= i + 2) {
|
for (i= 0; i < fPairs.length; i= i + 2) {
|
||||||
if (nextChar == fPairs[i]) {
|
// if (nextChar == fPairs[i]) {
|
||||||
fStartPos= fOffset;
|
// fStartPos= fOffset;
|
||||||
pairIndex1= i;
|
// pairIndex1= i;
|
||||||
} else if (prevChar == fPairs[i]) {
|
// } else
|
||||||
|
if (prevChar == fPairs[i]) {
|
||||||
fStartPos= fOffset - 1;
|
fStartPos= fOffset - 1;
|
||||||
pairIndex1= i;
|
pairIndex1= i;
|
||||||
}
|
}
|
||||||
|
@ -116,13 +102,13 @@ public class CPairMatcher {
|
||||||
if (prevChar == fPairs[i]) {
|
if (prevChar == fPairs[i]) {
|
||||||
fEndPos= fOffset - 1;
|
fEndPos= fOffset - 1;
|
||||||
pairIndex2= i;
|
pairIndex2= i;
|
||||||
} else if (nextChar == fPairs[i]) {
|
|
||||||
fEndPos= fOffset;
|
|
||||||
pairIndex2= i;
|
|
||||||
}
|
}
|
||||||
|
// else if (nextChar == fPairs[i]) {
|
||||||
|
// fEndPos= fOffset;
|
||||||
|
// pairIndex2= i;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fEndPos > -1) {
|
if (fEndPos > -1) {
|
||||||
fAnchor= RIGHT;
|
fAnchor= RIGHT;
|
||||||
fStartPos= searchForOpeningPeer(fEndPos, fPairs[pairIndex2 - 1], fPairs[pairIndex2], fDocument);
|
fStartPos= searchForOpeningPeer(fEndPos, fPairs[pairIndex2 - 1], fPairs[pairIndex2], fDocument);
|
||||||
|
@ -139,15 +125,80 @@ public class CPairMatcher {
|
||||||
fStartPos= -1;
|
fStartPos= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
} catch (IOException x) {
|
} catch (IOException x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// protected boolean matchPairsAt() {
|
||||||
|
//
|
||||||
|
// int i;
|
||||||
|
// int pairIndex1 = fPairs.length;
|
||||||
|
// int pairIndex2 = fPairs.length;
|
||||||
|
//
|
||||||
|
// fStartPos = -1;
|
||||||
|
// fEndPos = -1;
|
||||||
|
//
|
||||||
|
// // get the chars preceding and following the start position
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// A quick hack to get around the fact that we can't bracket
|
||||||
|
// match on the very first element of a document. We make the
|
||||||
|
// character to match a null character which is unlikely to match.
|
||||||
|
// */
|
||||||
|
// char prevChar = (fOffset > 0) ? fDocument.getChar(fOffset - 1) : '\0';
|
||||||
|
// char nextChar = fDocument.getChar(fOffset);
|
||||||
|
//
|
||||||
|
// // search for opening peer character next to the activation point
|
||||||
|
// for (i = 0; i < fPairs.length; i = i + 2) {
|
||||||
|
// if (nextChar == fPairs[i]) {
|
||||||
|
// fStartPos = fOffset;
|
||||||
|
// pairIndex1 = i;
|
||||||
|
// } else if (prevChar == fPairs[i]) {
|
||||||
|
// fStartPos = fOffset - 1;
|
||||||
|
// pairIndex1 = i;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // search for closing peer character next to the activation point
|
||||||
|
// for (i = 1; i < fPairs.length; i = i + 2) {
|
||||||
|
// if (prevChar == fPairs[i]) {
|
||||||
|
// fEndPos = fOffset - 1;
|
||||||
|
// pairIndex2 = i;
|
||||||
|
// } else if (nextChar == fPairs[i]) {
|
||||||
|
// fEndPos = fOffset;
|
||||||
|
// pairIndex2 = i;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (fEndPos > -1) {
|
||||||
|
// fAnchor = RIGHT;
|
||||||
|
// fStartPos = searchForOpeningPeer(fEndPos, fPairs[pairIndex2 - 1], fPairs[pairIndex2], fDocument);
|
||||||
|
// if (fStartPos > -1)
|
||||||
|
// return true;
|
||||||
|
// else
|
||||||
|
// fEndPos = -1;
|
||||||
|
// } else if (fStartPos > -1) {
|
||||||
|
// fAnchor = LEFT;
|
||||||
|
// fEndPos = searchForClosingPeer(fStartPos, fPairs[pairIndex1], fPairs[pairIndex1 + 1], fDocument);
|
||||||
|
// if (fEndPos > -1)
|
||||||
|
// return true;
|
||||||
|
// else
|
||||||
|
// fStartPos = -1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// } catch (BadLocationException x) {
|
||||||
|
// } catch (IOException x) {
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
protected int searchForClosingPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException {
|
protected int searchForClosingPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException {
|
||||||
|
|
||||||
fReader.configureForwardReader(document, offset + 1, document.getLength(), true, true);
|
fReader.configureForwardReader(document, offset + 1, document.getLength(), true, true);
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.util;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IContainer;
|
|
||||||
import org.eclipse.core.resources.IFolder;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
|
|
||||||
|
|
||||||
public class CoreUtility {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a nauture to a project
|
|
||||||
*/
|
|
||||||
public static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
|
|
||||||
IProjectDescription description = proj.getDescription();
|
|
||||||
String[] prevNatures= description.getNatureIds();
|
|
||||||
String[] newNatures= new String[prevNatures.length + 1];
|
|
||||||
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
|
|
||||||
newNatures[prevNatures.length]= natureId;
|
|
||||||
description.setNatureIds(newNatures);
|
|
||||||
proj.setDescription(description, monitor);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Creates a folder and all parent folders if not existing
|
|
||||||
* Project must exist
|
|
||||||
*/
|
|
||||||
public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
|
|
||||||
if (!folder.exists()) {
|
|
||||||
IContainer parent= folder.getParent();
|
|
||||||
if (parent instanceof IFolder) {
|
|
||||||
createFolder((IFolder)parent, force, local, monitor);
|
|
||||||
}
|
|
||||||
folder.create(force, local, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue