Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java65
1 files changed, 35 insertions, 30 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java
index 3a4b472907..45c98384d9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java
@@ -110,7 +110,7 @@ public class DragSource extends Widget {
static Callback dragSource2Args, dragSource3Args, dragSource4Args, dragSource5Args, dragSource6Args;
static final byte[] SWT_OBJECT = {'S', 'W', 'T', '_', 'O', 'B', 'J', 'E', 'C', 'T', '\0'};
- static long /*int*/ proc2 = 0, proc3 = 0, proc4 = 0, proc5 = 0, proc6 = 0;
+ static long proc2 = 0, proc3 = 0, proc4 = 0, proc5 = 0, proc6 = 0;
String paths[];
boolean exist[];
@@ -122,28 +122,23 @@ public class DragSource extends Widget {
dragSource2Args = new Callback(clazz, "dragSourceProc", 2);
proc2 = dragSource2Args.getAddress();
- if (proc2 == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
dragSource3Args = new Callback(clazz, "dragSourceProc", 3);
proc3 = dragSource3Args.getAddress();
- if (proc3 == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
dragSource4Args = new Callback(clazz, "dragSourceProc", 4);
proc4 = dragSource4Args.getAddress();
- if (proc4 == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
dragSource5Args = new Callback(clazz, "dragSourceProc", 5);
proc5 = dragSource5Args.getAddress();
- if (proc5 == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
dragSource6Args = new Callback(clazz, "dragSourceProc", 6);
proc6 = dragSource6Args.getAddress();
- if (proc6 == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
- long /*int*/ cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+ long cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
- long /*int*/ draggedImage_endedAt_operationProc = OS.CALLBACK_draggedImage_endedAt_operation_(proc5);
+ long draggedImage_endedAt_operationProc = OS.CALLBACK_draggedImage_endedAt_operation_(proc5);
// Add the NSDraggingSource callbacks
OS.class_addMethod(cls, OS.sel_draggingSourceOperationMaskForLocal_, proc3, "@:I");
@@ -168,7 +163,7 @@ public class DragSource extends Widget {
static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$
- private long /*int*/ delegateJniRef;
+ private long delegateJniRef;
private Point dragOffset;
/**
@@ -248,17 +243,17 @@ public DragSource(Control control, int style) {
// Tables and trees already implement dragging, so we need to override their drag methods instead of creating a dragging source.
if (control instanceof Tree || control instanceof Table) {
- long /*int*/ cls = OS.object_getClass(control.view.id);
+ long cls = OS.object_getClass(control.view.id);
if (cls == 0) {
DND.error(DND.ERROR_CANNOT_INIT_DRAG);
}
// If we already added it, no need to do it again.
- long /*int*/ procPtr = OS.class_getMethodImplementation(cls, OS.sel_draggingSourceOperationMaskForLocal_);
+ long procPtr = OS.class_getMethodImplementation(cls, OS.sel_draggingSourceOperationMaskForLocal_);
if (procPtr == proc3) return;
- long /*int*/ draggedImage_endedAt_operationProc = OS.CALLBACK_draggedImage_endedAt_operation_(proc5);
+ long draggedImage_endedAt_operationProc = OS.CALLBACK_draggedImage_endedAt_operation_(proc5);
// Add the NSDraggingSource overrides.
OS.class_addMethod(cls, OS.sel_draggingSourceOperationMaskForLocal_, proc3, "@:I");
@@ -311,21 +306,21 @@ public void addDragListener(DragSourceListener listener) {
addListener (DND.DragEnd, typedListener);
}
-void dndCallSuper(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, NSPoint arg1, long /*int*/ arg2) {
+void dndCallSuper(long id, long sel, long arg0, NSPoint arg1, long arg2) {
objc_super super_struct = new objc_super();
super_struct.receiver = id;
super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
OS.objc_msgSendSuper(super_struct, sel, arg0, arg1, arg2);
}
-void dndCallSuper(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) {
+void dndCallSuper(long id, long sel, long arg0, long arg1) {
objc_super super_struct = new objc_super();
super_struct.receiver = id;
super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
OS.objc_msgSendSuper(super_struct, sel, arg0, arg1);
}
-long /*int*/ dndCallSuperObject(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2, long /*int*/ arg3) {
+long dndCallSuperObject(long id, long sel, long arg0, long arg1, long arg2, long arg3) {
objc_super super_struct = new objc_super();
super_struct.receiver = id;
super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
@@ -403,7 +398,12 @@ void drag(Event dragDetectEvent) {
void dragOutlineViewStart(Event dragDetectEvent) {
DNDEvent event = startDrag(dragDetectEvent);
- if (event == null) return;
+ if (event == null) {
+ // This causes our 'outlineView:writeItems:toPasteboard:' listener
+ // to return NO to cancel drag.
+ dragDetectEvent.doit = false;
+ return;
+ }
// Save off the custom image, if any.
dragImageFromListener = event.image;
@@ -413,13 +413,13 @@ void dragOutlineViewStart(Event dragDetectEvent) {
dragOffset = new Point(event.offsetX, event.offsetY);
}
-void draggedImage_beganAt(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) {
+void draggedImage_beganAt(long id, long sel, long arg0, long arg1) {
if (new NSObject(id).isKindOfClass(OS.class_NSTableView)) {
dndCallSuper(id, sel, arg0, arg1);
}
}
-void draggedImage_endedAt_operation(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, NSPoint arg1, long /*int*/ arg2) {
+void draggedImage_endedAt_operation(long id, long sel, long arg0, NSPoint arg1, long arg2) {
int swtOperation = osOpToOp(arg2);
if (paths != null) {
NSFileManager fileManager = NSFileManager.defaultManager();
@@ -452,7 +452,7 @@ void draggedImage_endedAt_operation(long /*int*/ id, long /*int*/ sel, long /*in
}
}
-long /*int*/ dragImageForRowsWithIndexes_tableColumns_event_offset(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2, long /*int*/ arg3) {
+long dragImageForRowsWithIndexes_tableColumns_event_offset(long id, long sel, long arg0, long arg1, long arg2, long arg3) {
if (dragImageFromListener != null) {
NSPoint point = new NSPoint();
point.x = dragOffset.x;
@@ -467,12 +467,12 @@ long /*int*/ dragImageForRowsWithIndexes_tableColumns_event_offset(long /*int*/
/**
* Cocoa NSDraggingSource implementations
*/
-long /*int*/ draggingSourceOperationMaskForLocal(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) {
+long draggingSourceOperationMaskForLocal(long id, long sel, long arg0) {
// Drag operations are same for local or remote drags.
return dragOperations;
}
-static long /*int*/ dragSourceProc(long /*int*/ id, long /*int*/ sel) {
+static long dragSourceProc(long id, long sel) {
Display display = Display.findDisplay(Thread.currentThread());
if (display == null || display.isDisposed()) return 0;
Widget widget = display.findWidget(id);
@@ -494,7 +494,7 @@ static long /*int*/ dragSourceProc(long /*int*/ id, long /*int*/ sel) {
return 0;
}
-static long /*int*/ dragSourceProc(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) {
+static long dragSourceProc(long id, long sel, long arg0) {
Display display = Display.findDisplay(Thread.currentThread());
if (display == null || display.isDisposed()) return 0;
Widget widget = display.findWidget(id);
@@ -516,7 +516,7 @@ static long /*int*/ dragSourceProc(long /*int*/ id, long /*int*/ sel, long /*int
return 0;
}
-static long /*int*/ dragSourceProc(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) {
+static long dragSourceProc(long id, long sel, long arg0, long arg1) {
Display display = Display.findDisplay(Thread.currentThread());
if (display == null || display.isDisposed()) return 0;
Widget widget = display.findWidget(id);
@@ -540,7 +540,7 @@ static long /*int*/ dragSourceProc(long /*int*/ id, long /*int*/ sel, long /*int
return 0;
}
-static long /*int*/ dragSourceProc(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2) {
+static long dragSourceProc(long id, long sel, long arg0, long arg1, long arg2) {
Display display = Display.findDisplay(Thread.currentThread());
if (display == null || display.isDisposed()) return 0;
Widget widget = display.findWidget(id);
@@ -564,7 +564,7 @@ static long /*int*/ dragSourceProc(long /*int*/ id, long /*int*/ sel, long /*int
return 0;
}
-static long /*int*/ dragSourceProc(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2, long /*int*/ arg3) {
+static long dragSourceProc(long id, long sel, long arg0, long arg1, long arg2, long arg3) {
Display display = Display.findDisplay(Thread.currentThread());
if (display == null || display.isDisposed()) return 0;
Widget widget = display.findWidget(id);
@@ -658,7 +658,7 @@ public Transfer[] getTransfer(){
/**
* We always want the modifier keys to potentially update the drag.
*/
-boolean ignoreModifierKeysWhileDragging(long /*int*/ id, long /*int*/ sel) {
+boolean ignoreModifierKeysWhileDragging(long id, long sel) {
return false;
}
@@ -701,7 +701,7 @@ int opToOsOp(int operation) {
return osOperation;
}
-int osOpToOp(long /*int*/ osOperation){
+int osOpToOp(long osOperation){
int operation = 0;
if ((osOperation & OS.NSDragOperationCopy) != 0){
operation |= DND.DROP_COPY;
@@ -721,7 +721,7 @@ int osOpToOp(long /*int*/ osOperation){
return operation;
}
-void pasteboard_provideDataForType(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) {
+void pasteboard_provideDataForType(long id, long sel, long arg0, long arg1) {
NSPasteboard pasteboard = new NSPasteboard(arg0);
NSString dataType = new NSString(arg1);
if (pasteboard == null || dataType == null) return;
@@ -756,7 +756,7 @@ void pasteboard_provideDataForType(long /*int*/ id, long /*int*/ sel, long /*int
pasteboard.writeObjects(NSArray.arrayWithObject(url));
} else if (dataType.isEqual(OS.NSFilenamesPboardType) || dataType.isEqual(OS.kUTTypeFileURL)) {
NSArray array = (NSArray) transferData.data;
- int count = (int) /*64*/ array.count();
+ int count = (int) array.count();
paths = new String[count];
exist = new boolean[count];
NSFileManager fileManager = NSFileManager.defaultManager();
@@ -819,6 +819,11 @@ public void setTransfer(Transfer... transferAgents){
this.transferAgents = transferAgents;
}
+boolean canBeginDrag() {
+ if (transferAgents == null || transferAgents.length == 0) return false;
+ return true;
+}
+
DNDEvent startDrag(Event dragEvent) {
DNDEvent event = new DNDEvent();
event.widget = this;
@@ -827,7 +832,7 @@ DNDEvent startDrag(Event dragEvent) {
event.time = dragEvent.time;
event.doit = true;
notifyListeners(DND.DragStart, event);
- if (!event.doit || transferAgents == null || transferAgents.length == 0) return null;
+ if (!event.doit || !canBeginDrag()) return null;
NSPasteboard dragBoard = NSPasteboard.pasteboardWithName(OS.NSDragPboard);
NSMutableArray nativeTypeArray = NSMutableArray.arrayWithCapacity(10);

Back to the top