Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Patch to cdt.ui

Hi all,

I've commited the following code to cdt.ui to continue the 2.0
cleanup. It does the following:

- brings the editor partition scanning to use the new 2.0 scanner
- cleans up some of the preferences and makes them look like the JDT
ones a little more
- adds the line number ruler
- adds the problem summary ruler

Sebastien


Index: src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
diff -N src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java	9 Aug 2002
02:22:12 -0000
***************
*** 0 ****
--- 1,75 ----
+ /*
+  * (c) Copyright IBM Corp. 2000, 2001.
+  * All Rights Reserved.
+  */
+ package org.eclipse.cdt.internal.ui.dialogs;
+ 
+ import org.eclipse.core.runtime.IStatus;
+ 
+ import org.eclipse.jface.dialogs.DialogPage;
+ 
+ /**
+  * A utility class to work with IStatus.
+  */
+ public class StatusUtil {
+ 
+ 	/**
+ 	 * Compares two instances of <code>IStatus</code>. The more severe
is returned:
+ 	 * An error is more severe than a warning, and a warning is more
severe
+ 	 * than ok. If the two stati have the same severity, the second is
returned.
+ 	 */
+ 	public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
+ 		if (s1.getSeverity() > s2.getSeverity()) {
+ 			return s1;
+ 		} else {
+ 			return s2;
+ 		}
+ 	}
+ 
+ 	/**
+ 	 * Finds the most severe status from a array of stati.
+ 	 * An error is more severe than a warning, and a warning is more
severe
+ 	 * than ok.
+ 	 */
+ 	public static IStatus getMostSevere(IStatus[] status) {
+ 		IStatus max= null;
+ 		for (int i= 0; i < status.length; i++) {
+ 			IStatus curr= status[i];
+ 			if (curr.matches(IStatus.ERROR)) {
+ 				return curr;
+ 			}
+ 			if (max == null || curr.getSeverity() >
max.getSeverity()) {
+ 				max= curr;
+ 			}
+ 		}
+ 		return max;
+ 	}
+ 		
+ 	/**
+ 	 * Applies the status to the status line of a dialog page.
+ 	 */
+ 	public static void applyToStatusLine(DialogPage page, IStatus
status) {
+ 		String message= status.getMessage();
+ 		switch (status.getSeverity()) {
+ 			case IStatus.OK:
+ 				page.setMessage(message, DialogPage.NONE);
+ 				page.setErrorMessage(null);
+ 				break;
+ 			case IStatus.WARNING:
+ 				page.setMessage(message,
DialogPage.WARNING);
+ 				page.setErrorMessage(null);
+ 				break;				
+ 			case IStatus.INFO:
+ 				page.setMessage(message,
DialogPage.INFORMATION);
+ 				page.setErrorMessage(null);
+ 				break;			
+ 			default:
+ 				if (message.length() == 0) {
+ 					message= null;
+ 				}
+ 				page.setMessage(null);
+ 				page.setErrorMessage(message);
+ 				break;		
+ 		}
+ 	}
+ }
Index: src/org/eclipse/cdt/internal/ui/editor/CEditor.java
===================================================================
RCS file:
/home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEdito
r.java,v
retrieving revision 1.2
diff -c -r1.2 CEditor.java
*** src/org/eclipse/cdt/internal/ui/editor/CEditor.java	26 Jun 2002 21:53:41
-0000	1.2
--- src/org/eclipse/cdt/internal/ui/editor/CEditor.java	9 Aug 2002 02:22:12
-0000
***************
*** 44,52 ****
--- 44,56 ----
  import org.eclipse.jface.text.ITextViewerExtension;
  import org.eclipse.jface.text.Position;
  import org.eclipse.jface.text.source.Annotation;
+ import org.eclipse.jface.text.source.AnnotationRulerColumn;
+ import org.eclipse.jface.text.source.CompositeRuler;
  import org.eclipse.jface.text.source.IAnnotationModel;
  import org.eclipse.jface.text.source.ISourceViewer;
  import org.eclipse.jface.text.source.IVerticalRuler;
+ import org.eclipse.jface.text.source.IVerticalRulerColumn;
+ import org.eclipse.jface.text.source.LineNumberRulerColumn;
  import org.eclipse.jface.text.source.SourceViewer;
  import org.eclipse.jface.text.source.SourceViewerConfiguration;
  import org.eclipse.jface.util.PropertyChangeEvent;
***************
*** 56,61 ****
--- 60,66 ----
  import org.eclipse.jface.viewers.IStructuredSelection;
  import org.eclipse.jface.viewers.SelectionChangedEvent;
  import org.eclipse.jface.viewers.StructuredSelection;
+ import org.eclipse.swt.SWT;
  import org.eclipse.swt.custom.ST;
  import org.eclipse.swt.custom.StyledText;
  import org.eclipse.swt.custom.VerifyKeyListener;
***************
*** 67,76 ****
--- 72,84 ----
  import org.eclipse.swt.events.VerifyListener;
  import org.eclipse.swt.graphics.Color;
  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.Composite;
  import org.eclipse.swt.widgets.Control;
  import org.eclipse.swt.widgets.Display;
+ import org.eclipse.swt.widgets.Layout;
  import org.eclipse.swt.widgets.Shell;
  import org.eclipse.ui.IEditorActionBarContributor;
  import org.eclipse.ui.IEditorInput;
***************
*** 102,107 ****
--- 110,116 ----
  import org.eclipse.cdt.internal.ui.IContextMenuConstants;
  import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
  import org.eclipse.cdt.internal.ui.text.CTextTools;
+ import org.eclipse.cdt.internal.ui.text.IColorManager;
  import org.eclipse.cdt.ui.ICDTConstants;
  import org.eclipse.cdt.ui.ICEditorContextMenuAction;
  import org.eclipse.cdt.ui.ICEditorRulerAction;
***************
*** 147,152 ****
--- 156,164 ----
  	
  	/** Listener to annotation model changes that updates the error tick
in the tab image */
  	private CEditorErrorTickUpdater fCEditorErrorTickUpdater;
+ 	
+ 	/** The line number ruler column */
+ 	private LineNumberRulerColumn fLineNumberRulerColumn;
  
  
  	/* Preference key line color shading */
***************
*** 181,186 ****
--- 193,206 ----
  	public final static String SPACES_FOR_TABS= "spacesForTabs";
  	/** Preference key for linked position color */
  	public final static String LINKED_POSITION_COLOR=
"linkedPositionColor"; //$NON-NLS-1$
+ 	/** Preference key for shwoing the overview ruler */
+ 	public final static String OVERVIEW_RULER= "overviewRuler";
//$NON-NLS-1$
+ 	
+ 	/** Preference key for showing the line number ruler */
+ 	public final static String LINE_NUMBER_RULER= "lineNumberRuler";
//$NON-NLS-1$
+ 	/** Preference key for the foreground color of the line numbers */
+ 	public final static String LINE_NUMBER_COLOR= "lineNumberColor";
//$NON-NLS-1$
+ 	
  
  	/**
  	 * Default constructor.
***************
*** 459,464 ****
--- 479,507 ----
 
setBracketHighlightingStyle();
  					return;
  				}
+ 				if (LINE_NUMBER_RULER.equals(property)) {
+ 					if (isLineNumberRulerVisible())
+ 						showLineNumberRuler();
+ 					else
+ 						hideLineNumberRuler();
+ 					return;
+ 				}
+ 			
+ 				if (fLineNumberRulerColumn != null &&
+
(LINE_NUMBER_COLOR.equals(property) || 
+
PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)  ||
+
PREFERENCE_COLOR_BACKGROUND.equals(property))) {
+ 					
+
initializeLineNumberRulerColumn(fLineNumberRulerColumn);
+ 				}
+ 				
+ 				if (OVERVIEW_RULER.equals(property))  {
+ 					if (isOverviewRulerVisible())
+ 						showOverviewRuler();
+ 					else
+ 						hideOverviewRuler();
+ 					return;
+ 				}
  			}
  		} finally {
  
***************
*** 1170,1175 ****
--- 1213,1266 ----
  	public final static String LANGUAGE_CPP=  "CEditor.language.cpp";

  	public final static String LANGUAGE_C=  "CEditor.language.c";	
  	
+ 	
+ 	class AdaptedRulerLayout extends Layout {
+ 		
+ 		protected int fGap;
+ 		protected AdaptedSourceViewer fAdaptedSourceViewer;
+ 		
+ 		
+ 		protected AdaptedRulerLayout(int gap, AdaptedSourceViewer
asv) {
+ 			fGap= gap;
+ 			fAdaptedSourceViewer= asv;
+ 		}
+ 		
+ 		protected Point computeSize(Composite composite, int wHint,
int hHint, boolean flushCache) {
+ 			Control[] children= composite.getChildren();
+ 			Point s= children[children.length -
1].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ 			if (fAdaptedSourceViewer.isVerticalRulerVisible())
+ 				s.x +=
fAdaptedSourceViewer.getVerticalRuler().getWidth() + fGap;
+ 			return s;
+ 		}
+ 		
+ 		protected void layout(Composite composite, boolean
flushCache) {
+ 			Rectangle clArea= composite.getClientArea();
+ 			if (fAdaptedSourceViewer.isVerticalRulerVisible()) {
+ 				
+ 				StyledText textWidget=
fAdaptedSourceViewer.getTextWidget();
+ 				Rectangle trim= textWidget.computeTrim(0, 0,
0, 0);
+ 				int scrollbarHeight= trim.height;
+ 				
+ 				IVerticalRuler vr=
fAdaptedSourceViewer.getVerticalRuler();
+ 				int vrWidth=vr.getWidth();
+ 				
+ 				int orWidth= 0;
+ 				if
(fAdaptedSourceViewer.isOverviewRulerVisible()) {
+ 					OverviewRuler or=
fAdaptedSourceViewer.getOverviewRuler();
+ 					orWidth= or.getWidth();
+
or.getControl().setBounds(clArea.width - orWidth, scrollbarHeight, orWidth,
clArea.height - 3*scrollbarHeight);
+ 				}
+ 				
+ 				textWidget.setBounds(vrWidth + fGap, 0,
clArea.width - vrWidth - orWidth - 2*fGap, clArea.height);
+ 				vr.getControl().setBounds(0, 0, vrWidth,
clArea.height - scrollbarHeight);
+ 				
+ 			} else {
+ 				StyledText textWidget=
fAdaptedSourceViewer.getTextWidget();
+ 				textWidget.setBounds(0, 0, clArea.width,
clArea.height);
+ 			}
+ 		}
+ 	};
+ 	
  	/**
  	 * Adapted source viewer for CEditor
  	 */
***************
*** 1178,1208 ****
  		
  		private List fTextConverters;
  		private String fDisplayLanguage;
! 		//private OverviewRuler fOverviewRuler;
! 		//private boolean fIsOverviewRulerVisible;
  		
! 		//private IVerticalRuler fCachedVerticalRuler;
! 		//private boolean fCachedIsVerticalRulerVisible;
  		
  		
  		public AdaptedSourceViewer(Composite parent, IVerticalRuler
ruler, int styles, String language) {
  			super(parent, ruler, styles);
  			
  			fDisplayLanguage = language;
! 			//fCachedVerticalRuler= ruler;
! 			//fCachedIsVerticalRulerVisible= (ruler != null);
! 			//fOverviewRuler= new
OverviewRuler(VERTICAL_RULER_WIDTH);
  			
! 			//delayedCreateControl(parent, styles);
  		}
  
  		/*
  		 * @see ISourceViewer#showAnnotations(boolean)
! 		 *
  		public void showAnnotations(boolean show) {
  			fCachedIsVerticalRulerVisible= (show &&
fCachedVerticalRuler != null);
  			super.showAnnotations(show);
! 		} */
  		/*
  		public IContentAssistant getContentAssistant() {
  			return fContentAssistant;
--- 1269,1299 ----
  		
  		private List fTextConverters;
  		private String fDisplayLanguage;
! 		private OverviewRuler fOverviewRuler;
! 		private boolean fIsOverviewRulerVisible;
  		
! 		private IVerticalRuler fCachedVerticalRuler;
! 		private boolean fCachedIsVerticalRulerVisible;
  		
  		
  		public AdaptedSourceViewer(Composite parent, IVerticalRuler
ruler, int styles, String language) {
  			super(parent, ruler, styles);
  			
  			fDisplayLanguage = language;
! 			fCachedVerticalRuler= ruler;
! 			fCachedIsVerticalRulerVisible= (ruler != null);
! 			fOverviewRuler= new
OverviewRuler(VERTICAL_RULER_WIDTH);
  			
! 			delayedCreateControl(parent, styles);
  		}
  
  		/*
  		 * @see ISourceViewer#showAnnotations(boolean)
! 		 */
  		public void showAnnotations(boolean show) {
  			fCachedIsVerticalRulerVisible= (show &&
fCachedVerticalRuler != null);
  			super.showAnnotations(show);
! 		}
  		/*
  		public IContentAssistant getContentAssistant() {
  			return fContentAssistant;
***************
*** 1268,1274 ****
  			}
  		}
  		
- 		/*
  		public IVerticalRuler getVerticalRuler() {
  			return fCachedVerticalRuler;
  		}
--- 1359,1364 ----
***************
*** 1283,1289 ****
  		
  		/*
  		 * @see TextViewer#createControl(Composite, int)
! 		 *
  		protected void createControl(Composite parent, int styles) {
  			// do nothing here
  		}
--- 1373,1379 ----
  		
  		/*
  		 * @see TextViewer#createControl(Composite, int)
! 		 */
  		protected void createControl(Composite parent, int styles) {
  			// do nothing here
  		}
***************
*** 1320,1334 ****
  		
  		public boolean isOverviewRulerVisible() {
  			return fIsOverviewRulerVisible;
! 		} */
  		
  		/*
  		 * @see ISourceViewer#setDocument(IDocument,
IAnnotationModel, int, int)
! 		 *
  		public void setDocument(IDocument document, IAnnotationModel
annotationModel, int visibleRegionOffset, int visibleRegionLength) {
  			super.setDocument(document, annotationModel,
visibleRegionOffset, visibleRegionLength);
  			fOverviewRuler.setModel(annotationModel);
! 		} */
  		
   		/**
  		 * Invalidates the current presentation by sending an
initialization
--- 1410,1424 ----
  		
  		public boolean isOverviewRulerVisible() {
  			return fIsOverviewRulerVisible;
! 		}
  		
  		/*
  		 * @see ISourceViewer#setDocument(IDocument,
IAnnotationModel, int, int)
! 		 */
  		public void setDocument(IDocument document, IAnnotationModel
annotationModel, int visibleRegionOffset, int visibleRegionLength) {
  			super.setDocument(document, annotationModel,
visibleRegionOffset, visibleRegionLength);
  			fOverviewRuler.setModel(annotationModel);
! 		}
  		
   		/**
  		 * Invalidates the current presentation by sending an
initialization
***************
*** 1638,1642 ****
--- 1728,1835 ----
  			}
  		}
  		return (ICEditorRulerAction[])rulerActions.toArray( new
ICEditorRulerAction[0] );
+ 	}
+ 	
+ 	/**
+ 	 * Creates a new line number ruler column that is appropriately
initialized.
+ 	 */
+ 	protected IVerticalRulerColumn createLineNumberRulerColumn() {
+ 		fLineNumberRulerColumn= new LineNumberRulerColumn();
+ 		initializeLineNumberRulerColumn(fLineNumberRulerColumn);
+ 		return fLineNumberRulerColumn;
+ 	}
+ 	
+ 	/*
+ 	 * @see AbstractTextEditor#createVerticalRuler()
+ 	 */
+ 	protected IVerticalRuler createVerticalRuler() {
+ 		CompositeRuler ruler= new CompositeRuler();
+ 		ruler.addDecorator(0, new
AnnotationRulerColumn(VERTICAL_RULER_WIDTH));
+ 		if (isLineNumberRulerVisible())
+ 			ruler.addDecorator(1,
createLineNumberRulerColumn());
+ 		return ruler;
+ 	}
+ 	
+ 	/**
+ 	 * Initializes the given line number ruler column from the
preference store.
+ 	 * @param rulerColumn the ruler column to be initialized
+ 	 */
+ 	protected void initializeLineNumberRulerColumn(LineNumberRulerColumn
rulerColumn) {
+ 		CTextTools textTools= CPlugin.getDefault().getTextTools();
+ 		IColorManager manager= textTools.getColorManager();	
+ 		
+ 		IPreferenceStore store= getPreferenceStore();
+ 		if (store != null) {	
+ 		
+ 			RGB rgb=  null;
+ 			// foreground color
+ 			if (store.contains(LINE_NUMBER_COLOR)) {
+ 				if (store.isDefault(LINE_NUMBER_COLOR))
+ 					rgb=
PreferenceConverter.getDefaultColor(store, LINE_NUMBER_COLOR);
+ 				else
+ 					rgb=
PreferenceConverter.getColor(store, LINE_NUMBER_COLOR);
+ 			}
+ 			rulerColumn.setForeground(manager.getColor(rgb));
+ 			
+ 			
+ 			rgb= null;
+ 			// background color
+ 			if
(!store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
+ 				if
(store.contains(PREFERENCE_COLOR_BACKGROUND)) {
+ 					if
(store.isDefault(PREFERENCE_COLOR_BACKGROUND))
+ 						rgb=
PreferenceConverter.getDefaultColor(store, PREFERENCE_COLOR_BACKGROUND);
+ 					else
+ 						rgb=
PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND);
+ 				}
+ 			}
+ 			rulerColumn.setBackground(manager.getColor(rgb));
+ 		}
+ 	}
+ 	
+ 	/**
+ 	 * Shows the line number ruler column.
+ 	 */
+ 	private void showLineNumberRuler() {
+ 		IVerticalRuler v= getVerticalRuler();
+ 		if (v instanceof CompositeRuler) {
+ 			CompositeRuler c= (CompositeRuler) v;
+ 			c.addDecorator(1, createLineNumberRulerColumn());
+ 		}
+ 	}
+ 	
+ 	/**
+ 	 * Hides the line number ruler column.
+ 	 */
+ 	private void hideLineNumberRuler() {
+ 		IVerticalRuler v= getVerticalRuler();
+ 		if (v instanceof CompositeRuler) {
+ 			CompositeRuler c= (CompositeRuler) v;
+ 			c.removeDecorator(1);
+ 		}
+ 	}
+ 	
+ 	/**
+ 	 * Return whether the line number ruler column should be 
+ 	 * visible according to the preference store settings.
+ 	 * @return <code>true</code> if the line numbers should be visible
+ 	 */
+ 	private boolean isLineNumberRulerVisible() {
+ 		IPreferenceStore store= getPreferenceStore();
+ 		return store.getBoolean(LINE_NUMBER_RULER);
+ 	}
+ 	
+ 		private void showOverviewRuler() {
+ 		AdaptedSourceViewer asv= (AdaptedSourceViewer)
getSourceViewer();
+ 		asv.showOverviewRuler();
+ 	}
+ 	
+ 	private void hideOverviewRuler() {
+ 		AdaptedSourceViewer asv= (AdaptedSourceViewer)
getSourceViewer();
+ 		asv.hideOverviewRuler();
+ 	}
+ 	
+ 	private boolean isOverviewRulerVisible() {
+ 		IPreferenceStore store= getPreferenceStore();
+ 		return store.getBoolean(OVERVIEW_RULER);
  	}
  }
Index: src/org/eclipse/cdt/internal/ui/editor/OverviewRuler.java
===================================================================
RCS file: src/org/eclipse/cdt/internal/ui/editor/OverviewRuler.java
diff -N src/org/eclipse/cdt/internal/ui/editor/OverviewRuler.java
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- src/org/eclipse/cdt/internal/ui/editor/OverviewRuler.java	9 Aug 2002
02:22:11 -0000
***************
*** 0 ****
--- 1,498 ----
+ 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.CPlugin;
+ import org.eclipse.cdt.internal.ui.text.CTextTools;
+ 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 */
+ 	private IAnnotationModel fModel;
+ 	/** The view to which this ruler is connected */
+ 	private 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;
+ 	}
+ 	
+ 	private 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.
+ 	 */
+ 	private 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.
+ 	 */
+ 	private 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= CPlugin.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.
+ 	 */
+ 	private 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;
+ 	}
+ 	
+ 	private 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();
+ 		}
+ 	}
+ 	
+ 	private 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;
+ 			}
+ 		}				
+ 	}
+ }
Index:
src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
===================================================================
RCS file:
/home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/C
EditorPreferencePage.java,v
retrieving revision 1.1
diff -c -r1.1 CEditorPreferencePage.java
*** src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
26 Jun 2002 20:55:44 -0000	1.1
--- src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
9 Aug 2002 02:22:12 -0000
***************
*** 8,13 ****
--- 8,14 ----
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
+ import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
***************
*** 48,59 ****
--- 49,63 ----
  
  import org.eclipse.cdt.internal.ui.CPlugin;
  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.utils.ui.controls.TabFolderLayout;
+ import org.eclipse.core.runtime.IStatus;
  
  
  /*
***************
*** 107,112 ****
--- 111,121 ----
  		
  		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),
***************
*** 132,137 ****
--- 141,155 ----
  		{ "Others", ICColorConstants.C_DEFAULT }
  	};
  	
+ 	private 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$
+ 	};
+ 	
  	private OverlayPreferenceStore fOverlayStore;
  	private CTextTools fCTextTools;
  	
***************
*** 171,177 ****
  	private Button fBackgroundCustomRadioButton;
  	private Button fBackgroundColorButton;
  	private Button fBoldCheckBox;
! 	private SourceViewer fPreviewViewer;	
  	
  	public CEditorPreferencePage() {
 
setDescription(CPlugin.getResourceString("CEditorPreferencePage.description"
));
--- 189,199 ----
  	private Button fBackgroundCustomRadioButton;
  	private Button fBackgroundColorButton;
  	private Button fBoldCheckBox;
! 	private SourceViewer fPreviewViewer;
! 	
! 	private List fAppearanceColorList;
! 	private ColorEditor fSyntaxForegroundColorEditor;
! 	private ColorEditor fAppearanceForegroundColorEditor;
  	
  	public CEditorPreferencePage() {
 
setDescription(CPlugin.getResourceString("CEditorPreferencePage.description"
));
***************
*** 238,243 ****
--- 260,270 ----
  		
  		PreferenceConverter.setDefault(store,
CEditor.LINKED_POSITION_COLOR, new RGB(0, 200 , 100));	
  		
+ 		store.setDefault(CEditor.LINE_NUMBER_RULER, false);
+ 		PreferenceConverter.setDefault(store,
CEditor.LINE_NUMBER_COLOR, new RGB(0, 0, 0));
+ 		
+ 		store.setDefault(CEditor.OVERVIEW_RULER, true);
+ 		
  		store.setDefault(ContentAssistPreference.AUTOACTIVATION,
false);
 
store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
  		
***************
*** 521,526 ****
--- 548,559 ----
  		}
  	}
  	
+ 	private ArrayList fNumberFields= new ArrayList();
+ 	private ModifyListener fNumberFieldListener= new ModifyListener() {
+ 		public void modifyText(ModifyEvent e) {
+ 			numberFieldChanged((Text) e.widget);
+ 		}
+ 	};
  	
  	private Button fBracketHighlightButton;
  	private Button fBracketHighlightBoxButton;
***************
*** 535,540 ****
--- 568,579 ----
  	private Control fFindScopeColor;
  	private Control fLinkedPositionColor;
  	
+ 	private void handleAppearanceColorListSelection() {	
+ 		int i= fAppearanceColorList.getSelectionIndex();
+ 		String key= fAppearanceColorListModel[i][1];
+ 		RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
+ 		fAppearanceForegroundColorEditor.setColorValue(rgb);

+ 	}
  	private Control createBehaviorPage(Composite parent) {
  
  		Composite behaviorComposite= new Composite(parent,
SWT.NULL);
***************
*** 546,552 ****
  		addTextFontEditor(behaviorComposite, label,
CEditor.PREFERENCE_FONT);
  		
  		label= "Displayed &tab width:";
! 		addTextField(behaviorComposite, label,
CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH, 2, 0);
  		
  		label= "Insert &space for tabs";
  		addCheckBox(behaviorComposite, label,
CEditor.SPACES_FOR_TABS, 0);
--- 585,594 ----
  		addTextFontEditor(behaviorComposite, label,
CEditor.PREFERENCE_FONT);
  		
  		label= "Displayed &tab width:";
! 		addTextField(behaviorComposite, label,
CSourceViewerConfiguration.PREFERENCE_TAB_WIDTH, 2, 0, true);
! 		
! 		label= "Print margin col&umn:";
! 		fPrintMarginColumn= addTextField(behaviorComposite, label,
CEditor.PRINT_MARGIN_COLUMN, 4, 0, true);
  		
  		label= "Insert &space for tabs";
  		addCheckBox(behaviorComposite, label,
CEditor.SPACES_FOR_TABS, 0);
***************
*** 559,618 ****
  
  		label= "Only c&olor bracket text";
  		fBracketHighlightBoxButton= addCheckBox(behaviorComposite,
label, CEditor.MATCHING_BRACKETS_NOBOX, 0);
- 
- 		label= "Matching &brackets highlight color:";
- 		fBracketHighlightColor= addColorButton(behaviorComposite,
label, CEditor.MATCHING_BRACKETS_COLOR, 0);
- 
- 		fBracketHighlightButton.addSelectionListener(new
SelectionListener() {
- 			public void widgetSelected(SelectionEvent e) {
- 				setEnabled(fBracketHighlightColor,
fBracketHighlightButton.getSelection());
- 				setEnabled(fBracketHighlightBoxButton,
fBracketHighlightButton.getSelection());
- 			}
- 			public void widgetDefaultSelected(SelectionEvent e)
{
- 			}
- 		});
- 
  		
  		
  		label= "Highlight &current line";
  		fLineHighlightButton= addCheckBox(behaviorComposite, label,
CEditor.CURRENT_LINE, 0);
  		
- 		label= "Current &line highlight color:";
- 		fLineHighlightColor= addColorButton(behaviorComposite,
label, CEditor.CURRENT_LINE_COLOR, 0);
- 
- 		fLineHighlightButton.addSelectionListener(new
SelectionListener() {
- 			public void widgetSelected(SelectionEvent e) {
- 				setEnabled(fLineHighlightColor,
fLineHighlightButton.getSelection());
- 			}
- 			public void widgetDefaultSelected(SelectionEvent e)
{
- 			}
- 		});
- 		
- 		
  		label= "Highlight &problems";
  		fProblemIndicationButton= addCheckBox(behaviorComposite,
label, CEditor.PROBLEM_INDICATION, 0);
  		
! 		label= "Prob&lem highlight color:";
! 		fProblemIndicationColor= addColorButton(behaviorComposite,
label, CEditor.PROBLEM_INDICATION_COLOR, 0);
! 
! 		fProblemIndicationButton.addSelectionListener(new
SelectionListener() {
! 			public void widgetSelected(SelectionEvent e) {
! 				setEnabled(fProblemIndicationColor,
fProblemIndicationButton.getSelection());
! 			}
! 			public void widgetDefaultSelected(SelectionEvent e)
{
! 			}
! 		});
! 		
  		
  		label= "Show print &margin";
  		fPrintMarginButton= addCheckBox(behaviorComposite, label,
CEditor.PRINT_MARGIN, 0);
  		
- 		label= "Print m&argin color:";
- 		fPrintMarginColor= addColorButton(behaviorComposite, label,
CEditor.PRINT_MARGIN_COLOR, 0);
- 
- 		label= "Print margin col&umn:";
- 		fPrintMarginColumn= addTextField(behaviorComposite, label,
CEditor.PRINT_MARGIN_COLUMN, 4, 0);
- 		
  		fPrintMarginButton.addSelectionListener(new
SelectionListener() {
  			public void widgetSelected(SelectionEvent e) {
  				boolean enabled=
fPrintMarginButton.getSelection();
--- 601,622 ----
  
  		label= "Only c&olor bracket text";
  		fBracketHighlightBoxButton= addCheckBox(behaviorComposite,
label, CEditor.MATCHING_BRACKETS_NOBOX, 0);
  		
+ 		label= "Show line numbers"; //$NON-NLS-1$
+ 		addCheckBox(behaviorComposite, label,
CEditor.LINE_NUMBER_RULER, 0);
  		
  		label= "Highlight &current line";
  		fLineHighlightButton= addCheckBox(behaviorComposite, label,
CEditor.CURRENT_LINE, 0);
  		
  		label= "Highlight &problems";
  		fProblemIndicationButton= addCheckBox(behaviorComposite,
label, CEditor.PROBLEM_INDICATION, 0);
  		
! 		label= "Show overview ruler"; //$NON-NLS-1$
! 		addCheckBox(behaviorComposite, label,
CEditor.OVERVIEW_RULER, 0);
  		
  		label= "Show print &margin";
  		fPrintMarginButton= addCheckBox(behaviorComposite, label,
CEditor.PRINT_MARGIN, 0);
  		
  		fPrintMarginButton.addSelectionListener(new
SelectionListener() {
  			public void widgetSelected(SelectionEvent e) {
  				boolean enabled=
fPrintMarginButton.getSelection();
***************
*** 623,633 ****
  			}
  		});
  		
  		
! 		//label= "F&ind Scope:";
! 		//fFindScopeColor= addColorButton(behaviorComposite, label,
CEditor.PREFERENCE_COLOR_FIND_SCOPE, 0);
! 		label= "Lin&ked position color:"; //$NON-NLS-1$
! 		fLinkedPositionColor= addColorButton(behaviorComposite,
label, CEditor.LINKED_POSITION_COLOR, 0);
  		
  		return behaviorComposite;
  	}
--- 627,698 ----
  			}
  		});
  		
+ 		Label l= new Label(behaviorComposite, SWT.LEFT );
+ 		GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ 		gd.horizontalSpan= 2;
+ 		gd.heightHint= convertHeightInCharsToPixels(1) / 2;
+ 		l.setLayoutData(gd);
  		
! 		l= new Label(behaviorComposite, SWT.LEFT);
! 		l.setText("Appearance color options"); //$NON-NLS-1$
! 		gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
! 		gd.horizontalSpan= 2;
! 		l.setLayoutData(gd);
! 
! 		Composite editorComposite= new Composite(behaviorComposite,
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);	
! 		
! 		fAppearanceColorList= new List(editorComposite, SWT.SINGLE |
SWT.V_SCROLL | SWT.BORDER);
! 		gd= new GridData(GridData.FILL_BOTH);
! 		gd.heightHint= convertHeightInCharsToPixels(5);
! 		fAppearanceColorList.setLayoutData(gd);
! 		
! 		Composite stylesComposite= new Composite(editorComposite,
SWT.NONE);
! 		layout= new GridLayout();
! 		layout.marginHeight= 0;
! 		layout.marginWidth= 0;
! 		layout.numColumns= 2;
! 		stylesComposite.setLayout(layout);
! 		stylesComposite.setLayoutData(new
GridData(GridData.FILL_BOTH));
! 		
! 		l= new Label(stylesComposite, SWT.LEFT);
! 		l.setText("Color:"); //$NON-NLS-1$
! 		gd= new GridData();
! 		gd.horizontalAlignment= GridData.BEGINNING;
! 		l.setLayoutData(gd);
! 
! 		fAppearanceForegroundColorEditor= new
ColorEditor(stylesComposite);
! 		Button foregroundColorButton=
fAppearanceForegroundColorEditor.getButton();
! 		gd= new GridData(GridData.FILL_HORIZONTAL);
! 		gd.horizontalAlignment= GridData.BEGINNING;
! 		foregroundColorButton.setLayoutData(gd);
! 
! 		fAppearanceColorList.addSelectionListener(new
SelectionListener() {
! 			public void widgetDefaultSelected(SelectionEvent e)
{
! 				// do nothing
! 			}
! 			public void widgetSelected(SelectionEvent e) {
! 				handleAppearanceColorListSelection();
! 			}
! 		});
! 		foregroundColorButton.addSelectionListener(new
SelectionListener() {
! 			public void widgetDefaultSelected(SelectionEvent e)
{
! 				// do nothing
! 			}
! 			public void widgetSelected(SelectionEvent e) {
! 				int i=
fAppearanceColorList.getSelectionIndex();
! 				String key= fAppearanceColorListModel[i][1];
! 				
! 				PreferenceConverter.setValue(fOverlayStore,
key, fAppearanceForegroundColorEditor.getColorValue());
! 			}
! 		});
  		
  		return behaviorComposite;
  	}
***************
*** 657,666 ****
  		//addCheckBox(contentAssistComposite, label,
ContentAssistPreference.ADD_INCLUDE, 0);
  		
  		label= "Auto activation dela&y:";
! 		addTextField(contentAssistComposite, label,
ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0);
  		
  		label= "Auto activation &triggers for C:";
! 		addTextField(contentAssistComposite, label,
ContentAssistPreference.AUTOACTIVATION_TRIGGERS_C, 25, 0);
  		
  		//label= "Auto activation triggers for &JavaDoc:";
  		//addTextField(contentAssistComposite, label,
ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC, 25, 0);
--- 722,731 ----
  		//addCheckBox(contentAssistComposite, label,
ContentAssistPreference.ADD_INCLUDE, 0);
  		
  		label= "Auto activation dela&y:";
! 		addTextField(contentAssistComposite, label,
ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true);
  		
  		label= "Auto activation &triggers for C:";
! 		addTextField(contentAssistComposite, label,
ContentAssistPreference.AUTOACTIVATION_TRIGGERS_C, 25, 0, true);
  		
  		//label= "Auto activation triggers for &JavaDoc:";
  		//addTextField(contentAssistComposite, label,
ContentAssistPreference.AUTOACTIVATION_TRIGGERS_JAVADOC, 25, 0);
***************
*** 722,727 ****
--- 787,795 ----
  		
  		for (int i= 0; i < fListModel.length; i++)
  			fList.add(fListModel[i][0]);
+ 					
+ 		for (int i= 0; i < fAppearanceColorListModel.length; i++)
+
fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
  			
  		fList.getDisplay().asyncExec(new Runnable() {
  			public void run() {
***************
*** 729,734 ****
--- 797,809 ----
  				handleListSelection();
  			}
  		});
+ 		
+ 		fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
+ 			public void run() {
+ 				fAppearanceColorList.select(0);
+ 				handleAppearanceColorListSelection();
+ 			}
+ 		});
  	}
  	
  	private void initializeFields() {
***************
*** 763,770 ****
  		fBackgroundCustomRadioButton.setSelection(!default_);
  		fBackgroundColorButton.setEnabled(!default_);
  		
! 		setEnabled(fBracketHighlightColor,
fBracketHighlightButton.getSelection());
! 		setEnabled(fLineHighlightColor,
fLineHighlightButton.getSelection());
  	}
  	
  	/*
--- 838,844 ----
  		fBackgroundCustomRadioButton.setSelection(!default_);
  		fBackgroundColorButton.setEnabled(!default_);
  		
! 		//updateAutoactivationControls();
  	}
  	
  	/*
***************
*** 786,795 ****
  		fOverlayStore.loadDefaults();
  		initializeFields();
  		handleListSelection();
  		
  		super.performDefaults();
  		
! 		//fPreviewViewer.invalidateTextPresentation();
  	}
  	
  	/*
--- 860,870 ----
  		fOverlayStore.loadDefaults();
  		initializeFields();
  		handleListSelection();
+ 		handleAppearanceColorListSelection();
  		
  		super.performDefaults();
  		
! 		fPreviewViewer.invalidateTextPresentation();
  	}
  	
  	/*
***************
*** 861,895 ****
  		return checkBox;
  	}
  	
! 	private Control addTextField(Composite parent, String label, String
key, int textLimit, int indentation) {
  		
- 		Composite composite= new Composite(parent, SWT.NONE);
- 		GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- 		gd.horizontalSpan= 2;
- 		composite.setLayoutData(gd);
- 		
- 		GridLayout layout= new GridLayout();
- 		layout.numColumns= 2;
- 		layout.marginWidth= 0;
- 		layout.marginHeight= 0;
- 		composite.setLayout(layout);
- 
  		Label labelControl= new Label(composite, SWT.NONE);
  		labelControl.setText(label);
! 		gd= new GridData(GridData.FILL_HORIZONTAL);
  		gd.horizontalIndent= indentation;
  		labelControl.setLayoutData(gd);
  		
  		Text textControl= new Text(composite, SWT.BORDER |
SWT.SINGLE);		
! 		gd= new GridData(GridData.FILL_HORIZONTAL);
  		gd.widthHint= convertWidthInCharsToPixels(textLimit + 1);
- 		gd.horizontalAlignment= GridData.END;
  		textControl.setLayoutData(gd);
  		textControl.setTextLimit(textLimit);
- 		textControl.addModifyListener(fTextFieldListener);
  		fTextFields.put(textControl, key);
! 		
! 		return composite;
  	}
  	
  	private void addTextFontEditor(Composite parent, String label,
String key) {
--- 936,963 ----
  		return checkBox;
  	}
  	
! 	private Control addTextField(Composite composite, String label,
String key, int textLimit, int indentation, boolean isNumber) {
  		
  		Label labelControl= new Label(composite, SWT.NONE);
  		labelControl.setText(label);
! 		GridData gd= new
GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
  		gd.horizontalIndent= indentation;
  		labelControl.setLayoutData(gd);
  		
  		Text textControl= new Text(composite, SWT.BORDER |
SWT.SINGLE);		
! 		gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
  		gd.widthHint= convertWidthInCharsToPixels(textLimit + 1);
  		textControl.setLayoutData(gd);
  		textControl.setTextLimit(textLimit);
  		fTextFields.put(textControl, key);
! 		if (isNumber) {
! 			fNumberFields.add(textControl);
! 			textControl.addModifyListener(fNumberFieldListener);
! 		} else {
! 			textControl.addModifyListener(fTextFieldListener);
! 		}
! 			
! 		return textControl;
  	}
  	
  	private void addTextFontEditor(Composite parent, String label,
String key) {
***************
*** 925,930 ****
--- 993,1034 ----
  			}
  		}
  		return buffer.toString();
+ 	}
+ 	
+ 	private void numberFieldChanged(Text textControl) {
+ 		String number= textControl.getText();
+ 		IStatus status= validatePositiveNumber(number);
+ 		if (!status.matches(IStatus.ERROR))
+ 			fOverlayStore.setValue((String)
fTextFields.get(textControl), number);
+ 		updateStatus(status);
+ 	}
+ 	
+ 	private IStatus validatePositiveNumber(String number) {
+ 		StatusInfo status= new StatusInfo();
+ 		if (number.length() == 0) {
+
//status.setError("CEditorPreferencePage.empty_input"); //$NON-NLS-1$
+ 		} else {
+ 			try {
+ 				int value= Integer.parseInt(number);
+ 				if (value < 0)
+
status.setError("CEditorPreferencePage.invalid_input"); //$NON-NLS-1$
+ 			} catch (NumberFormatException e) {
+
status.setError("CEditorPreferencePage.invalid_input"); //$NON-NLS-1$
+ 			}
+ 		}
+ 		return status;
+ 	}
+ 	
+ 	private void updateStatus(IStatus status) {
+ 		if (!status.matches(IStatus.ERROR)) {
+ 			for (int i= 0; i < fNumberFields.size(); i++) {
+ 				Text text= (Text) fNumberFields.get(i);
+ 				IStatus s=
validatePositiveNumber(text.getText());
+ 				status= StatusUtil.getMoreSevere(s, status);
+ 			}
+ 		}	
+ 		setValid(!status.matches(IStatus.ERROR));
+ 		StatusUtil.applyToStatusLine(this, status);
  	}
  }
  
Index: src/org/eclipse/cdt/internal/ui/text/CPartitionScanner.java
===================================================================
RCS file:
/home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPartiti
onScanner.java,v
retrieving revision 1.1
diff -c -r1.1 CPartitionScanner.java
*** src/org/eclipse/cdt/internal/ui/text/CPartitionScanner.java	26 Jun 2002
20:55:44 -0000	1.1
--- src/org/eclipse/cdt/internal/ui/text/CPartitionScanner.java	9 Aug 2002
02:22:12 -0000
***************
*** 8,27 ****
  import java.util.ArrayList;
  import java.util.List;
  
- 
- import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
  import org.eclipse.jface.text.rules.EndOfLineRule;
! import org.eclipse.jface.text.rules.IRule;
  import org.eclipse.jface.text.rules.IToken;
  import org.eclipse.jface.text.rules.IWordDetector;
  import org.eclipse.jface.text.rules.SingleLineRule;
  import org.eclipse.jface.text.rules.Token;
  
  
  /**
   * This scanner recognizes comments
   */
! public class CPartitionScanner extends BufferedRuleBasedScanner {
  
  
  	private final static String SKIP= "__skip";
--- 8,29 ----
  import java.util.ArrayList;
  import java.util.List;
  
  import org.eclipse.jface.text.rules.EndOfLineRule;
! import org.eclipse.jface.text.rules.ICharacterScanner;
! import org.eclipse.jface.text.rules.IPredicateRule;
  import org.eclipse.jface.text.rules.IToken;
  import org.eclipse.jface.text.rules.IWordDetector;
+ import org.eclipse.jface.text.rules.MultiLineRule;
+ import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
  import org.eclipse.jface.text.rules.SingleLineRule;
  import org.eclipse.jface.text.rules.Token;
+ import org.eclipse.jface.text.rules.WordRule;
  
  
  /**
   * This scanner recognizes comments
   */
! public class CPartitionScanner extends RuleBasedPartitionScanner {
  
  
  	private final static String SKIP= "__skip";
***************
*** 37,52 ****
  	 */
  	static class EmptyCommentDetector implements IWordDetector {
  
! 
! 		/**
  		 * @see IWordDetector#isWordStart
  		 */
  		public boolean isWordStart(char c) {
  			return (c == '/');
  		}
  
! 
! 		/**
  		 * @see IWordDetector#isWordPart
  		 */
  		public boolean isWordPart(char c) {
--- 39,52 ----
  	 */
  	static class EmptyCommentDetector implements IWordDetector {
  
! 		/*
  		 * @see IWordDetector#isWordStart
  		 */
  		public boolean isWordStart(char c) {
  			return (c == '/');
  		}
  
! 		/*
  		 * @see IWordDetector#isWordPart
  		 */
  		public boolean isWordPart(char c) {
***************
*** 54,66 ****
  		}
  	};
  
  
  	/**
  	 * Creates the partitioner and sets up the appropriate rules.
  	 */
  	public CPartitionScanner() {
! 		// Set buffer size to 1k
! 		super(1000);
  		
  		IToken comment= new Token(C_MULTILINE_COMMENT);
  		IToken single_comment= new Token(C_SINGLE_LINE_COMMENT);
--- 54,95 ----
  		}
  	};
  
+ 	/**
+ 	 * Word rule for empty comments.
+ 	 */
+ 	static class EmptyCommentRule extends WordRule implements
IPredicateRule {
+ 		
+ 		private IToken fSuccessToken;
+ 		/**
+ 		 * Constructor for EmptyCommentRule.
+ 		 * @param defaultToken
+ 		 */
+ 		public EmptyCommentRule(IToken successToken) {
+ 			super(new EmptyCommentDetector());
+ 			fSuccessToken= successToken;
+ 			addWord("/**/", fSuccessToken); //$NON-NLS-1$
+ 		}
+ 		
+ 		/*
+ 		 * @see IPredicateRule#evaluate(ICharacterScanner, boolean)
+ 		 */
+ 		public IToken evaluate(ICharacterScanner scanner, boolean
resume) {
+ 			return evaluate(scanner);
+ 		}
  
+ 		/*
+ 		 * @see IPredicateRule#getSuccessToken()
+ 		 */
+ 		public IToken getSuccessToken() {
+ 			return fSuccessToken;
+ 		}
+ 	};
+ 	
  	/**
  	 * Creates the partitioner and sets up the appropriate rules.
  	 */
  	public CPartitionScanner() {
! 		super();
  		
  		IToken comment= new Token(C_MULTILINE_COMMENT);
  		IToken single_comment= new Token(C_SINGLE_LINE_COMMENT);
***************
*** 84,102 ****
  		rules.add(new SingleLineRule("\"", "\"", string, '\\'));
  		rules.add(new SingleLineRule("'", "'", skip, '\\'));
  
- 
  		// Add special case word rule.
! 		//WordRule wordRule= new WordRule(new
EmptyCommentDetector());
! 		//wordRule.addWord("/**/", comment);
! 		//rules.add(wordRule);
  
  
  		// Add rules for multi-line comments.
! 		//rules.add(new MultiLineRule("/*", "*/", comment));
! 		rules.add(new CMultilineCommentScanner(comment, (char)0,
false));
  
! 		IRule[] result= new IRule[rules.size()];
  		rules.toArray(result);
! 		setRules(result);
  	}
  }
--- 113,129 ----
  		rules.add(new SingleLineRule("\"", "\"", string, '\\'));
  		rules.add(new SingleLineRule("'", "'", skip, '\\'));
  
  		// Add special case word rule.
! 		EmptyCommentRule wordRule= new EmptyCommentRule(comment);
! 		rules.add(wordRule);
  
  
  		// Add rules for multi-line comments.
! 		rules.add(new MultiLineRule("/*", "*/", comment));
! 		//rules.add(new CMultilineCommentScanner(comment, (char)0,
false));
  
! 		IPredicateRule[] result= new IPredicateRule[rules.size()];
  		rules.toArray(result);
! 		setPredicateRules(result);
  	}
  }
Index: src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
===================================================================
RCS file:
/home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceV
iewerConfiguration.java,v
retrieving revision 1.4
diff -c -r1.4 CSourceViewerConfiguration.java
*** src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
12 Jul 2002 17:13:49 -0000	1.4
--- src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
9 Aug 2002 02:22:12 -0000
***************
*** 27,33 ****
--- 27,35 ----
  import org.eclipse.jface.text.presentation.PresentationReconciler;
  import org.eclipse.jface.text.reconciler.IReconciler;
  import org.eclipse.jface.text.reconciler.Reconciler;
+ import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
  import org.eclipse.jface.text.rules.DefaultPartitioner;
+ import org.eclipse.jface.text.rules.RuleBasedDamagerRepairer;
  import org.eclipse.jface.text.rules.RuleBasedScanner;
  import org.eclipse.jface.text.source.IAnnotationHover;
  import org.eclipse.jface.text.source.ISourceViewer;
***************
*** 37,43 ****
  import org.eclipse.cdt.internal.ui.CPlugin;
  import org.eclipse.cdt.internal.ui.editor.CEditor;
  import org.eclipse.cdt.internal.ui.editor.CEditorTextHoverDispatcher;
- import
org.eclipse.cdt.internal.ui.text.eclipse2.CRuleBasedDamagerRepairer;
  import org.eclipse.cdt.ui.ICDTConstants;
  
  
--- 39,44 ----
***************
*** 134,155 ****
  			scanner= fTextTools.getCCodeScanner();
  		}
  
! 		CRuleBasedDamagerRepairer dr= new
CRuleBasedDamagerRepairer(scanner);
  
  		reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
  		reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
  
  		//TextAttribute attr = new
TextAttribute(manager.getColor(ICColorConstants.C_DEFAULT));
  		
! 		dr= new
CRuleBasedDamagerRepairer(getSinglelineCommentScanner());		
  		reconciler.setDamager(dr,
CPartitionScanner.C_SINGLE_LINE_COMMENT);
  		reconciler.setRepairer(dr,
CPartitionScanner.C_SINGLE_LINE_COMMENT);
  		
! 		dr= new CRuleBasedDamagerRepairer(getStringScanner());
  		reconciler.setDamager(dr, CPartitionScanner.C_STRING);
  		reconciler.setRepairer(dr, CPartitionScanner.C_STRING);
  		
! 		dr= new
CRuleBasedDamagerRepairer(getMultilineCommentScanner());		
  		reconciler.setDamager(dr,
CPartitionScanner.C_MULTILINE_COMMENT);
  		reconciler.setRepairer(dr,
CPartitionScanner.C_MULTILINE_COMMENT);
  
--- 135,156 ----
  			scanner= fTextTools.getCCodeScanner();
  		}
  
! 		DefaultDamagerRepairer dr= new
DefaultDamagerRepairer(scanner);
  
  		reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
  		reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
  
  		//TextAttribute attr = new
TextAttribute(manager.getColor(ICColorConstants.C_DEFAULT));
  		
! 		dr= new
DefaultDamagerRepairer(getSinglelineCommentScanner());		
  		reconciler.setDamager(dr,
CPartitionScanner.C_SINGLE_LINE_COMMENT);
  		reconciler.setRepairer(dr,
CPartitionScanner.C_SINGLE_LINE_COMMENT);
  		
! 		dr= new DefaultDamagerRepairer(getStringScanner());
  		reconciler.setDamager(dr, CPartitionScanner.C_STRING);
  		reconciler.setRepairer(dr, CPartitionScanner.C_STRING);
  		
! 		dr= new
DefaultDamagerRepairer(getMultilineCommentScanner());		
  		reconciler.setDamager(dr,
CPartitionScanner.C_MULTILINE_COMMENT);
  		reconciler.setRepairer(dr,
CPartitionScanner.C_MULTILINE_COMMENT);
  


Back to the top