本文整理汇总了Java中org.eclipse.jdt.ui.IWorkingCopyManager类的典型用法代码示例。如果您正苦于以下问题:Java IWorkingCopyManager类的具体用法?Java IWorkingCopyManager怎么用?Java IWorkingCopyManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWorkingCopyManager类属于org.eclipse.jdt.ui包,在下文中一共展示了IWorkingCopyManager类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: update
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入依赖的package包/类
@Override
public void update() {
ITextEditor editor= getTextEditor();
boolean checked= (editor != null && editor.showsHighlightRangeOnly());
setChecked(checked);
if (editor instanceof CompilationUnitEditor) {
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
setEnabled(manager.getWorkingCopy(editor.getEditorInput()) != null);
} else if (editor instanceof ClassFileEditor) {
IEditorInput input= editor.getEditorInput();
IClassFile cf= null;
if (input instanceof IClassFileEditorInput) {
IClassFileEditorInput cfi= (IClassFileEditorInput)input;
cf= cfi.getClassFile();
}
setEnabled(cf != null && cf.exists());
} else
setEnabled(editor != null);
}
示例3: 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;
}
示例4: 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
示例5: 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;
}
示例6: 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);
}
示例7: 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());
}
示例8: 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());
}
示例9: revalidateCompilationUnits
import org.eclipse.jdt.ui.IWorkingCopyManager; //导入依赖的package包/类
/**
* Forces re-validation of a set of compilation units by the JDT Java Builder.
*
* @param cus the compilation units to re-validate
* @param description a brief description of the external job that forcing the
* re-validation. This shows up in the Eclipse status bar while
* re-validation is taking place.
*/
public static void revalidateCompilationUnits(
final Set<ICompilationUnit> cus, String description) {
WorkspaceJob revalidateJob = new WorkspaceJob(description) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor)
throws CoreException {
final IWorkingCopyManager wcManager = JavaPlugin.getDefault().getWorkingCopyManager();
for (ICompilationUnit cu : cus) {
if (!cu.getResource().exists()) {
CorePluginLog.logWarning(MessageFormat.format(
"Cannot revalidate non-existent compilation unit {0}",
cu.getElementName()));
continue;
}
final IEditorPart editorPart = getOpenEditor(cu);
/*
* If the .java file is open in an editor (without unsaved changes),
* make a "null" edit by inserting an empty string at the top of the
* file and then tell the editor to save. If incremental building is
* enabled, this will trigger a re-validation of the file.
*/
if (editorPart != null && !editorPart.isDirty()) {
// Need to do the editor stuff from the UI thread
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
// Get the working copy open in the editor
ICompilationUnit wc = wcManager.getWorkingCopy(editorPart.getEditorInput());
wc.getBuffer().replace(0, 0, "");
editorPart.doSave(new NullProgressMonitor());
} catch (JavaModelException e) {
CorePluginLog.logError(e);
}
}
});
} else {
/*
* If the .java file is not currently open, or if it's open with
* unsaved changes, trigger re-validation by touching the underlying
* resource.
*/
cu.getResource().touch(null);
}
}
return StatusUtilities.OK_STATUS;
}
};
revalidateJob.schedule();
}
示例10: 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);
}
}
示例11: 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;
}