[英]WorkSpace from an Eclipse Application
I am creating a standalone eclipse application and I need to acquire my workspace from the application. 我正在创建一个独立的Eclipse应用程序,我需要从该应用程序获取我的工作区。 I don't want an Eclipse plugin as it wont solve my purpose. 我不想要Eclipse插件,因为它无法解决我的目的。
IWorkSpaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
But this is gives me an exception as the workspace is closed. 但这是我的例外,因为工作区已关闭。 Either my current workspace or any new workspace which could be accessed using a standalone application would solve my purpose. 我当前的工作空间或可以使用独立应用程序访问的任何新工作空间都可以解决我的目的。
Does Manifest.MF
contain the org.eclipse.core.resources
in the Require-bundle of your plugin? Manifest.MF
是否在插件的Require-bundle中包含org.eclipse.core.resources
?
And do you launch your Application as a plugin ? 您是否将应用程序作为插件启动? (not as a 'Java Application') (不作为“ Java应用程序”)
You can access the workspace from the resources plugin class (defined in
org.eclipse.core.resources
). 您可以从资源插件类(在org.eclipse.core.resources
定义)访问工作空间。When the resources plug-in is not running, the workspace exists solely in the file system and is viewed or manipulated by the user via standard file-based tools. 当资源插件未运行时,工作空间仅存在于文件系统中,并且用户可以通过基于标准文件的工具对其进行查看或操作。 Let's look at what a workspace looks like on disk as we explain the resources plug-in API. 在解释资源插件API时,让我们看一下磁盘上的工作区是什么样的。
See Book for more details. 有关更多详细信息,请参见预订 。
As a Java application, you cannot use ResourcesPlugin functions. 作为Java应用程序,您不能使用ResourcesPlugin函数。 So you need to access resources through classic File resources. 因此,您需要通过经典的文件资源访问资源。
I use the below dirty workaround for this issue. 我针对此问题使用了以下肮脏的解决方法。 You will need to manually updated the configuration for your RCP standalone. 您将需要手动更新RCP独立配置。
osgi.instance.area.default=<Workspace Loc>
编辑config.ini文件的最后一行: osgi.instance.area.default=<Workspace Loc>
osgi.instance.area.default=D:/WorkspaceFolder/WorkspaceNew
例如: osgi.instance.area.default=D:/WorkspaceFolder/WorkspaceNew
Important: Forward Slash (/) should be used as separator when specifying the workspace. 重要说明:指定工作区时,应使用正斜杠(/)作为分隔符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.