Home » Modeling » GMF (Graphical Modeling Framework) » Strange CreateView Constructor
| Strange CreateView Constructor [message #111701] |
Wed, 14 March 2007 01:41  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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
> > >
|
|
| | | | |
Goto Forum:
Current Time: Mon Nov 10 08:47:35 EST 2025
Powered by FUDForum. Page generated in 0.05693 seconds
|