Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Re: create file
Re: create file [message #181602] Wed, 09 April 2008 12:14 Go to next message
Eclipse UserFriend
Originally posted by: marsha.rohrer.swisscom.com

Hi,

I'm trying to create my model and diagram file programmatically. And I did
it following this thread
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg11278.html.

I get the exception posted bellow, what am I doing wrong? (I want to
create the resources from an other plugin but I don't think that this is a
problem)

Thank you for your help
Marsha

!MESSAGE Unable to set charset for file /asdf/pluginTest.gfme
!STACK 1
org.eclipse.core.internal.resources.ResourceException: Resource
'/asdf/pluginTest.gfme' does not exist.
at
org.eclipse.core.internal.resources.Resource.checkExists(Res ource.java:310)
at
org.eclipse.core.internal.resources.Resource.checkAccessible (Resource.java:193)
at org.eclipse.core.internal.resources.File.setCharset(File.jav a:434)
at
gfme.diagram.part.GfmeDiagramEditorUtil.setCharset(GfmeDiagr amEditorUtil.java:97)
at
gfme.diagram.part.GfmeDiagramEditorUtil.createDiagram(GfmeDi agramEditorUtil.java:209)
at
com.swisscom.oms.plugins.gamemergertwo.OpenGfmeDiagramAction .run(OpenGfmeDiagramAction.java:49)
at
org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:256)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:546)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:490)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:402)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 19)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:289)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:169)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:363)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
Re: create file [message #181608 is a reply to message #181602] Wed, 09 April 2008 12:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

Maybe your URI is not correct?


Cheers,

Tomas

Marsha wrote:
> Hi,
>
> I'm trying to create my model and diagram file programmatically. And I
> did it following this thread
> http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg11278.html.
> I get the exception posted bellow, what am I doing wrong? (I want to
> create the resources from an other plugin but I don't think that this is
> a problem)
>
> Thank you for your help
> Marsha
>
> !MESSAGE Unable to set charset for file /asdf/pluginTest.gfme
> !STACK 1
> org.eclipse.core.internal.resources.ResourceException: Resource
> '/asdf/pluginTest.gfme' does not exist.
> at
> org.eclipse.core.internal.resources.Resource.checkExists(Res ource.java:310)
> at
> org.eclipse.core.internal.resources.Resource.checkAccessible (Resource.java:193)
>
> at org.eclipse.core.internal.resources.File.setCharset(File.jav a:434)
> at
> gfme.diagram.part.GfmeDiagramEditorUtil.setCharset(GfmeDiagr amEditorUtil.java:97)
>
> at
> gfme.diagram.part.GfmeDiagramEditorUtil.createDiagram(GfmeDi agramEditorUtil.java:209)
>
> at
> com.swisscom.oms.plugins.gamemergertwo.OpenGfmeDiagramAction .run(OpenGfmeDiagramAction.java:49)
>
> at
> org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:256)
> at
> org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:546)
>
> at
> org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:490)
>
> at
> org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:402)
>
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3682)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3293)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2389)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 19)
> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:289)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:461)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:169)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:363)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:176)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 508)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
>
Re: create file [message #181840 is a reply to message #181608] Wed, 09 April 2008 12:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marsha.rohrer.swisscom.com

> Maybe your URI is not correct?
I think it is.

The code you posted earlier is invoked whithin the run() method of an
Action. This action can be lauched with the context menu of a project. The
aim of that method is to merge all *.editor1 files into the model (and
later diagram) file and to visualize it as *.editor2_diagram.

In the electionChanged() method I fetch the URI of the project as follows:

IProject project = (IProject) structuredSelection.getFirstElement();
basePath = project.getLocationURI();

Then I try to set up the URI for the model and the diagram:

URI diagramURI = URI.createURI(basePath + "/pluginTest.gfme_diagram");
URI modelURI = URI.createURI(basePath + "/pluginTest.gfme");

I checked the coresponding folder and those files are being created...

Is it a problem that I'm trying to use the same project folder? Or does
getLocationURI() not return the URI needed (no error markers in my code)?

Thanks,
Marsha
Re: create file [message #181856 is a reply to message #181840] Wed, 09 April 2008 13:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Marsha,

Comments below.

Marsha wrote:
>
>> Maybe your URI is not correct?
> I think it is.
>
> The code you posted earlier is invoked whithin the run() method of an
> Action. This action can be lauched with the context menu of a project.
> The aim of that method is to merge all *.editor1 files into the model
> (and later diagram) file and to visualize it as *.editor2_diagram.
> In the electionChanged() method I fetch the URI of the project as
> follows:
>
> IProject project = (IProject) structuredSelection.getFirstElement();
> basePath = project.getLocationURI();
Not a good idea. This is the physical location of the project. Use
URI.createPlatformResourceURI("/" + project.getName + "/...) to get a
logical URI that will reference the workspace properly..
>
> Then I try to set up the URI for the model and the diagram:
>
> URI diagramURI = URI.createURI(basePath + "/pluginTest.gfme_diagram");
> URI modelURI = URI.createURI(basePath + "/pluginTest.gfme");
>
> I checked the coresponding folder and those files are being created...
>
> Is it a problem that I'm trying to use the same project folder? Or
> does getLocationURI() not return the URI needed (no error markers in
> my code)?
Yes, it's not the URI you should be using...
>
> Thanks,
> Marsha
>
Re: create file [message #181880 is a reply to message #181856] Wed, 09 April 2008 13:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marsha.rohrer.swisscom.com

Hi Ed,

Thanks a lot, that works perfectly. The method you recommend me to use is
deprecated however.

I saw that URI.createPlatformResourceURI(String pathName, boolean encode)
isn't. What does this boolean value effect?

Thank you,
Marsha
Re: create file [message #181898 is a reply to message #181880] Wed, 09 April 2008 13:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Marsha,

Oops. :-) The boolean determines whether to encode characters that are
normally not used in a URI, like space. It's best to always use true
except in the rare case that you know the string is already encoded...


Marsha wrote:
> Hi Ed,
>
> Thanks a lot, that works perfectly. The method you recommend me to use
> is deprecated however.
> I saw that URI.createPlatformResourceURI(String pathName, boolean
> encode) isn't. What does this boolean value effect?
>
> Thank you,
> Marsha
>
Re: create file [message #181906 is a reply to message #181898] Wed, 09 April 2008 13:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marsha.rohrer.swisscom.com

Thanks you very much for your help.

Cheers,
Marsha
Re: create file [message #181938 is a reply to message #181856] Wed, 09 April 2008 14:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

I've been trying to launch an editor from a context-menu myself. My
problem is that while it works great in the "File menu", I can't get it
to work in a popup-menu for the diagram.

Have you accomplished this Marsha? (could you show me your solution if
you have?)


Best Regards,

Tomas Zijdemans

Ed Merks wrote:
> Marsha,
>
> Comments below.
>
> Marsha wrote:
>>
>>> Maybe your URI is not correct?
>> I think it is.
>>
>> The code you posted earlier is invoked whithin the run() method of an
>> Action. This action can be lauched with the context menu of a project.
>> The aim of that method is to merge all *.editor1 files into the model
>> (and later diagram) file and to visualize it as *.editor2_diagram.
>> In the electionChanged() method I fetch the URI of the project as
>> follows:
>>
>> IProject project = (IProject) structuredSelection.getFirstElement();
>> basePath = project.getLocationURI();
> Not a good idea. This is the physical location of the project. Use
> URI.createPlatformResourceURI("/" + project.getName + "/...) to get a
> logical URI that will reference the workspace properly..
>>
>> Then I try to set up the URI for the model and the diagram:
>>
>> URI diagramURI = URI.createURI(basePath + "/pluginTest.gfme_diagram");
>> URI modelURI = URI.createURI(basePath + "/pluginTest.gfme");
>>
>> I checked the coresponding folder and those files are being created...
>>
>> Is it a problem that I'm trying to use the same project folder? Or
>> does getLocationURI() not return the URI needed (no error markers in
>> my code)?
> Yes, it's not the URI you should be using...
>> Thanks,
>> Marsha
>>
Re: create file [message #182041 is a reply to message #181938] Thu, 10 April 2008 07:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marsha.rohrer.swisscom.com

Hi Tomas,

> I've been trying to launch an editor from a context-menu myself. My
> problem is that while it works great in the "File menu", I can't get it
> to work in a popup-menu for the diagram.

What do you mean by popup-menu for the diagram? Are you talking of the
context menu that appears when right-clicking into the diagram canvas or
on a diagram element directly?

> Have you accomplished this Marsha? (could you show me your solution if
> you have?)

Actually my popup menu extension is established with a object contribution
with the following object class org.eclipse.core.resources.IProject. But
if you explain me in more detail what you are trying to do maybe I can
help you...

Greets,
Marsha
Re: create file [message #182166 is a reply to message #182041] Thu, 10 April 2008 12:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

Hi Marsha.

Sorry, I can see now that I was quite unclear, comments below.


> What do you mean by popup-menu for the diagram? Are you talking of the
> context menu that appears when right-clicking into the diagram canvas

Yes. I've added an action to it that I want to launch a new editor/diagram.

> if you explain me in more
> detail what you are trying to do maybe I can help you...

What I want is to right click an element an select to launch another
editor/diagram. I've accomplished to make such an action in the File
menu (with an IWorkbenchWindowActionDelegate). This works because the
action is located in that plugins ...part/ package.

Say we have plugin A and B. I want to launch editor B from an object in A.

I create a standard IObjectActionDelegate for the object in A. This
action is located in A's ...part/ package. When I call
"EditorDiagramEditorUtil.createDiagram..." in that action it creates an
A diagram (because it only have access to A's classes, not B's)


Thanks for helping,

Tomas Zijdemans
Re: create file [message #182278 is a reply to message #182166] Thu, 10 April 2008 14:03 Go to previous message
Eclipse UserFriend
Originally posted by: marsha.rohrer.swisscom.com

Hi Tomas

> What I want is to right click an element an select to launch another
> editor/diagram. I've accomplished to make such an action in the File
> menu (with an IWorkbenchWindowActionDelegate). This works because the
> action is located in that plugins ...part/ package.

> Say we have plugin A and B. I want to launch editor B from an object in A.

> I create a standard IObjectActionDelegate for the object in A. This
> action is located in A's ...part/ package. When I call
> "EditorDiagramEditorUtil.createDiagram..." in that action it creates an
> A diagram (because it only have access to A's classes, not B's)

So if I get you right you have to plugins one XXX.a.diagram and the other
XXX.b.diagram. So you also have the corresponding ADiagramEditorUtil and
BDiagramEditorUtil classes in those plugins right? If you want to open a B
diagram you have to use BDiagramEditorUtil.createDiagram().

The context menu I'm using is established in a plugin apart from my editor
plugins. To be able to create the editor I have to add the specific editor
plugin into the plugin dependencies of the "context menu plugin". In your
case you should include the B editor plugin to the plugin dependencies to
be able to create such a diagram.

But I'm not sure if I got you right although...

Greets,
Marsha
Previous Topic:Generate Figures Plug-in
Next Topic:Putting labels on both sides of a link
Goto Forum:
  


Current Time: Thu Apr 25 10:04:51 GMT 2024

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

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

Back to the top