use of org.eclipse.jface.text.source.AnnotationRulerColumn 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.AnnotationRulerColumn 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;
}
use of org.eclipse.jface.text.source.AnnotationRulerColumn in project eclipse.platform.text by eclipse.
the class AnnotationColumn method initialize.
/**
* Initializes the given line number ruler column from the preference store.
*/
private void initialize() {
if (fDelegate == null)
fDelegate = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, new DefaultMarkerAnnotationAccess());
IPreferenceStore store = getPreferenceStore();
if (store != null && fDelegate instanceof AnnotationRulerColumn) {
final AnnotationRulerColumn column = (AnnotationRulerColumn) fDelegate;
// initial set up
for (Iterator<AnnotationPreference> iter2 = fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext(); ) {
AnnotationPreference preference = iter2.next();
String key = preference.getVerticalRulerPreferenceKey();
boolean showAnnotation = true;
if (key != null && store.contains(key))
showAnnotation = store.getBoolean(key);
if (showAnnotation)
column.addAnnotationType(preference.getAnnotationType());
}
column.addAnnotationType(Annotation.TYPE_UNKNOWN);
// link to preference store
fPropertyListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
AnnotationPreference annotationPreference = getVerticalRulerAnnotationPreference(property);
if (annotationPreference != null && property.equals(annotationPreference.getVerticalRulerPreferenceKey())) {
Object type = annotationPreference.getAnnotationType();
if (getPreferenceStore().getBoolean(property))
column.addAnnotationType(type);
else
column.removeAnnotationType(type);
column.redraw();
}
}
};
store.addPropertyChangeListener(fPropertyListener);
}
}
use of org.eclipse.jface.text.source.AnnotationRulerColumn in project hale by halestudio.
the class SimpleAnnotationUtil method createDefaultAnnotationRuler.
/**
* Create a default annotation ruler configured for displaying
* {@link SimpleAnnotations}.
*
* @param annotationModel the annotation model
* @return the annotation ruler
*/
public static AnnotationRulerColumn createDefaultAnnotationRuler(IAnnotationModel annotationModel) {
AnnotationRulerColumn annotations = new AnnotationRulerColumn(annotationModel, 12, new SimpleAnnotations());
// error
annotations.addAnnotationType(SimpleAnnotations.TYPE_ERROR);
// warning
annotations.addAnnotationType(SimpleAnnotations.TYPE_WARN);
// information
annotations.addAnnotationType(SimpleAnnotations.TYPE_INFO);
annotations.setHover(new DefaultAnnotationHover());
return annotations;
}
Aggregations