本文整理汇总了Java中org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.getEditorInputJavaElement方法的典型用法代码示例。如果您正苦于以下问题:Java EditorUtility.getEditorInputJavaElement方法的具体用法?Java EditorUtility.getEditorInputJavaElement怎么用?Java EditorUtility.getEditorInputJavaElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.ui.javaeditor.EditorUtility
的用法示例。
在下文中一共展示了EditorUtility.getEditorInputJavaElement方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShell(event);
ISelection sel = HandlerUtil.getActiveMenuSelection(event);
ICompilationUnit cu = null;
if (sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
Object el = selection.getFirstElement();
if (el instanceof ICompilationUnit)
cu = (ICompilationUnit) el;
} else if (HandlerUtil.getActivePartId(event).equals("org.eclipse.jdt.ui.CompilationUnitEditor")) {
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
cu = (ICompilationUnit) EditorUtility.getEditorInputJavaElement(editor, false);
}
if (cu != null) {
doRename(shell, cu);
} else {
MessageDialog.openInformation(shell, "Info", "Please select a Java source file");
}
return null;
}
示例2: getCompilationUnit
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
/**
* Returns the compilation unit that content assist is invoked in, <code>null</code> if there
* is none.
*
* @return the compilation unit that content assist is invoked in, possibly <code>null</code>
*/
public ICompilationUnit getCompilationUnit() {
if (!fCUComputed) {
fCUComputed= true;
if (fCollector != null)
fCU= fCollector.getCompilationUnit();
else {
IJavaElement je= EditorUtility.getEditorInputJavaElement(fEditor, false);
if (je instanceof ICompilationUnit)
fCU= (ICompilationUnit)je;
}
}
return fCU;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:JavaContentAssistInvocationContext.java
示例3: run
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
@Override
public final void run() {
IJavaElement inputElement= EditorUtility.getEditorInputJavaElement(fEditor, false);
if (!(inputElement instanceof ITypeRoot && inputElement.exists()))
return;
ITypeRoot typeRoot= (ITypeRoot) inputElement;
ISourceRange sourceRange;
try {
sourceRange= typeRoot.getSourceRange();
if (sourceRange == null || sourceRange.getLength() == 0) {
MessageDialog.openInformation(fEditor.getEditorSite().getShell(),
SelectionActionMessages.StructureSelect_error_title,
SelectionActionMessages.StructureSelect_error_message);
return;
}
} catch (JavaModelException e) {
}
ITextSelection selection= getTextSelection();
ISourceRange newRange= getNewSelectionRange(createSourceRange(selection), typeRoot);
// Check if new selection differs from current selection
if (selection.getOffset() == newRange.getOffset() && selection.getLength() == newRange.getLength())
return;
fSelectionHistory.remember(new SourceRange(selection.getOffset(), selection.getLength()));
try {
fSelectionHistory.ignoreSelectionChanges();
fEditor.selectAndReveal(newRange.getOffset(), newRange.getLength());
} finally {
fSelectionHistory.listenToSelectionChanges();
}
}
示例4: install
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
@Override
public void install(ITextViewer textViewer) {
super.install(textViewer);
fPartListener= new PartListener();
IWorkbenchPartSite site= fTextEditor.getSite();
IWorkbenchWindow window= site.getWorkbenchWindow();
window.getPartService().addPartListener(fPartListener);
fActivationListener= new ActivationListener(textViewer.getTextWidget());
Shell shell= window.getShell();
shell.addShellListener(fActivationListener);
fJavaElementChangedListener= new ElementChangedListener();
JavaCore.addElementChangedListener(fJavaElementChangedListener);
fResourceChangeListener= new ResourceChangeListener();
IWorkspace workspace= JavaPlugin.getWorkspace();
workspace.addResourceChangeListener(fResourceChangeListener);
fPropertyChangeListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (SpellingService.PREFERENCE_SPELLING_ENABLED.equals(event.getProperty()) || SpellingService.PREFERENCE_SPELLING_ENGINE.equals(event.getProperty()))
forceReconciling();
}
};
JavaPlugin.getDefault().getCombinedPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
fReconciledElement= EditorUtility.getEditorInputJavaElement(fTextEditor, false);
}
示例5: firePostSelectionChanged
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
/**
* A post selection event has occurred.
*
* @param selection the selection
*/
public void firePostSelectionChanged(final ITextSelection selection) {
if (fCurrentJob != null) {
fCurrentJob.cancel();
}
IJavaElement input= EditorUtility.getEditorInputJavaElement(fPart, false);
if (!(input instanceof ITypeRoot)) {
return;
}
final ITypeRoot typeRoot= (ITypeRoot) input;
fCurrentJob= new Job(JavaUIMessages.SelectionListenerWithASTManager_job_title) {
@Override
public IStatus run(IProgressMonitor monitor) {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
synchronized (fJobLock) {
return calculateASTandInform(typeRoot, selection, monitor);
}
}
};
fCurrentJob.setPriority(Job.DECORATE);
fCurrentJob.setSystem(true);
fCurrentJob.schedule();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:SelectionListenerWithASTManager.java
示例6: getCompilationUnit
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
/**
* Returns the compilation unit that content assist is invoked in, <code>null</code> if there
* is none.
*
* @return the compilation unit that content assist is invoked in, possibly <code>null</code>
*/
public ICompilationUnit getCompilationUnit() {
if (!fCUComputed) {
fCUComputed= true;
if (fCollector != null)
fCU= fCollector.getCompilationUnit();
else {
IJavaElement je= EditorUtility.getEditorInputJavaElement(fEditor, false);
if (je instanceof ICompilationUnit)
fCU= (ICompilationUnit)je;
}
}
return fCU;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:JavaContentAssistInvocationContext.java
示例7: resolveCompilationUnit
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
public static ITypeRoot resolveCompilationUnit(ITextEditor textEditor) {
return EditorUtility.getEditorInputJavaElement(textEditor, true);
}
示例8: getCompilationUnit
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
private ICompilationUnit getCompilationUnit() {
return (ICompilationUnit) EditorUtility.getEditorInputJavaElement(fEditor, false);
}
示例9: getInputElement
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
private IJavaElement getInputElement() {
if (fEditor == null)
return null;
return EditorUtility.getEditorInputJavaElement(fEditor, false);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:DefaultJavaFoldingStructureProvider.java
示例10: getEditorInputJavaElement
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
protected ITypeRoot getEditorInputJavaElement() {
IEditorPart editor= getEditor();
if (editor != null)
return EditorUtility.getEditorInputJavaElement(editor, false);
return null;
}
示例11: getInput
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; //导入方法依赖的package包/类
/**
* Returns the input element of the given editor.
*
* @param editor the Java editor
* @param primaryOnly if <code>true</code> only primary working copies will be returned
* @return the type root which is the editor input, or <code>null</code> if none
* @since 3.2
*/
private static ITypeRoot getInput(JavaEditor editor, boolean primaryOnly) {
if (editor == null)
return null;
return EditorUtility.getEditorInputJavaElement(editor, primaryOnly);
}