Search in sources :

Example 6 with LineNumberRulerColumn

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;
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) SimpleJavaSourceViewerConfiguration(org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration) DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) SourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport) IAnnotationHover(org.eclipse.jface.text.source.IAnnotationHover) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) AnnotationRulerColumn(org.eclipse.jface.text.source.AnnotationRulerColumn) Shell(org.eclipse.swt.widgets.Shell) IInformationControl(org.eclipse.jface.text.IInformationControl) JavaSourceViewer(org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) DefaultAnnotationHover(org.eclipse.jface.text.source.DefaultAnnotationHover)

Example 7 with LineNumberRulerColumn

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

Example 8 with LineNumberRulerColumn

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

Example 9 with LineNumberRulerColumn

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));
}
Also used : ISharedTextColors(org.eclipse.jface.text.source.ISharedTextColors) LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) RGB(org.eclipse.swt.graphics.RGB)

Example 10 with LineNumberRulerColumn

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;
}
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

LineNumberRulerColumn (org.eclipse.jface.text.source.LineNumberRulerColumn)13 CompositeRuler (org.eclipse.jface.text.source.CompositeRuler)11 Display (org.eclipse.swt.widgets.Display)6 RGB (org.eclipse.swt.graphics.RGB)5 SourceViewer (org.eclipse.jface.text.source.SourceViewer)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 IDocument (org.eclipse.jface.text.IDocument)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 ISharedTextColors (org.eclipse.jface.text.source.ISharedTextColors)2 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2