Package org.eclipse.jface.text.source
Class VerticalRuler
java.lang.Object
org.eclipse.jface.text.source.VerticalRuler
- All Implemented Interfaces:
IVerticalRuler,IVerticalRulerExtension,IVerticalRulerInfo
A vertical ruler which is connected to a text viewer. Single column standard
implementation of
IVerticalRuler.
The same can be achieved by using CompositeRuler configured
with an AnnotationRulerColumn. Clients may use this class as
is.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionVerticalRuler(int width) Constructs a vertical ruler with the given width.VerticalRuler(int width, IAnnotationAccess annotationAcccess) Constructs a vertical ruler with the given width and the given annotation access. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMouseListener(MouseListener listener) Deprecated.will be removedcreateControl(Composite parent, ITextViewer textViewer) Creates the ruler's SWT control.protected voidDraws the vertical ruler w/o drawing the Canvas background.protected voidDraws the vertical ruler w/o drawing the Canvas background.Returns the ruler's SWT control.intReturns the line number of the last mouse button activity.getModel()Returns the current annotation model of this ruler ornullif the ruler has no model.intgetWidth()Returns the width of this ruler's control.voidremoveMouseListener(MouseListener listener) Deprecated.will be removedvoidSets the font of this vertical ruler.voidsetLocationOfLastMouseButtonActivity(int x, int y) Sets the location of the last mouse button activity.voidsetModel(IAnnotationModel model) Associates an annotation model with this ruler.inttoDocumentLineNumber(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.voidupdate()Thread-safe implementation.protected static final intwidgetLine2ModelLine(ITextViewer viewer, int widgetLine) Returns the line of the viewer's document that corresponds to the given widget line.
-
Constructor Details
-
VerticalRuler
public VerticalRuler(int width) Constructs a vertical ruler with the given width.- Parameters:
width- the width of the vertical ruler
-
VerticalRuler
Constructs a vertical ruler with the given width and the given annotation access.- Parameters:
width- the width of the vertical rulerannotationAcccess- the annotation access- Since:
- 3.0
-
-
Method Details
-
getControl
Description copied from interface:IVerticalRulerInfoReturns the ruler's SWT control.- Specified by:
getControlin interfaceIVerticalRulerInfo- Returns:
- the ruler's SWT control
-
createControl
Description copied from interface:IVerticalRulerCreates the ruler's SWT control.- Specified by:
createControlin interfaceIVerticalRuler- Parameters:
parent- the parent control of the ruler's controltextViewer- the text viewer to which this ruler belongs- Returns:
- the ruler's SWT control
-
doPaint
Draws the vertical ruler w/o drawing the Canvas background.- Parameters:
gc- the GC to draw into
-
doPaint1
Draws the vertical ruler w/o drawing the Canvas background. UsesITextViewerExtension5for its implementation. Will replacedoPaint(GC).- Parameters:
gc- the GC to draw into
-
update
public void update()Thread-safe implementation. Can be called from any thread.- Specified by:
updatein interfaceIVerticalRuler
-
setModel
Description copied from interface:IVerticalRulerAssociates an annotation model with this ruler. A valuenullis acceptable and clears the ruler.- Specified by:
setModelin interfaceIVerticalRuler- Parameters:
model- the new annotation model, may benull
-
getModel
Description copied from interface:IVerticalRulerReturns the current annotation model of this ruler ornullif the ruler has no model.- Specified by:
getModelin interfaceIVerticalRuler- Returns:
- this ruler's annotation model or
nullif there is no model
-
getWidth
public int getWidth()Description copied from interface:IVerticalRulerInfoReturns the width of this ruler's control.- Specified by:
getWidthin interfaceIVerticalRulerInfo- Returns:
- the width of this ruler's control
-
getLineOfLastMouseButtonActivity
public int getLineOfLastMouseButtonActivity()Description copied from interface:IVerticalRulerInfoReturns the line number of the last mouse button activity. Based on the input document of the connected text viewer.- Specified by:
getLineOfLastMouseButtonActivityin interfaceIVerticalRulerInfo- Returns:
- the line number of the last mouse button activity or
-1if the last mouse activity does not correspond to a valid document line
-
toDocumentLineNumber
public int toDocumentLineNumber(int y_coordinate) Description copied from interface:IVerticalRulerInfoTranslates a y-coordinate of the ruler's SWT control into the according line number of the document of the connected text viewer.- Specified by:
toDocumentLineNumberin interfaceIVerticalRulerInfo- Parameters:
y_coordinate- a y-coordinate of the ruler's SWT control- Returns:
- the line number of that coordinate or
-1if that coordinate does not correspond to a valid document line
-
widgetLine2ModelLine
Returns the line of the viewer's document that corresponds to the given widget line.- Parameters:
viewer- the viewerwidgetLine- the widget line- Returns:
- the corresponding line of the viewer's document
- Since:
- 2.1
-
setFont
Description copied from interface:IVerticalRulerExtensionSets the font of this vertical ruler.- Specified by:
setFontin interfaceIVerticalRulerExtension- Parameters:
font- the new font of the vertical ruler
-
setLocationOfLastMouseButtonActivity
public void setLocationOfLastMouseButtonActivity(int x, int y) Description copied from interface:IVerticalRulerExtensionSets the location of the last mouse button activity. This method is used for example by external mouse listeners.- Specified by:
setLocationOfLastMouseButtonActivityin interfaceIVerticalRulerExtension- Parameters:
x- the x-coordinatey- the y-coordinate
-
addMouseListener
Deprecated.will be removedAdds the given mouse listener.- Parameters:
listener- the listener to be added- Since:
- 2.0
-
removeMouseListener
Deprecated.will be removedRemoves the given mouse listener.- Parameters:
listener- the listener to be removed- Since:
- 2.0
-