net.sourceforge.rssowl.controller.dnd
Class FavoritesTreeDND

java.lang.Object
  extended bynet.sourceforge.rssowl.controller.dnd.FavoritesTreeDND

public class FavoritesTreeDND
extends Object

Basic Drag and Drop support for the tree holding favorites in RSSOwl. Currently favorites, categories and blogrolls may be dragged and dropped into other categories.

The tree is also the drop target for tabs that are dragged to create a new favorite

Version:
1.1.3
Author:
Benjamin Pasero

Field Summary
(package private)  org.eclipse.swt.widgets.Item dragSourceItem
           
(package private)  FavoritesTree rssOwlFavoritesTree
           
private  org.eclipse.swt.dnd.DragSource source
           
(package private)  boolean sourceIsCategory
           
private  org.eclipse.swt.dnd.DropTarget target
           
(package private)  org.eclipse.swt.widgets.Tree tree
           
private static org.eclipse.swt.dnd.Transfer[] types
          Array of transfer types
 
Constructor Summary
FavoritesTreeDND(FavoritesTree rssOwlFavoritesTree)
          Instantiate a new FavoritesTreeDND
 
Method Summary
private  void createDragSource()
          Create the Drag Source on the Tree.
private  void createDropTarget()
          Create the drop target.
(package private)  void createFavorite(Favorite rssOwlFavorite, org.eclipse.swt.widgets.TreeItem parent)
          Create a new favorite in the selected category
 void dispose()
          Dispose DragSource and DragTarget
 org.eclipse.swt.widgets.Item getDragSourceItem()
          Get the item that is currently being dragged.
(package private)  org.eclipse.swt.widgets.TreeItem getValidDragSourceTreeItem()
          This method will return the selected treeitem if its a favorite, category or root blogroll.
private  void initDragAndDrop()
          Init Drag and Drop on the tree widget
(package private)  boolean isValidTargetForCategory(org.eclipse.swt.widgets.TreeItem source, org.eclipse.swt.widgets.TreeItem target, org.eclipse.swt.dnd.DropTargetEvent event)
          Check wether the dragged category is dragged over a valid target category.
(package private)  boolean isValidTargetForFavorite(org.eclipse.swt.widgets.TreeItem source, org.eclipse.swt.widgets.TreeItem target)
          Check wether the dragged favorite is dragged over a valid target.
(package private)  void moveCategory(String catPath, org.eclipse.swt.widgets.TreeItem parent)
          Move the category specified by the catPath into the treeitem
(package private)  void moveCategoryToRoot(String catPath)
          Move the category specified by the catPath to the Root of the Tree.
(package private)  void moveFavorite(String favoriteTitle, org.eclipse.swt.widgets.TreeItem parent)
          Move the favorite represented by its name into the treeitem which is a category.
 void setDragSourceItem(org.eclipse.swt.widgets.Item dragSourceItem)
          Set the item that is currently being dragged.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

types

private static final org.eclipse.swt.dnd.Transfer[] types
Array of transfer types


source

private org.eclipse.swt.dnd.DragSource source

target

private org.eclipse.swt.dnd.DropTarget target

dragSourceItem

org.eclipse.swt.widgets.Item dragSourceItem

rssOwlFavoritesTree

FavoritesTree rssOwlFavoritesTree

sourceIsCategory

boolean sourceIsCategory

tree

org.eclipse.swt.widgets.Tree tree
Constructor Detail

FavoritesTreeDND

public FavoritesTreeDND(FavoritesTree rssOwlFavoritesTree)
Instantiate a new FavoritesTreeDND

Parameters:
rssOwlFavoritesTree - The favorites tree to apply basic drag and drop support
Method Detail

dispose

public void dispose()
Dispose DragSource and DragTarget


getDragSourceItem

public org.eclipse.swt.widgets.Item getDragSourceItem()
Get the item that is currently being dragged. This may either be a treeitem or a tabitem

Returns:
Item The item that is currently dragged

setDragSourceItem

public void setDragSourceItem(org.eclipse.swt.widgets.Item dragSourceItem)
Set the item that is currently being dragged. This may either be a treeitem or a tabitem.

Parameters:
dragSourceItem - The dragged item

createDragSource

private void createDragSource()
Create the Drag Source on the Tree. Valid drag sources are favorites, categories and the root blogroll element


createDropTarget

private void createDropTarget()
Create the drop target. Currently only categories and favorites are valid drop targets.


initDragAndDrop

private void initDragAndDrop()
Init Drag and Drop on the tree widget


createFavorite

void createFavorite(Favorite rssOwlFavorite,
                    org.eclipse.swt.widgets.TreeItem parent)
Create a new favorite in the selected category

Parameters:
rssOwlFavorite - The new favorite to create
parent - The category to add the favorite

getValidDragSourceTreeItem

org.eclipse.swt.widgets.TreeItem getValidDragSourceTreeItem()
This method will return the selected treeitem if its a favorite, category or root blogroll. Any other selection, or no selection will return null.

Returns:
TreeItem The selected treeitem or null

isValidTargetForCategory

boolean isValidTargetForCategory(org.eclipse.swt.widgets.TreeItem source,
                                 org.eclipse.swt.widgets.TreeItem target,
                                 org.eclipse.swt.dnd.DropTargetEvent event)
Check wether the dragged category is dragged over a valid target category. Invalid categories are:
o Target and Source have same parents and Target is no category
o Target and Source are equal
o Target is Parent of Source
o Target is a nested child of the Source

Parameters:
source - The source treeitem
target - The target treeitem
event - The DropTargetEvent carrying some additional Information
Returns:
boolean TRUE if target is valid

isValidTargetForFavorite

boolean isValidTargetForFavorite(org.eclipse.swt.widgets.TreeItem source,
                                 org.eclipse.swt.widgets.TreeItem target)
Check wether the dragged favorite is dragged over a valid target. Invalid targets are: o Target and Source have same parents and Target is no category
o Target is Parent of Source

Parameters:
source - The source treeitem
target - The target treeitem
Returns:
boolean TRUE if target is valid

moveCategory

void moveCategory(String catPath,
                  org.eclipse.swt.widgets.TreeItem parent)
Move the category specified by the catPath into the treeitem

Parameters:
catPath - Qualified path to the moved category
parent - The treeitem to add the category into

moveCategoryToRoot

void moveCategoryToRoot(String catPath)
Move the category specified by the catPath to the Root of the Tree.

Parameters:
catPath - Qualified path to the moved category

moveFavorite

void moveFavorite(String favoriteTitle,
                  org.eclipse.swt.widgets.TreeItem parent)
Move the favorite represented by its name into the treeitem which is a category.

Parameters:
favoriteTitle - The title of the favorite
parent - The category to move the favorite into


RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo