Search in sources :

Example 61 with ITextEditor

use of org.eclipse.ui.texteditor.ITextEditor in project linuxtools by eclipse.

the class SpecOutlinePageAdapterFactory method getAdapter.

@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
    if (IContentOutlinePage.class.equals(adapterType)) {
        if (adaptableObject instanceof ExtensionBasedTextEditor || adaptableObject instanceof SpecfileEditor) {
            ITextEditor specEditor = (ITextEditor) adaptableObject;
            IFile editorFile = specEditor.getEditorInput().getAdapter(IFile.class);
            if (editorFile.getLocation().toOSString().endsWith(".spec")) {
                // $NON-NLS-1$
                SpecfileContentOutlinePage page = new SpecfileContentOutlinePage(specEditor);
                page.setInput(specEditor.getEditorInput());
                return (T) page;
            }
        }
    }
    return null;
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IFile(org.eclipse.core.resources.IFile) SpecfileEditor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor) ExtensionBasedTextEditor(org.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor)

Example 62 with ITextEditor

use of org.eclipse.ui.texteditor.ITextEditor in project linuxtools by eclipse.

the class DoubleClickTest method testDoubleClickLine.

@Test
public void testDoubleClickLine() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testDoubleClickLine");
    doDoubleClick();
    IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    assertTrue("editor should be ITextEditor", editor instanceof ITextEditor);
    ITextEditor textEditor = (ITextEditor) editor;
    ISelection selection = textEditor.getSelectionProvider().getSelection();
    assertTrue("selection must be TextSelection", selection instanceof TextSelection);
    TextSelection textSelection = (TextSelection) selection;
    // zero-indexed
    int line = textSelection.getStartLine() + 1;
    assertEquals(frame.getLine(), line);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) TextSelection(org.eclipse.jface.text.TextSelection) ISelection(org.eclipse.jface.viewers.ISelection) IEditorPart(org.eclipse.ui.IEditorPart) Test(org.junit.Test)

Aggregations

ITextEditor (org.eclipse.ui.texteditor.ITextEditor)62 IEditorPart (org.eclipse.ui.IEditorPart)27 IDocument (org.eclipse.jface.text.IDocument)24 Test (org.junit.Test)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)13 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)12 IFile (org.eclipse.core.resources.IFile)10 BadLocationException (org.eclipse.jface.text.BadLocationException)9 ISelection (org.eclipse.jface.viewers.ISelection)9 PartInitException (org.eclipse.ui.PartInitException)9 AbstractQueuedBuildDataTest (org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest)9 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)9 TextSelection (org.eclipse.jface.text.TextSelection)6 Annotation (org.eclipse.jface.text.source.Annotation)6 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)6 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)5 Position (org.eclipse.jface.text.Position)5 AbstractTextSearchResult (org.eclipse.search.ui.text.AbstractTextSearchResult)5 IWorkbench (org.eclipse.ui.IWorkbench)5 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)5