Search in sources :

Example 56 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.

the class ViewerTestDTD method addActions.

protected void addActions(IContributionManager mgr) {
    if (mgr != null) {
        mgr.add(new Action() {

            public String getText() {
                return getToolTipText();
            }

            public String getToolTipText() {
                return "New HTML";
            }

            public void run() {
                super.run();
                BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {

                    public void run() {
                        setupViewerForNew();
                        fSourceViewer.setEditable(true);
                    }
                });
            }
        });
        mgr.add(new Separator());
        mgr.add(new Action() {

            public String getText() {
                return getToolTipText();
            }

            public String getToolTipText() {
                return "Change Visibility";
            }

            public void run() {
                super.run();
                NumberInputDialog dlg = new NumberInputDialog(fSourceViewer.getControl().getShell());
                int proceed = dlg.open();
                if (proceed == Window.CANCEL)
                    return;
                fSourceViewer.resetVisibleRegion();
                fSourceViewer.setVisibleRegion(dlg.startValue, dlg.lengthValue);
            }
        });
        mgr.add(new Action() {

            public String getText() {
                return getToolTipText();
            }

            public String getToolTipText() {
                return "Show All";
            }

            public void run() {
                super.run();
                fSourceViewer.resetVisibleRegion();
            }
        });
        mgr.add(new Action() {

            public String getText() {
                return getToolTipText();
            }

            public String getToolTipText() {
                return "Change Visibility in Editor";
            }

            public void run() {
                super.run();
                StructuredTextViewer sourceViewer = null;
                IEditorPart part = getViewSite().getWorkbenchWindow().getActivePage().getActiveEditor();
                if (part != null && part instanceof StructuredTextEditor) {
                    sourceViewer = ((StructuredTextEditor) part).getTextViewer();
                }
                if (sourceViewer != null) {
                    NumberInputDialog dlg = new NumberInputDialog(sourceViewer.getControl().getShell());
                    int proceed = dlg.open();
                    if (proceed == Window.CANCEL)
                        return;
                    sourceViewer.resetVisibleRegion();
                    sourceViewer.setVisibleRegion(dlg.startValue, dlg.lengthValue);
                }
            }
        });
        mgr.add(new Action() {

            public String getText() {
                return getToolTipText();
            }

            public String getToolTipText() {
                return "Show All in Editor";
            }

            public void run() {
                super.run();
                StructuredTextViewer sourceViewer = null;
                IEditorPart part = getViewSite().getWorkbenchWindow().getActivePage().getActiveEditor();
                if (part != null && part instanceof StructuredTextEditor) {
                    sourceViewer = ((StructuredTextEditor) part).getTextViewer();
                }
                if (sourceViewer != null) {
                    sourceViewer.resetVisibleRegion();
                }
            }
        });
        mgr.add(new Separator());
        // no longer able to set fInput to NULL
        // mgr.add(new Action() {
        // public String getText() {
        // return getToolTipText();
        // }
        // 
        // public String getToolTipText() {
        // return "Set Input to NULL";
        // }
        // public void run() {
        // super.run();
        // viewer.setInput(null);
        // }
        // });
        mgr.add(new Action() {

            public String getText() {
                return getToolTipText();
            }

            public String getToolTipText() {
                return "Take Input from Active Editor";
            }

            public void run() {
                super.run();
                ITextEditor textEditor = getActiveEditor();
                if (textEditor != null) {
                    setupViewerForEditor(textEditor);
                    fSourceViewer.setEditable(true);
                }
            }
        });
        mgr.add(new Action() {

            public String getText() {
                return getToolTipText();
            }

            public String getToolTipText() {
                return "Take Input and Follow Selection";
            }

            public void run() {
                super.run();
                followSelection();
                fSourceViewer.setEditable(true);
            }
        });
        mgr.add(new Action() {

            public String getText() {
                return getToolTipText();
            }

            public String getToolTipText() {
                return "Take Input and Follow Selection As ReadOnly";
            }

            public void run() {
                super.run();
                followSelection();
                fSourceViewer.setEditable(false);
            }
        });
        mgr.add(new Action() {

            public String getText() {
                return getToolTipText();
            }

            public String getToolTipText() {
                return "Stop Following Selection";
            }

            public void run() {
                super.run();
                stopFollowSelection();
            }
        });
    }
}
Also used : Action(org.eclipse.jface.action.Action) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IEditorPart(org.eclipse.ui.IEditorPart) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) Separator(org.eclipse.jface.action.Separator)

Example 57 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.

the class TestXSLHyperlinkDetector method initializeSourceViewer.

protected void initializeSourceViewer() {
    // some test environments might not have a "real" display
    if (Display.getCurrent() != null) {
        if (PlatformUI.isWorkbenchRunning()) {
            shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        } else {
            shell = new Shell(Display.getCurrent());
        }
        parent = new Composite(shell, SWT.NONE);
        // dummy viewer
        sourceViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
    } else {
        Assert.fail("Unable to run the test as a display must be available.");
    }
    configureSourceViewer();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer)

Example 58 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.

the class TestXSLLineStyleProvider method initializeSourceViewer.

protected void initializeSourceViewer() {
    // some test environments might not have a "real" display
    if (Display.getCurrent() != null) {
        if (PlatformUI.isWorkbenchRunning()) {
            shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        } else {
            shell = new Shell(Display.getCurrent());
        }
        parent = new Composite(shell, SWT.NONE);
        // dummy viewer
        sourceViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
    } else {
        fail("Unable to run the test as a display must be available.");
    }
    configureSourceViewer();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer)

Example 59 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.

the class AbstractSourceViewerTest method initializeSourceViewer.

protected void initializeSourceViewer() {
    // some test environments might not have a "real" display
    if (Display.getCurrent() != null) {
        if (PlatformUI.isWorkbenchRunning()) {
            shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        } else {
            shell = new Shell(Display.getCurrent());
        }
        parent = new Composite(shell, SWT.NONE);
        // dummy viewer
        sourceViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
    } else {
        Assert.fail("Unable to run the test as a display must be available.");
    }
    configureSourceViewer();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer)

Example 60 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project liferay-ide by liferay.

the class AlloyTestsUtils method getWebSevicesProposals.

public static ICompletionProposal[] getWebSevicesProposals(IFile file, String elementName) throws Exception {
    final StructuredTextViewer viewer = getEditor(file).getTextViewer();
    final SourceViewerConfiguration srcViewConf = getSourceViewerConfiguraionFromOpenedEditor(file);
    final ContentAssistant contentAssistant = (ContentAssistant) srcViewConf.getContentAssistant(viewer);
    final String partitionTypeID = viewer.getDocument().getPartition(getElementContentEndOffset(file, elementName)).getType();
    final IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(partitionTypeID);
    final ICompletionProposal[] proposals = processor.computeCompletionProposals(viewer, getElementContentEndOffset(file, elementName));
    return proposals;
}
Also used : SourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewerConfiguration) IContentAssistProcessor(org.eclipse.jface.text.contentassist.IContentAssistProcessor) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ContentAssistant(org.eclipse.jface.text.contentassist.ContentAssistant) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer)

Aggregations

StructuredTextViewer (org.eclipse.wst.sse.ui.internal.StructuredTextViewer)62 StructuredTextEditor (org.eclipse.wst.sse.ui.StructuredTextEditor)21 IDocument (org.eclipse.jface.text.IDocument)19 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)18 IFile (org.eclipse.core.resources.IFile)14 SourceViewer (org.eclipse.jface.text.source.SourceViewer)14 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)14 Composite (org.eclipse.swt.widgets.Composite)13 Shell (org.eclipse.swt.widgets.Shell)13 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)12 StructuredTextViewerConfiguration (org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration)9 LineStyleProvider (org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider)8 ArrayList (java.util.ArrayList)7 BadLocationException (org.eclipse.jface.text.BadLocationException)6 Position (org.eclipse.jface.text.Position)6 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)6 List (java.util.List)5 Action (org.eclipse.jface.action.Action)4 IContributionManager (org.eclipse.jface.action.IContributionManager)4 Separator (org.eclipse.jface.action.Separator)4