Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Access EMF Model from Resources of Deployed plugin- "Not workspace"
Access EMF Model from Resources of Deployed plugin- "Not workspace" [message #1223213] Sun, 22 December 2013 19:55 Go to next message
Salwa Alzahmi is currently offline Salwa AlzahmiFriend
Messages: 37
Registered: June 2013
Member
Hi,
I have an EMF model stored in my plugin under directory /models/devices.pvt
so to access the files in the deployed plugin I used :
Bundle bundle = Platform.getBundle("com.arean.system");
String filePath = FileLocator.resolve(bundle.getEntry("/models/devices.pvt ")).getFile();

Is there is a way to create IFile from the file path.

usually I used blow code to access the one in the workspace , but definitely it is not the same when access plugin resources.

IFile modelFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path.append(fileName));


appreciate anyhelp
salwa
Re: Access EMF Model from Resources of Deployed plugin- "Not workspace" [message #1223362 is a reply to message #1223213] Mon, 23 December 2013 06:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Salwa,

Comments below.

On 22/12/2013 8:55 PM, Salwa Alzahmi wrote:
> Hi, I have an EMF model stored in my plugin under directory
> /models/devices.pvt so to access the files in the deployed plugin I
> used :
> Bundle bundle = Platform.getBundle("com.arean.system"); String
> filePath = FileLocator.resolve(bundle.getEntry("/models/devices.pvt
> ")).getFile();
You can use
URI.createPlatformPluginURI("/com.arean.system/models/devices.pvt") to
create a URI that can be used to load that resource in a resource set; I
believe a file locator as you've used will cause the jarred bundle to be
unpacked, which isn't necessary...
>
> Is there is a way to create IFile from the file path.
No, not if the file isn't in the workspace. But it doesn't need to be
in the workspace in order to load it into a resource set, you only need
the URI that accesses it as I showed above.
>
> usually I used blow code to access the one in the workspace , but
> definitely it is not the same when access plugin resources.
>
> IFile modelFile =
> ResourcesPlugin.getWorkspace().getRoot().getFile(path.append(fileName));
>
>
> appreciate anyhelp
> salwa


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Access EMF Model from Resources of Deployed plugin- "Not workspace" [message #1223405 is a reply to message #1223362] Mon, 23 December 2013 09:39 Go to previous messageGo to next message
Salwa Alzahmi is currently offline Salwa AlzahmiFriend
Messages: 37
Registered: June 2013
Member
Hi Ed and thank for your reply,

I have used this to load the resources ..
ResourceSet resourceSet = new ResourceSetImpl();
URI fileUri = URI.createPlatformPluginURI("/com.arean.system/models/devices.pvt", false) ;
resource .load(null);

still I need to get the IFile to this resources , so I can set it as an input to my editor . ???
salwa
Re: Access EMF Model from Resources of Deployed plugin- "Not workspace" [message #1223410 is a reply to message #1223405] Mon, 23 December 2013 09:53 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Salwa,

Firstly you can only have IFiles for things in the workspace, and this
file is not in the workspace, so no you can't get that. Secondly, it is
a resource in your bundle so you should not be modifying it. Thirdly,
there's org.eclipse.emf.common.ui.URIEditorInput for opening an editor
for a URI.


On 23/12/2013 10:39 AM, Salwa Alzahmi wrote:
> Hi Ed and thank for your reply,
> I have used this to load the resources ..
> ResourceSet resourceSet = new ResourceSetImpl();
> URI fileUri =
> URI.createPlatformPluginURI("/com.arean.system/models/devices.pvt",
> false) ;
> resource .load(null);
>
> still I need to get the IFile to this resources , so I can set it as
> an input to my editor . ???
> salwa


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:models referencing across editors
Next Topic:[Edapt] visualizing the migration process
Goto Forum:
  


Current Time: Thu Mar 28 23:50:13 GMT 2024

Powered by FUDForum. Page generated in 0.03088 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top