Eclipse Platform
Release 3.1

org.eclipse.jface.text.source
Class LineNumberChangeRulerColumn

java.lang.Object
  extended byorg.eclipse.jface.text.source.LineNumberRulerColumn
      extended byorg.eclipse.jface.text.source.LineNumberChangeRulerColumn
All Implemented Interfaces:
IChangeRulerColumn, IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension

public final class LineNumberChangeRulerColumn
extends LineNumberRulerColumn
implements IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn

A vertical ruler column displaying line numbers and serving as a UI for quick diff. Clients usually instantiate and configure object of this class.

Since:
3.0

Field Summary
 
Fields inherited from interface org.eclipse.jface.text.source.IChangeRulerColumn
QUICK_DIFF_MODEL_ID
 
Constructor Summary
LineNumberChangeRulerColumn(ISharedTextColors sharedColors)
          Creates a new instance.
 
Method Summary
 void addVerticalRulerListener(IVerticalRulerListener listener)
          Registers a vertical ruler listener to be informed if an annotation gets selected on the vertical ruler.
protected  int computeNumberOfDigits()
          Does the real computation of the number of digits.
protected  String createDisplayString(int line)
          Computes the string to be printed for line.
 IAnnotationHover getHover()
          Returns the hover for this vertical ruler (column).
 int getLineOfLastMouseButtonActivity()
          Returns the line number of the last mouse button activity.
 IAnnotationModel getModel()
          Returns the model currently used by the receiver.
protected  void handleDispose()
          Disposes the column's resources.
protected  void paintLine(int line, int y, int lineheight, GC gc, Display display)
          Paints the line.
 void removeVerticalRulerListener(IVerticalRulerListener listener)
          Removes a previously registered listener.
 void setAddedColor(Color addedColor)
          Sets the background color for added lines.
 void setChangedColor(Color changedColor)
          Sets the background color for changed lines.
 void setDeletedColor(Color deletedColor)
          Sets the color for the deleted lines indicator.
 void setDisplayMode(boolean characterMode)
          Sets the the display mode of the ruler.
 void setHover(IAnnotationHover hover)
          Sets the hover of this ruler column.
 void setModel(IAnnotationModel model)
          Associates an annotation model with this ruler column.
 int toDocumentLineNumber(int y_coordinate)
          Translates a y-coordinate of the ruler's SWT control into the according line number of the document of the connected text viewer.
 
Methods inherited from class org.eclipse.jface.text.source.LineNumberRulerColumn
computeIndentations, createControl, getBackground, getControl, getForeground, getParentRuler, getVisibleLinesInViewport, getWidth, layout, postRedraw, redraw, setBackground, setFont, setForeground, updateNumberOfDigits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.text.source.IVerticalRulerInfo
getControl, getWidth
 
Methods inherited from interface org.eclipse.jface.text.source.IChangeRulerColumn
setBackground
 
Methods inherited from interface org.eclipse.jface.text.source.IVerticalRulerColumn
createControl, getControl, getWidth, redraw, setFont
 

Constructor Detail

LineNumberChangeRulerColumn

public LineNumberChangeRulerColumn(ISharedTextColors sharedColors)
Creates a new instance.

Parameters:
sharedColors - the shared colors provider to use
Method Detail

handleDispose

protected void handleDispose()
Description copied from class: LineNumberRulerColumn
Disposes the column's resources.

Overrides:
handleDispose in class LineNumberRulerColumn

paintLine

protected void paintLine(int line,
                         int y,
                         int lineheight,
                         GC gc,
                         Display display)
Description copied from class: LineNumberRulerColumn
Paints the line. After this method is called the line numbers are painted on top of the result of this method.

This default implementation does nothing.

Overrides:
paintLine in class LineNumberRulerColumn
Parameters:
line - the line of the document which the ruler is painted for
y - the y-coordinate of the box being painted for line, relative to gc
lineheight - the height of one line (and therefore of the box being painted)
gc - the drawing context the client may choose to draw on.
display - the display the drawing occurs on

getLineOfLastMouseButtonActivity

public int getLineOfLastMouseButtonActivity()
Description copied from interface: IVerticalRulerInfo
Returns the line number of the last mouse button activity. Based on the input document of the connected text viewer. The smallest possible line number is 0.

Specified by:
getLineOfLastMouseButtonActivity in interface IVerticalRulerInfo
Returns:
the line number of the last mouse button activity

toDocumentLineNumber

public int toDocumentLineNumber(int y_coordinate)
Description copied from interface: IVerticalRulerInfo
Translates a y-coordinate of the ruler's SWT control into the according line number of the document of the connected text viewer.

Specified by:
toDocumentLineNumber in interface IVerticalRulerInfo
Parameters:
y_coordinate - a y-coordinate of the ruler's SWT control
Returns:
the line number of that coordinate or -1 if that coordinate does not correspond to a valid document line

getHover

public IAnnotationHover getHover()
Description copied from interface: IVerticalRulerInfoExtension
Returns the hover for this vertical ruler (column).

Specified by:
getHover in interface IVerticalRulerInfoExtension
Returns:
the hover for this column

setHover

public void setHover(IAnnotationHover hover)
Sets the hover of this ruler column.

Specified by:
setHover in interface IChangeRulerColumn
Parameters:
hover - the hover that will produce hover information text for this ruler column

setModel

public void setModel(IAnnotationModel model)
Description copied from interface: IVerticalRulerColumn
Associates an annotation model with this ruler column. A value null is acceptable and clears the ruler.

Specified by:
setModel in interface IVerticalRulerColumn
Overrides:
setModel in class LineNumberRulerColumn

setAddedColor

public void setAddedColor(Color addedColor)
Sets the background color for added lines. The color has to be disposed of by the caller when the receiver is no longer used.

Specified by:
setAddedColor in interface IChangeRulerColumn
Parameters:
addedColor - the new color to be used for the added lines background

setChangedColor

public void setChangedColor(Color changedColor)
Sets the background color for changed lines. The color has to be disposed of by the caller when the receiver is no longer used.

Specified by:
setChangedColor in interface IChangeRulerColumn
Parameters:
changedColor - the new color to be used for the changed lines background

setDeletedColor

public void setDeletedColor(Color deletedColor)
Sets the color for the deleted lines indicator. The color has to be disposed of by the caller when the receiver is no longer used.

Specified by:
setDeletedColor in interface IChangeRulerColumn
Parameters:
deletedColor - the new color to be used for the deleted lines indicator.

setDisplayMode

public void setDisplayMode(boolean characterMode)
Sets the the display mode of the ruler. If character mode is set to true, diff information will be displayed textually on the line number ruler.

Parameters:
characterMode - true if diff information is to be displayed textually.

getModel

public IAnnotationModel getModel()
Description copied from interface: IVerticalRulerInfoExtension
Returns the model currently used by the receiver.

Specified by:
getModel in interface IVerticalRulerInfoExtension
Returns:
the model of the receiver, or null if no model is installed.

createDisplayString

protected String createDisplayString(int line)
Description copied from class: LineNumberRulerColumn
Computes the string to be printed for line. The default implementation returns Integer.toString(line + 1).

Overrides:
createDisplayString in class LineNumberRulerColumn
Parameters:
line - the line number for which the line number string is generated
Returns:
the string to be printed on the line number bar for line

computeNumberOfDigits

protected int computeNumberOfDigits()
Description copied from class: LineNumberRulerColumn
Does the real computation of the number of digits. Subclasses may override this method if they need extra space on the line number ruler.

Overrides:
computeNumberOfDigits in class LineNumberRulerColumn
Returns:
the number of digits to be displayed on the line number ruler.

addVerticalRulerListener

public void addVerticalRulerListener(IVerticalRulerListener listener)
Description copied from interface: IVerticalRulerInfoExtension
Registers a vertical ruler listener to be informed if an annotation gets selected on the vertical ruler.

Specified by:
addVerticalRulerListener in interface IVerticalRulerInfoExtension
Parameters:
listener - the listener to be informed

removeVerticalRulerListener

public void removeVerticalRulerListener(IVerticalRulerListener listener)
Description copied from interface: IVerticalRulerInfoExtension
Removes a previously registered listener. If listener is not registered with the receiver, calling this method has no effect.

Specified by:
removeVerticalRulerListener in interface IVerticalRulerInfoExtension
Parameters:
listener - the listener to be removed

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.