Search in sources :

Example 11 with CompositeRuler

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;
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) Display(org.eclipse.swt.widgets.Display)

Example 12 with CompositeRuler

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;
}
Also used : IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) ISharedTextColors(org.eclipse.jface.text.source.ISharedTextColors) DefaultMarkerAnnotationAccess(org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess) IAnnotationAccess(org.eclipse.jface.text.source.IAnnotationAccess) IVerticalRuler(org.eclipse.jface.text.source.IVerticalRuler) Iterator(java.util.Iterator) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference) ReconcilerViewer(org.talend.designer.core.ui.viewer.ReconcilerViewer)

Example 13 with CompositeRuler

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;
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) Display(org.eclipse.swt.widgets.Display)

Example 14 with CompositeRuler

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;
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) Display(org.eclipse.swt.widgets.Display)

Example 15 with CompositeRuler

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;
}
Also used : SourceViewer(org.eclipse.jface.text.source.SourceViewer) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) GridLayout(org.eclipse.swt.layout.GridLayout) SourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewerConfiguration) Button(org.eclipse.swt.widgets.Button) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) InputDialog(org.eclipse.jface.dialogs.InputDialog) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) LabelProvider(org.eclipse.jface.viewers.LabelProvider) IDocument(org.eclipse.jface.text.IDocument) Display(org.eclipse.swt.widgets.Display) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Aggregations

CompositeRuler (org.eclipse.jface.text.source.CompositeRuler)16 LineNumberRulerColumn (org.eclipse.jface.text.source.LineNumberRulerColumn)11 Display (org.eclipse.swt.widgets.Display)6 IVerticalRuler (org.eclipse.jface.text.source.IVerticalRuler)5 StyledText (org.eclipse.swt.custom.StyledText)3 RGB (org.eclipse.swt.graphics.RGB)3 FillLayout (org.eclipse.swt.layout.FillLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 SQLDocument (com.cubrid.common.ui.query.editor.SQLDocument)2 SQLPartitionScanner (com.cubrid.common.ui.query.editor.SQLPartitionScanner)2 SQLTextViewer (com.cubrid.common.ui.query.editor.SQLTextViewer)2 SQLViewerConfiguration (com.cubrid.common.ui.query.editor.SQLViewerConfiguration)2 Document (org.eclipse.jface.text.Document)2 DocumentEvent (org.eclipse.jface.text.DocumentEvent)2 IDocument (org.eclipse.jface.text.IDocument)2 IDocumentListener (org.eclipse.jface.text.IDocumentListener)2 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)2 TextViewerUndoManager (org.eclipse.jface.text.TextViewerUndoManager)2 FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)2 AnnotationRulerColumn (org.eclipse.jface.text.source.AnnotationRulerColumn)2