use of org.eclipse.jface.text.source.CompositeRuler in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method showChangeRulerInformation.
/**
* Opens a sticky change ruler hover for the caret line. Does nothing if no change hover is
* available.
*
* @since 3.5
*/
private void showChangeRulerInformation() {
IVerticalRuler ruler = getVerticalRuler();
if (!(ruler instanceof CompositeRuler) || fLineColumn == null)
return;
CompositeRuler compositeRuler = (CompositeRuler) ruler;
// fake a mouse move (some hovers rely on this to determine the hovered line):
int x = fLineColumn.getControl().getLocation().x;
ISourceViewer sourceViewer = getSourceViewer();
StyledText textWidget = sourceViewer.getTextWidget();
int caretOffset = textWidget.getCaretOffset();
int caretLine = textWidget.getLineAtOffset(caretOffset);
int y = textWidget.getLinePixel(caretLine);
compositeRuler.setLocationOfLastMouseButtonActivity(x, y);
IAnnotationHover hover = fLineColumn.getHover();
showFocusedRulerHover(hover, sourceViewer, caretOffset);
}
use of org.eclipse.jface.text.source.CompositeRuler in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method createColumnSupport.
@Override
protected final IColumnSupport createColumnSupport() {
return new ColumnSupport(this, RulerColumnRegistry.getDefault()) {
@Override
protected void initializeColumn(IContributedRulerColumn column) {
super.initializeColumn(column);
RulerColumnDescriptor descriptor = column.getDescriptor();
IVerticalRuler ruler = internalGetVerticalRuler();
if (ruler instanceof CompositeRuler) {
if (AnnotationColumn.ID.equals(descriptor.getId())) {
((AnnotationColumn) column).setDelegate(createAnnotationRulerColumn((CompositeRuler) ruler));
} else if (LineNumberColumn.ID.equals(descriptor.getId())) {
fLineColumn = ((LineNumberColumn) column);
fLineColumn.setForwarder(new LineNumberColumn.ICompatibilityForwarder() {
@Override
public IVerticalRulerColumn createLineNumberRulerColumn() {
return AbstractDecoratedTextEditor.this.createLineNumberRulerColumn();
}
@Override
public boolean isQuickDiffEnabled() {
return AbstractDecoratedTextEditor.this.isPrefQuickDiffAlwaysOn();
}
@Override
public boolean isLineNumberRulerVisible() {
return AbstractDecoratedTextEditor.this.isLineNumberRulerVisible();
}
});
}
}
}
@Override
public void dispose() {
fLineColumn = null;
super.dispose();
}
};
}
use of org.eclipse.jface.text.source.CompositeRuler in project eclipse.platform.text by eclipse.
the class LineNumberRulerColumnTest method testRedrawAfterDispose.
@Test
public void testRedrawAfterDispose() {
LineNumberRulerColumn lineNumberRulerColumn = new LineNumberRulerColumn();
CompositeRuler ruler = new CompositeRuler();
ruler.addDecorator(0, lineNumberRulerColumn);
SourceViewer sourceViewer = new SourceViewer(fParent, ruler, SWT.NONE);
lineNumberRulerColumn.getControl().setSize(10, 10);
sourceViewer.getTextWidget().dispose();
lineNumberRulerColumn.redraw();
}
use of org.eclipse.jface.text.source.CompositeRuler in project xtext-xtend by eclipse.
the class DerivedSourceView method createSourceViewer.
@Override
protected SourceViewer createSourceViewer(Composite parent) {
IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
IOverviewRuler overviewRuler = new OverviewRuler(defaultMarkerAnnotationAccess, OVERVIEW_RULER_WIDTH, getSharedTextColors());
AnnotationRulerColumn annotationRulerColumn = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, defaultMarkerAnnotationAccess);
List<AnnotationPreference> annotationPreferences = markerAnnotationPreferences.getAnnotationPreferences();
for (AnnotationPreference annotationPreference : annotationPreferences) {
String key = annotationPreference.getVerticalRulerPreferenceKey();
boolean showAnnotation = true;
if (key != null && store.contains(key)) {
showAnnotation = store.getBoolean(key);
}
if (showAnnotation) {
annotationRulerColumn.addAnnotationType(annotationPreference.getAnnotationType());
}
}
annotationRulerColumn.addAnnotationType(Annotation.TYPE_UNKNOWN);
lineNumberRulerColumn = new LineNumberRulerColumn();
CompositeRuler compositeRuler = new CompositeRuler();
compositeRuler.addDecorator(0, annotationRulerColumn);
compositeRuler.addDecorator(1, lineNumberRulerColumn);
javaSourceViewer = new JavaSourceViewer(parent, compositeRuler, overviewRuler, true, SWT.V_SCROLL | SWT.H_SCROLL, store);
javaSourceViewerConfiguration = new SimpleJavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, true) {
@Override
public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(final Shell parent) {
return new DefaultInformationControl(parent, true);
}
};
}
@Override
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
return new DefaultAnnotationHover();
}
};
javaSourceViewer.configure(javaSourceViewerConfiguration);
javaSourceViewer.setEditable(false);
javaSourceViewer.showAnnotations(true);
sourceViewerDecorationSupport = new SourceViewerDecorationSupport(javaSourceViewer, overviewRuler, defaultMarkerAnnotationAccess, getSharedTextColors());
for (AnnotationPreference annotationPreference : annotationPreferences) {
sourceViewerDecorationSupport.setAnnotationPreference(annotationPreference);
}
sourceViewerDecorationSupport.install(preferenceStoreAccess.getPreferenceStore());
return javaSourceViewer;
}
use of org.eclipse.jface.text.source.CompositeRuler in project hale by halestudio.
the class GroovyScriptPage method createVerticalRuler.
@Override
protected IVerticalRuler createVerticalRuler() {
final Display display = Display.getCurrent();
CompositeRuler ruler = new CompositeRuler(3);
AnnotationRulerColumn annotations = SimpleAnnotationUtil.createDefaultAnnotationRuler(annotationModel);
ruler.addDecorator(0, annotations);
LineNumberRulerColumn lineNumbers = new LineNumberRulerColumn();
// SWT.COLOR_INFO_BACKGROUND));
lineNumbers.setBackground(display.getSystemColor(SWT.COLOR_GRAY));
// SWT.COLOR_INFO_FOREGROUND));
lineNumbers.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
lineNumbers.setFont(JFaceResources.getTextFont());
ruler.addDecorator(1, lineNumbers);
return ruler;
}
Aggregations