Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » JFace Drag and Drop
JFace Drag and Drop [message #324582] Mon, 28 January 2008 03:21 Go to next message
Eclipse UserFriend
Hi,

I use
StructuredViewer.addDragSupport, addDropSupport
and ViewerDropAdapter to implement DnD in my RCP-App.
Now I read the following in the Javadoc for DragSource/DropTarget:

"Creating an instance of a DropTarget may cause system resources to be
allocated depending on the platform. It is therefore mandatory that the
DropTarget instance be disposed when no longer required."

Is this taken care of for me or do I have to do anything regarding this?

thanks,
Manuel

--
Re: JFace Drag and Drop [message #324587 is a reply to message #324582] Mon, 28 January 2008 06:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------080703090009040304060008
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Manuel,

It's a bit of an odd comment considering the source code which clearly
indicates that the drop target is disposed when the control itself is
disposed:

public DropTarget(Control control, int style) {
super (control, checkStyle(style));
this.control = control;
if (control.getData(DROPTARGETID) != null) {
DND.error(DND.ERROR_CANNOT_INIT_DROP);
}
control.setData(DROPTARGETID, this);
createCOMInterfaces();
this.AddRef();

if (COM.CoLockObjectExternal(iDropTarget.getAddress(), true,
true) != COM.S_OK)
DND.error(DND.ERROR_CANNOT_INIT_DROP);
if (COM.RegisterDragDrop( control.handle,
iDropTarget.getAddress()) != COM.S_OK)
DND.error(DND.ERROR_CANNOT_INIT_DROP);

* controlListener = new Listener () {
public void handleEvent (Event event) {
if (!DropTarget.this.isDisposed()){
DropTarget.this.dispose();
}
}
};
control.addListener (SWT.Dispose, controlListener);*

this.addListener(SWT.Dispose, new Listener () {
public void handleEvent (Event event) {
onDispose();
}
});

Object effect = control.getData(DEFAULT_DROP_TARGET_EFFECT);
if (effect instanceof DropTargetEffect) {
dropEffect = (DropTargetEffect) effect;
} else if (control instanceof Table) {
dropEffect = new TableDropTargetEffect((Table) control);
} else if (control instanceof Tree) {
dropEffect = new TreeDropTargetEffect((Tree) control);
}
}





Manuel Steurer wrote:
> Hi,
>
> I use
> StructuredViewer.addDragSupport, addDropSupport
> and ViewerDropAdapter to implement DnD in my RCP-App.
> Now I read the following in the Javadoc for DragSource/DropTarget:
>
> "Creating an instance of a DropTarget may cause system resources to be
> allocated depending on the platform. It is therefore mandatory that the
> DropTarget instance be disposed when no longer required."
>
> Is this taken care of for me or do I have to do anything regarding this?
>
> thanks,
> Manuel
>
>


--------------080703090009040304060008
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Manuel,<br>
<br>
It's a bit of an odd comment considering the source code which clearly
indicates that the drop target is disposed when the control itself is
disposed:<br>
<blockquote><small>public DropTarget(Control control, int style) {</small><br>
<small>&nbsp;&nbsp;&nbsp; super (control, checkStyle(style));</small><br>
<small>&nbsp;&nbsp;&nbsp; this.control = control;</small><br>
<small>&nbsp;&nbsp;&nbsp; if (control.getData(DROPTARGETID) != null) {</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; DND.error(DND.ERROR_CANNOT_INIT_DROP);</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; control.setData(DROPTARGETID, this);</small><br>
<small>&nbsp;&nbsp;&nbsp; createCOMInterfaces();</small><br>
<small>&nbsp;&nbsp;&nbsp; this.AddRef();</small><br>
<small>&nbsp;&nbsp;&nbsp; </small><br>
<small>&nbsp;&nbsp;&nbsp; if (COM.CoLockObjectExternal(iDropTarget.getAddress(),
true, true) != COM.S_OK)</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; DND.error(DND.ERROR_CANNOT_INIT_DROP);</small><br>
<small>&nbsp;&nbsp;&nbsp; if (COM.RegisterDragDrop( control.handle,
iDropTarget.getAddress()) != COM.S_OK)</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; DND.error(DND.ERROR_CANNOT_INIT_DROP);</small><br>
<br>
<b><small>&nbsp;&nbsp;&nbsp; controlListener = new Listener () {</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public void handleEvent (Event event) {</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!DropTarget.this.isDisposed()){</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; DropTarget.this.dispose();</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; };</small><br>
<small>&nbsp;&nbsp;&nbsp; control.addListener (SWT.Dispose, controlListener);</small></b><br>
<small>&nbsp;&nbsp;&nbsp; </small><br>
<small>&nbsp;&nbsp;&nbsp; this.addListener(SWT.Dispose, new Listener () {</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public void handleEvent (Event event) {</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; onDispose();</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; });</small><br>
<small>&nbsp;&nbsp;&nbsp; </small><br>
<small>&nbsp;&nbsp;&nbsp; Object effect =
control.getData(DEFAULT_DROP_TARGET_EFFECT);</small><br>
<small>&nbsp;&nbsp;&nbsp; if (effect instanceof DropTargetEffect) {</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dropEffect = (DropTargetEffect) effect;</small><br>
<small>&nbsp;&nbsp;&nbsp; } else if (control instanceof Table) {</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dropEffect = new TableDropTargetEffect((Table)
control);</small><br>
<small>&nbsp;&nbsp;&nbsp; } else if (control instanceof Tree) {</small><br>
<small>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dropEffect = new TreeDropTargetEffect((Tree) control);</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>}</small><br>
</blockquote>
<br>
<br>
<br>
<br>
Manuel Steurer wrote:
<blockquote cite="mid:fnk3b3$veq$1@build.eclipse.org" type="cite">
<pre wrap="">Hi,

I use
StructuredViewer.addDragSupport, addDropSupport
and ViewerDropAdapter to implement DnD in my RCP-App.
Now I read the following in the Javadoc for DragSource/DropTarget:

"Creating an instance of a DropTarget may cause system resources to be
allocated depending on the platform. It is therefore mandatory that the
DropTarget instance be disposed when no longer required."

Is this taken care of for me or do I have to do anything regarding this?

thanks,
Manuel

</pre>
</blockquote>
<br>
</body>
</html>

--------------080703090009040304060008--
Re: JFace Drag and Drop [message #324590 is a reply to message #324587] Mon, 28 January 2008 08:02 Go to previous message
Eclipse UserFriend
Thanks for your answer, it's clear to me now.

Ed Merks wrote:

> Manuel,
>
> It's a bit of an odd comment considering the source code which
> clearly indicates that the drop target is disposed when the control
> itself is disposed:
>
> public DropTarget(Control control, int style) {
> super (control, checkStyle(style));
> this.control = control;
> if (control.getData(DROPTARGETID) != null) {
> DND.error(DND.ERROR_CANNOT_INIT_DROP);
> }
> control.setData(DROPTARGETID, this);
> createCOMInterfaces();
> this.AddRef();
> if (COM.CoLockObjectExternal(iDropTarget.getAddress(),
> true, true) != COM.S_OK)
> DND.error(DND.ERROR_CANNOT_INIT_DROP);
> if (COM.RegisterDragDrop( control.handle,
> iDropTarget.getAddress()) != COM.S_OK)
> DND.error(DND.ERROR_CANNOT_INIT_DROP);
>
> * controlListener = new Listener () {
> public void handleEvent (Event event) {
> if (!DropTarget.this.isDisposed()){
> DropTarget.this.dispose();
> }
> }
> };
> control.addListener (SWT.Dispose, controlListener);*
> this.addListener(SWT.Dispose, new Listener () {
> public void handleEvent (Event event) {
> onDispose();
> }
> });
> Object effect =
> control.getData(DEFAULT_DROP_TARGET_EFFECT); if (effect
> instanceof DropTargetEffect) { dropEffect =
> (DropTargetEffect) effect; } else if (control instanceof
> Table) { dropEffect = new TableDropTargetEffect((Table)
> control); } else if (control instanceof Tree) {
> dropEffect = new TreeDropTargetEffect((Tree) control);
> }
> }
>
>
>
>
>
> Manuel Steurer wrote:
> > Hi,
> >
> > I use StructuredViewer.addDragSupport, addDropSupport
> > and ViewerDropAdapter to implement DnD in my RCP-App.
> > Now I read the following in the Javadoc for DragSource/DropTarget:
> >
> > "Creating an instance of a DropTarget may cause system resources to
> > be allocated depending on the platform. It is therefore mandatory
> > that the DropTarget instance be disposed when no longer required."
> >
> > Is this taken care of for me or do I have to do anything regarding
> > this?
> >
> > thanks,
> > Manuel
> >
> >



--
Previous Topic:resource.getWorkspace() vs. ResourcesPlugin.getWorkspace()
Next Topic:PDE builds and builds and builds...
Goto Forum:
  


Current Time: Fri Sep 19 19:46:49 EDT 2025

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

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

Back to the top