Skip to main content



      Home
Home » Modeling » EMF » Non-Model Intermediary View Objects
Non-Model Intermediary View Objects [message #389554] Fri, 26 November 2004 11:50 Go to next message
Eclipse UserFriend
Hi,

I created a model and followed the example in section 14.2.3 in the
EMF-book to add additional nodes to the viewer.

My model (simplified):
Main
- io 1
- io 2
- io n
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

My view (simplified):
Main
+ ios
- io 1
- io 2
- io n
+ dps
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

I created an ItemProvider for "ios" and "dps" which are added in the
getChildren method of "Main" to the list of children. The function's are
added without an extra ItemProvider.

Everything works fine, except when I try to move a function to a different
position inwith "Main", the final position depends on the number of io's
and dp's. If there are no io's and dp's the "wrong" offset is 2, if there
a 2 io's or 2 dp's or 1 io and 1 dp, the final position after the movement
is correct.

Regarding a similar problem I had before Ed wrote something about the
method "factorAddCommand" and a correction of the index there. But in my
case this mehtod is not invoked. I think because the function is a
StructuralFeature.

Thanks for any help.
Re: Non-Model Intermediary View Objects [message #389557 is a reply to message #389554] Fri, 26 November 2004 13:31 Go to previous messageGo to next message
Eclipse UserFriend
Harald,

If it's a MoveCommand that's being created in this case, then it's
factorMoveCommand that needs the index correction.


Harald wrote:

> Hi,
>
> I created a model and followed the example in section 14.2.3 in the
> EMF-book to add additional nodes to the viewer.
>
> My model (simplified):
> Main
> - io 1
> - io 2
> - io n
> - dp 1
> - dp 2
> - dp n
> - function 1
> - function 2
> - function n
>
> My view (simplified):
> Main
> + ios
> - io 1
> - io 2
> - io n
> + dps
> - dp 1
> - dp 2
> - dp n
> - function 1
> - function 2
> - function n
>
> I created an ItemProvider for "ios" and "dps" which are added in the
> getChildren method of "Main" to the list of children. The function's
> are added without an extra ItemProvider.
>
> Everything works fine, except when I try to move a function to a
> different position inwith "Main", the final position depends on the
> number of io's and dp's. If there are no io's and dp's the "wrong"
> offset is 2, if there a 2 io's or 2 dp's or 1 io and 1 dp, the final
> position after the movement is correct.
>
> Regarding a similar problem I had before Ed wrote something about the
> method "factorAddCommand" and a correction of the index there. But in
> my case this mehtod is not invoked. I think because the function is a
> StructuralFeature.
>
> Thanks for any help.
>
>
Re: Non-Model Intermediary View Objects [message #389559 is a reply to message #389557] Fri, 26 November 2004 13:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: harald.loehnert.utanet.at

Ed,

the movement is done using the mouse (drag&drop), so I think it's a
RemoveCommand followed by an AddComand. By debugging the "createAddCommand"
in the Main-ItemProvider I could see, that this gets invoked, but not the
factorAddCommand.

Thanks,
Harald

"Ed Merks" <merks@ca.ibm.com> schrieb im Newsbeitrag
news:co7sqn$b65$1@www.eclipse.org...
> Harald,
>
> If it's a MoveCommand that's being created in this case, then it's
> factorMoveCommand that needs the index correction.
>
>
> Harald wrote:
>
> > Hi,
> >
> > I created a model and followed the example in section 14.2.3 in the
> > EMF-book to add additional nodes to the viewer.
> >
> > My model (simplified):
> > Main
> > - io 1
> > - io 2
> > - io n
> > - dp 1
> > - dp 2
> > - dp n
> > - function 1
> > - function 2
> > - function n
> >
> > My view (simplified):
> > Main
> > + ios
> > - io 1
> > - io 2
> > - io n
> > + dps
> > - dp 1
> > - dp 2
> > - dp n
> > - function 1
> > - function 2
> > - function n
> >
> > I created an ItemProvider for "ios" and "dps" which are added in the
> > getChildren method of "Main" to the list of children. The function's
> > are added without an extra ItemProvider.
> >
> > Everything works fine, except when I try to move a function to a
> > different position inwith "Main", the final position depends on the
> > number of io's and dp's. If there are no io's and dp's the "wrong"
> > offset is 2, if there a 2 io's or 2 dp's or 1 io and 1 dp, the final
> > position after the movement is correct.
> >
> > Regarding a similar problem I had before Ed wrote something about the
> > method "factorAddCommand" and a correction of the index there. But in
> > my case this mehtod is not invoked. I think because the function is a
> > StructuralFeature.
> >
> > Thanks for any help.
> >
> >
Re: Non-Model Intermediary View Objects [message #389560 is a reply to message #389559] Fri, 26 November 2004 14:15 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------090303000502010602090007
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Harald,

DragAndDropCommand.prepareDropMoveInsert will try to create a
MoveCommand in some cases, such as when moving objects from and to the
same parent, which sounds like this case. All of the commands created
by the DragAndDropCommand require the feature to be deduced, so some
"factor" method will be called.


harald l
Re: Non-Model Intermediary View Objects [message #389561 is a reply to message #389560] Fri, 26 November 2004 15:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: harald .loehnert.brueckner.de

This is a multi-part message in MIME format.

------=_NextPart_000_001F_01C4D402.34ACCEE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks Ed,

you are right, the "factorMoveCommand" gets called.
Now I overwrite the "factorMoveCommand" in my Main-ItemProvider and =
decrease the index by 2.
It works like this. Is it also the best way to do it ?

Thanks,
Harald.

protected Command factorMoveCommand(EditingDomain domain, =
CommandParameter commandParameter) {
=20
final EObject eObject =3D commandParameter.getEOwner();
final Object value =3D commandParameter.getValue();
int index =3D commandParameter.getIndex();

EStructuralFeature childFeature =3D getChildFeature(eObject, =
value);

if (childFeature !=3D null && childFeature.isMany()) {
index -=3D 2;=20
// Create a command for this feature,
//
return createMoveCommand(domain, eObject, childFeature, value, =
index);
} else {
return UnexecutableCommand.INSTANCE;
}
}

"Ed Merks" <merks@ca.ibm.com> schrieb im Newsbeitrag =
news:co7vd7$emk$1@www.eclipse.org...
Harald,

DragAndDropCommand.prepareDropMoveInsert will try to create a =
MoveCommand in some cases, such as when moving objects from and to the =
same parent, which sounds like this case. All of the commands created =
by the DragAndDropCommand require the feature to be deduced, so some =
"factor" method will be called.


harald l=F6hnert wrote:=20
Ed,

the movement is done using the mouse (drag&drop), so I think it's a
RemoveCommand followed by an AddComand. By debugging the =
"createAddCommand"
in the Main-ItemProvider I could see, that this gets invoked, but not =
the
factorAddCommand.

Thanks,
Harald

"Ed Merks" <merks@ca.ibm.com> schrieb im Newsbeitrag
news:co7sqn$b65$1@www.eclipse.org...
Harald,

If it's a MoveCommand that's being created in this case, then it's
factorMoveCommand that needs the index correction.


Harald wrote:

Hi,

I created a model and followed the example in section 14.2.3 in the
EMF-book to add additional nodes to the viewer.

My model (simplified):
Main
- io 1
- io 2
- io n
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

My view (simplified):
Main
+ ios
- io 1
- io 2
- io n
+ dps
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

I created an ItemProvider for "ios" and "dps" which are added in the
getChildren method of "Main" to the list of children. The function's
are added without an extra ItemProvider.

Everything works fine, except when I try to move a function to a
different position inwith "Main", the final position depends on the
number of io's and dp's. If there are no io's and dp's the "wrong"
offset is 2, if there a 2 io's or 2 dp's or 1 io and 1 dp, the final
position after the movement is correct.

Regarding a similar problem I had before Ed wrote something about the
method "factorAddCommand" and a correction of the index there. But in
my case this mehtod is not invoked. I think because the function is a
StructuralFeature.

Thanks for any help.


=20

=20

------=_NextPart_000_001F_01C4D402.34ACCEE0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>you are right, the "factorMoveCommand" =
gets=20
called.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Now I&nbsp;overwrite the=20
"factorMoveCommand"&nbsp;in my Main-ItemProvider and decrease the index =
by=20
2.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>It works like this. Is it also the best =
way to do=20
it ?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Harald.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><EM><STRONG>protected Command=20
factorMoveCommand(EditingDomain domain, CommandParameter =
commandParameter)=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; </STRONG></EM></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><EM><STRONG>&nbsp;&nbsp;&nbsp;&nbsp; =
final EObject=20
eObject =3D commandParameter.getEOwner();<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
final Object=20
value =3D commandParameter.getValue();<BR>&nbsp;&nbsp;&nbsp;&nbsp; int =
index =3D=20
commandParameter.getIndex();</STRONG></EM></FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2><EM><STRONG></STRONG></EM></FONT>&nbsp;</DIV >
<DIV><FONT face=3DArial size=3D2><EM><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;=20
EStructuralFeature childFeature =3D getChildFeature(eObject,=20
value);</STRONG></EM></FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2><EM><STRONG></STRONG></EM></FONT>&nbsp;</DIV >
<DIV><FONT face=3DArial size=3D2><EM><STRONG>&nbsp;&nbsp;&nbsp;&nbsp; if =

(childFeature !=3D null &amp;&amp; childFeature.isMany())=20
{</STRONG></EM></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><EM><STRONG>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
index -=3D 2;&nbsp;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Create a =
command=20
for this feature,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =
createMoveCommand(domain,=20
eObject, childFeature, value, index);<BR>&nbsp;&nbsp;&nbsp;&nbsp; } else =

{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return=20
UnexecutableCommand.INSTANCE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;}</STRONG></EM></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
schrieb im Newsbeitrag <A=20
=
href=3D"news:co7vd7$emk$1@www.eclipse.org">news:co7vd7$emk$1@www.eclipse.=
org</A>...</DIV>Harald,<BR><BR>DragAndDropCommand.prepareDropMoveInsert=20
will try to create a MoveCommand in some cases, such as when moving =
objects=20
from and to the same parent, which sounds like this case.&nbsp;&nbsp; =
All of=20
the commands created by the DragAndDropCommand require the feature to =
be=20
deduced, so some "factor" method will be called.<BR><BR><BR>harald =
l=F6hnert=20
wrote:=20
<BLOCKQUOTE cite=3Dmidco7tgs$c33$1@www.eclipse.org type=3D"cite"><PRE =
wrap=3D"">Ed,

the movement is done using the mouse (drag&amp;drop), so I think it's a
RemoveCommand followed by an AddComand. By debugging the =
"createAddCommand"
in the Main-ItemProvider I could see, that this gets invoked, but not =
the
factorAddCommand.

Thanks,
Harald

"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> schrieb im =
Newsbeitrag
<A class=3Dmoz-txt-link-freetext =
href=3D"news:co7sqn$b65$1@www.eclipse.org">news:co7sqn$b65$1@www.eclipse.=
org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Harald,

If it's a MoveCommand that's being created in this case, then it's
factorMoveCommand that needs the index correction.


Harald wrote:

</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I created a model and followed the example in section 14.2.3 in the
EMF-book to add additional nodes to the viewer.

My model (simplified):
Main
- io 1
- io 2
- io n
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

My view (simplified):
Main
+ ios
- io 1
- io 2
- io n
+ dps
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

I created an ItemProvider for "ios" and "dps" which are added in the
getChildren method of "Main" to the list of children. The function's
are added without an extra ItemProvider.

Everything works fine, except when I try to move a function to a
different position inwith "Main", the final position depends on the
number of io's and dp's. If there are no io's and dp's the "wrong"
offset is 2, if there a 2 io's or 2 dp's or 1 io and 1 dp, the final
position after the movement is correct.

Regarding a similar problem I had before Ed wrote something about the
method "factorAddCommand" and a correction of the index there. But in
my case this mehtod is not invoked. I think because the function is a
StructuralFeature.

Thanks for any help.


</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_001F_01C4D402.34ACCEE0--
Re: Non-Model Intermediary View Objects [message #389562 is a reply to message #389561] Fri, 26 November 2004 16:19 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------060109030003040805050009
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Harald,

Since the "section" items are there even when they have no children,
there will always be 2 children before the functions, so that sounds
right. Given that the eObject must be a "Main", you could use
((Main)eObject).getFunctions().contains(value) as your condition...


harald loehnert wrote:

> Thanks Ed,
>
> you are right, the "factorMoveCommand" gets called.
> Now I overwrite the "factorMoveCommand" in my Main-ItemProvider and
> decrease the index by 2.
> It works like this. Is it also the best way to do it ?
>
> Thanks,
> Harald.
>
> /*protected Command factorMoveCommand(EditingDomain domain,
> CommandParameter commandParameter) {
> */
> /* final EObject eObject = commandParameter.getEOwner();
> final Object value = commandParameter.getValue();
> int index = commandParameter.getIndex();*/
> /**/
> /* EStructuralFeature childFeature = getChildFeature(eObject,
> value);*/
> /**/
> /* if (childFeature != null && childFeature.isMany()) {*/
> /* index -= 2;
> // Create a command for this feature,
> //
> return createMoveCommand(domain, eObject, childFeature, value,
> index);
> } else {
> return UnexecutableCommand.INSTANCE;
> }
> }*/
>
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> schrieb im
> Newsbeitrag news:co7vd7$emk$1@www.eclipse.org...
> Harald,
>
> DragAndDropCommand.prepareDropMoveInsert will try to create a
> MoveCommand in some cases, such as when moving objects from and to
> the same parent, which sounds like this case. All of the
> commands created by the DragAndDropCommand require the feature to
> be deduced, so some "factor" method will be called.
>
>
> harald l
Re: Non-Model Intermediary View Objects [message #389563 is a reply to message #389562] Fri, 26 November 2004 16:40 Go to previous message
Eclipse UserFriend
Originally posted by: harald .loehnert.brueckner.de

This is a multi-part message in MIME format.

------=_NextPart_000_00F9_01C4D408.F2892E80
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ed,

I did like you suggested.
Thanks again for the great support.
Harald.
"Ed Merks" <merks@ca.ibm.com> schrieb im Newsbeitrag =
news:co86l8$on0$1@www.eclipse.org...
Harald,

Since the "section" items are there even when they have no children, =
there will always be 2 children before the functions, so that sounds =
right. Given that the eObject must be a "Main", you could use =
((Main)eObject).getFunctions().contains(value) as your condition...


harald loehnert wrote:=20
Thanks Ed,

you are right, the "factorMoveCommand" gets called.
Now I overwrite the "factorMoveCommand" in my Main-ItemProvider and =
decrease the index by 2.
It works like this. Is it also the best way to do it ?

Thanks,
Harald.

protected Command factorMoveCommand(EditingDomain domain, =
CommandParameter commandParameter) {
=20
final EObject eObject =3D commandParameter.getEOwner();
final Object value =3D commandParameter.getValue();
int index =3D commandParameter.getIndex();

EStructuralFeature childFeature =3D getChildFeature(eObject, =
value);

if (childFeature !=3D null && childFeature.isMany()) {
index -=3D 2;=20
// Create a command for this feature,
//
return createMoveCommand(domain, eObject, childFeature, =
value, index);
} else {
return UnexecutableCommand.INSTANCE;
}
}

"Ed Merks" <merks@ca.ibm.com> schrieb im Newsbeitrag =
news:co7vd7$emk$1@www.eclipse.org...
Harald,

DragAndDropCommand.prepareDropMoveInsert will try to create a =
MoveCommand in some cases, such as when moving objects from and to the =
same parent, which sounds like this case. All of the commands created =
by the DragAndDropCommand require the feature to be deduced, so some =
"factor" method will be called.


harald l=F6hnert wrote:=20
Ed,

the movement is done using the mouse (drag&drop), so I think it's a
RemoveCommand followed by an AddComand. By debugging the =
"createAddCommand"
in the Main-ItemProvider I could see, that this gets invoked, but not =
the
factorAddCommand.

Thanks,
Harald

"Ed Merks" <merks@ca.ibm.com> schrieb im Newsbeitrag
news:co7sqn$b65$1@www.eclipse.org...
Harald,

If it's a MoveCommand that's being created in this case, then it's
factorMoveCommand that needs the index correction.


Harald wrote:

Hi,

I created a model and followed the example in section 14.2.3 in the
EMF-book to add additional nodes to the viewer.

My model (simplified):
Main
- io 1
- io 2
- io n
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

My view (simplified):
Main
+ ios
- io 1
- io 2
- io n
+ dps
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

I created an ItemProvider for "ios" and "dps" which are added in the
getChildren method of "Main" to the list of children. The function's
are added without an extra ItemProvider.

Everything works fine, except when I try to move a function to a
different position inwith "Main", the final position depends on the
number of io's and dp's. If there are no io's and dp's the "wrong"
offset is 2, if there a 2 io's or 2 dp's or 1 io and 1 dp, the final
position after the movement is correct.

Regarding a similar problem I had before Ed wrote something about the
method "factorAddCommand" and a correction of the index there. But in
my case this mehtod is not invoked. I think because the function is a
StructuralFeature.

Thanks for any help.


=20

=20



------=_NextPart_000_00F9_01C4D408.F2892E80
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I did like you suggested.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thanks again for the great =
support.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Harald.</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
schrieb im Newsbeitrag <A=20
=
href=3D"news:co86l8$on0$1@www.eclipse.org">news:co86l8$on0$1@www.eclipse.=
org</A>...</DIV>Harald,<BR><BR>Since=20
the "section" items are there even when they have no children, there =
will=20
always be 2 children before the functions, so that sounds right.&nbsp; =
Given=20
that the eObject must be a "Main", you could use=20
((Main)eObject).getFunctions().contains(value) as your=20
condition...<BR><BR><BR>harald loehnert wrote:=20
<BLOCKQUOTE cite=3Dmidco84us$luu$1@www.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>Thanks Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>you are right, the =
"factorMoveCommand" gets=20
called.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Now I&nbsp;overwrite the=20
"factorMoveCommand"&nbsp;in my Main-ItemProvider and decrease the =
index by=20
2.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>It works like this. Is it also the =
best way to=20
do it ?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Harald.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><EM><STRONG>protected Command=20
factorMoveCommand(EditingDomain domain, CommandParameter =
commandParameter)=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; </STRONG></EM></FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2><EM><STRONG>&nbsp;&nbsp;&nbsp;&nbsp; final=20
EObject eObject =3D =
commandParameter.getEOwner();<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
final Object value =3D=20
commandParameter.getValue();<BR>&nbsp;&nbsp;&nbsp;&nbsp; int index =
=3D=20
commandParameter.getIndex();</STRONG></EM></FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2><EM><STRONG></STRONG></EM></FONT>&nbsp;</DIV >
<DIV><FONT face=3DArial =
size=3D2><EM><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;=20
EStructuralFeature childFeature =3D getChildFeature(eObject,=20
value);</STRONG></EM></FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2><EM><STRONG></STRONG></EM></FONT>&nbsp;</DIV >
<DIV><FONT face=3DArial =
size=3D2><EM><STRONG>&nbsp;&nbsp;&nbsp;&nbsp; if=20
(childFeature !=3D null &amp;&amp; childFeature.isMany())=20
{</STRONG></EM></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><EM><STRONG>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; index -=3D =
2;&nbsp;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =20
// Create a command for this=20
feature,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =20
//<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =
createMoveCommand(domain,=20
eObject, childFeature, value, index);<BR>&nbsp;&nbsp;&nbsp;&nbsp; } =
else=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return=20
UnexecutableCommand.INSTANCE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;}</STRONG></EM></FONT></DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; schrieb =
im=20
Newsbeitrag <A=20
=
href=3D"news:co7vd7$emk$1@www.eclipse.org">news:co7vd7$emk$1@www.eclipse.=
org</A>...</DIV>Harald,<BR><BR>DragAndDropCommand.prepareDropMoveInsert=20
will try to create a MoveCommand in some cases, such as when =
moving=20
objects from and to the same parent, which sounds like this=20
case.&nbsp;&nbsp; All of the commands created by the =
DragAndDropCommand=20
require the feature to be deduced, so some "factor" method will be =

called.<BR><BR><BR>harald l=F6hnert wrote:=20
<BLOCKQUOTE cite=3Dmidco7tgs$c33$1@www.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Ed,

the movement is done using the mouse (drag&amp;drop), so I think it's a
RemoveCommand followed by an AddComand. By debugging the =
"createAddCommand"
in the Main-ItemProvider I could see, that this gets invoked, but not =
the
factorAddCommand.

Thanks,
Harald

"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> schrieb im =
Newsbeitrag
<A class=3Dmoz-txt-link-freetext =
href=3D"news:co7sqn$b65$1@www.eclipse.org">news:co7sqn$b65$1@www.eclipse.=
org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Harald,

If it's a MoveCommand that's being created in this case, then it's
factorMoveCommand that needs the index correction.


Harald wrote:

</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I created a model and followed the example in section 14.2.3 in the
EMF-book to add additional nodes to the viewer.

My model (simplified):
Main
- io 1
- io 2
- io n
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

My view (simplified):
Main
+ ios
- io 1
- io 2
- io n
+ dps
- dp 1
- dp 2
- dp n
- function 1
- function 2
- function n

I created an ItemProvider for "ios" and "dps" which are added in the
getChildren method of "Main" to the list of children. The function's
are added without an extra ItemProvider.

Everything works fine, except when I try to move a function to a
different position inwith "Main", the final position depends on the
number of io's and dp's. If there are no io's and dp's the "wrong"
offset is 2, if there a 2 io's or 2 dp's or 1 io and 1 dp, the final
position after the movement is correct.

Regarding a similar problem I had before Ed wrote something about the
method "factorAddCommand" and a correction of the index there. But in
my case this mehtod is not invoked. I think because the function is a
StructuralFeature.

Thanks for any help.


</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BODY>=
</HTML>

------=_NextPart_000_00F9_01C4D408.F2892E80--
Previous Topic:More about 'partial code generation'
Next Topic:EMF genererated code
Goto Forum:
  


Current Time: Mon Sep 15 17:47:28 EDT 2025

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

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

Back to the top