net.sourceforge.rssowl.controller
Class FavoritesTree

java.lang.Object
  extended bynet.sourceforge.rssowl.controller.FavoritesTree
All Implemented Interfaces:
IFontChangeable, ITranslatable

public class FavoritesTree
extends Object
implements ITranslatable, IFontChangeable

This is the Tree that holds the categorys and its RSS favorites.

Version:
1.1.3
Author:
Benjamin Pasero

Field Summary
private  org.eclipse.swt.widgets.ToolItem aggregateAll
           
private  org.eclipse.swt.widgets.ToolItem closeControllsToolItem
           
private  org.eclipse.swt.widgets.MenuItem closeMenuItem
           
(package private)  org.eclipse.swt.custom.SashForm contentPane
           
private  boolean deletionInProgress
           
private  org.eclipse.swt.widgets.Display display
           
(package private)  EventManager eventManager
           
(package private)  org.eclipse.swt.widgets.Tree favoritesTree
           
private  org.eclipse.swt.widgets.Composite favoritesTreeHolder
           
private  org.eclipse.swt.widgets.ToolItem markAllRead
           
private  org.eclipse.swt.widgets.ToolItem reloadAll
           
(package private)  org.eclipse.swt.widgets.Composite renameEditorContainer
           
private  FavoritesTreeDND rssOwlFavoritesTreeDND
           
(package private)  GUI rssOwlGui
           
private  FavoritesTreePopup rssOwlPopUpMenu
           
private  org.eclipse.swt.widgets.ToolItem searchAll
           
(package private)  org.eclipse.swt.widgets.Shell shell
           
(package private)  org.eclipse.swt.widgets.MenuItem toggleToolBarMenuItem
           
private  org.eclipse.swt.widgets.Menu topToolBarMenu
           
(package private)  org.eclipse.swt.custom.TreeEditor treeEditor
           
private  ViewForm treeViewForm
           
private  org.eclipse.swt.widgets.Composite treeViewFormCenterHeader
           
private  org.eclipse.swt.widgets.Label treeViewFormHeaderLabel
           
private  org.eclipse.swt.widgets.Composite treeViewFormLeftHeader
           
 
Constructor Summary
FavoritesTree(org.eclipse.swt.widgets.Display display, org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.custom.SashForm contentPane, GUI rssOwlGui, EventManager eventManager)
          Instantiate a new FavoritesTree
 
Method Summary
 void addCategory(String name, Category parentCat)
          Add a new category to the Tree
private  void addCategoryOrFavorite(Hashtable favoritOrCategory, TreeSet sortedTitles, org.eclipse.swt.widgets.Widget parent, Category rssOwlCategory)
          Recursivly add Favorites and Categorys to the URL Tree.
 void addFavorite(Category selectedCat, String link, String title, Favorite oldFavorite)
          Add a new Favorite to the Tree
 void addFavorite(String catPath, String link, String title, Favorite oldFavorite)
          Add a new Favorite to the Tree
private  org.eclipse.swt.widgets.TreeItem addTreeItem(String name, org.eclipse.swt.graphics.Image icon, String catName, org.eclipse.swt.widgets.Widget parent, boolean isBlogroll, int unreadNewsCount)
          Insert a new item into the favorites tree.
 void appendUnreadCount(org.eclipse.swt.widgets.TreeItem treeItem, String name, int unreadCount)
          This Method will append the given unread-count to the TreeItem's name.
 void buildFavoritesTree()
          Build the complete favorites Tree from the RSSOwlFavTree.
 void createAmphetaRateFeed()
          Creates or updates the AmphetaRate feed
(package private)  void createPopUpMenu()
          Create a new popup menuStructure
 org.eclipse.swt.widgets.Tree getFavoritesTree()
          Let other objects access this controll (for example to focus on it)
 FavoritesTreeDND getRSSOwlFavoritesTreeDND()
          Get the DND class that allows drag and drop on this favorites tree
 Category getSelectedCat()
          Get the selected category
 Category getSelectedCat(String path)
          Get the selected category from the given path
 Favorite getSelectedFav()
          Get the selected favorite
(package private)  TreeItemData getSelectedTreeItemData()
          Get the current selected TreeItem's data.
 boolean getTreeHasUnreadFavs()
          Check if RSSOwl contains favorites with unread news
 String getTreePath(boolean skipFavorite)
          Return the TreePath of the selected TreeItem
 String getTreePath(org.eclipse.swt.widgets.TreeItem selectedTree, boolean skipFavorite)
          Return the TreePath of the selected TreeItem
 void handleTreeItemSelect(boolean isSingleClick)
          Open the newsfeed if the user has clicked on a favorite.
private  void initComponents()
          Init all components
private  void initTopContextMenu(org.eclipse.swt.widgets.Control parent)
          Initialize the Context Menu that toggles visibility of the Favorites Tree ToolBar and allows to Close the Favorites Tree.
(package private)  void onKeyPressed(org.eclipse.swt.events.KeyEvent e)
          Called whenever a Key is pressed on the Tree
(package private)  void onMouseDoubleClick(org.eclipse.swt.widgets.Event event)
          The tree was doubleclicked with the mouse
(package private)  void onMouseUp(org.eclipse.swt.events.MouseEvent event)
          The favorites tree was selected with the Mouse
(package private)  void onSelection()
          The tree was selected
(package private)  void onTreeEvent(org.eclipse.swt.events.TreeEvent e, boolean expanded)
          Called whenever a TreeItem is expanded
(package private)  void performDeletion()
          Delete selected cat or fav or sub
private  void rename(org.eclipse.swt.widgets.TreeItem item)
          Open an in-place Text editor field to rename the given TreeItem.
(package private)  void renameCategory(Category category, String newTitle)
          Rename the given Category using the new title
(package private)  void renameFavorite(Favorite favorite, String newTitle)
          Rename the given Favorite using the new title
(package private)  void renameSelectedItem()
          Rename the selected TreeItem (in place)
private  void restoreExpanded(org.eclipse.swt.widgets.TreeItem[] items, Category rssOwlCategory)
          Recursivly restore expanded status for the TreeItems
private  void restoreSelection(String path)
          Restore selection of given treepath
 void setShowToolBar(boolean show)
          Toggles the visibility of the Tree ToolBar.
 void stopRenaming()
          Disposes the Container for the Text Control that is used when the user is going to Rename an Item of the Tree in place.
 void updateFonts()
          All implementing classes must provide a method to update the fonts of all GUI elements that provide a setFont() Method.
 void updateI18N()
          Update all controlls text with i18n
 void updateTreeItemIcon(org.eclipse.swt.widgets.TreeItem treeItem)
          Update the icon on a TreeItem in dependance of the "isError" flag.
 void updateTreeReadStatus(org.eclipse.swt.widgets.TreeItem treeItem)
          Recursivly update all parent categories of the given TreeItem to set / unset the unread status, which is indicated by a slightly different category icon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aggregateAll

private org.eclipse.swt.widgets.ToolItem aggregateAll

closeControllsToolItem

private org.eclipse.swt.widgets.ToolItem closeControllsToolItem

closeMenuItem

private org.eclipse.swt.widgets.MenuItem closeMenuItem

deletionInProgress

private boolean deletionInProgress

display

private org.eclipse.swt.widgets.Display display

favoritesTreeHolder

private org.eclipse.swt.widgets.Composite favoritesTreeHolder

markAllRead

private org.eclipse.swt.widgets.ToolItem markAllRead

reloadAll

private org.eclipse.swt.widgets.ToolItem reloadAll

rssOwlFavoritesTreeDND

private FavoritesTreeDND rssOwlFavoritesTreeDND

rssOwlPopUpMenu

private FavoritesTreePopup rssOwlPopUpMenu

searchAll

private org.eclipse.swt.widgets.ToolItem searchAll

topToolBarMenu

private org.eclipse.swt.widgets.Menu topToolBarMenu

treeViewForm

private ViewForm treeViewForm

treeViewFormCenterHeader

private org.eclipse.swt.widgets.Composite treeViewFormCenterHeader

treeViewFormHeaderLabel

private org.eclipse.swt.widgets.Label treeViewFormHeaderLabel

treeViewFormLeftHeader

private org.eclipse.swt.widgets.Composite treeViewFormLeftHeader

contentPane

org.eclipse.swt.custom.SashForm contentPane

eventManager

EventManager eventManager

favoritesTree

org.eclipse.swt.widgets.Tree favoritesTree

renameEditorContainer

org.eclipse.swt.widgets.Composite renameEditorContainer

rssOwlGui

GUI rssOwlGui

shell

org.eclipse.swt.widgets.Shell shell

toggleToolBarMenuItem

org.eclipse.swt.widgets.MenuItem toggleToolBarMenuItem

treeEditor

org.eclipse.swt.custom.TreeEditor treeEditor
Constructor Detail

FavoritesTree

public FavoritesTree(org.eclipse.swt.widgets.Display display,
                     org.eclipse.swt.widgets.Shell shell,
                     org.eclipse.swt.custom.SashForm contentPane,
                     GUI rssOwlGui,
                     EventManager eventManager)
Instantiate a new FavoritesTree

Parameters:
display - The display
shell - The shell
contentPane - The Sashform where to add the URL-Tree
rssOwlGui - Access some methods of the main controller
eventManager - The event manager
Method Detail

addCategory

public void addCategory(String name,
                        Category parentCat)
Add a new category to the Tree

Parameters:
name - Name of the category
parentCat - The Parent category

addFavorite

public void addFavorite(Category selectedCat,
                        String link,
                        String title,
                        Favorite oldFavorite)
Add a new Favorite to the Tree

Parameters:
selectedCat - The category to add this favorite into
link - Link to the XML
title - Desired Title of the Favorite
oldFavorite - If this field is not NULL the oldFavorite is being updated and given as parameter to clone its settings

addFavorite

public void addFavorite(String catPath,
                        String link,
                        String title,
                        Favorite oldFavorite)
Add a new Favorite to the Tree

Parameters:
catPath - Name of the Category
link - Link to the XML
title - Desired Title of the Favorite
oldFavorite - If this field is not NULL the oldFavorite is being updated and given as parameter to clone its settings

appendUnreadCount

public void appendUnreadCount(org.eclipse.swt.widgets.TreeItem treeItem,
                              String name,
                              int unreadCount)
This Method will append the given unread-count to the TreeItem's name. If the value is 0, just the Name is used as Text.

Parameters:
treeItem - The TreeItem that is to be changed.
name - The Name of the TreeItem.
unreadCount - The Number to append to the Name.

buildFavoritesTree

public void buildFavoritesTree()
Build the complete favorites Tree from the RSSOwlFavTree. The favtree contains categorys with favorites.


createAmphetaRateFeed

public void createAmphetaRateFeed()
Creates or updates the AmphetaRate feed


getFavoritesTree

public org.eclipse.swt.widgets.Tree getFavoritesTree()
Let other objects access this controll (for example to focus on it)

Returns:
The URL Tree

getRSSOwlFavoritesTreeDND

public FavoritesTreeDND getRSSOwlFavoritesTreeDND()
Get the DND class that allows drag and drop on this favorites tree

Returns:
FavoritesTreeDND The dnd class of this favorite tree

getSelectedCat

public Category getSelectedCat()
Get the selected category

Returns:
Category Selected category

getSelectedCat

public Category getSelectedCat(String path)
Get the selected category from the given path

Parameters:
path - Path to the category (e.g. "Test > Sub1 > Sub2")
Returns:
Category Selected category

getSelectedFav

public Favorite getSelectedFav()
Get the selected favorite

Returns:
Favorite Selected Favorite

getTreeHasUnreadFavs

public boolean getTreeHasUnreadFavs()
Check if RSSOwl contains favorites with unread news

Returns:
boolean TRUE if there are favorites with unread news available

getTreePath

public String getTreePath(boolean skipFavorite)
Return the TreePath of the selected TreeItem

Parameters:
skipFavorite - TRUE if a favorite does not count as selection in the path
Returns:
String The TreePath

getTreePath

public String getTreePath(org.eclipse.swt.widgets.TreeItem selectedTree,
                          boolean skipFavorite)
Return the TreePath of the selected TreeItem

Parameters:
selectedTree - The selected TreeItem
skipFavorite - TRUE if a favorite does not count as selection in the path
Returns:
String The TreePath

handleTreeItemSelect

public void handleTreeItemSelect(boolean isSingleClick)
Open the newsfeed if the user has clicked on a favorite. Open the category if the user has clicked on a category.

Parameters:
isSingleClick - if TRUE, the selection was made with a single click

setShowToolBar

public void setShowToolBar(boolean show)
Toggles the visibility of the Tree ToolBar.

Parameters:
show - If TRUE, show the Tree ToolBar.

stopRenaming

public void stopRenaming()
Disposes the Container for the Text Control that is used when the user is going to Rename an Item of the Tree in place. This Method is called from the DND Support to guarantee that the Rename-Box is closing as soon as Drag is about to begin.


updateFonts

public void updateFonts()
Description copied from interface: IFontChangeable
All implementing classes must provide a method to update the fonts of all GUI elements that provide a setFont() Method.

Specified by:
updateFonts in interface IFontChangeable
See Also:
IFontChangeable.updateFonts()

updateI18N

public void updateI18N()
Update all controlls text with i18n

Specified by:
updateI18N in interface ITranslatable

updateTreeItemIcon

public void updateTreeItemIcon(org.eclipse.swt.widgets.TreeItem treeItem)
Update the icon on a TreeItem in dependance of the "isError" flag.

Parameters:
treeItem - The TreeItem to update

updateTreeReadStatus

public void updateTreeReadStatus(org.eclipse.swt.widgets.TreeItem treeItem)
Recursivly update all parent categories of the given TreeItem to set / unset the unread status, which is indicated by a slightly different category icon.

Parameters:
treeItem - The starting point TreeItem

addCategoryOrFavorite

private void addCategoryOrFavorite(Hashtable favoritOrCategory,
                                   TreeSet sortedTitles,
                                   org.eclipse.swt.widgets.Widget parent,
                                   Category rssOwlCategory)
Recursivly add Favorites and Categorys to the URL Tree.

Parameters:
favoritOrCategory - contains favorites or categorys
sortedTitles - Sorted Titles of favorits or categorys
parent - The parent Widget of the new treeitems
rssOwlCategory - Current category

addTreeItem

private org.eclipse.swt.widgets.TreeItem addTreeItem(String name,
                                                     org.eclipse.swt.graphics.Image icon,
                                                     String catName,
                                                     org.eclipse.swt.widgets.Widget parent,
                                                     boolean isBlogroll,
                                                     int unreadNewsCount)
Insert a new item into the favorites tree.

Parameters:
name - Name of the Item
icon - Icon (for example folder)
catName - Name of the category
parent - The parent of the new treeitem
isBlogroll - TRUE if favorite is from a blogroll
unreadNewsCount - The Number of unread News, or 0 if none.
Returns:
TreeItem The new treeitem

initComponents

private void initComponents()
Init all components


initTopContextMenu

private void initTopContextMenu(org.eclipse.swt.widgets.Control parent)
Initialize the Context Menu that toggles visibility of the Favorites Tree ToolBar and allows to Close the Favorites Tree.

Parameters:
parent - The Parent Control to create the Menu.

rename

private void rename(org.eclipse.swt.widgets.TreeItem item)
Open an in-place Text editor field to rename the given TreeItem.

Parameters:
item - The TreeItem to rename

restoreExpanded

private void restoreExpanded(org.eclipse.swt.widgets.TreeItem[] items,
                             Category rssOwlCategory)
Recursivly restore expanded status for the TreeItems

Parameters:
items - The TreeItems
rssOwlCategory - Current working category

restoreSelection

private void restoreSelection(String path)
Restore selection of given treepath

Parameters:
path - The path to the selected item

createPopUpMenu

void createPopUpMenu()
Create a new popup menuStructure


getSelectedTreeItemData

TreeItemData getSelectedTreeItemData()
Get the current selected TreeItem's data.

Returns:
TreeItemData The data of the selected item

onKeyPressed

void onKeyPressed(org.eclipse.swt.events.KeyEvent e)
Called whenever a Key is pressed on the Tree

Parameters:
e - The occuring KeyEvent

onMouseDoubleClick

void onMouseDoubleClick(org.eclipse.swt.widgets.Event event)
The tree was doubleclicked with the mouse

Parameters:
event - The occured event

onMouseUp

void onMouseUp(org.eclipse.swt.events.MouseEvent event)
The favorites tree was selected with the Mouse

Parameters:
event - The occured mouse event

onSelection

void onSelection()
The tree was selected


onTreeEvent

void onTreeEvent(org.eclipse.swt.events.TreeEvent e,
                 boolean expanded)
Called whenever a TreeItem is expanded

Parameters:
e - The occuring TreeEvent
expanded - If TRUE the TreeItem was expanded

performDeletion

void performDeletion()
Delete selected cat or fav or sub


renameCategory

void renameCategory(Category category,
                    String newTitle)
Rename the given Category using the new title

Parameters:
category - The category to rename
newTitle - The new title of the category

renameFavorite

void renameFavorite(Favorite favorite,
                    String newTitle)
Rename the given Favorite using the new title

Parameters:
favorite - The favorite to rename
newTitle - The new title of the favorite

renameSelectedItem

void renameSelectedItem()
Rename the selected TreeItem (in place)



RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo