JDT:Open Resource Action代码阅读
来源:互联网 发布:直通车关键词软件 编辑:程序博客网 时间:2024/06/18 16:40
源码位于org.eclipse.ui.internal.ide.handlers.OpenResourceHandler类。
//弹出打开资源对话框private final Object[] queryFileResource() {final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();if (window == null) {return null;}final Shell parent = window.getShell(); //在整个工作空间final IContainer input = ResourcesPlugin.getWorkspace().getRoot(); //打开资源对话框final OpenResourceDialog dialog = new OpenResourceDialog(parent, input,IResource.FILE);final int resultCode = dialog.open();if (resultCode != Window.OK) {return null;}final Object[] result = dialog.getResult();return result;}//处理:利用编辑打开选中的资源(可选择使用内部或外部编辑器)public final Object execute(final ExecutionEvent event)throws ExecutionException {final List files = new ArrayList();if (event.getParameter(PARAM_ID_FILE_PATH) == null) {// Prompt the user for the resource to open.Object[] result = queryFileResource();if (result != null) {for (int i = 0; i < result.length; i++) {if (result[i] instanceof IFile) {files.add(result[i]);}}}} else {// Use the given parameter.final IResource resource = (IResource) event.getObjectParameterForExecution(PARAM_ID_FILE_PATH);if (!(resource instanceof IFile)) {throw new ExecutionException("filePath parameter must identify a file"); //$NON-NLS-1$}files.add(resource);}if (files.size() > 0) {final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();if (window == null) {throw new ExecutionException("no active workbench window"); //$NON-NLS-1$}final IWorkbenchPage page = window.getActivePage();if (page == null) {throw new ExecutionException("no active workbench page"); //$NON-NLS-1$}try {for (Iterator it = files.iterator(); it.hasNext();) {IDE.openEditor(page, (IFile) it.next(), true);//在编辑器中文件内容}} catch (final PartInitException e) {throw new ExecutionException("error opening file in editor", e); //$NON-NLS-1$}}return null;}
- JDT:Open Resource Action代码阅读
- open resource
- 调用JDT进行格式化代码
- SSH-Could not open ServletContext resource [/WEB-INF/action-servlet.xml]
- java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/action-servlet.xml]
- java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/action-servlet.xml]
- Java代码分析器(一): JDT入门
- jdt.core.formatter.CodeFormatter格式化java代码
- open vswitch研究: action
- Could not open ServletContext resource
- Could not open ServletContext resource
- Liferay PortletURL(Render, Action, Resource)
- open.c源代码阅读
- yarn-resource.java阅读笔记
- cannot create linked resource '/.org.eclipse.jdt.core.external.folders/.link0'. the parent resource is not accessible 解决办法
- 使用eclipse的JDT实现JAVA代码格式化功能
- 扩展 JDT 实现自动代码注释与格式化
- 扩展 JDT 实现自动代码注释与格式化
- 走穴
- iphone ios http 异步同步操作
- 架构基础及工作原理介绍
- Linux virtual server
- TCP/TLS/UDP 有什么区别?
- JDT:Open Resource Action代码阅读
- DOS批处理 删除文件中的空行
- python官方文档
- Windows Store apps开发[18]Metro Revealed Building Windows 8 apps with XAML and C#中文翻译全部汇总
- osg for android 学习之十一:从3dmax导出osg文件
- Chapter7 Linking(2)——CSAPP读书笔记
- 牛人博客
- 用SSH实现X11转发
- web学习—css样式表—css语法(二)