Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.jface.viewers
Class ViewerDropAdapter


java.lang.Object
  extended by 

org.eclipse.swt.dnd.DropTargetAdapter
      extended by 
org.eclipse.jface.viewers.ViewerDropAdapter
All Implemented Interfaces:
EventListener, DropTargetListener, org.eclipse.swt.internal.SWTEventListener
Direct Known Subclasses:
PluginDropAdapter

public abstract class ViewerDropAdapter
extends DropTargetAdapter

This adapter class provides generic drag-and-drop support for a viewer.

Subclasses must implement the following methods:

  • validateDrop - identifies valid drop targets in viewer
  • performDrop - carries out a drop into a viewer
The setFeedbackEnabled method can be called to turn on and off visual insertion feedback (on by default).


Field Summary
static int LOCATION_AFTER
          Constant describing the position of the cursor relative to the target object.
static int LOCATION_BEFORE
          Constant describing the position of the cursor relative to the target object.
static int LOCATION_NONE
          Constant describing the position of the cursor relative to the target object.
static int LOCATION_ON
          Constant describing the position of the cursor relative to the target object.
 
Constructor Summary
protected ViewerDropAdapter ( Viewer viewer)
          Creates a new drop adapter for the given viewer.
 
Method Summary
protected  void clearState ()
          Clears internal state of this drop adapter.
protected  int determineLocation ( DropTargetEvent event)
          Returns the position of the given event's coordinates relative to its target.
protected   Object determineTarget ( DropTargetEvent event)
          Returns the target item of the given drop event.
 void dragEnter ( DropTargetEvent event)
          This implementation of dragEnter permits the default operation defined in event.detailto be performed on the current data type defined in event.currentDataType.
 void dragOperationChanged ( DropTargetEvent event)
          This implementation of dragOperationChanged permits the default operation defined in event.detailto be performed on the current data type defined in event.currentDataType.
 void dragOver ( DropTargetEvent event)
          This implementation of dragOver permits the default operation defined in event.detailto be performed on the current data type defined in event.currentDataType.
 void drop ( DropTargetEvent event)
          This implementation of drop does nothing.
 void dropAccept ( DropTargetEvent event)
          This implementation of dropAccept permits the default operation defined in event.detailto be performed on the current data type defined in event.currentDataType.
protected   Rectangle getBounds ( Item item)
          Returns the bounds of the given SWT tree or table item.
protected   DropTargetEvent getCurrentEvent ()
          Returns the current DropTargetEvent.
protected  int getCurrentLocation ()
          Returns a constant describing the position of the mouse relative to the target (before, on, or after the target.
protected  int getCurrentOperation ()
          Returns the current operation.
protected   Object getCurrentTarget ()
          Returns the target object currently under the mouse.
 boolean getFeedbackEnabled ()
          Returns whether visible insertion feedback should be presented to the user.
protected   Object getSelectedObject ()
          Returns the object currently selected by the viewer.
protected   Viewer getViewer ()
           
protected  void handleException ( Throwable exception, DropTargetEvent event)
          Deprecated. this method should not be used. Exception handling has been removed from DropTargetAdapter methods overridden by this class. Handles any exception that occurs during callback, including rethrowing behavior.

[Issue: Implementation prints stack trace and eats exception to avoid crashing VA/J. Consider conditionalizing the implementation to do one thing in VAJ and something more reasonable in other operating environments. ]

protected  void overrideOperation (int operation)
          Overrides the current operation for a drop that happens immediately after the current validateDrop.
abstract  boolean performDrop ( Object data)
          Performs any work associated with the drop.
 void setExpandEnabled (boolean value)
          Sets whether auto expanding should be provided during dragging.
 void setFeedbackEnabled (boolean value)
          Sets whether visible insertion feedback should be presented to the user.
 void setScrollEnabled (boolean value)
          Sets whether auto scrolling should be provided during dragging.
 void setScrollExpandEnabled (boolean value)
          Sets whether auto scrolling and expanding should be provided during dragging.
 void setSelectionFeedbackEnabled (boolean value)
          Sets whether selection feedback should be provided during dragging.
abstract  boolean validateDrop ( Object target, int operation, TransferData transferType)
          Validates dropping on the given object.
 
Methods inherited from class org.eclipse.swt.dnd. DropTargetAdapter
dragLeave
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCATION_BEFORE

public static final int LOCATION_BEFORE
Constant describing the position of the cursor relative to the target object. This means the mouse is positioned slightly before the target.

See Also:
getCurrentLocation(), Constant Field Values

LOCATION_AFTER

public static final int LOCATION_AFTER
Constant describing the position of the cursor relative to the target object. This means the mouse is positioned slightly after the target.

See Also:
getCurrentLocation(), Constant Field Values

LOCATION_ON

public static final int LOCATION_ON
Constant describing the position of the cursor relative to the target object. This means the mouse is positioned directly on the target.

See Also:
getCurrentLocation(), Constant Field Values

LOCATION_NONE

public static final int LOCATION_NONE
Constant describing the position of the cursor relative to the target object. This means the mouse is not positioned over or near any valid target.

See Also:
getCurrentLocation(), Constant Field Values
Constructor Detail

ViewerDropAdapter

protected ViewerDropAdapter(
Viewer viewer)
Creates a new drop adapter for the given viewer.

Parameters:
viewer - the viewer
Method Detail

clearState

protected void clearState()
Clears internal state of this drop adapter. This method can be called when no DnD operation is underway, to clear internal state from previous drop operations.

Since:
3.5

determineLocation

protected int determineLocation(
DropTargetEvent event)
Returns the position of the given event's coordinates relative to its target. The position is determined to be before, after, or on the item, based on some threshold value.

Parameters:
event - the event
Returns:
one of the LOCATION_* constants defined in this class

determineTarget

protected 
Object determineTarget(
DropTargetEvent event)
Returns the target item of the given drop event.

Parameters:
event - the event
Returns:
The target of the drop, may be null.

dragEnter

public void dragEnter(
DropTargetEvent event)
Description copied from class: DropTargetAdapter
This implementation of dragEnter permits the default operation defined in event.detailto be performed on the current data type defined in event.currentDataType. For additional information see DropTargetListener.dragEnter.

Specified by:
dragEnter in interface DropTargetListener
Overrides:
dragEnter in class DropTargetAdapter
Parameters:
event - the information associated with the drag enter event
See Also:
DropTargetEvent

dragOperationChanged

public void dragOperationChanged(
DropTargetEvent event)
Description copied from class: DropTargetAdapter
This implementation of dragOperationChanged permits the default operation defined in event.detailto be performed on the current data type defined in event.currentDataType. For additional information see DropTargetListener.dragOperationChanged.

Specified by:
dragOperationChanged in interface DropTargetListener
Overrides:
dragOperationChanged in class DropTargetAdapter
Parameters:
event - the information associated with the drag operation changed event
See Also:
DropTargetEvent

dragOver

public void dragOver(
DropTargetEvent event)
Description copied from class: DropTargetAdapter
This implementation of dragOver permits the default operation defined in event.detailto be performed on the current data type defined in event.currentDataType. For additional information see DropTargetListener.dragOver.

Specified by:
dragOver in interface DropTargetListener
Overrides:
dragOver in class DropTargetAdapter
Parameters:
event - the information associated with the drag over event
See Also:
DropTargetEvent

drop

public void drop(
DropTargetEvent event)
Description copied from class: DropTargetAdapter
This implementation of drop does nothing. For additional information see DropTargetListener.drop.

Specified by:
drop in interface DropTargetListener
Overrides:
drop in class DropTargetAdapter
Parameters:
event - the information associated with the drop event
See Also:
DropTargetEvent

dropAccept

public void dropAccept(
DropTargetEvent event)
Description copied from class: DropTargetAdapter
This implementation of dropAccept permits the default operation defined in event.detailto be performed on the current data type defined in event.currentDataType. For additional information see DropTargetListener.dropAccept.

Specified by:
dropAccept in interface DropTargetListener
Overrides:
dropAccept in class DropTargetAdapter
Parameters:
event - the information associated with the drop accept event
See Also:
DropTargetEvent

getBounds

protected 
Rectangle getBounds(
Item item)
Returns the bounds of the given SWT tree or table item.

Parameters:
item - the SWT Item
Returns:
the bounds, or null if it is not a known type of item

getCurrentLocation

protected int getCurrentLocation()
Returns a constant describing the position of the mouse relative to the target (before, on, or after the target.

Returns:
one of the LOCATION_* constants defined in this type

getCurrentOperation

protected int getCurrentOperation()
Returns the current operation.

Returns:
a DROP_* constant from class DND
See Also:
DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK, DND.DROP_NONE

getCurrentTarget

protected 
Object getCurrentTarget()
Returns the target object currently under the mouse.

Returns:
the current target object

getCurrentEvent

protected 
DropTargetEvent getCurrentEvent()
Returns the current DropTargetEvent. This may be called only inside of the validateDrop(Object, int, TransferData) or performDrop(Object) methods.

Returns:
the DropTargetEvent
Since:
3.5

getFeedbackEnabled

public boolean getFeedbackEnabled()
Returns whether visible insertion feedback should be presented to the user.

Typical insertion feedback is the horizontal insertion bars that appear between adjacent items while dragging.

Returns:
true if visual feedback is desired, and false if not

getSelectedObject

protected 
Object getSelectedObject()
Returns the object currently selected by the viewer.

Returns:
the selected object, or null if either no object or multiple objects are selected

getViewer

protected 
Viewer getViewer()
Returns:
the viewer to which this drop support has been added.

handleException

protected void handleException(
Throwable exception,
                               
DropTargetEvent event)
Deprecated. this method should not be used. Exception handling has been removed from DropTargetAdapter methods overridden by this class. Handles any exception that occurs during callback, including rethrowing behavior.

[Issue: Implementation prints stack trace and eats exception to avoid crashing VA/J. Consider conditionalizing the implementation to do one thing in VAJ and something more reasonable in other operating environments. ]

Parameters:
exception - the exception
event - the event

performDrop

public abstract boolean performDrop(
Object data)
Performs any work associated with the drop.

Subclasses must implement this method to provide drop behavior.

Parameters:
data - the drop data
Returns:
true if the drop was successful, and false otherwise

overrideOperation

protected void overrideOperation(int operation)
Overrides the current operation for a drop that happens immediately after the current validateDrop. This maybe called only from within a validateDrop(Object, int, TransferData) method

Parameters:
operation - the operation to be used for the drop.
Since:
3.5
See Also:
DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK, DND.DROP_NONE

setFeedbackEnabled

public void setFeedbackEnabled(boolean value)
Sets whether visible insertion feedback should be presented to the user.

Typical insertion feedback is the horizontal insertion bars that appear between adjacent items while dragging.

Parameters:
value - true if visual feedback is desired, and false if not

setSelectionFeedbackEnabled

public void setSelectionFeedbackEnabled(boolean value)
Sets whether selection feedback should be provided during dragging.

Parameters:
value - true if selection feedback is desired, and false if not
Since:
3.2

setScrollExpandEnabled

public void setScrollExpandEnabled(boolean value)
Sets whether auto scrolling and expanding should be provided during dragging.

Parameters:
value - true if scrolling and expanding is desired, and false if not
Since:
2.0

setExpandEnabled

public void setExpandEnabled(boolean value)
Sets whether auto expanding should be provided during dragging.

Parameters:
value - true if expanding is desired, and false if not
Since:
3.4

setScrollEnabled

public void setScrollEnabled(boolean value)
Sets whether auto scrolling should be provided during dragging.

Parameters:
value - true if scrolling is desired, and false if not
Since:
3.4

validateDrop

public abstract boolean validateDrop(
Object target,
                                     int operation,
                                     
TransferData transferType)
Validates dropping on the given object. This method is called whenever some aspect of the drop operation changes.

Subclasses must implement this method to define which drops make sense.

Parameters:
target - the object that the mouse is currently hovering over, or null if the mouse is hovering over empty space
operation - the current drag operation (copy, move, etc.)
transferType - the current transfer type
Returns:
true if the drop is valid, and false otherwise

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire