summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam <lshanmugam>2011-03-04 19:15:20 +0000
committerLakshmi Shanmugam <lshanmugam>2011-03-04 19:15:20 +0000
commit6f22938cbd7ef81aa977b611e1d837442e73821d (patch)
tree5a41cb1649e4ef0fd662a67bb1211df7f193b688
parent4386c9c02d6b1814bbe975a148b2cae593f3838f (diff)
downloadeclipse.platform.swt-6f22938cbd7ef81aa977b611e1d837442e73821d.tar.gz
eclipse.platform.swt-6f22938cbd7ef81aa977b611e1d837442e73821d.tar.xz
eclipse.platform.swt-6f22938cbd7ef81aa977b611e1d837442e73821d.zip
Bug 310242 - Tree expands while dragging over non-leaf item
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TableDropTargetEffect.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TreeDropTargetEffect.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java10
8 files changed, 82 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java
index 4302109771..95f5cb7d09 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java
@@ -745,7 +745,6 @@ boolean outlineView_acceptDrop_item_childIndex(int /*long*/ id, int /*long*/ sel
}
int /*long*/ outlineView_validateDrop_proposedItem_proposedChildIndex(int /*long*/ id, int /*long*/ sel, int /*long*/ outlineView, int /*long*/ info, int /*long*/ item, int /*long*/ index) {
- //TODO stop scrolling and expansion when app does not set FEEDBACK_SCROLL and/or FEEDBACK_EXPAND
//TODO expansion animation and auto collapse not working because of outlineView:shouldExpandItem:
NSOutlineView widget = new NSOutlineView(outlineView);
NSObject sender = new NSObject(info);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TableDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TableDropTargetEffect.java
index 6fdf4f774f..567973a0c6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TableDropTargetEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TableDropTargetEffect.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.dnd;
+import org.eclipse.swt.internal.cocoa.*;
import org.eclipse.swt.widgets.*;
/**
@@ -43,7 +44,8 @@ import org.eclipse.swt.widgets.*;
* @since 3.3
*/
public class TableDropTargetEffect extends DropTargetEffect {
-
+ boolean shouldEnableScrolling;
+
/**
* Creates a new <code>TableDropTargetEffect</code> to handle the drag under effect on the specified
* <code>Table</code>.
@@ -93,6 +95,11 @@ public class TableDropTargetEffect extends DropTargetEffect {
* @see DropTargetEvent
*/
public void dragLeave(DropTargetEvent event) {
+ if (shouldEnableScrolling) {
+ shouldEnableScrolling = false;
+ OS.objc_msgSend(control.view.id, OS.sel_setShouldScrollClipView_, 1);
+ control.redraw();
+ }
}
/**
@@ -115,5 +122,11 @@ public class TableDropTargetEffect extends DropTargetEffect {
public void dragOver(DropTargetEvent event) {
int effect = checkEffect(event.feedback);
((DropTarget)event.widget).feedback = effect;
+ if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+ shouldEnableScrolling = true;
+ OS.objc_msgSend(control.view.id, OS.sel_setShouldScrollClipView_, 0);
+ } else {
+ OS.objc_msgSend(control.view.id, OS.sel_setShouldScrollClipView_, 1);
+ }
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TreeDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TreeDropTargetEffect.java
index fac1c86426..c573f6efc1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TreeDropTargetEffect.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TreeDropTargetEffect.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.dnd;
+import org.eclipse.swt.internal.cocoa.*;
import org.eclipse.swt.widgets.*;
/**
@@ -46,6 +47,7 @@ import org.eclipse.swt.widgets.*;
* @since 3.3
*/
public class TreeDropTargetEffect extends DropTargetEffect {
+ boolean shouldEnableScrolling;
/**
* Creates a new <code>TreeDropTargetEffect</code> to handle the drag under effect on the specified
@@ -96,6 +98,12 @@ public class TreeDropTargetEffect extends DropTargetEffect {
* @see DropTargetEvent
*/
public void dragLeave(DropTargetEvent event) {
+ OS.objc_msgSend(control.view.id, OS.sel_setShouldExpandItem_, 1);
+ if (shouldEnableScrolling) {
+ shouldEnableScrolling = false;
+ OS.objc_msgSend(control.view.id, OS.sel_setShouldScrollClipView_, 1);
+ control.redraw();
+ }
}
/**
@@ -119,5 +127,12 @@ public class TreeDropTargetEffect extends DropTargetEffect {
public void dragOver(DropTargetEvent event) {
int effect = checkEffect(event.feedback);
((DropTarget)event.widget).feedback = effect;
+ OS.objc_msgSend(control.view.id, OS.sel_setShouldExpandItem_, (effect & DND.FEEDBACK_EXPAND) == 0 ? 0 : 1);
+ if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+ shouldEnableScrolling = true;
+ OS.objc_msgSend(control.view.id, OS.sel_setShouldScrollClipView_, 0);
+ } else {
+ OS.objc_msgSend(control.view.id, OS.sel_setShouldScrollClipView_, 1);
+ }
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index de762cd645..bf74738de4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -107,6 +107,9 @@ public class OS extends C {
public static final int /*long*/ sel_clearDeferFlushing = sel_registerName("clearDeferFlushing");
+ public static final int /*long*/ sel_setShouldExpandItem_ = sel_registerName("setShouldExpandItem:");
+ public static final int /*long*/ sel_setShouldScrollClipView_ = sel_registerName("setShouldScroll:");
+
/* These are not generated in order to avoid creating static methods on all classes */
public static final int /*long*/ sel_isSelectorExcludedFromWebScript_ = sel_registerName("isSelectorExcludedFromWebScript:");
public static final int /*long*/ sel_webScriptNameForSelector_ = sel_registerName("webScriptNameForSelector:");
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index 7c1e3ec93a..5a62c97776 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -2575,6 +2575,9 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_outlineView_setObjectValue_forTableColumn_byItem_, proc6, "@:@@@@");
OS.class_addMethod(cls, OS.sel_outlineView_shouldEditTableColumn_item_, proc5, "@:@@@");
OS.class_addMethod(cls, OS.sel_outlineView_shouldTrackCell_forTableColumn_item_, proc6, "@:@@@i");
+ OS.class_addMethod(cls, OS.sel_outlineView_shouldExpandItem_, proc4, "@:@@");
+ OS.class_addMethod(cls, OS.sel_setShouldExpandItem_, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_setShouldScrollClipView_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_outlineViewColumnDidMove_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_outlineViewColumnDidResize_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_outlineView_didClickTableColumn_, proc4, "@:@@");
@@ -2749,6 +2752,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_tableView_setObjectValue_forTableColumn_row_, proc6, "@:@@@i");
OS.class_addMethod(cls, OS.sel_tableViewColumnDidMove_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_tableViewColumnDidResize_, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_setShouldScrollClipView_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_tableView_didClickTableColumn_, proc4, "@:@@");
OS.class_addMethod(cls, OS.sel_tableView_selectionIndexesForProposedSelection_, proc4, "@:@@");
OS.class_addMethod(cls, OS.sel_canDragRowsWithIndexes_atPoint_, canDragRowsWithIndexes_atPoint_Proc, "@:@{NSPoint=ff}");
@@ -5661,6 +5665,10 @@ static int /*long*/ windowProc(int /*long*/ id, int /*long*/ sel, int /*long*/ a
widget.viewWillMoveToWindow(id, sel, arg0);
} else if (sel == OS.sel_cancelOperation_) {
widget.cancelOperation(id, sel, arg0);
+ } else if (sel == OS.sel_setShouldExpandItem_) {
+ widget.setShouldExpandItem(id, sel, arg0 != 0);
+ } else if (sel == OS.sel_setShouldScrollClipView_) {
+ widget.setShouldScrollClipView(id, sel, arg0 != 0);
}
return 0;
}
@@ -5728,6 +5736,8 @@ static int /*long*/ windowProc(int /*long*/ id, int /*long*/ sel, int /*long*/ a
return widget.validRequestorForSendType(id, sel, arg0, arg1);
} else if (sel == OS.sel_writeSelectionToPasteboard_types_) {
return (widget.writeSelectionToPasteboard(id, sel, arg0, arg1) ? 1 : 0);
+ } else if (sel == OS.sel_outlineView_shouldExpandItem_) {
+ return (widget.outlineView_shouldExpandItem_item(id, sel, arg0, arg1) ? 1 : 0);
}
return 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
index 24cf23313f..5712ea5b46 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
@@ -77,6 +77,9 @@ public class Table extends Composite {
int columnCount, itemCount, lastIndexOf, sortDirection;
boolean ignoreSelect, fixScrollWidth, drawExpansion, didSelect;
Rectangle imageBounds;
+
+ /* Used to control drop feedback when FEEDBACK_SCROLL is set/not set */
+ boolean shouldScroll = true;
static int NEXT_ID;
@@ -2240,6 +2243,10 @@ void reskinChildren (int flags) {
super.reskinChildren (flags);
}
+void scrollClipViewToPoint(int /*long*/ id, int /*long*/ sel, int /*long*/ clipView, NSPoint point) {
+ if (shouldScroll) super.scrollClipViewToPoint(id, sel, clipView, point);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains
@@ -2813,6 +2820,10 @@ public void setSelection (TableItem [] items) {
}
}
+void setShouldScrollClipView(int /*long*/ id, int /*long*/ sel, boolean shouldScroll) {
+ this.shouldScroll = shouldScroll;
+}
+
/**
* Sets the column used by the sort indicator for the receiver. A null
* value will clear the sort indicator. The current sort column is cleared
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
index ebda1fbd3a..7c21720d64 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
@@ -87,6 +87,9 @@ public class Tree extends Composite {
Rectangle imageBounds;
TreeItem insertItem;
boolean insertBefore;
+
+ /* Used to control drop feedback when DND.FEEDBACK_EXPAND and DND.FEEDBACK_SCROLL is set/not set */
+ boolean shouldExpand = true, shouldScroll = true;
static int NEXT_ID;
@@ -2079,6 +2082,10 @@ int /*long*/ outlineView_numberOfChildrenOfItem (int /*long*/ id, int /*long*/ s
return ((TreeItem) display.getWidget (item)).itemCount;
}
+boolean outlineView_shouldExpandItem_item (int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int arg1) {
+ return shouldExpand;
+}
+
boolean outlineView_shouldReorderColumn_toColumn(int /*long*/ id, int /*long*/ sel, int /*long*/ aTableView, int /*long*/ currentColIndex, int /*long*/ newColIndex) {
// Check column should never move and no column can be dragged to the left of it, if present.
if ((style & SWT.CHECK) != 0) {
@@ -2283,6 +2290,10 @@ void outlineViewColumnDidResize (int /*long*/ id, int /*long*/ sel, int /*long*/
}
}
+void scrollClipViewToPoint (int /*long*/ id, int /*long*/ sel, int /*long*/ clipView, NSPoint point) {
+ if (shouldScroll) super.scrollClipViewToPoint(id, sel, clipView, point);
+}
+
void sendSelection () {
if (ignoreSelect) return;
NSOutlineView widget = (NSOutlineView) view;
@@ -2937,6 +2948,14 @@ boolean setScrollWidth (TreeItem item) {
return false;
}
+void setShouldExpandItem (int /*long*/ id, int /*long*/ sel, boolean shouldExpand) {
+ this.shouldExpand = shouldExpand;
+}
+
+void setShouldScrollClipView (int /*long*/ id, int /*long*/ sel, boolean shouldScroll) {
+ this.shouldScroll = shouldScroll;
+}
+
/**
* Sets the receiver's selection to the given item.
* The current selection is cleared before the new item is selected.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
index c89af3979a..273bdf4bfb 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
@@ -1194,6 +1194,10 @@ int /*long*/ outlineView_numberOfChildrenOfItem(int /*long*/ id, int /*long*/ se
return 0;
}
+boolean outlineView_shouldExpandItem_item(int /*long*/ id, int /*long*/ sel, int /*long*/ outlineView, int /*long*/ item) {
+ return true;
+}
+
boolean outlineView_shouldReorderColumn_toColumn(int /*long*/ id, int /*long*/ sel, int /*long*/ aTableView, int /*long*/ columnIndex, int /*long*/ newColumnIndex) {
return true;
}
@@ -1846,6 +1850,12 @@ void setObjectValue(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
callSuper(id, sel, arg0);
}
+void setShouldExpandItem(int /*long*/ id, int /*long*/ sel, boolean shouldExpand) {
+}
+
+void setShouldScrollClipView(int /*long*/ id, int /*long*/ sel, boolean shouldScroll) {
+}
+
boolean setTabGroupFocus () {
return setTabItemFocus ();
}