Display display = event.display; display.asyncExec(new Runnable() { public void run() { if (DropTarget.this.control == null || DropTarget.this.control.isDisposed() || DropTarget.this.control.isVisible()) return;  unregisterDropTarget(); } });
int[] args = new int[]{OS.XmNdropSiteActivity,   OS.XmDROP_SITE_INACTIVE,}; OS.XmDropSiteUpdate(DropTarget.this.control.handle, args, args.length/2);
public DropTarget(Control control, int style) {	super (control, checkStyle(style));	this.control = control;	if (DropProc == null || DragProc == null || TransferProc == null) {		DND.error(DND.ERROR_CANNOT_INIT_DROP);	}	if (control.getData(DROPTARGETID) != null) {		DND.error(DND.ERROR_CANNOT_INIT_DROP);	}	control.setData(DROPTARGETID, this);	controlListener = new Listener () {		public void handleEvent (Event event) {			switch (event.type) {				case SWT.Dispose: {					if (!DropTarget.this.isDisposed()){						onDispose();					}					break;				}				case SWT.Show: {					Display display = event.display;					display.asyncExec(new Runnable() {						public void run() {							if (DropTarget.this.control == null || 								DropTarget.this.control.isDisposed() ||								!DropTarget.this.control.isVisible()) return;							registerDropTarget();						}					});					break;				}				case SWT.Hide: {					Display display = event.display;					display.asyncExec(new Runnable() {						public void run() {							if (DropTarget.this.control == null || 							    DropTarget.this.control.isDisposed() || 							    DropTarget.this.control.isVisible()) return;												unregisterDropTarget();						}					});						break;				}			}		}	};	control.addListener (SWT.Dispose, controlListener);	Control c = control;	while (c != null) {		c.addListener (SWT.Show, controlListener);		c.addListener (SWT.Hide, controlListener);		c = c.getParent();	}	this.addListener(SWT.Dispose, new Listener () {		public void handleEvent (Event event) {			if (DropTarget.this.control == null || 				DropTarget.this.control.isDisposed()) return;						unregisterDropTarget();			onDispose();		}	});	// Drag under effect	if (control instanceof Tree) {		effect = new TreeDragUnderEffect((Tree)control);	} else if (control instanceof Table) {		effect = new TableDragUnderEffect((Table)control);	} else {		effect = new NoDragUnderEffect(control);	}	if (control.isVisible()) registerDropTarget();		dragOverHeartbeat = new Runnable() {		public void run() {			if (DropTarget.this.control.isDisposed() || dragOverStart == 0) return;			long time = System.currentTimeMillis();			int delay = DRAGOVER_HYSTERESIS;			if (time < dragOverStart) {				delay = (int)(dragOverStart - time);			} else {					int allowedOperations = dragOverEvent.operations;				TransferData[] allowedTypes = dragOverEvent.dataTypes;				//pass a copy of data types in to listeners in case application modifies it				TransferData[] dataTypes = new TransferData[allowedTypes.length];				System.arraycopy(allowedTypes, 0, dataTypes, 0, dataTypes.length);					DNDEvent event = new DNDEvent();				event.widget = dragOverEvent.widget;				event.x = dragOverEvent.x;				event.y = dragOverEvent.y;				event.time = (int)time;				event.feedback = DND.FEEDBACK_SELECT;				event.dataTypes = dataTypes;				event.dataType = selectedDataType;				event.operations = dragOverEvent.operations;				event.detail  = selectedOperation;								try {					notifyListeners(DND.DragOver, event);				} catch (Throwable e) {					event.dataType = null;					event.detail  = DND.DROP_NONE;				}								effect.show(event.feedback, event.x, event.y);								selectedDataType = null;				if (event.dataType != null) {					for (int i = 0; i < allowedTypes.length; i++) {						if (allowedTypes[i].type == event.dataType.type) {							selectedDataType = event.dataType;							break;						}					}				}				selectedOperation = DND.DROP_NONE;				if (selectedDataType != null && (event.detail & allowedOperations) != 0) {					selectedOperation = event.detail;				}			}			DropTarget.this.control.getDisplay().timerExec(delay, dragOverHeartbeat);		}	};}