invisble views after reload [message #500225] |
Wed, 25 November 2009 07:50  |
Eclipse User |
|
|
|
Hi,
I've a diagram with various view types, nodes, compartments and
terminals. The model and diagram data are stored in a database. The
model is serialized into various predefined tables and the diagram
stored as simple clob. The diagram data are serialized by calling the
ordinary XMLSave's save-method provided by the GMFResource.createXMLSave().
The diagram load goes the opposite way using the XMLLoad provided by the
resource.
So far so good. Everything is fine.
The save optimizes the diagram data skipping all default values
(including nodes located at a default location - what ever that is...).
And of course the load retieves the reduced diagram.
Now the problem: The diagram editor does not restores the nodes skipped
on save. The CanonicalEditPolicies gets activated, but no views/edit
parts are created for these optimized elements. The ViewServices usually
called for view creation are not triggered.
a) is there a resource option forcing to save all views or
b) how can I trigger the corresponding edit policies explicitely (or
invoking the ViewService(s) directly).
Thanks in Advance,
Sven
|
|
|
|
|
Re: invisble views after reload [message #500251 is a reply to message #500225] |
Wed, 25 November 2009 08:59   |
Eclipse User |
|
|
|
Hi,
I had the same problem in my application.
I can't remember what exactly, but something isn't intialized at startup. It is a registry of some kind, maybe your xxViewProvider.
The thing is, gmf tries to instantiate the class the first time it needs it, but expects a semantic hint, and fails because the CanonicalEditPolicy's method getFactoryHint() returns null. Of course, without the provider the view can't be created.
When creating a new element, the tool provides a factory hint to the request so you get the provider and then the views.
What I did is letting the canonical edit policy provide a semantic hint :
@Override
protected String getFactoryHint(IAdaptable elementAdapter) {
CanonicalElementAdapter element = (CanonicalElementAdapter) elementAdapter;
int VID = xxVisualIDRegistry.getNodeVisualID((View) getHost().getModel(), (EObject)element.getRealObject());
return xxVisualIDRegistry.getType(VID);
}
edit : oh, my bad.
[Updated on: Wed, 25 November 2009 09:01] by Moderator
|
|
|
|
Re: invisble views after reload [message #500281 is a reply to message #500251] |
Wed, 25 November 2009 09:38  |
Eclipse User |
|
|
|
Hi Oliver,
works fine. Its better than persisting everything.
Sven
Olivier Marot schrieb:
> Hi,
>
> I had the same problem in my application.
> I can't remember what exactly, but something isn't intialized at
> startup. It is a registry of some kind, maybe your xxViewProvider.
>
> The thing is, gmf tries to instantiate the class the first time it needs
> it, but expects a factory hint, and fails because the
> CanonicalEditPolicy's method getFactoryHint() returns null. Of course,
> without the provider the view can't be created.
>
> When creating a new element, the tool provides a factory hint to the
> request so you get the provider and then the views.
> What I did is letting the canonical edit policy provide a factory hint :
>
> @Override
> protected String getFactoryHint(IAdaptable elementAdapter) {
> CanonicalElementAdapter element = (CanonicalElementAdapter)
> elementAdapter;
> int VID = xxVisualIDRegistry.getNodeVisualID((View)
> getHost().getModel(), (EObject)element.getRealObject());
> return xxVisualIDRegistry.getType(VID);
> }
|
|
|
Powered by
FUDForum. Page generated in 0.04209 seconds