use of org.eclipse.jface.text.source.CompositeRuler 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.CompositeRuler in project tdi-studio-se by Talend.
the class TalendJavaSourceViewer method initializeViewer.
private static ReconcilerViewer initializeViewer(Composite composite, int styles, boolean checkCode, IDocument document, int visibleOffset) {
IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
ISharedTextColors sharedColors = JavaPlugin.getDefault().getJavaTextTools().getColorManager();
IOverviewRuler overviewRuler = null;
IVerticalRuler verticalRuler = null;
if (checkCode) {
overviewRuler = new OverviewRuler(annotationAccess, 12, sharedColors);
Iterator e = EditorsPlugin.getDefault().getMarkerAnnotationPreferences().getAnnotationPreferences().iterator();
while (e.hasNext()) {
AnnotationPreference preference = (AnnotationPreference) e.next();
if (preference.contributesToHeader()) {
overviewRuler.addHeaderAnnotationType(preference.getAnnotationType());
}
}
}
verticalRuler = new CompositeRuler(12);
ReconcilerViewer viewer = new TalendJavaSourceViewer(composite, verticalRuler, overviewRuler, checkCode, styles, annotationAccess, sharedColors, checkCode, document);
if (visibleOffset != -1) {
viewer.setVisibleRegion(visibleOffset, 0);
}
return viewer;
}
use of org.eclipse.jface.text.source.CompositeRuler in project hale by halestudio.
the class SourceViewerPage 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.CompositeRuler in project hale by halestudio.
the class GroovyEditor method createRuler.
/**
* Create the vertical ruler for the source viewer.
*
* @return the vertical ruler
*/
private IVerticalRuler createRuler() {
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.CompositeRuler 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