Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » EFS usage in RCP (no workspace)
EFS usage in RCP (no workspace) [message #869806] Fri, 04 May 2012 11:10 Go to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
Hi,
I'm trying to use a custom EFS derived from my EMF model.
I got partial success by doing the following:

public class WorldFileSystem extends FileSystem {

private static Map<URI, Model> worldModelCache = new HashMap<URI, Model>();

public static WorldFileSystem getInstance(Model model) {
try {
WorldFileSystem wfs = (WorldFileSystem) (EFS.getFileSystem("world"));
if (!worldModelCache.containsValue(model)) {
wfs.createWorld(model);
worldModelCache.put(model.getResource().getURI(), model);
}
return wfs;
} catch (CoreException e) {
e.printStackTrace();
}
return null;
}
....

wfs.createWorld(model) actually walks the EMF model and creates a bunch of "WorldFileStore extends FileStore" for each of the "interesting" EObjects.

I then can open a "file" in EFS by doing:

public IEditorInput createEditorInput(Scene scene) {
WorldFileSystem wfs = WorldFileSystem.getInstance(model);
URI u = scene.eResource().getURI().appendFragment(scene.eResource().getURIFragment(scene));
String s = u.toString();
s = s.replaceFirst("^[^:]+:", "world:");
java.net.URI uri;
try {
uri = new java.net.URI(s);
IFileStore ifs = wfs.getStore(uri);
IEditorInput iei = new FileStoreEditorInput(ifs);
return iei;
} catch (URISyntaxException e) {
e.printStackTrace();
}
return null;
}

All this works as expected, but I'm obviously missing one step: The actual creation of a link.
This becomes evident when I try to create a Marker because

FileStoreEditorInput fsei = ...
IFile[] fa = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(fsei.getURI());

returns an empty IFile[].
I tried following the path and I think the problem is the AliasManager knows nothing about my added Resource.
As said I *think* the root problem is I am not properly creating a linked resource, but I don't know how I should do it.
All references I found are about "regular" projects with a Workspace/Project structure while I currently open my Resourceby:

URI uri = file.toURI();
try {
IFileStore fs = EFS.getStore(uri);
IEditorInput ei = new LocalEditorInput(fs);
IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
try {
page.openEditor(ei, WorldEditor.ID);
....

Can someone help me sort this mess, pretti please?

TiA
Mauro
Re: EFS usage in RCP (no workspace) [message #870307 is a reply to message #869806] Mon, 07 May 2012 15:42 Go to previous message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
Uhm,
no answers?
Is this the right place to ask questions about EFS?
Should I post somewhere else?

Thanks in Advance
Mauro

On 04/05/2012 13:10, Mauro Condarelli wrote:
> Hi,
> I'm trying to use a custom EFS derived from my EMF model.
> I got partial success by doing the following:
>
> public class WorldFileSystem extends FileSystem {
>
> private static Map<URI, Model> worldModelCache = new HashMap<URI, Model>();
>
> public static WorldFileSystem getInstance(Model model) {
> try {
> WorldFileSystem wfs = (WorldFileSystem) (EFS.getFileSystem("world"));
> if (!worldModelCache.containsValue(model)) {
> wfs.createWorld(model);
> worldModelCache.put(model.getResource().getURI(), model);
> }
> return wfs;
> } catch (CoreException e) {
> e.printStackTrace();
> }
> return null;
> }
> ...
>
> wfs.createWorld(model) actually walks the EMF model and creates a bunch of "WorldFileStore extends FileStore" for each of the "interesting" EObjects.
>
> I then can open a "file" in EFS by doing:
>
> public IEditorInput createEditorInput(Scene scene) {
> WorldFileSystem wfs = WorldFileSystem.getInstance(model);
> URI u = scene.eResource().getURI().appendFragment(scene.eResource().getURIFragment(scene));
> String s = u.toString();
> s = s.replaceFirst("^[^:]+:", "world:");
> java.net.URI uri;
> try {
> uri = new java.net.URI(s);
> IFileStore ifs = wfs.getStore(uri);
> IEditorInput iei = new FileStoreEditorInput(ifs);
> return iei;
> } catch (URISyntaxException e) {
> e.printStackTrace();
> }
> return null;
> }
>
> All this works as expected, but I'm obviously missing one step: The actual creation of a link.
> This becomes evident when I try to create a Marker because
>
> FileStoreEditorInput fsei = ...
> IFile[] fa = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(fsei.getURI());
>
> returns an empty IFile[].
> I tried following the path and I think the problem is the AliasManager knows nothing about my added Resource.
> As said I *think* the root problem is I am not properly creating a linked resource, but I don't know how I should do it.
> All references I found are about "regular" projects with a Workspace/Project structure while I currently open my Resourceby:
>
> URI uri = file.toURI();
> try {
> IFileStore fs = EFS.getStore(uri);
> IEditorInput ei = new LocalEditorInput(fs);
> IWorkbenchWindow window = PlatformUI.getWorkbench()
> .getActiveWorkbenchWindow();
> IWorkbenchPage page = window.getActivePage();
> try {
> page.openEditor(ei, WorldEditor.ID);
> ...
>
> Can someone help me sort this mess, pretty please?
>
> TiA
> Mauro
Previous Topic:Plugin org.eclipse.core.runtime in target but invisible for plugins
Next Topic:RCP plugin to use logic disigner
Goto Forum:
  


Current Time: Tue Mar 19 11:54:50 GMT 2024

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

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

Back to the top