diff options
author | Duong Nguyen <dnguyen> | 2008-01-31 23:46:46 +0000 |
---|---|---|
committer | Duong Nguyen <dnguyen> | 2008-01-31 23:46:46 +0000 |
commit | aa5419e56e01885ca4c9df155e825d50244cd302 (patch) | |
tree | e5739923fbbd22a81d785d24db99bc1287c778c0 | |
parent | a20b50f37993a2c9cacb239016558958f4a7c1bd (diff) | |
download | eclipse.platform.swt-aa5419e56e01885ca4c9df155e825d50244cd302.tar.gz eclipse.platform.swt-aa5419e56e01885ca4c9df155e825d50244cd302.tar.xz eclipse.platform.swt-aa5419e56e01885ca4c9df155e825d50244cd302.zip |
Bug 215388 - Add API to make the DropTarget more open
8 files changed, 193 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java index d536101f94..8a7a028ba1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java @@ -384,6 +384,41 @@ public Control getControl () { } /** + * Returns an array of listeners who will be notified when a drag and drop + * operation is in progress, by sending it one of the messages defined in + * the <code>DragSourceListener</code> interface. + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see DragSourceListener + * @see #addDragListener + * @see #removeDragListener + * @see DragSourceEvent + * + * @since 3.4 + */ +public DragSourceListener[] getDragListeners() { + Listener[] listeners = getListeners(DND.DragStart); + int length = listeners.length; + DragSourceListener[] dragListeners = new DragSourceListener[length]; + int count = 0; + for (int i = 0; i < length; i++) { + Listener listener = listeners[i]; + if (listener instanceof DNDListener) { + dragListeners[count] = (DragSourceListener) ((DNDListener) listener).getEventListener(); + count++; + } + } + if (count == length) return dragListeners; + DragSourceListener[] result = new DragSourceListener[count]; + System.arraycopy(dragListeners, 0, result, 0, count); + return result; +} + +/** * Returns the drag effect that is registered for this DragSource. This drag * effect will be used during a drag and drop operation. * diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java index 9cca32f3ab..1778506094 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java @@ -505,6 +505,41 @@ public Control getControl () { } /** + * Returns an array of listeners who will be notified when a drag and drop + * operation is in progress, by sending it one of the messages defined in + * the <code>DropTargetListener</code> interface. + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see DropTargetListener + * @see #addDropListener + * @see #removeDropListener + * @see DropTargetEvent + * + * @since 3.4 + */ +public DropTargetListener[] getDropListeners() { + Listener[] listeners = getListeners(DND.DragEnter); + int length = listeners.length; + DropTargetListener[] dropListeners = new DropTargetListener[length]; + int count = 0; + for (int i = 0; i < length; i++) { + Listener listener = listeners[i]; + if (listener instanceof DNDListener) { + dropListeners[count] = (DropTargetListener) ((DNDListener) listener).getEventListener(); + count++; + } + } + if (count == length) return dropListeners; + DropTargetListener[] result = new DropTargetListener[count]; + System.arraycopy(dropListeners, 0, result, 0, count); + return result; +} + +/** * Returns the drop effect for this DropTarget. This drop effect will be * used during a drag and drop to display the drag under effect on the * target widget. diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java index 216f0b6a1a..ebe13998be 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java @@ -467,6 +467,40 @@ public Control getControl () { return control; } /** + * Returns an array of listeners who will be notified when a drag and drop + * operation is in progress, by sending it one of the messages defined in + * the <code>DragSourceListener</code> interface. + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see DragSourceListener + * @see #addDragListener + * @see #removeDragListener + * @see DragSourceEvent + * + * @since 3.4 + */ +public DragSourceListener[] getDragListeners() { + Listener[] listeners = getListeners(DND.DragStart); + int length = listeners.length; + DragSourceListener[] dragListeners = new DragSourceListener[length]; + int count = 0; + for (int i = 0; i < length; i++) { + Listener listener = listeners[i]; + if (listener instanceof DNDListener) { + dragListeners[count] = (DragSourceListener) ((DNDListener) listener).getEventListener(); + count++; + } + } + if (count == length) return dragListeners; + DragSourceListener[] result = new DragSourceListener[count]; + System.arraycopy(dragListeners, 0, result, 0, count); + return result; +} +/** * Returns the drag effect that is registered for this DragSource. This drag * effect will be used during a drag and drop operation. * diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java index cff8fbf7d2..72ce4ed634 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java @@ -520,6 +520,41 @@ public Control getControl () { } /** + * Returns an array of listeners who will be notified when a drag and drop + * operation is in progress, by sending it one of the messages defined in + * the <code>DropTargetListener</code> interface. + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see DropTargetListener + * @see #addDropListener + * @see #removeDropListener + * @see DropTargetEvent + * + * @since 3.4 + */ +public DropTargetListener[] getDropListeners() { + Listener[] listeners = getListeners(DND.DragEnter); + int length = listeners.length; + DropTargetListener[] dropListeners = new DropTargetListener[length]; + int count = 0; + for (int i = 0; i < length; i++) { + Listener listener = listeners[i]; + if (listener instanceof DNDListener) { + dropListeners[count] = (DropTargetListener) ((DNDListener) listener).getEventListener(); + count++; + } + } + if (count == length) return dropListeners; + DropTargetListener[] result = new DropTargetListener[count]; + System.arraycopy(dropListeners, 0, result, 0, count); + return result; +} + +/** * Returns the drop effect for this DropTarget. This drop effect will be * used during a drag and drop to display the drag under effect on the * target widget. diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/wpf/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/wpf/org/eclipse/swt/dnd/DragSource.java index 57b2437427..652a562378 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/wpf/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/wpf/org/eclipse/swt/dnd/DragSource.java @@ -11,7 +11,6 @@ package org.eclipse.swt.dnd; -import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.wpf.*; import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; @@ -308,8 +307,7 @@ public DragSourceListener[] getDragListeners() { for (int i = 0; i < length; i++) { Listener listener = listeners[i]; if (listener instanceof DNDListener) { - SWTEventListener eventListener = ((DNDListener) listener).getEventListener(); - dragListeners[count] = (DragSourceListener) eventListener; + dragListeners[count] = (DragSourceListener) ((DNDListener) listener).getEventListener(); count++; } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/wpf/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/wpf/org/eclipse/swt/dnd/DropTarget.java index f2aaf8f0c0..760ca721e1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/wpf/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/wpf/org/eclipse/swt/dnd/DropTarget.java @@ -11,10 +11,9 @@ package org.eclipse.swt.dnd; +import org.eclipse.swt.internal.wpf.*; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.*; -import org.eclipse.swt.internal.wpf.*; import org.eclipse.swt.widgets.*; /** @@ -465,8 +464,7 @@ public DropTargetListener[] getDropListeners() { for (int i = 0; i < length; i++) { Listener listener = listeners[i]; if (listener instanceof DNDListener) { - SWTEventListener eventListener = ((DNDListener) listener).getEventListener(); - dropListeners[count] = (DropTargetListener) eventListener; + dropListeners[count] = (DropTargetListener) ((DNDListener) listener).getEventListener(); count++; } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java index 40c7f7c605..85f2211763 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java @@ -521,6 +521,32 @@ public Display getDisplay () { return display; } +/** + * Returns an array of listeners who will be notified when an event + * of the given type occurs. The event type is one of the event constants + * defined in class <code>SWT</code>. + * + * @param eventType the type of event to listen for + * @return an array of listeners that will be notified when the event occurs + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see Listener + * @see SWT + * @see #addListener(int, Listener) + * @see #removeListener(int, Listener) + * @see #notifyListeners + * + * @since 3.4 + */ +public Listener[] getListeners (int eventType) { + checkWidget(); + return eventTable.getListeners(eventType); +} + String getName () { // String string = getClass ().getName (); // int index = string.lastIndexOf ('.'); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java index b240ffb31d..c2a6aca195 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java @@ -464,6 +464,31 @@ public Display getDisplay () { if (display == null) error (SWT.ERROR_WIDGET_DISPOSED); return display; } +/** + * Returns an array of listeners who will be notified when an event + * of the given type occurs. The event type is one of the event constants + * defined in class <code>SWT</code>. + * + * @param eventType the type of event to listen for + * @return an array of listeners that will be notified when the event occurs + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see Listener + * @see SWT + * @see #addListener(int, Listener) + * @see #removeListener(int, Listener) + * @see #notifyListeners + * + * @since 3.4 + */ +public Listener[] getListeners (int eventType) { + checkWidget(); + return eventTable.getListeners(eventType); +} String getName () { String string = getClass ().getName (); int index = string.lastIndexOf ('.'); |