Yes but the problem is that in your implementation (that I got from your CVS repo), you load the persistent model (the one serialized in resource file) :
IEditorInput input = ....//the new model to load
But what I wanna do is load the model from memory.
I don't wanna have to save the model before reloading it.
To explain more precisely what I wanna do, I posted another topic (and reported a bug) because when I add marker to the resource file (after some validation process), it causes the editor to crash.
So I use your ReloadModelInvokable class to reload the editor and then getting it back "alive" ...
But the problem is that I want the user to be able to launch model validation without having to save the model first, so after the validation process, I need to reload the model from memory and not from serialized resource ...
One solution may be to manage to "convert" the logical model in memory in an IEditorInput .... but I don't knwo how to do that properly. I tried to re-serialize it in a temporary file and give this file to the input but the problem is that it is now the temporary file that is loaded in the editor ...
I hope I was clear ....
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would like to set a logical diagram in an editor manually.
I tried this :
editor.setLogicDiagram(context.getModelInstance().getRoot());
System.out.println(context.getModelInstance().getRoot().getChildren().size());
System.out.println(editor.getCurrentRootObject().getChildren().size());
And it seems to work because the 2 prints confirm that logical model have been set properly to my editor.
PROBLEM : the graphics doesn't update, I want the new model to show up and resource to be set as "has to be saved state" ...
Do you know why graphics doesn't update ????
Thanks.
I think you want to do something similar to what I do with the class org.gems.designer.dsml.trigger.ReloadModelInvokable:
public void run() {
IWorkbenchWindow
window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
try {
GemsEditor editor = ...//get the editor from ModelRepo
ModelObject rootobj =
editor.getLogicDiagram().getEncapsulatedRoot();
String editorid =
rootobj.getClass().getPackage().getName()+".editor";
page.closeEditor(editor, false);
IEditorInput input = ....//the new model to load
page.openEditor(input, editorid);
} catch (Exception e) {
e.printStackTrace();
}
}
Yes but the problem is that in your implementation (that I got from your CVS repo), you load the persistent model (the one serialized in resource file) :
IEditorInput input = ....//the new model to load
But what I wanna do is load the model from memory.
I don't wanna have to save the model before reloading it.
To explain more precisely what I wanna do, I posted another topic (and reported a bug) because when I add marker to the resource file (after some validation process), it causes the editor to crash.
So I use your ReloadModelInvokable class to reload the editor and then getting it back "alive" ...
But the problem is that I want the user to be able to launch model validation without having to save the model first, so after the validation process, I need to reload the model from memory and not from serialized resource ...
One solution may be to manage to "convert" the logical model in memory in an IEditorInput .... but I don't knwo how to do that properly. I tried to re-serialize it in a temporary file and give this file to the input but the problem is that it is now the temporary file that is loaded in the editor ...
I hope I was clear ....
Thanks.