try { notifyListeners(DND.DropAccept, event); } catch (Throwable e) { event.detail = DND.DROP_NONE; event.dataType = null; }
private int dragReceiveHandler(int theWindow, int handlerRefCon, int theDrag) {	updateDragOverHover(0, null);	effect.show(DND.FEEDBACK_NONE, 0, 0);	if (keyOperation == -1) return OS.dragNotAcceptedErr;	DNDEvent event = new DNDEvent();	event.widget = this;	event.time = (int)System.currentTimeMillis();	event.detail = DND.DROP_NONE;	try {		notifyListeners(DND.DragLeave, event);	} catch (Throwable e) {}			event = new DNDEvent();	if (!setEventData(theDrag, event)) {		return OS.dragNotAcceptedErr;	}	keyOperation = -1;			int allowedOperations = event.operations;	TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];	System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, event.dataTypes.length);		event.dataType = selectedDataType;	event.detail = selectedOperation;	try {		notifyListeners(DND.DropAccept, event);	} catch (Throwable e) {		event.detail = DND.DROP_NONE;		event.dataType = null;	}		selectedDataType = null;	if (event.dataType != null) {		for (int i = 0; i < allowedDataTypes.length; i++) {			if (allowedDataTypes[i].type == event.dataType.type) {				selectedDataType = allowedDataTypes[i];				break;			}		}	}	selectedOperation = DND.DROP_NONE;	if (selectedDataType != null && (event.detail & allowedOperations) != 0) {		selectedOperation = event.detail;	}		if (selectedOperation == DND.DROP_NONE) {		// this was not a successful drop		return OS.dragNotAcceptedErr;	}		// ask drag source for dropped data	byte[][] data  = data = new byte[0][];	// locate all the items with data of the desired type 	short[] numItems = new short[1];	OS.CountDragItems(theDrag, numItems);	for (short i = 0; i < numItems[0]; i++) {		int[] theItemRef = new int[1];		OS.GetDragItemReferenceNumber(theDrag, (short) (i+1), theItemRef);		int[] size = new int[1];		OS.GetFlavorDataSize(theDrag, theItemRef[0], selectedDataType.type, size);		if (size[0] > 0) {			byte[] buffer = new byte[size[0]];			OS.GetFlavorData(theDrag, theItemRef[0], selectedDataType.type, buffer, size, 0);			byte[][] newData = new byte[data.length + 1][];			System.arraycopy(data, 0, newData, 0, data.length);			newData[data.length] = buffer;			data = newData;		}	}	// Get Data in a Java format	Object object = null;	for (int i = 0; i < transferAgents.length; i++) {		Transfer transfer = transferAgents[i];		if (transfer.isSupportedType(selectedDataType)) {			selectedDataType.data = data;			object = transfer.nativeToJava(selectedDataType);			break;		}	}		if (object == null) {		selectedOperation = DND.DROP_NONE;	}			event.dataType = selectedDataType;	event.detail = selectedOperation;	event.data = object;	try	{		notifyListeners(DND.Drop, event);		selectedOperation = DND.DROP_NONE;		if ((allowedOperations & event.detail) == event.detail) {			selectedOperation = event.detail;		}	} catch (Throwable e) {		selectedOperation = DND.DROP_NONE;	} 	//notify source of action taken	int action = opToOsOp(selectedOperation);	OS.SetDragDropAction(theDrag, action);	return (selectedOperation == DND.DROP_NONE) ? OS.dragNotAcceptedErr : OS.noErr;}