|
Re: How do I go about implementing paste at position [message #193441 is a reply to message #191841] |
Thu, 19 June 2008 08:15 |
Kristian O'Connor Messages: 29 Registered: July 2009 |
Junior Member |
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0020_01C8D1ED.076E42A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all -
I have come up with a solution whereby I put the 'to be pasted' books =
notational and semantical positions into a 'hints' map - then use that =
later in the copy and paste process to paste those elements at the =
specific positions...
ie. had to hack out the ClipboardSupportUtil and change the =
appendEObjectAt method to take a position argument...
eg.
public static EObject appendEObjectAt(int position, EObject eObject, =
EReference reference, EObject referencedObject)
{
if (isOkToAppendEObjectAt(eObject, reference, referencedObject) =
=3D=3D false)
{
return null;
}
if (reference.isContainment())
{
((InternalEObject) referencedObject).eSetResource(null, null);
sendCreateEvent(referencedObject);
}
// if pasting into a list...
if (((Collection) eObject.eGet(reference)) instanceof BasicEList && =
position >=3D 0)
{
((BasicEList) eObject.eGet(reference)).add(position, =
referencedObject);
}
else
{
// default behaviour...
((Collection) eObject.eGet(reference)).add(referencedObject);
}
return referencedObject;
}
Its a bit hacky but seems to work... the only issue left is that the =
pasted elements (i.e. when more than one book was copied) occur in the =
reverse order of the selection...
Thanks all..
K.
"Kristian O'Connor" <kristian.oconnor@gmail.com> wrote in message =
news:g2ljgl$fdt$1@build.eclipse.org...
> Hi all -
>=20
> I hope someone can help - currently developing something akin to a =
bookshelf=20
> with an ordered list of books on it... the bookshelf is a compartment =
and=20
> the books are added into that compartment as a list - i.e. they have=20
> position...
>=20
> When copying and pasting between compartments - the book always gets =
added=20
> to the end of the list... but I would like to paste at a specific =
position=20
> in the list...
>=20
> Currently we have a ripped up some of the GMF codebase to allow for =
pasting=20
> within containers... but how would I go about determining the position =
the=20
> paste occured in the compartment - and pass that along in a modified =
version=20
> of PasteRequest! or can I gain access to that location when executing =
a=20
> paste command.?!
>=20
> Any thoughts - is this possible.?!
>=20
> Thanks in advance -
> Kristian O'Connor=20
>=20
>
------=_NextPart_000_0020_01C8D1ED.076E42A0
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=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16640" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi all -</FONT></DIV>
<DIV><FONT size=3D2><FONT face=3DArial =
size=3D2></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have come up with a solution whereby =
I put the=20
'to be pasted' books notational and semantical positions into a 'hints' =
map -=20
then use that later in the copy and paste process to paste those =
elements at the=20
specific positions...</FONT></DIV>
<DIV><FONT size=3D2><FONT face=3DArial =
size=3D2></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>ie. had to hack out the =
ClipboardSupportUtil and=20
change the appendEObjectAt method to take a position =
argument...</FONT></DIV>
<DIV><FONT size=3D2><FONT face=3DArial =
size=3D2></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>eg.</FONT></DIV>
<DIV align=3Djustify><B><FONT color=3D#7f0055><FONT face=3DArial=20
size=3D2>public</FONT></B></FONT><FONT size=3D2><FONT face=3DArial> =
<B><FONT=20
color=3D#7f0055>static</B></FONT></FONT></FONT><FONT size=3D2><FONT =
face=3DArial>=20
EObject appendEObjectAt(<B><FONT =
color=3D#7f0055>int</B></FONT></FONT></FONT><FONT=20
face=3DArial size=3D2> position, EObject eObject, </FONT><FONT =
face=3DArial=20
size=3D2>EReference reference, EObject referencedObject)</FONT></DIV>
<DIV align=3Djustify><FONT face=3DArial size=3D2>{</FONT></DIV>
<DIV align=3Djustify><B><FONT color=3D#7f0055><FONT face=3DArial=20
size=3D2> if</FONT></B></FONT><FONT size=3D2><FONT =
face=3DArial>=20
(<I>isOkToAppendEObjectAt</I>(eObject, reference, referencedObject) =
=3D=3D <B><FONT=20
color=3D#7f0055>false</B></FONT></FONT></FONT><FONT face=3DArial=20
size=3D2>)</FONT></DIV>
<DIV align=3Djustify><FONT face=3DArial size=3D2> =
{</FONT></DIV>
<DIV align=3Djustify><B><FONT color=3D#7f0055><FONT face=3DArial=20
size=3D2> =
return</FONT></B></FONT><FONT=20
size=3D2><FONT face=3DArial> <B><FONT=20
color=3D#7f0055>null</B></FONT></FONT></FONT><FONT face=3DArial=20
size=3D2>;</FONT></DIV>
<DIV align=3Djustify><FONT face=3DArial size=3D2> =
}</FONT></DIV>
<DIV align=3Djustify><B><FONT color=3D#7f0055><FONT face=3DArial=20
size=3D2> if</FONT></B></FONT><FONT face=3DArial =
size=3D2>=20
(reference.isContainment())</FONT></DIV>
<DIV align=3Djustify><FONT face=3DArial size=3D2> =
{</FONT></DIV>
<DIV align=3Djustify><FONT size=3D2><FONT =
face=3DArial> =20
((InternalEObject) =
referencedObject).eSetResource(<B><FONT=20
color=3D#7f0055>null</B></FONT></FONT></FONT><FONT size=3D2><FONT =
face=3DArial>,=20
<B><FONT color=3D#7f0055>null</B></FONT></FONT></FONT><FONT face=3DArial =
size=3D2>);</FONT></DIV>
<DIV align=3Djustify><FONT size=3D2><FONT =
face=3DArial><I> =20
=
sendCreateEvent</I>(referencedObject);</FONT></FONT></DIV >
<DIV align=3Djustify><FONT face=3DArial size=3D2> =
}</FONT></DIV>
<DIV align=3Djustify><FONT size=3D2><FONT size=3D2><FONT face=3DArial=20
size=3D2></FONT></FONT></FONT> </DIV>
<DIV align=3Djustify><FONT color=3D#3f7f5f><FONT face=3DArial=20
size=3D2> // if pasting into a =
list...</FONT></DIV></FONT>
<DIV align=3Djustify><B><FONT color=3D#7f0055><FONT face=3DArial=20
size=3D2> if</FONT> </B></FONT><FONT =
size=3D2><FONT=20
face=3DArial> (((Collection) eObject.eGet(reference)) <B><FONT=20
color=3D#7f0055>instanceof</B></FONT></FONT></FONT><FONT face=3DArial =
size=3D2>=20
BasicEList </FONT><FONT face=3DArial size=3D2>&& position =
>=3D=20
0)</FONT></DIV>
<DIV align=3Djustify><FONT face=3DArial size=3D2> =
{</FONT></DIV>
<DIV align=3Djustify><FONT face=3DArial size=3D2> =
=20
((BasicEList) eObject.eGet(reference)).add(position,=20
referencedObject);</FONT></DIV>
<DIV align=3Djustify><FONT face=3DArial=20
size=3D2> }</FONT></DIV >
<DIV align=3Dleft><B><FONT color=3D#7f0055><FONT face=3DArial=20
size=3D2> else</FONT></DIV></B></FONT><FONT size=3D2>
<DIV align=3Dleft><FONT face=3DArial> {</FONT></DIV>
<DIV align=3Dleft></FONT><FONT color=3D#3f7f5f size=3D2><FONT=20
face=3DArial> // default=20
behaviour...</FONT></DIV></FONT><FONT size=3D2>
<DIV align=3Dleft><FONT face=3DArial> =
=20
((Collection) =
eObject.eGet(reference)).add(referencedObject);</FONT></DIV >
<DIV align=3Dleft><FONT face=3DArial> }</FONT></DIV>
<DIV align=3Dleft></FONT><B><FONT color=3D#7f0055 size=3D2><FONT=20
face=3DArial> return</FONT></B></FONT><FONT =
size=3D2><FONT=20
face=3DArial> referencedObject;</FONT></DIV>
<DIV><FONT face=3DArial>}</FONT></DIV></FONT>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Its a bit hacky but seems to work... =
the only issue=20
left is that the pasted elements (i.e. when more than one book was =
copied) occur=20
in the reverse order of the selection...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks all..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>K.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>"Kristian O'Connor" <</FONT><A=20
href=3D"mailto:kristian.oconnor@gmail.com"><FONT face=3DArial=20
size=3D2>kristian.oconnor@gmail.com</FONT></A><FONT face=3DArial =
size=3D2>> wrote=20
in message </FONT><A href=3D"news:g2ljgl$fdt$1@build.eclipse.org"><FONT =
face=3DArial=20
size=3D2>news:g2ljgl$fdt$1@build.eclipse.org</FONT></A><FONT =
face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>> Hi all =
-<BR>> <BR>> I=20
hope someone can help - currently developing something akin to a =
bookshelf=20
<BR>> with an ordered list of books on it... the bookshelf is a =
compartment and <BR>> the books are added into that compartment as a =
list -=20
i.e. they have <BR>> position...<BR>> <BR>> When copying and =
pasting=20
between compartments - the book always gets added <BR>> to the end of =
the=20
list... but I would like to paste at a specific position <BR>> in the =
list...<BR>> <BR>> Currently we have a ripped up some of the GMF =
codebase=20
to allow for pasting <BR>> within containers... but how would I go =
about=20
determining the position the <BR>> paste occured in the compartment - =
and=20
pass that along in a modified version <BR>> of PasteRequest! or can I =
gain=20
access to that location when executing a <BR>> paste =
command.?!<BR>>=20
<BR>> Any thoughts - is this possible.?!<BR>> <BR>> Thanks in =
advance=20
-<BR>> Kristian O'Connor <BR>> <BR>></FONT></BODY></HTML>
------=_NextPart_000_0020_01C8D1ED.076E42A0--
|
|
|
Powered by
FUDForum. Page generated in 0.03350 seconds