Class DndHelper


  • public class DndHelper
    extends java.lang.Object
    The drag-drop helper for properties and tree/table viewers.
    Author:
    Christopher Mindus
    • Constructor Summary

      Constructors 
      ConstructorDescription
      DndHelper() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static org.eclipse.jface.viewers.ITreeContentProvidercreateCommonContentProvider()
      Creates a common navigator content provider.
      static NavigatorDecoratingLabelProviderExcreateCommonLabelProvider()
      Creates the common label provider.
      static org.eclipse.core.resources.IContainergetActualTarget​(org.eclipse.core.resources.IResource mouseTarget)
      Returns the actual target of the drop, given the resource under the mouse.
      static org.eclipse.jface.viewers.ViewergetViewer​(org.eclipse.swt.widgets.Control control)
      Gets a Viewer from a Control.
      static voidregister​(int dragOperations, int dropOperations, org.eclipse.jface.viewers.StructuredViewer viewer)
      Registers the TreeViewer or TableViewer control.
      static voidregister​(org.eclipse.jface.viewers.Viewer viewer)
      Registers the Viewer for Drag-and-Drop.
      static voidsaveNavigatorContentService​(org.eclipse.ui.navigator.INavigatorContentService service)
      Saves the content service from the common navigator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DndHelper

        public DndHelper()
    • Method Detail

      • saveNavigatorContentService

        public static void saveNavigatorContentService​(org.eclipse.ui.navigator.INavigatorContentService service)
        Saves the content service from the common navigator.
      • register

        public static void register​(org.eclipse.jface.viewers.Viewer viewer)
        Registers the Viewer for Drag-and-Drop.
      • getViewer

        public static org.eclipse.jface.viewers.Viewer getViewer​(org.eclipse.swt.widgets.Control control)
        Gets a Viewer from a Control.
        Parameters:
        control - control.
        Returns:
        The viewer for the control or null for none.
      • register

        public static void register​(int dragOperations,
                                    int dropOperations,
                                    org.eclipse.jface.viewers.StructuredViewer viewer)
        Registers the TreeViewer or TableViewer control.
        Parameters:
        dragOperations - The supported drag operations.
        dropOperations - The supported drop operations.
        viewer - The TreeViewer or TableViewer, if wrong class, an assert exception is thrown.
      • getActualTarget

        public static org.eclipse.core.resources.IContainer getActualTarget​(org.eclipse.core.resources.IResource mouseTarget)
        Returns the actual target of the drop, given the resource under the mouse. If the mouse target is a file, then the drop actually occurs in its parent. If the drop location is before or after the mouse target and feedback is enabled, the target is also the parent.
      • createCommonContentProvider

        public static org.eclipse.jface.viewers.ITreeContentProvider createCommonContentProvider()
        Creates a common navigator content provider.