Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Strange CreateView Constructor
Strange CreateView Constructor [message #111701] Wed, 14 March 2007 01:41 Go to next message
Eclipse UserFriend
Hi,
I'm trying to enable DND on my diagramm. I enabled
LocalSelectionTransfers so I can DND semantic elements on my diagramm.
The default DiagramDragDropEditPolicy already supports this usecase -
which is nice. But: It creates a CreateView Command, which is also the
right thing. For this is builds up CreateViewRequests. And here comes
the problem. The code uses a small version of the CreateViewRequest
which looks like this

public ViewDescriptor(IAdaptable elementAdapter, Class viewkind,boolean
persisted, PreferencesHint preferencesHint) {
this(elementAdapter, viewkind, "",persisted,
preferencesHint); //$NON-NLS-1$
}

The problem is with the third parameter, which should be the semantic
hint. However, during command execution it is assumed that the semantic
hint is either null or the VisualID. An empty string is not supported
and hence command execution fails...

This seems to be a bug, can anyone from runtime confirm this? Or is
there some intention I dont get for the empty string?

Cheers,
Steffen
Re: Strange CreateView Constructor [message #111738 is a reply to message #111701] Wed, 14 March 2007 06:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jan.herriger.gmx.de

Hi Steffen,

this may not be a direct answer. But anyway...

I enabled DnD, by enabling Shortcuts for my diagram. This results in
generated code, which supports dragging elements onto the canvas. Since
I don't want views to be decorated as shortcuts, I just removed
corresponding code in myModelEditPart. This seems to work quite fine.

Regards
Jan

Steffen Becker schrieb:
> Hi,
> I'm trying to enable DND on my diagramm. I enabled
> LocalSelectionTransfers so I can DND semantic elements on my diagramm.
> The default DiagramDragDropEditPolicy already supports this usecase -
> which is nice. But: It creates a CreateView Command, which is also the
> right thing. For this is builds up CreateViewRequests. And here comes
> the problem. The code uses a small version of the CreateViewRequest
> which looks like this
>
> public ViewDescriptor(IAdaptable elementAdapter, Class viewkind,boolean
> persisted, PreferencesHint preferencesHint) {
> this(elementAdapter, viewkind, "",persisted,
> preferencesHint); //$NON-NLS-1$
> }
>
> The problem is with the third parameter, which should be the semantic
> hint. However, during command execution it is assumed that the semantic
> hint is either null or the VisualID. An empty string is not supported
> and hence command execution fails...
>
> This seems to be a bug, can anyone from runtime confirm this? Or is
> there some intention I dont get for the empty string?
>
> Cheers,
> Steffen
Re: Strange CreateView Constructor [message #111800 is a reply to message #111701] Wed, 14 March 2007 10:35 Go to previous messageGo to next message
Eclipse UserFriend
Steffen,

Where is the code that is assuming the semantic hint is either null or
the VisualID? My quick answer would be to say that this could is making
false assumptions.

- Cherie

Steffen Becker wrote:
> Hi,
> I'm trying to enable DND on my diagramm. I enabled
> LocalSelectionTransfers so I can DND semantic elements on my diagramm.
> The default DiagramDragDropEditPolicy already supports this usecase -
> which is nice. But: It creates a CreateView Command, which is also the
> right thing. For this is builds up CreateViewRequests. And here comes
> the problem. The code uses a small version of the CreateViewRequest
> which looks like this
>
> public ViewDescriptor(IAdaptable elementAdapter, Class viewkind,boolean
> persisted, PreferencesHint preferencesHint) {
> this(elementAdapter, viewkind, "",persisted,
> preferencesHint); //$NON-NLS-1$
> }
>
> The problem is with the third parameter, which should be the semantic
> hint. However, during command execution it is assumed that the semantic
> hint is either null or the VisualID. An empty string is not supported
> and hence command execution fails...
>
> This seems to be a bug, can anyone from runtime confirm this? Or is
> there some intention I dont get for the empty string?
>
> Cheers,
> Steffen
Re: Strange CreateView Constructor [message #111805 is a reply to message #111800] Wed, 14 March 2007 10:41 Go to previous messageGo to next message
Eclipse UserFriend
Sorry, just read my reply, let's change the grammar...
"My quick answer would be to say that this code is making
false assumptions."

Cherie Revells wrote:
> Steffen,
>
> Where is the code that is assuming the semantic hint is either null or
> the VisualID? My quick answer would be to say that this could is making
> false assumptions.
>
> - Cherie
>
> Steffen Becker wrote:
>> Hi,
>> I'm trying to enable DND on my diagramm. I enabled
>> LocalSelectionTransfers so I can DND semantic elements on my diagramm.
>> The default DiagramDragDropEditPolicy already supports this usecase -
>> which is nice. But: It creates a CreateView Command, which is also the
>> right thing. For this is builds up CreateViewRequests. And here comes
>> the problem. The code uses a small version of the CreateViewRequest
>> which looks like this
>>
>> public ViewDescriptor(IAdaptable elementAdapter, Class
>> viewkind,boolean persisted, PreferencesHint preferencesHint) {
>> this(elementAdapter, viewkind, "",persisted,
>> preferencesHint); //$NON-NLS-1$
>> }
>>
>> The problem is with the third parameter, which should be the semantic
>> hint. However, during command execution it is assumed that the
>> semantic hint is either null or the VisualID. An empty string is not
>> supported and hence command execution fails...
>>
>> This seems to be a bug, can anyone from runtime confirm this? Or is
>> there some intention I dont get for the empty string?
>>
>> Cheers,
>> Steffen
Re: Strange CreateView Constructor [message #112083 is a reply to message #111805] Thu, 15 March 2007 01:18 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

One place is in the generated ???VisualIDRegistry... The method
getNodeVisualID looks like below in my example. Notice the checks of the
type "semanticHint == null || SignatureEditPart.VISUAL_ID ==
nodeVisualID". They become true only if the semanticHint is null or the
IDs are matching. However, having a semanticHint of "" the nodeVisualID
is always -1 never matching. Hence, with a semanticHint of "" it fails.
But in my experience this is not the only place where this is assumed,
because if I patch this location, it fails somewhere else. I didn't
track it down, as setting semanticHint to null in first place works
perfectly, so I assumed that null is the right value....

Thanks,
Steffen

---SNIP
public static int getNodeVisualID(View containerView,
EObject domainElement, EClass domainElementMetaclass,
String semanticHint) {
String containerModelID = getModelID(containerView);
if (!RepositoryEditPart.MODEL_ID.equals(containerModelID)) {
return -1;
}
int containerVisualID;
if (RepositoryEditPart.MODEL_ID.equals(containerModelID)) {
containerVisualID = getVisualID(containerView);
} else {
if (containerView instanceof Diagram) {
containerVisualID = RepositoryEditPart.VISUAL_ID;
} else {
return -1;
}
}
int nodeVisualID = semanticHint != null ? getVisualID(semanticHint)
: -1;
switch (containerVisualID) {
case InterfaceEditPart.VISUAL_ID:
if (InterfaceEntityNameEditPart.VISUAL_ID == nodeVisualID) {
return InterfaceEntityNameEditPart.VISUAL_ID;
}
if (InterfaceSignatureListEditPart.VISUAL_ID == nodeVisualID) {
return InterfaceSignatureListEditPart.VISUAL_ID;
}
return getUnrecognizedInterface_2101ChildNodeID(domainElement,
semanticHint);
case BasicComponentEditPart.VISUAL_ID:
if (BasicComponentEntityNameEditPart.VISUAL_ID == nodeVisualID) {
return BasicComponentEntityNameEditPart.VISUAL_ID;
}
if (BasicComponentSEFFCompartmentEditPart.VISUAL_ID == nodeVisualID) {
return BasicComponentSEFFCompartmentEditPart.VISUAL_ID;
}
return getUnrecognizedBasicComponent_2102ChildNodeID(domainElement,
semanticHint);
case CompleteComponentTypeEditPart.VISUAL_ID:
if (CompleteComponentTypeEntityNameEditPart.VISUAL_ID == nodeVisualID) {
return CompleteComponentTypeEntityNameEditPart.VISUAL_ID;
}
return getUnrecognizedCompleteComponentType_2103ChildNodeID(
domainElement, semanticHint);
case ProvidesComponentTypeEditPart.VISUAL_ID:
if (ProvidesComponentTypeEntityNameEditPart.VISUAL_ID == nodeVisualID) {
return ProvidesComponentTypeEntityNameEditPart.VISUAL_ID;
}
return getUnrecognizedProvidesComponentType_2104ChildNodeID(
domainElement, semanticHint);
case CompositeComponentEditPart.VISUAL_ID:
return getUnrecognizedCompositeComponent_2105ChildNodeID(
domainElement, semanticHint);
case SignatureEditPart.VISUAL_ID:
return getUnrecognizedSignature_3101ChildNodeID(domainElement,
semanticHint);
case ResourceDemandingSEFFEditPart.VISUAL_ID:
return getUnrecognizedResourceDemandingSEFF_3102ChildNodeID(
domainElement, semanticHint);
case InterfaceSignatureListEditPart.VISUAL_ID:
if ((semanticHint == null || SignatureEditPart.VISUAL_ID == nodeVisualID)
&& RepositoryPackage.eINSTANCE.getSignature()
.isSuperTypeOf(domainElementMetaclass)
&& (domainElement == null || isNodeSignature_3101((Signature)
domainElement))) {
return SignatureEditPart.VISUAL_ID;
}
return getUnrecognizedInterfaceSignatureList_7101ChildNodeID(
domainElement, semanticHint);
case BasicComponentSEFFCompartmentEditPart.VISUAL_ID:
if ((semanticHint == null || ResourceDemandingSEFFEditPart.VISUAL_ID
== nodeVisualID)
&& SeffPackage.eINSTANCE.getResourceDemandingSEFF()
.isSuperTypeOf(domainElementMetaclass)
&& (domainElement == null ||
isNodeResourceDemandingSEFF_3102((ResourceDemandingSEFF) domainElement))) {
return ResourceDemandingSEFFEditPart.VISUAL_ID;
}
return getUnrecognizedBasicComponentSEFFCompartment_7102ChildNodeID (
domainElement, semanticHint);
case RepositoryEditPart.VISUAL_ID:
if ((semanticHint == null || InterfaceEditPart.VISUAL_ID == nodeVisualID)
&& RepositoryPackage.eINSTANCE.getInterface()
.isSuperTypeOf(domainElementMetaclass)
&& (domainElement == null || isNodeInterface_2101((Interface)
domainElement))) {
return InterfaceEditPart.VISUAL_ID;
}
if ((semanticHint == null || BasicComponentEditPart.VISUAL_ID ==
nodeVisualID)
&& RepositoryPackage.eINSTANCE.getBasicComponent()
.isSuperTypeOf(domainElementMetaclass)
&& (domainElement == null ||
isNodeBasicComponent_2102((BasicComponent) domainElement))) {
return BasicComponentEditPart.VISUAL_ID;
}
if ((semanticHint == null || CompleteComponentTypeEditPart.VISUAL_ID
== nodeVisualID)
&& RepositoryPackage.eINSTANCE.getCompleteComponentType()
.isSuperTypeOf(domainElementMetaclass)
&& (domainElement == null ||
isNodeCompleteComponentType_2103((CompleteComponentType) domainElement))) {
return CompleteComponentTypeEditPart.VISUAL_ID;
}
if ((semanticHint == null || ProvidesComponentTypeEditPart.VISUAL_ID
== nodeVisualID)
&& RepositoryPackage.eINSTANCE.getProvidesComponentType()
.isSuperTypeOf(domainElementMetaclass)
&& (domainElement == null ||
isNodeProvidesComponentType_2104((ProvidesComponentType) domainElement))) {
return ProvidesComponentTypeEditPart.VISUAL_ID;
}
if ((semanticHint == null || CompositeComponentEditPart.VISUAL_ID ==
nodeVisualID)
&& RepositoryPackage.eINSTANCE.getCompositeComponent()
.isSuperTypeOf(domainElementMetaclass)
&& (domainElement == null ||
isNodeCompositeComponent_2105((CompositeComponent) domainElement))) {
return CompositeComponentEditPart.VISUAL_ID;
}
return getUnrecognizedRepository_1000ChildNodeID(domainElement,
semanticHint);
case ProvidedRoleEditPart.VISUAL_ID:
if (ProvidesStereotypeLabelEditPart.VISUAL_ID == nodeVisualID) {
return ProvidesStereotypeLabelEditPart.VISUAL_ID;
}
return getUnrecognizedProvidedRole_4101LinkLabelID(semanticHint);
case RequiredRoleEditPart.VISUAL_ID:
if (RequiresStereotypeLabelEditPart.VISUAL_ID == nodeVisualID) {
return RequiresStereotypeLabelEditPart.VISUAL_ID;
}
return getUnrecognizedRequiredRole_4102LinkLabelID(semanticHint);
}
return -1;
}
---SNIP

> Sorry, just read my reply, let's change the grammar...
> "My quick answer would be to say that this code is making
> false assumptions."
>
> Cherie Revells wrote:
> > Steffen,
> >
> > Where is the code that is assuming the semantic hint is
> either null or
> > the VisualID? My quick answer would be to say that this
> could is making
> > false assumptions.
> >
> > - Cherie
> >
Re: Strange CreateView Constructor [message #112568 is a reply to message #112083] Fri, 16 March 2007 15:57 Go to previous messageGo to next message
Eclipse UserFriend
Steffen,

It sounds like this might be something the generated code is assuming,
but the runtime code is not assuming. Can you override the code in the
DiagramDragDropEditPolicy so that null is passed in instead? Maybe the
code generation team can comment on this.

- Cherie

Steffen Becker wrote:
> Hi,
>
> One place is in the generated ???VisualIDRegistry... The method
> getNodeVisualID looks like below in my example. Notice the checks of the
> type "semanticHint == null || SignatureEditPart.VISUAL_ID ==
> nodeVisualID". They become true only if the semanticHint is null or the
> IDs are matching. However, having a semanticHint of "" the nodeVisualID
> is always -1 never matching. Hence, with a semanticHint of "" it fails.
> But in my experience this is not the only place where this is assumed,
> because if I patch this location, it fails somewhere else. I didn't
> track it down, as setting semanticHint to null in first place works
> perfectly, so I assumed that null is the right value....
>
> Thanks,
> Steffen
>
> ---SNIP
> public static int getNodeVisualID(View containerView,
> EObject domainElement, EClass domainElementMetaclass,
> String semanticHint) {
> String containerModelID = getModelID(containerView);
> if (!RepositoryEditPart.MODEL_ID.equals(containerModelID)) {
> return -1;
> }
> int containerVisualID;
> if (RepositoryEditPart.MODEL_ID.equals(containerModelID)) {
> containerVisualID = getVisualID(containerView);
> } else {
> if (containerView instanceof Diagram) {
> containerVisualID = RepositoryEditPart.VISUAL_ID;
> } else {
> return -1;
> }
> }
> int nodeVisualID = semanticHint != null ? getVisualID(semanticHint)
> : -1;
> switch (containerVisualID) {
> case InterfaceEditPart.VISUAL_ID:
> if (InterfaceEntityNameEditPart.VISUAL_ID == nodeVisualID) {
> return InterfaceEntityNameEditPart.VISUAL_ID;
> }
> if (InterfaceSignatureListEditPart.VISUAL_ID == nodeVisualID) {
> return InterfaceSignatureListEditPart.VISUAL_ID;
> }
> return getUnrecognizedInterface_2101ChildNodeID(domainElement,
> semanticHint);
> case BasicComponentEditPart.VISUAL_ID:
> if (BasicComponentEntityNameEditPart.VISUAL_ID ==
> nodeVisualID) {
> return BasicComponentEntityNameEditPart.VISUAL_ID;
> }
> if (BasicComponentSEFFCompartmentEditPart.VISUAL_ID ==
> nodeVisualID) {
> return BasicComponentSEFFCompartmentEditPart.VISUAL_ID;
> }
> return
> getUnrecognizedBasicComponent_2102ChildNodeID(domainElement,
> semanticHint);
> case CompleteComponentTypeEditPart.VISUAL_ID:
> if (CompleteComponentTypeEntityNameEditPart.VISUAL_ID ==
> nodeVisualID) {
> return CompleteComponentTypeEntityNameEditPart.VISUAL_ID;
> }
> return getUnrecognizedCompleteComponentType_2103ChildNodeID(
> domainElement, semanticHint);
> case ProvidesComponentTypeEditPart.VISUAL_ID:
> if (ProvidesComponentTypeEntityNameEditPart.VISUAL_ID ==
> nodeVisualID) {
> return ProvidesComponentTypeEntityNameEditPart.VISUAL_ID;
> }
> return getUnrecognizedProvidesComponentType_2104ChildNodeID(
> domainElement, semanticHint);
> case CompositeComponentEditPart.VISUAL_ID:
> return getUnrecognizedCompositeComponent_2105ChildNodeID(
> domainElement, semanticHint);
> case SignatureEditPart.VISUAL_ID:
> return getUnrecognizedSignature_3101ChildNodeID(domainElement,
> semanticHint);
> case ResourceDemandingSEFFEditPart.VISUAL_ID:
> return getUnrecognizedResourceDemandingSEFF_3102ChildNodeID(
> domainElement, semanticHint);
> case InterfaceSignatureListEditPart.VISUAL_ID:
> if ((semanticHint == null || SignatureEditPart.VISUAL_ID ==
> nodeVisualID)
> && RepositoryPackage.eINSTANCE.getSignature()
> .isSuperTypeOf(domainElementMetaclass)
> && (domainElement == null ||
> isNodeSignature_3101((Signature) domainElement))) {
> return SignatureEditPart.VISUAL_ID;
> }
> return getUnrecognizedInterfaceSignatureList_7101ChildNodeID(
> domainElement, semanticHint);
> case BasicComponentSEFFCompartmentEditPart.VISUAL_ID:
> if ((semanticHint == null ||
> ResourceDemandingSEFFEditPart.VISUAL_ID == nodeVisualID)
> && SeffPackage.eINSTANCE.getResourceDemandingSEFF()
> .isSuperTypeOf(domainElementMetaclass)
> && (domainElement == null ||
> isNodeResourceDemandingSEFF_3102((ResourceDemandingSEFF) domainElement))) {
> return ResourceDemandingSEFFEditPart.VISUAL_ID;
> }
> return
> getUnrecognizedBasicComponentSEFFCompartment_7102ChildNodeID (
> domainElement, semanticHint);
> case RepositoryEditPart.VISUAL_ID:
> if ((semanticHint == null || InterfaceEditPart.VISUAL_ID ==
> nodeVisualID)
> && RepositoryPackage.eINSTANCE.getInterface()
> .isSuperTypeOf(domainElementMetaclass)
> && (domainElement == null ||
> isNodeInterface_2101((Interface) domainElement))) {
> return InterfaceEditPart.VISUAL_ID;
> }
> if ((semanticHint == null ||
> BasicComponentEditPart.VISUAL_ID == nodeVisualID)
> && RepositoryPackage.eINSTANCE.getBasicComponent()
> .isSuperTypeOf(domainElementMetaclass)
> && (domainElement == null ||
> isNodeBasicComponent_2102((BasicComponent) domainElement))) {
> return BasicComponentEditPart.VISUAL_ID;
> }
> if ((semanticHint == null ||
> CompleteComponentTypeEditPart.VISUAL_ID == nodeVisualID)
> &&
> RepositoryPackage.eINSTANCE.getCompleteComponentType()
> .isSuperTypeOf(domainElementMetaclass)
> && (domainElement == null ||
> isNodeCompleteComponentType_2103((CompleteComponentType) domainElement))) {
> return CompleteComponentTypeEditPart.VISUAL_ID;
> }
> if ((semanticHint == null ||
> ProvidesComponentTypeEditPart.VISUAL_ID == nodeVisualID)
> &&
> RepositoryPackage.eINSTANCE.getProvidesComponentType()
> .isSuperTypeOf(domainElementMetaclass)
> && (domainElement == null ||
> isNodeProvidesComponentType_2104((ProvidesComponentType) domainElement))) {
> return ProvidesComponentTypeEditPart.VISUAL_ID;
> }
> if ((semanticHint == null ||
> CompositeComponentEditPart.VISUAL_ID == nodeVisualID)
> && RepositoryPackage.eINSTANCE.getCompositeComponent()
> .isSuperTypeOf(domainElementMetaclass)
> && (domainElement == null ||
> isNodeCompositeComponent_2105((CompositeComponent) domainElement))) {
> return CompositeComponentEditPart.VISUAL_ID;
> }
> return getUnrecognizedRepository_1000ChildNodeID(domainElement,
> semanticHint);
> case ProvidedRoleEditPart.VISUAL_ID:
> if (ProvidesStereotypeLabelEditPart.VISUAL_ID ==
> nodeVisualID) {
> return ProvidesStereotypeLabelEditPart.VISUAL_ID;
> }
> return
> getUnrecognizedProvidedRole_4101LinkLabelID(semanticHint);
> case RequiredRoleEditPart.VISUAL_ID:
> if (RequiresStereotypeLabelEditPart.VISUAL_ID ==
> nodeVisualID) {
> return RequiresStereotypeLabelEditPart.VISUAL_ID;
> }
> return
> getUnrecognizedRequiredRole_4102LinkLabelID(semanticHint);
> }
> return -1;
> }
> ---SNIP
>
> > Sorry, just read my reply, let's change the grammar...
> > "My quick answer would be to say that this code is making
> > false assumptions."
> >
> > Cherie Revells wrote:
> > > Steffen,
> > >
> > > Where is the code that is assuming the semantic hint is
> > either null or
> > > the VisualID? My quick answer would be to say that this
> > could is making
> > > false assumptions.
> > >
> > > - Cherie
> > >
Re: Strange CreateView Constructor [message #112606 is a reply to message #112568] Fri, 16 March 2007 20:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

As I wrote in one of the previous mails, that is what I did: Passing
null as semantic hint works perfectly as workaround. I don't see any
issues... That was why I expected to be null the right option...

Cheers,
Steffen

Cherie Revells schrieb:
> Steffen,
>
> It sounds like this might be something the generated code is assuming,
> but the runtime code is not assuming. Can you override the code in the
> DiagramDragDropEditPolicy so that null is passed in instead? Maybe the
> code generation team can comment on this.
>
> - Cherie
>
Re: Strange CreateView Constructor [message #112830 is a reply to message #112568] Mon, 19 March 2007 12:50 Go to previous messageGo to next message
Eclipse UserFriend
Hello Cherie,

> It sounds like this might be something the generated code is assuming,
> but the runtime code is not assuming. Can you override the code in
> the DiagramDragDropEditPolicy so that null is passed in instead?
> Maybe the code generation team can comment on this.
Currently generated ???VisualIdRegistry works only with null semantic
hints or with the semantic hints keeping visualID inside. If the contract
for SemanticHint is different then we probably have to adopt code generator
to this situation. BTW, what's wrong with semanticHint == null if we don't
know it?

-----------------
Alex Shatalin
Re: Strange CreateView Constructor [message #112977 is a reply to message #112830] Mon, 19 March 2007 19:43 Go to previous messageGo to next message
Eclipse UserFriend
Alex Shatalin schrieb:
> Hello Cherie,
>
>> It sounds like this might be something the generated code is assuming,
>> but the runtime code is not assuming. Can you override the code in
>> the DiagramDragDropEditPolicy so that null is passed in instead?
>> Maybe the code generation team can comment on this.
> Currently generated ???VisualIdRegistry works only with null semantic
> hints or with the semantic hints keeping visualID inside. If the
> contract for SemanticHint is different then we probably have to adopt
> code generator to this situation. BTW, what's wrong with semanticHint ==
> null if we don't know it?
>
Hi,
AFAIU there is an issue between runtime and tooling here, should we file
a bugzilla entry to sort this issue out?

Cheers,
Steffen
Re: Strange CreateView Constructor [message #113067 is a reply to message #112977] Tue, 20 March 2007 07:12 Go to previous message
Eclipse UserFriend
Hello Steffen,

> AFAIU there is an issue between runtime and tooling here, should we
> file
> a bugzilla entry to sort this issue out?
Yes, I think so.

-----------------
Alex Shatalin
Previous Topic:FSM in GMF editor
Next Topic:Background Grid and colour
Goto Forum:
  


Current Time: Mon Nov 10 10:04:42 EST 2025

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

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

Back to the top