Saving a file from the editor [message #723387] |
Thu, 08 September 2011 12:53 |
amalia.msanusi Messages: 6 Registered: March 2011 |
Junior Member |
|
|
Hello,
I've created a statechart editor and I did some customization similar to the GMF Mindmap Tutorial 3.
Basically when I right click the diagram, a model transformation is done, which is executed using Command. This seems to work except that I can't save the transformed diagram into another file. I've got an error: java.net.UnknownServiceException: protocol doesn't support output.
Any idea how to do this?
Here;s the code for Command:
protected Command createUnitApplicationCommand(final UnitApplication unitApplication, final EObject statechart) {
return new AbstractCommand() {
@Override
public void execute() {
boolean result = unitApplication.execute();
if (result) {
System.out.println("Successful");
if (statechart == null) {
System.err.println("statechart is null");
return;
}
Bundle bundle = Platform.getBundle("tue.examples.statechart");
String path = bundle.getEntry("model/default2.sm").toExternalForm();
URI modelUri = URI.createURI(path);
statechart.eResource().setURI(modelUri);
try {
statechart.eResource().save(null);
} catch (IOException e) {
e.printStackTrace();
}
} else {
System.err.println("Not successful");
}
}
};
|
|
|
|
Re: Saving a file from the editor [message #723751 is a reply to message #723475] |
Fri, 09 September 2011 11:01 |
amalia.msanusi Messages: 6 Registered: March 2011 |
Junior Member |
|
|
Hi Ed,
What I am trying to achieve is to save the result of model transformation into a file. I've tried the following, but it didn't save the file at all. Do you know how to save it into a file?
URI modelUri = URI.createFileURI(new File("D:/Documents/Eclipse/tue.examples.statechart.diagram.custom/model" + "statechart.henshin")
.getAbsolutePath());
Resource res = resourceSet.createResource(modelUri, "henshin");
try {
res.getContents().add(tsResult);
res.save(null);
} catch (IOException e) {
e.printStackTrace();
}
[Updated on: Fri, 09 September 2011 11:18] Report message to a moderator
|
|
|
Re: Saving a file from the editor [message #723768 is a reply to message #723751] |
Fri, 09 September 2011 12:29 |
Ed Merks Messages: 33139 Registered: July 2009 |
Senior Member |
|
|
Amalia,
Comments below.
On 09/09/2011 4:01 AM, amalia.msanusi wrote:
> Hi Ed,
>
> What I am trying to achieve is to save the result of model
> transformation into a file. I've tried the following, but it didn't
> save the file at all. Do you know how to save it into a file?
> URI modelUri = URI.createFileURI(new File("PATH_TO" +
> "statechart.henshin")
> .getAbsolutePath());
You've used the debugger to look at the value this produces. I.e.,
where are you looking to see if it's saved?
> Resource res =
> resourceSet.createResource(modelUri, "henshin");
>
> try {
> res.getContents().add(tsResult);
> res.save(null);
> } catch (IOException e) {
> e.printStackTrace();
Does it thrown an exception? If so, what does it tell you?
> }
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04662 seconds