本文整理汇总了Java中org.eclipse.jdt.ui.IWorkingCopyManager.getWorkingCopy方法的典型用法代码示例。如果您正苦于以下问题:Java IWorkingCopyManager.getWorkingCopy方法的具体用法?Java IWorkingCopyManager.getWorkingCopy怎么用?Java IWorkingCopyManager.getWorkingCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.ui.IWorkingCopyManager
的用法示例。
在下文中一共展示了IWorkingCopyManager.getWorkingCopy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findElement
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入方法依赖的package包/类
/**
* Returns the updated java element for the old java element.
*
* @param element Old Java element
* @return Updated Java element
*/
private IJavaElement findElement(IJavaElement element) {
if (element == null)
return null;
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
ICompilationUnit unit= manager.getWorkingCopy(getEditorInput());
if (unit != null) {
try {
JavaModelUtil.reconcile(unit);
IJavaElement[] findings= unit.findElements(element);
if (findings != null && findings.length > 0)
return findings[0];
} catch (JavaModelException x) {
JavaPlugin.log(x.getStatus());
// nothing found, be tolerant and go on
}
}
return null;
}
示例2: getCompilationUnit
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入方法依赖的package包/类
/**
* Returns the compilation unit of the compilation unit editor invoking the <code>AutoIndentStrategy</code>,
* might return <code>null</code> on error.
* @return the compilation unit represented by the document
*/
private static ICompilationUnit getCompilationUnit() {
IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null)
return null;
IWorkbenchPage page= window.getActivePage();
if (page == null)
return null;
IEditorPart editor= page.getActiveEditor();
if (editor == null)
return null;
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
ICompilationUnit unit= manager.getWorkingCopy(editor.getEditorInput());
if (unit == null)
return null;
return unit;
}
示例3: isEnabled
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入方法依赖的package包/类
@Override
protected boolean isEnabled(ISelection selection) {
if (selection.isEmpty()) {
JavaEditor editor= getEditor();
if (editor != null) {
// we check whether editor shows CompilationUnit
IEditorInput editorInput= editor.getEditorInput();
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
return manager.getWorkingCopy(editorInput) != null;
}
return false;
}
if (selection instanceof IStructuredSelection) {
Object o= ((IStructuredSelection)selection).getFirstElement();
if (o instanceof ICompilationUnit)
return true;
}
return super.isEnabled(selection);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JavaAddElementFromHistoryImpl.java
示例4: execute
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell parentShell = HandlerUtil.getActiveShell(event);
IEditorPart editor = HandlerUtil.getActiveEditor(event);
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
ICompilationUnit compilationUnit = manager.getWorkingCopy(editor.getEditorInput());
generate(event.getCommand().getId(), currentSelection, compilationUnit, parentShell);
return null;
}
示例5: getInput
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入方法依赖的package包/类
private static IJavaElement getInput(JavaEditor editor) {
if (editor == null)
return null;
IEditorInput input= editor.getEditorInput();
if (input instanceof IClassFileEditorInput)
return ((IClassFileEditorInput)input).getClassFile();
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
return manager.getWorkingCopy(input);
}
示例6: getCompilationUnit
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入方法依赖的package包/类
private ICompilationUnit getCompilationUnit () {
if (fEditor == null) {
return null;
}
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
return manager.getWorkingCopy(fEditor.getEditorInput());
}
示例7: getCurrentCompilationUnit
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入方法依赖的package包/类
public ICompilationUnit getCurrentCompilationUnit(ExecutionEvent event) {
IEditorPart editor = handlerUtilWrapper.getActiveEditor(event);
IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
return manager.getWorkingCopy(editor.getEditorInput());
}
示例8: doSave
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入方法依赖的package包/类
@Override
public void doSave(IProgressMonitor progressMonitor) {
IDocumentProvider p= getDocumentProvider();
if (p == null) {
// editor has been closed
return;
}
if (p.isDeleted(getEditorInput())) {
if (isSaveAsAllowed()) {
/*
* 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.
* Changed Behavior to make sure that if called inside a regular save (because
* of deletion of input element) there is a way to report back to the caller.
*/
performSaveAs(progressMonitor);
} else {
/*
* 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there
* Missing resources.
*/
Shell shell= getSite().getShell();
MessageDialog.openError(shell, JavaEditorMessages.CompilationUnitEditor_error_saving_title1, JavaEditorMessages.CompilationUnitEditor_error_saving_message1);
}
} else {
setStatusLineErrorMessage(null);
updateState(getEditorInput());
validateState(getEditorInput());
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
ICompilationUnit unit= manager.getWorkingCopy(getEditorInput());
if (unit != null) {
synchronized (unit) {
performSave(false, progressMonitor);
}
} else
performSave(false, progressMonitor);
}
}
示例9: getCompilationUnit
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入方法依赖的package包/类
private static ICompilationUnit getCompilationUnit(JavaEditor editor) {
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
ICompilationUnit cu= manager.getWorkingCopy(editor.getEditorInput());
return cu;
}