if (display == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); if (display.isDisposed()) DND.error(SWT.ERROR_DEVICE_DISPOSED);
checkWidget();
public void setContents(Object[] data, Transfer[] dataTypes) {	if (display == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);	if (display.isDisposed()) DND.error(SWT.ERROR_DEVICE_DISPOSED);	if (data == null || dataTypes == null || data.length != dataTypes.length) {		DND.error(SWT.ERROR_INVALID_ARGUMENT);	}		PhClipHeader[] clips = new PhClipHeader[0];	int count = 0;	for (int i = 0; i < dataTypes.length; i++) {		String[] names = dataTypes[i].getTypeNames();		int[] ids = dataTypes[i].getTypeIds();		for (int j = 0; j < names.length; j++) {			TransferData transferData = new TransferData();			transferData.type = ids[j];			dataTypes[i].javaToNative(data[i], transferData);			PhClipHeader clip = new PhClipHeader();			clip.data = transferData.pData;			clip.length = (short)transferData.length;			byte[] buffer = Converter.wcsToMbcs(null, names[j], false);			System.arraycopy(buffer, 0, clip.type, 0, Math.min(clip.type.length - 1, buffer.length));			PhClipHeader[] newClips = new PhClipHeader[count + 1];			System.arraycopy(clips, 0, newClips, 0, clips.length);			clips = newClips;			clips[count++] = clip;		}	}		if (count == 0) return;	// Copy data to clipboard	byte[] buffer = new byte[count * PhClipHeader.sizeof];	byte[] temp = new byte[PhClipHeader.sizeof];	for (int i = 0; i < count; i++) {		OS.memmove(temp, clips[i], PhClipHeader.sizeof);		System.arraycopy(temp, 0, buffer, i * PhClipHeader.sizeof, temp.length);	}		int ig = OS.PhInputGroup(0);	if (OS.PhClipboardCopy((short)ig, count, buffer) != 0) {		DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);	}		// Free allocated data	for (int i = 0; i < count; i++) {		OS.free(clips[i].data);	}}