• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IWorkingCopyManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:CompilationUnitEditor.java


示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:TogglePresentationAction.java


示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:JavaDocAutoIndentStrategy.java


示例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;
}
 
开发者ID:maximeAudrain,项目名称:jenerate,代码行数:11,代码来源:MethodGeneratorHandler.java


示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:TextSelectionConverter.java


示例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());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:AddImportOnSelectionAction.java


示例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());

}
 
开发者ID:helospark,项目名称:SparkBuilderGenerator,代码行数:7,代码来源:WorkingCopyManagerWrapper.java


示例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();
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:61,代码来源:BuilderUtilities.java


示例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);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:49,代码来源:CompilationUnitEditor.java


示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:FindBrokenNLSKeysAction.java



注:本文中的org.eclipse.jdt.ui.IWorkingCopyManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Node类代码示例发布时间:2022-05-22
下一篇:
Java Configuration类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap