EclipseJDT ASTViewer Source Viewer

Home|eclipse_jdt_astviewer/src/org/eclipse/jdt/astview/EditorUtility.java
1/*******************************************************************************
2 * Copyright (c) 2000, 2007 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 *     IBM Corporation - initial API and implementation
13 *******************************************************************************/
14package org.eclipse.jdt.astview;
15
16
17import org.eclipse.ui.IEditorInput;
18import org.eclipse.ui.IEditorPart;
19import org.eclipse.ui.IWorkbenchPage;
20import org.eclipse.ui.IWorkbenchWindow;
21import org.eclipse.ui.PlatformUI;
22
23import org.eclipse.ui.texteditor.ITextEditor;
24
25import org.eclipse.jdt.core.IJavaElement;
26import org.eclipse.jdt.core.ITypeRoot;
27
28import org.eclipse.jdt.ui.JavaUI;
29
30/**
31 *
32 */
33public class EditorUtility {
34    private EditorUtility() {
35        super();
36    }
37
38    public static IEditorPart getActiveEditor() {
39        IWorkbenchWindow windowPlatformUI.getWorkbench().getActiveWorkbenchWindow();
40        if (window != null) {
41            IWorkbenchPage pagewindow.getActivePage();
42            if (page != null) {
43                return page.getActiveEditor();
44            }
45        }
46        return null;
47    }
48
49    public static ITypeRoot getJavaInput(IEditorPart part) {
50        IEditorInput editorInputpart.getEditorInput();
51        if (editorInput != null) {
52            IJavaElement inputJavaUI.getEditorInputJavaElement(editorInput);
53            if (input instanceof ITypeRoot) {
54                return (ITypeRootinput;
55            }
56        }
57        return null;
58    }
59
60    public static void selectInEditor(ITextEditor editorint offsetint length) {
61        IEditorPart active = getActiveEditor();
62        if (active != editor) {
63            editor.getSite().getPage().activate(editor);
64        }
65        editor.selectAndReveal(offsetlength);
66    }
67}
68
MembersX
EditorUtility:getActiveEditor:Block:Block:page
EditorUtility:getActiveEditor:Block:window
EditorUtility:getJavaInput:Block:Block:input
EditorUtility:EditorUtility
EditorUtility:selectInEditor
EditorUtility:selectInEditor:Block:active
EditorUtility:getJavaInput
EditorUtility:getJavaInput:Block:editorInput
EditorUtility:getActiveEditor
Members
X