JFace Drag and Drop [message #324582] |
Mon, 28 January 2008 03:21  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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> super (control, checkStyle(style));</small><br>
<small> this.control = control;</small><br>
<small> if (control.getData(DROPTARGETID) != null) {</small><br>
<small> DND.error(DND.ERROR_CANNOT_INIT_DROP);</small><br>
<small> }</small><br>
<small> control.setData(DROPTARGETID, this);</small><br>
<small> createCOMInterfaces();</small><br>
<small> this.AddRef();</small><br>
<small> </small><br>
<small> if (COM.CoLockObjectExternal(iDropTarget.getAddress(),
true, true) != COM.S_OK)</small><br>
<small> DND.error(DND.ERROR_CANNOT_INIT_DROP);</small><br>
<small> if (COM.RegisterDragDrop( control.handle,
iDropTarget.getAddress()) != COM.S_OK)</small><br>
<small> DND.error(DND.ERROR_CANNOT_INIT_DROP);</small><br>
<br>
<b><small> controlListener = new Listener () {</small><br>
<small> public void handleEvent (Event event) {</small><br>
<small> if (!DropTarget.this.isDisposed()){</small><br>
<small> DropTarget.this.dispose();</small><br>
<small> }</small><br>
<small> }</small><br>
<small> };</small><br>
<small> control.addListener (SWT.Dispose, controlListener);</small></b><br>
<small> </small><br>
<small> this.addListener(SWT.Dispose, new Listener () {</small><br>
<small> public void handleEvent (Event event) {</small><br>
<small> onDispose();</small><br>
<small> }</small><br>
<small> });</small><br>
<small> </small><br>
<small> Object effect =
control.getData(DEFAULT_DROP_TARGET_EFFECT);</small><br>
<small> if (effect instanceof DropTargetEffect) {</small><br>
<small> dropEffect = (DropTargetEffect) effect;</small><br>
<small> } else if (control instanceof Table) {</small><br>
<small> dropEffect = new TableDropTargetEffect((Table)
control);</small><br>
<small> } else if (control instanceof Tree) {</small><br>
<small> dropEffect = new TreeDropTargetEffect((Tree) control);</small><br>
<small> }</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  |
Eclipse User |
|
|
|
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
> >
> >
--
|
|
|
Powered by
FUDForum. Page generated in 0.04896 seconds