Search in sources :

Example 56 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer in project webtools.sourceediting by eclipse.

the class NewTagTemplatesWizardPage method doCreateViewer.

private SourceViewer doCreateViewer(Composite parent) {
    Label label = new Label(parent, SWT.NONE);
    label.setText(JSPUIMessages.NewTagTemplatesWizardPage_5);
    GridData data = new GridData();
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    SourceViewer viewer = createViewer(parent);
    viewer.setEditable(false);
    Control control = viewer.getControl();
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    data.heightHint = convertHeightInCharsToPixels(5);
    // [261274] - source viewer was growing to fit the max line width of the template
    data.widthHint = convertWidthInCharsToPixels(2);
    control.setLayoutData(data);
    return viewer;
}
Also used : Control(org.eclipse.swt.widgets.Control) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 57 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer in project webtools.sourceediting by eclipse.

the class XSLSyntaxColoringPage method createContents.

@Override
protected Control createContents(final Composite parent) {
    initializeDialogUnits(parent);
    defaultForeground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
    defaultBackground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
    Composite pageComponent = createComposite(parent, 2);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.XML_PREFWEBX_STYLES_HELPID);
    Link link = new Link(pageComponent, SWT.WRAP);
    link.setText(Messages.XSLSyntaxColoringPage);
    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
        }
    });
    GridData linkData = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1);
    // only expand further if anyone else requires
    linkData.widthHint = 150;
    // it
    link.setLayoutData(linkData);
    new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
    new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
    SashForm editor = new SashForm(pageComponent, SWT.VERTICAL);
    GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData2.horizontalSpan = 2;
    editor.setLayoutData(gridData2);
    SashForm top = new SashForm(editor, SWT.HORIZONTAL);
    Composite styleEditor = createComposite(top, 1);
    ((GridLayout) styleEditor.getLayout()).marginRight = 5;
    ((GridLayout) styleEditor.getLayout()).marginLeft = 0;
    createLabel(styleEditor, XMLUIMessages.SyntaxColoringPage_0);
    stylesViewer = createStylesViewer(styleEditor);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.horizontalIndent = 0;
    Iterator iterator = styleToDescriptionMap.values().iterator();
    while (iterator.hasNext()) {
        gridData.widthHint = Math.max(gridData.widthHint, convertWidthInCharsToPixels(iterator.next().toString().length()));
    }
    gridData.heightHint = convertHeightInCharsToPixels(5);
    stylesViewer.getControl().setLayoutData(gridData);
    Composite editingComposite = createComposite(top, 1);
    ((GridLayout) styleEditor.getLayout()).marginLeft = 5;
    // $NON-NLS-1$
    createLabel(editingComposite, "");
    Button enabler = createCheckbox(editingComposite, XMLUIMessages.SyntaxColoringPage_2);
    enabler.setEnabled(false);
    enabler.setSelection(true);
    Composite editControls = createComposite(editingComposite, 2);
    ((GridLayout) editControls.getLayout()).marginLeft = 20;
    foregroundLabel = createLabel(editControls, SSEUIMessages.Foreground_UI_);
    ((GridData) foregroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
    foregroundLabel.setEnabled(false);
    foregroundColorEditor = new ColorSelector(editControls);
    Button fForegroundColor = foregroundColorEditor.getButton();
    GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
    fForegroundColor.setLayoutData(gd);
    foregroundColorEditor.setEnabled(false);
    backgroundLabel = createLabel(editControls, SSEUIMessages.Background_UI_);
    ((GridData) backgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
    backgroundLabel.setEnabled(false);
    backgroundColorEditor = new ColorSelector(editControls);
    Button fBackgroundColor = backgroundColorEditor.getButton();
    gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
    fBackgroundColor.setLayoutData(gd);
    backgroundColorEditor.setEnabled(false);
    bold = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_3);
    bold.setEnabled(false);
    ((GridData) bold.getLayoutData()).horizontalSpan = 2;
    italic = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_4);
    italic.setEnabled(false);
    ((GridData) italic.getLayoutData()).horizontalSpan = 2;
    strike = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_5);
    strike.setEnabled(false);
    ((GridData) strike.getLayoutData()).horizontalSpan = 2;
    underline = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_6);
    underline.setEnabled(false);
    ((GridData) underline.getLayoutData()).horizontalSpan = 2;
    clearStyle = new Button(editingComposite, SWT.PUSH);
    // = "Restore Default"
    clearStyle.setText(SSEUIMessages.Restore_Default_UI_);
    clearStyle.setLayoutData(new GridData(SWT.BEGINNING));
    ((GridData) clearStyle.getLayoutData()).horizontalIndent = 20;
    clearStyle.setEnabled(false);
    Composite sampleArea = createComposite(editor, 1);
    ((GridLayout) sampleArea.getLayout()).marginLeft = 5;
    ((GridLayout) sampleArea.getLayout()).marginTop = 5;
    // = "&Sample text:"
    createLabel(sampleArea, SSEUIMessages.Sample_text__UI_);
    SourceViewer viewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
    styledText = viewer.getTextWidget();
    GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData3.widthHint = convertWidthInCharsToPixels(20);
    gridData3.heightHint = convertHeightInCharsToPixels(5);
    gridData3.horizontalSpan = 2;
    styledText.setLayoutData(gridData3);
    styledText.setEditable(false);
    styledText.setFont(JFaceResources.getFont(// $NON-NLS-1$
    "org.eclipse.wst.sse.ui.textfont"));
    styledText.addKeyListener(getTextKeyListener());
    styledText.addSelectionListener(getTextSelectionListener());
    styledText.addMouseListener(getTextMouseListener());
    styledText.addTraverseListener(getTraverseListener());
    setAccessible(styledText, SSEUIMessages.Sample_text__UI_);
    try {
        File file = XSLUIPlugin.makeFileFor(XSLSyntaxColoringPage.XSLFILES_DIR, XSLSyntaxColoringPage.SYNTAXCOLORING_XSL);
        document = StructuredModelManager.getModelManager().createStructuredDocumentFor(file.getAbsolutePath(), new FileInputStream(file), null);
    } catch (Exception ex) {
        XSLUIPlugin.log(ex);
    }
    viewer.setDocument(document);
    top.setWeights(new int[] { 1, 1 });
    editor.setWeights(new int[] { 1, 1 });
    PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.XML_PREFWEBX_STYLES_HELPID);
    stylesViewer.setInput(getStylePreferenceKeys());
    applyStyles();
    stylesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (!event.getSelection().isEmpty()) {
                Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
                String namedStyle = o.toString();
                activate(namedStyle);
                if (namedStyle == null)
                    return;
            }
        }
    });
    foregroundColorEditor.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
                Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
                String namedStyle = o.toString();
                String prefString = getOverlayStore().getString(namedStyle);
                String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
                if (stylePrefs != null) {
                    String oldValue = stylePrefs[0];
                    // open color dialog to get new color
                    String newValue = ColorHelper.toRGBString(foregroundColorEditor.getColorValue());
                    if (!newValue.equals(oldValue)) {
                        stylePrefs[0] = newValue;
                        String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                        getOverlayStore().setValue(namedStyle, newPrefString);
                        applyStyles();
                        styledText.redraw();
                    }
                }
            }
        }
    });
    backgroundColorEditor.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
                Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
                String namedStyle = o.toString();
                String prefString = getOverlayStore().getString(namedStyle);
                String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
                if (stylePrefs != null) {
                    String oldValue = stylePrefs[1];
                    // open color dialog to get new color
                    String newValue = ColorHelper.toRGBString(backgroundColorEditor.getColorValue());
                    if (!newValue.equals(oldValue)) {
                        stylePrefs[1] = newValue;
                        String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                        getOverlayStore().setValue(namedStyle, newPrefString);
                        applyStyles();
                        styledText.redraw();
                        activate(namedStyle);
                    }
                }
            }
        }
    });
    bold.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[2];
                String newValue = String.valueOf(bold.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[2] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    styledText.redraw();
                }
            }
        }
    });
    italic.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[3];
                String newValue = String.valueOf(italic.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[3] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    styledText.redraw();
                }
            }
        }
    });
    strike.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[4];
                String newValue = String.valueOf(strike.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[4] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    styledText.redraw();
                }
            }
        }
    });
    underline.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            // get current (newly old) style
            Object o = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement();
            String namedStyle = o.toString();
            String prefString = getOverlayStore().getString(namedStyle);
            String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
            if (stylePrefs != null) {
                String oldValue = stylePrefs[5];
                String newValue = String.valueOf(underline.getSelection());
                if (!newValue.equals(oldValue)) {
                    stylePrefs[5] = newValue;
                    String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
                    getOverlayStore().setValue(namedStyle, newPrefString);
                    applyStyles();
                    styledText.redraw();
                }
            }
        }
    });
    clearStyle.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (stylesViewer.getSelection().isEmpty())
                return;
            String namedStyle = ((IStructuredSelection) stylesViewer.getSelection()).getFirstElement().toString();
            getOverlayStore().setToDefault(namedStyle);
            applyStyles();
            styledText.redraw();
            activate(namedStyle);
        }
    });
    return pageComponent;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) SourceViewer(org.eclipse.jface.text.source.SourceViewer) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FileInputStream(java.io.FileInputStream) SashForm(org.eclipse.swt.custom.SashForm) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) Iterator(java.util.Iterator) ColorSelector(org.eclipse.jface.preference.ColorSelector) File(java.io.File) Link(org.eclipse.swt.widgets.Link)

Example 58 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer in project soot by Sable.

the class SootPartManager method updatePart.

public void updatePart(IEditorPart part) {
    if (part == null)
        return;
    if (part instanceof JimpleEditor) {
        AbstractAttributesComputer aac = new JimpleAttributesComputer();
        SootAttributesJimpleColorer sajc = new SootAttributesJimpleColorer();
        SootAttrJimpleIconGenerator saji = new SootAttrJimpleIconGenerator();
        SourceViewer viewer = (SourceViewer) ((AbstractTextEditor) part).getAdapter(ITextOperationTarget.class);
        SootAttributesHandler handler = aac.getAttributesHandler((AbstractTextEditor) part);
        if (handler != null) {
            if (isUpdateForOpen() || handler.isUpdate()) {
                sajc.setEditorPart(part);
                sajc.setViewer(viewer);
                sajc.setHandler(handler);
                Thread cThread = new Thread(sajc);
                cThread.start();
                saji.setHandler(handler);
                saji.setRec((IFile) aac.getRec());
                Thread iThread = new Thread(saji);
                iThread.start();
                handler.setUpdate(false);
            }
        }
        handleKeys(handler);
        handleTypes(handler, (IFile) aac.getRec());
    } else if (part instanceof AbstractTextEditor) {
        IEditorInput input = ((AbstractTextEditor) part).getEditorInput();
        IJavaElement jElem = (IJavaElement) ((IAdaptable) input).getAdapter(IJavaElement.class);
        if (!(jElem instanceof ICompilationUnit))
            return;
        AbstractAttributesComputer aac = new JavaAttributesComputer();
        SootAttributesJavaColorer sajc = new SootAttributesJavaColorer();
        SootAttrJavaIconGenerator saji = new SootAttrJavaIconGenerator();
        SourceViewer viewer = (SourceViewer) ((AbstractTextEditor) part).getAdapter(ITextOperationTarget.class);
        SootAttributesHandler handler = aac.getAttributesHandler((AbstractTextEditor) part);
        if (handler != null) {
            if (isUpdateForOpen() || handler.isUpdate()) {
                sajc.setEditorPart(part);
                sajc.setViewer(viewer);
                sajc.setHandler(handler);
                Thread cThread = new Thread(sajc);
                cThread.start();
                saji.setHandler(handler);
                saji.setRec((IFile) aac.getRec());
                Thread iThread = new Thread(saji);
                iThread.start();
                handler.setUpdate(false);
            }
        }
        handleKeys(handler);
        handleTypes(handler, (IFile) aac.getRec());
    }
    setUpdateForOpen(false);
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) SourceViewer(org.eclipse.jface.text.source.SourceViewer) JimpleEditor(ca.mcgill.sable.soot.editors.JimpleEditor) ITextOperationTarget(org.eclipse.jface.text.ITextOperationTarget) AbstractTextEditor(org.eclipse.ui.texteditor.AbstractTextEditor)

Example 59 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer 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)

Example 60 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer in project hale by halestudio.

the class GroovyEditor method createAndLayoutTextField.

/**
 * Create the text field.
 *
 * @param parent the parent composite
 * @return the input text field.
 */
private SourceViewer createAndLayoutTextField(Composite parent) {
    IVerticalRuler ruler = createRuler();
    SourceViewer viewer = new SourceViewer(parent, ruler, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(7, 0).create());
    viewer.getTextWidget().setFont(JFaceResources.getTextFont());
    SourceViewerKeyBindings.installDefault(viewer);
    return viewer;
}
Also used : SourceViewer(org.eclipse.jface.text.source.SourceViewer) IVerticalRuler(org.eclipse.jface.text.source.IVerticalRuler)

Aggregations

SourceViewer (org.eclipse.jface.text.source.SourceViewer)67 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)39 IDocument (org.eclipse.jface.text.IDocument)26 GridData (org.eclipse.swt.layout.GridData)24 Label (org.eclipse.swt.widgets.Label)23 Composite (org.eclipse.swt.widgets.Composite)16 Document (org.eclipse.jface.text.Document)15 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)14 StructuredTextViewer (org.eclipse.wst.sse.ui.internal.StructuredTextViewer)14 Control (org.eclipse.swt.widgets.Control)13 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)13 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 Button (org.eclipse.swt.widgets.Button)11 Iterator (java.util.Iterator)10 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)8 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8