One diagram per file with an unsynchronized model [message #188182] |
Wed, 21 May 2008 08:17  |
Eclipse User |
|
|
|
Hi all,
I'm using GMF 2.0 with Eclipse 3.3.
My needs :
- I have my model loaded in a TreeViewer in my home-made explorer
and I want many diagrams representing everything or a part of
this model.
My solution :
- I've developped diagram editors unsynchronized from the model
and sharing a same transactional editing domain as described
in Tips section of the wiki.
- Then, I have no CanonicalEditPolicy installed in my EditParts.
My problem :
- When a model element is deleted from the TreeViewer or from one
diagram, the others diagrams are not updated when I reopen them.
- I get two situations with such EditPart which references an
unexisted model element :
1) The graphical view is marked with a cross
=> normal process I guess
2) The graphical view seems to reference the parent model element
and then show the name and icon of the parent for example
=> is it a bug from GMF or from my customization ?
This second situation seems to appear randomly when the
diagram was open during deletion.
Finaly, I would like to update diagrams as if I had a CanonicalEditPolicy.
If they are open during deletion or when I open them if they were closed.
Your solution :
- ??? :)
Thank you for your great job !
Sylvain
|
|
|
|
|
|
|
|
Re: One diagram per file with an unsynchronized model [message #189312 is a reply to message #188742] |
Mon, 26 May 2008 07:36   |
Eclipse User |
|
|
|
Originally posted by: jan.herriger.gmx.de
You could generate your editor with 'synchronized' set to true. Then,
modify generated CEP:
1) getSemanticChildrenList():
This is the list of element types, which will be created, if there is no
corresponding view. Return an empty list here.
2) isOrphaned(...):
Replace method body with
return MyDiagramUpdater.isShortcutOrphaned(view);
This way, views are removed automatically. But view creation is still up
to the user. Connections are still fully synchronized. But, there are
two more things to consider:
DeleteFromDiagramAction won't let you delete views. It checks, if the
parent is canonical. Which is true, because there is a canonical edit
policy installed. You have to write your own action, which ignores CEPs.
Add this action inside generated ContributionItemProvider. Inside
Plug-in manifest, remove predefined 'deleteFromDiagramAction' (if
exists) and declare your own.
Last thing is: pressing 'del' will delete both, view and semantic
element. To prevent this, you can install a modified ComponentEditPolicy
inside your edit parts:
installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy() {
protected boolean shouldDeleteSemantic() {
return false;
}});
May be, there are other/better solutions. But it works for me. Since I'm
still using 2.0, I wonder if there were any changes in GMF 2.1 regarding
the synchronization behavior?
Regards,
Jan
Sylvain Dudoit schrieb:
>
> Thx Alex, I will debug to understand this point.
>
> What about the way to update old diagrams by removing useless views ?
> Could you give me some help to understand how I could implement a kind
> of CanonicalEditPolicy ?
>
> Sylvain
>
>
> Alex Shatalin wrote:
>
>>> Do you know how I could mark the View with cross to avoid this
>>> behaviour ?
>> Well, isSetElement() should return true if setElement() was called for
>> this View instance. This means, in your situation all the elements
>> should be set AFAIU..
>> So, I suggest you to debug this method in case you have "cross" and
>> you have no "cross" and compare these two situations. As a result
>> you'll be able to find a reason of this problem.
>
>
>
|
|
|
|
Re: One diagram per file with an unsynchronized model [message #190655 is a reply to message #190613] |
Tue, 03 June 2008 08:23   |
Eclipse User |
|
|
|
Originally posted by: jan.herriger.gmx.de
Hi Sylvain,
this should be explained somewhere. But I don't know where right know.
This contributes your own action for a specific edit part and removes a
predefined one:
<extension point="org.eclipse.gmf.runtime.common.
ui.services.action.contributionItemProviders">
<?gmfgen generated="false"?>
<contributionItemProvider
class="yourPackage.diagram.providers.XxxContributionItemProvider "
checkPluginLoaded="false">
<Priority name="Low"/>
<popupContribution class="org.eclipse.gmf.runtime.diagram.ui.
providers.DiagramContextMenuProvider">
<popupStructuredContributionCriteria
objectClass="yourPackage.diagram.
edit.parts.XxxEditPart"/>
<popupAction
id="deleteFromDiagramAction"
path="/editGroup">
</popupAction>
<popupPredefinedItem
id="deleteFromDiagramAction"
remove="true">
</popupPredefinedItem>
</popupContribution>
.....
Your contribution provider should look like this:
protected IAction createAction(String actionId,
IWorkbenchPartDescriptor partDescriptor) {
if (actionId.equals(PrintPreviewAction.ID)) {
return new RenderedPrintPreviewAction(
new EnhancedPrintActionHelper());
} else if (actionId.equals(ActionIds.ACTION_DELETE_FROM_MODEL)) {
IWorkbenchPage workbenchPage = partDescriptor.getPartPage();
return new DeleteFromModelAction(workbenchPage);
} else if (actionId.equals(ActionIds.ACTION_DELETE_FROM_DIAGRAM)) {
IWorkbenchPage workbenchPage = partDescriptor.getPartPage();
return new DeleteFromDiagramAction(workbenchPage);
}
return super.createAction(actionId, partDescriptor);
}
Seems like I have my own delete from model action too... but I don't
remember why ;-)
btw: you don't use 'org.eclipse.ui.popupMenus' extension point here.
Sylvain Dudoit schrieb:
> Hi Jan,
>
> Thank you so much for your help !
>
> I have applied your indications with sucess. Well, I didn't found the
> method "isShortcutOrphaned(view)" in my generated "DiagramUpdater" but
> I've replaced it with a home-made one which checks for model element
> validity.
> For now, with a small example, it seems to work.
>
> My last problem is how to replace the DeleteFromDiagramAction inside
> generated ContributionItemProvider.
>
> The only way I've seen in this forum to add a custom action in the
> contextual menu is to contribute to the extension
> "org.eclipse.ui.popupMenus" as usual and to specify the selected item to
> " org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditP art ".
>
> Could you give me more details about the way to add a custom action ? If
> this information is explained somewhere, could you simply copy/paste the
> URL ?
>
> Thanks,
> Sylvain
>
>
|
|
|
Re: One diagram per file with an unsynchronized model [message #196051 is a reply to message #190655] |
Tue, 08 July 2008 05:30  |
Eclipse User |
|
|
|
Originally posted by: janiko.gmx.de
Hi, i applied your solution successfully, thanks a lot. But the
contributionItemProviders extension pint dont have any effect. The
yourPackage.diagram.providers.XxxContributionItemProvider is never
called. May you or anyone else can help me here.
Jan Herriger schrieb:
> Hi Sylvain,
>
> this should be explained somewhere. But I don't know where right know.
>
> This contributes your own action for a specific edit part and removes a
> predefined one:
>
> <extension point="org.eclipse.gmf.runtime.common.
> ui.services.action.contributionItemProviders">
> <?gmfgen generated="false"?>
> <contributionItemProvider
> class="yourPackage.diagram.providers.XxxContributionItemProvider "
> checkPluginLoaded="false">
> <Priority name="Low"/>
> <popupContribution class="org.eclipse.gmf.runtime.diagram.ui.
> providers.DiagramContextMenuProvider">
> <popupStructuredContributionCriteria
> objectClass="yourPackage.diagram.
> edit.parts.XxxEditPart"/>
> <popupAction
> id="deleteFromDiagramAction"
> path="/editGroup">
> </popupAction>
> <popupPredefinedItem
> id="deleteFromDiagramAction"
> remove="true">
> </popupPredefinedItem>
> </popupContribution>
> ....
>
> Your contribution provider should look like this:
>
> protected IAction createAction(String actionId,
> IWorkbenchPartDescriptor partDescriptor) {
> if (actionId.equals(PrintPreviewAction.ID)) {
> return new RenderedPrintPreviewAction(
> new EnhancedPrintActionHelper());
> } else if (actionId.equals(ActionIds.ACTION_DELETE_FROM_MODEL)) {
> IWorkbenchPage workbenchPage = partDescriptor.getPartPage();
> return new DeleteFromModelAction(workbenchPage);
> } else if (actionId.equals(ActionIds.ACTION_DELETE_FROM_DIAGRAM)) {
> IWorkbenchPage workbenchPage = partDescriptor.getPartPage();
> return new DeleteFromDiagramAction(workbenchPage);
> }
> return super.createAction(actionId, partDescriptor);
> }
>
> Seems like I have my own delete from model action too... but I don't
> remember why ;-)
>
> btw: you don't use 'org.eclipse.ui.popupMenus' extension point here.
>
> Sylvain Dudoit schrieb:
>> Hi Jan,
>>
>> Thank you so much for your help !
>>
>> I have applied your indications with sucess. Well, I didn't found the
>> method "isShortcutOrphaned(view)" in my generated "DiagramUpdater" but
>> I've replaced it with a home-made one which checks for model element
>> validity.
>> For now, with a small example, it seems to work.
>>
>> My last problem is how to replace the DeleteFromDiagramAction inside
>> generated ContributionItemProvider.
>>
>> The only way I've seen in this forum to add a custom action in the
>> contextual menu is to contribute to the extension
>> "org.eclipse.ui.popupMenus" as usual and to specify the selected item
>> to " org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditP art ".
>>
>> Could you give me more details about the way to add a custom action ?
>> If this information is explained somewhere, could you simply
>> copy/paste the URL ?
>>
>> Thanks,
>> Sylvain
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.04466 seconds