Skip to main content



      Home
Home » Eclipse Projects » GEF » a question on drag and drop a text from Word editor to Graphical Editor
a question on drag and drop a text from Word editor to Graphical Editor [message #14461] Mon, 22 July 2002 04:55 Go to next message
Eclipse UserFriend
Originally posted by: tiffany.chen.intech.com.tw

Hi,

I want to add a drop listener to my Graphical Editor which will receive
text dragged from Word. Actually I am modifing the example
com.ibm.etools.gef.examples.logicdesigner to fit my requirement, but I
can't get the text dragged from Word. I added a System.out.println
command in updateTargetReques to check out the dragged data, but it's
always null.
I also add dragEnter(DropTargetEvent event) and drop(DropTargetEvent
event) methods to updateTargetReques(), but they never get triggered. Why
is that?

Any help would be aprreciated.

Here is my code:
-----------------------
public class LogicEditor
extends GraphicalEditorWithPalette
implements CommandStackListener
{
protected void initializeGraphicalViewer() {
getGraphicalViewer().setContents(getLogicDiagram());
getGraphicalViewer().addDropTargetListener(
new TextTransferDropTargetListener(getGraphicalViewer(),

TextTransfer.getInstance()));

}
}
-------------------------
public class TextTransferDropTargetListener
extends AbstractTransferDropTargetListener
{

public TextTransferDropTargetListener(EditPartViewer viewer, Transfer
xfer) {
super(viewer, xfer);
}

protected boolean canHandleDrop(DropTargetEvent event) {
return true;
}

protected Request createTargetRequest() {
return new NativeDropRequest();
}

protected NativeDropRequest getNativeDropRequest() {
System.out.println("getNativeDropRequest");
return (NativeDropRequest)getTargetRequest();
}

protected void updateTargetRequest(){
getNativeDropRequest().setData(getCurrentEvent().data);

System.out.println("updateTargetRequest.data= " + getCurrentEvent
().data);
//the event data is null here

}
}
------------------
Re: a question on drag and drop a text from Word editor to Graphical Editor [message #14551 is a reply to message #14461] Mon, 22 July 2002 08:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.ibm.com

The data is always null until the actual drop occurs. This is due to
limitations on some SWT platforms.

The event data will be set only for the very last callback, which I think is
handleDrop or something.

"Tiffany" <tiffany.chen@intech.com.tw> wrote in message
news:ahgham$5mt$1@rogue.oti.com...
> Hi,
>
> I want to add a drop listener to my Graphical Editor which will receive
> text dragged from Word. Actually I am modifing the example
> com.ibm.etools.gef.examples.logicdesigner to fit my requirement, but I
> can't get the text dragged from Word. I added a System.out.println
> command in updateTargetReques to check out the dragged data, but it's
> always null.
> I also add dragEnter(DropTargetEvent event) and drop(DropTargetEvent
> event) methods to updateTargetReques(), but they never get triggered. Why
> is that?
>
> Any help would be aprreciated.
>
> Here is my code:
> -----------------------
> public class LogicEditor
> extends GraphicalEditorWithPalette
> implements CommandStackListener
> {
> protected void initializeGraphicalViewer() {
> getGraphicalViewer().setContents(getLogicDiagram());
> getGraphicalViewer().addDropTargetListener(
> new TextTransferDropTargetListener(getGraphicalViewer(),
>
> TextTransfer.getInstance()));
>
> }
> }
> -------------------------
> public class TextTransferDropTargetListener
> extends AbstractTransferDropTargetListener
> {
>
> public TextTransferDropTargetListener(EditPartViewer viewer, Transfer
> xfer) {
> super(viewer, xfer);
> }
>
> protected boolean canHandleDrop(DropTargetEvent event) {
> return true;
> }
>
> protected Request createTargetRequest() {
> return new NativeDropRequest();
> }
>
> protected NativeDropRequest getNativeDropRequest() {
> System.out.println("getNativeDropRequest");
> return (NativeDropRequest)getTargetRequest();
> }
>
> protected void updateTargetRequest(){
> getNativeDropRequest().setData(getCurrentEvent().data);
>
> System.out.println("updateTargetRequest.data= " + getCurrentEvent
> ().data);
> //the event data is null here
>
> }
> }
> ------------------
>
>
>
Re: a question on drag and drop a text from Word editor to Graphical Editor [message #14730 is a reply to message #14461] Mon, 22 July 2002 10:02 Go to previous messageGo to next message
Eclipse UserFriend
Tiffany,

Make sure your EditPart has an EditPolicy installed that is similar to
LogicLabelEditPolicy. Also, you can use the GEF debug view to see what's going
on during the drag. If you have the com.ibm.etools.gef.doc.isv plugin, go to
Window... Show View... Other and choose GEF Developer... GEF Debug. Click the
hand icon to see DND messages. If everything is working correctly, you should
see messages similar to these...

37 Drag Enter: com.ibm.etools.gef.dnd.DelegatingDropAdapter@1a5af9f
38 Entered EditPart: LogicLabelEditPart( Label #1 Text=Label )
39 Current listener
com.ibm.etools.gef.examples.logicdesigner.TextTransferDropTa rgetListener @15e538e
40 Drag Over:
com.ibm.etools.gef.examples.logicdesigner.TextTransferDropTa rgetListener @15e538e
41 Drag Over:
com.ibm.etools.gef.examples.logicdesigner.TextTransferDropTa rgetListener @15e538e
42 Drag Over:
com.ibm.etools.gef.examples.logicdesigner.TextTransferDropTa rgetListener @15e538e
43 Drag Over:
com.ibm.etools.gef.examples.logicdesigner.TextTransferDropTa rgetListener @15e538e
44 Drag Leave: com.ibm.etools.gef.dnd.DelegatingDropAdapter@1a5af9f
45 Drag Leave:
com.ibm.etools.gef.examples.logicdesigner.TextTransferDropTa rgetListener @15e538e
46 Drop Accept: com.ibm.etools.gef.dnd.DelegatingDropAdapter@1a5af9f
47 Drop Accept:
com.ibm.etools.gef.examples.logicdesigner.TextTransferDropTa rgetListener @15e538e
48 Drop: com.ibm.etools.gef.dnd.DelegatingDropAdapter@1a5af9f
49 Drop:
com.ibm.etools.gef.examples.logicdesigner.TextTransferDropTa rgetListener @15e538e
50 Exited EditPart: LogicLabelEditPart( Label #1 Text=New Text )
51 Entered EditPart: null
52 Current listener null



"Tiffany" <tiffany.chen@intech.com.tw> wrote in message
news:ahgham$5mt$1@rogue.oti.com...
> Hi,
>
> I want to add a drop listener to my Graphical Editor which will receive
> text dragged from Word. Actually I am modifing the example
> com.ibm.etools.gef.examples.logicdesigner to fit my requirement, but I
> can't get the text dragged from Word. I added a System.out.println
> command in updateTargetReques to check out the dragged data, but it's
> always null.
> I also add dragEnter(DropTargetEvent event) and drop(DropTargetEvent
> event) methods to updateTargetReques(), but they never get triggered. Why
> is that?
>
> Any help would be aprreciated.
>
> Here is my code:
> -----------------------
> public class LogicEditor
> extends GraphicalEditorWithPalette
> implements CommandStackListener
> {
> protected void initializeGraphicalViewer() {
> getGraphicalViewer().setContents(getLogicDiagram());
> getGraphicalViewer().addDropTargetListener(
> new TextTransferDropTargetListener(getGraphicalViewer(),
>
> TextTransfer.getInstance()));
>
> }
> }
> -------------------------
> public class TextTransferDropTargetListener
> extends AbstractTransferDropTargetListener
> {
>
> public TextTransferDropTargetListener(EditPartViewer viewer, Transfer
> xfer) {
> super(viewer, xfer);
> }
>
> protected boolean canHandleDrop(DropTargetEvent event) {
> return true;
> }
>
> protected Request createTargetRequest() {
> return new NativeDropRequest();
> }
>
> protected NativeDropRequest getNativeDropRequest() {
> System.out.println("getNativeDropRequest");
> return (NativeDropRequest)getTargetRequest();
> }
>
> protected void updateTargetRequest(){
> getNativeDropRequest().setData(getCurrentEvent().data);
>
> System.out.println("updateTargetRequest.data= " + getCurrentEvent
> ().data);
> //the event data is null here
>
> }
> }
> ------------------
>
>
>
Re: a question on drag and drop a text from Word editor to Graphical Editor [message #15602 is a reply to message #14730] Thu, 25 July 2002 02:34 Go to previous message
Eclipse UserFriend
Originally posted by: tiffany.chen.intech.com.tw

Thanks for your help. I got it working now.

Tiffany
Previous Topic:starting a connection not from the palette
Next Topic:Delegation of selection
Goto Forum:
  


Current Time: Sat May 10 15:13:27 EDT 2025

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

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

Back to the top