Package org.eclipse.jface.text.source

# Class CompositeRuler

java.lang.Object
org.eclipse.jface.text.source.CompositeRuler

All Implemented Interfaces:
  `IVerticalRuler`, `IVerticalRulerExtension`, `IVerticalRulerInfo`, `IVerticalRulerInfoExtension`

public class CompositeRuler extends Object implements IVerticalRuler, IVerticalRulerExtension, IVerticalRulerInfoExtension
Standard implementation of `IVerticalRuler`.

This ruler does not have a a visual representation of its own. The presentation comes from the configurable list of vertical ruler columns. Such columns must implement the `IVerticalRulerColumn`. interface.

Clients may instantiate and configure this class.

Since:
  2.0
See Also:
  - `IVerticalRulerColumn`
  - `ITextViewer`

## Constructor Summary

Constructors
Constructor
Description
`CompositeRuler()`
Constructs a new composite vertical ruler.
`CompositeRuler(int gap)`
Constructs a new composite ruler with the given gap between its columns.

## Method Summary

Modifier and Type
Method
Description
`void`
`addDecorator(int index, IVerticalRulerColumn rulerColumn)`
Inserts the given column at the specified slot to this composite ruler.
`void`
`addVerticalRulerListener(IVerticalRulerListener listener)`
Registers a vertical ruler listener to be informed if an annotation gets selected on the vertical ruler.
`Control`
`createControl(Composite parent, ITextViewer textViewer)`
Creates the ruler's SWT control.
`void`
`fireAnnotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu)`
Informs all registered vertical ruler listeners that the content menu on a selected annotation\ is about to be shown.
`void`
`fireAnnotationDefaultSelected(VerticalRulerEvent event)`
Fires the annotation default selected event to all registered vertical ruler listeners.
`void`
`fireAnnotationSelected(VerticalRulerEvent event)`
Fires the annotation selected event to all registered vertical ruler listeners.
`Control`
`getControl()`
Returns the ruler's SWT control.
`Iterator<IVerticalRulerColumn>`
`getDecoratorIterator()`
Returns an iterator over the `IVerticalRulerColumns` that make up this composite column.
`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 current annotation model of this ruler or `null` if the ruler has no model.
`ITextViewer`
`getTextViewer()`
Returns this ruler's text viewer.
`int`
`getWidth()`
Returns the width of this ruler's control.
`void`
`immediateUpdate()`
Immediately redraws the entire ruler (without asynchronous posting).
`void`
`relayout()`
Relayouts the receiver.
`void`
`removeDecorator(int index)`
Removes the decorator in the specified slot from this composite ruler.
`void`
`removeDecorator(IVerticalRulerColumn rulerColumn)`
Removes the given decorator from the composite ruler.
`void`
`removeVerticalRulerListener(IVerticalRulerListener listener)`
Removes a previously registered listener.
`void`
`setFont(Font font)`
Sets the font of this vertical ruler.
`void`
`setLocationOfLastMouseButtonActivity(int x, int y)`
Sets the location of the last mouse button activity.
`void`
`setModel(IAnnotationModel model)`
Associates an annotation model with this ruler.
`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.
`void`
`update()`
Forces the vertical ruler to synchronize itself with its annotation model and its viewer's view port.
`protected static final int`
`widgetLine2ModelLine(ITextViewer viewer, int widgetLine)`
Returns the line in the given viewer's document that correspond to the given line of the viewer's widget.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CompositeRuler

public CompositeRuler()
Constructs a new composite vertical ruler.

### CompositeRuler

public CompositeRuler(int gap)
Constructs a new composite ruler with the given gap between its columns.

Parameters:
  `gap` - the gap

## Method Details

### addDecorator

public void addDecorator(int index, IVerticalRulerColumn rulerColumn)
Inserts the given column at the specified slot to this composite ruler. Columns are counted from left to right.

Parameters:
  `index` - the index
  `rulerColumn` - the decorator to be inserted

### removeDecorator

public void removeDecorator(int index)
Removes the decorator in the specified slot from this composite ruler.

Parameters:
  `index` - the index

### removeDecorator

public void removeDecorator(IVerticalRulerColumn rulerColumn)
Removes the given decorator from the composite ruler.

Parameters:
  `rulerColumn` - the ruler column to be removed
Since:
  3.0

### getControl

public Control getControl()
Description copied from interface: `IVerticalRulerInfo`
Returns the ruler's SWT control.

Specified by:
  `getControl` in interface `IVerticalRulerInfo`
Returns:
  the ruler's SWT control

### createControl

public Control createControl(Composite parent, ITextViewer textViewer)
Description copied from interface: `IVerticalRuler`
Creates the ruler's SWT control.

Specified by:
  `createControl` in interface `IVerticalRuler`
Parameters:
  `parent` - the parent control of the ruler's control
  `textViewer` - the text viewer to which this ruler belongs
Returns:
  the ruler's SWT control

### setModel

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

Specified by:
  `setModel` in interface `IVerticalRuler`
Parameters:
  `model` - the new annotation model, may be `null`

### getModel

public IAnnotationModel getModel()
Description copied from interface: `IVerticalRuler`
Returns the current annotation model of this ruler or `null` if the ruler has no model.

Specified by:
  `getModel` in interface `IVerticalRuler`
Specified by:
  `getModel` in interface `IVerticalRulerInfoExtension`
Returns:
  this ruler's annotation model or `null` if there is no model

### update

public void update()
Description copied from interface: `IVerticalRuler`
Forces the vertical ruler to synchronize itself with its annotation model and its viewer's view port.

Specified by:
  `update` in interface `IVerticalRuler`

### immediateUpdate

public void immediateUpdate()
Immediately redraws the entire ruler (without asynchronous posting).

Since:
  3.2

### setFont

public void setFont(Font font)
Description copied from interface: `IVerticalRulerExtension`
Sets the font of this vertical ruler.

Specified by:
  `setFont` in interface `IVerticalRulerExtension`
Parameters:
  `font` - the new font of the vertical ruler

### getWidth

public int getWidth()
Description copied from interface: `IVerticalRulerInfo`
Returns the width of this ruler's control.

Specified by:
  `getWidth` in interface `IVerticalRulerInfo`
Returns:
  the width of this ruler's control

### 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.

Specified by:
  `getLineOfLastMouseButtonActivity` in interface `IVerticalRulerInfo`
Returns:
  the line number of the last mouse button activity or `-1` if the last mouse activity does not correspond to a valid document line

### 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

### widgetLine2ModelLine

protected static final int widgetLine2ModelLine(ITextViewer viewer, int widgetLine)
Returns the line in the given viewer's document that correspond to the given line of the viewer's widget.

Parameters:
  `viewer` - the viewer
  `widgetLine` - the widget line
Returns:
  the corresponding line the viewer's document
Since:
  2.1

### getTextViewer

public ITextViewer getTextViewer()
Returns this ruler's text viewer.

Returns:
  this ruler's text viewer

### setLocationOfLastMouseButtonActivity

public void setLocationOfLastMouseButtonActivity(int x, int y)
Description copied from interface: `IVerticalRulerExtension`
Sets the location of the last mouse button activity. This method is used for example by external mouse listeners.

Specified by:
  `setLocationOfLastMouseButtonActivity` in interface `IVerticalRulerExtension`
Parameters:
  `x` - the x-coordinate
  `y` - the y-coordinate

### getDecoratorIterator

public Iterator<IVerticalRulerColumn> getDecoratorIterator()
Returns an iterator over the `IVerticalRulerColumns` that make up this composite column.

Returns:
  an iterator over the contained columns.
Since:
  3.0

### 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

### 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

### fireAnnotationSelected

public void fireAnnotationSelected(VerticalRulerEvent event)
Fires the annotation selected event to all registered vertical ruler listeners. TODO use robust iterators

Parameters:
  `event` - the event to fire
Since:
  3.0

### fireAnnotationDefaultSelected

public void fireAnnotationDefaultSelected(VerticalRulerEvent event)
Fires the annotation default selected event to all registered vertical ruler listeners. TODO use robust iterators

Parameters:
  `event` - the event to fire
Since:
  3.0

### fireAnnotationContextMenuAboutToShow

public void fireAnnotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu)
Informs all registered vertical ruler listeners that the content menu on a selected annotation\ is about to be shown. TODO use robust iterators

Parameters:
  `event` - the event to fire
  `menu` - the menu that is about to be shown
Since:
  3.0

### relayout

public void relayout()
Relayouts the receiver.

Since:
  3.3