use of org.eclipse.jface.text.source.LineNumberRulerColumn 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.LineNumberRulerColumn 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.LineNumberRulerColumn in project hale by halestudio.
the class SourceViewerParameterPage method createVerticalRuler.
/**
* Create the vertical ruler for the source viewer.
*
* @return the vertical ruler
*/
protected IVerticalRuler createVerticalRuler() {
final Display display = Display.getCurrent();
CompositeRuler ruler = new CompositeRuler(3);
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(0, lineNumbers);
return ruler;
}
use of org.eclipse.jface.text.source.LineNumberRulerColumn in project eclipse.platform.text by eclipse.
the class LineNumberColumn method updateBackgroundColor.
private void updateBackgroundColor(IPreferenceStore store, IVerticalRulerColumn column) {
// background color: same as editor, or system default
RGB rgb;
if (store.getBoolean(USE_DEFAULT_BG_KEY))
rgb = null;
else
rgb = getColorFromStore(store, BG_COLOR_KEY);
ISharedTextColors sharedColors = getSharedColors();
if (column instanceof LineNumberRulerColumn)
((LineNumberRulerColumn) column).setBackground(sharedColors.getColor(rgb));
}
use of org.eclipse.jface.text.source.LineNumberRulerColumn in project hale by halestudio.
the class CRSPreferencePage method createContents.
/**
* @see PreferencePage#createContents(Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
page.setLayout(new GridLayout(1, false));
page.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Label label = new Label(page, SWT.NONE);
// $NON-NLS-1$
label.setText(Messages.CRSPreferencePage_0);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
// code list
listViewer = new ComboViewer(page);
listViewer.setContentProvider(ArrayContentProvider.getInstance());
listViewer.setLabelProvider(new LabelProvider());
listViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
codes = WKTPreferencesCRSFactory.getInstance().getCodes();
listViewer.setInput(codes);
listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
updateEditor(null);
} else {
if (selection instanceof IStructuredSelection) {
updateEditor((String) ((IStructuredSelection) selection).getFirstElement());
}
}
}
});
// fill wkt map
for (String code : codes) {
tmpWKTs.put(code, WKTPreferencesCRSFactory.getInstance().getWKT(code));
}
// WKT editor
final Display display = Display.getCurrent();
CompositeRuler ruler = new CompositeRuler(3);
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(0, lineNumbers);
wktEditor = new SourceViewer(page, ruler, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
wktEditor.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
wktEditor.getTextWidget().setFont(JFaceResources.getTextFont());
SourceViewerConfiguration conf = new SourceViewerConfiguration();
wktEditor.configure(conf);
// create initial document
IDocument doc = new Document();
// $NON-NLS-1$
doc.set("");
wktEditor.setInput(doc);
// button bar
Composite bar = new Composite(page, SWT.NONE);
bar.setLayout(new GridLayout(2, true));
bar.setLayoutData(new GridData(SWT.FILL, SWT.END, true, false));
// add button (using a directory dialog)
Button add = new Button(bar, SWT.PUSH);
add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
// $NON-NLS-1$
add.setText(Messages.CRSPreferencePage_2);
// $NON-NLS-1$
add.setToolTipText(Messages.CRSPreferencePage_3);
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final Display display = Display.getCurrent();
InputDialog dialog = new InputDialog(display.getActiveShell(), // $NON-NLS-1$ //$NON-NLS-2$
Messages.CRSPreferencePage_4, // $NON-NLS-1$ //$NON-NLS-2$
Messages.CRSPreferencePage_5, WKTPreferencesCRSFactory.AUTHORITY_PREFIX, new IInputValidator() {
@Override
public String isValid(String newText) {
if (!newText.startsWith(WKTPreferencesCRSFactory.AUTHORITY_PREFIX)) {
return MessageFormat.format(Messages.CRSPreferencePage_6, // $NON-NLS-1$
WKTPreferencesCRSFactory.AUTHORITY_PREFIX);
}
return null;
}
});
if (dialog.open() == InputDialog.OK) {
String value = dialog.getValue();
codes.add(value);
listViewer.refresh(false);
listViewer.setSelection(new StructuredSelection(value));
}
}
});
// remove button
Button remove = new Button(bar, SWT.PUSH);
remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
// $NON-NLS-1$
remove.setText(Messages.CRSPreferencePage_7);
// $NON-NLS-1$
remove.setToolTipText(Messages.CRSPreferencePage_8);
remove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ISelection selection = listViewer.getSelection();
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
String selected = (String) ((IStructuredSelection) selection).getFirstElement();
codes.remove(selected);
listViewer.refresh(false);
if (!codes.isEmpty()) {
listViewer.setSelection(new StructuredSelection(codes.get(0)));
}
tmpWKTs.remove(selected);
// mark as changed
changed = true;
}
}
});
// update selection
if (codes.isEmpty()) {
listViewer.setSelection(new StructuredSelection());
} else {
listViewer.setSelection(new StructuredSelection(codes.get(0)));
}
return page;
}
Aggregations