net.sourceforge.java.feednread.frontend.components.favoritestree
Class NewsFeedFavoritesTree

java.lang.Object
  extended bynet.sourceforge.java.feednread.frontend.components.favoritestree.NewsFeedFavoritesTree
All Implemented Interfaces:
EventListener, ILanguageResourceChangeListener

public class NewsFeedFavoritesTree
extends Object
implements ILanguageResourceChangeListener

Component to display a Tree of hierarchical Category and Favorite structures.

Author:
Sebastian Machhausen

Nested Class Summary
private  class NewsFeedFavoritesTree.RefreshFavoritesTreeTask
           Runnable task to refresh the NewsFeedFavoritesTree if the filter value changed.
 
Field Summary
private  TreeCellModifier cellModifier
           Describes how to edit an element in the favorites tree by querying the corresponding value from the model and putting the updated value back into the model again.
private  ToolItem clearFilterButton
           Button to clear the filter
private  ToolBar clearFilterToolBar
           The filter ToolBar
private  TreeViewerContentProvider contentProvider
           The favorites tree content provider which delivers the data from the underlying model layer to the gui layer.
private  TreeViewerDnDHandler dndHandler
           DnD support for the favorites TreeViewer
private  Object[] expandedElements
           A backup structure for the currently expanded elements.
private  TreeViewer favoritesViewer
           The TreeViewer that manages the NewsFeedFavoritesTree
private  TreeViewerFilter filter
           Default favorites tree filter which allows filtering the complete favorites tree upon a filter keyword.
private static int FILTER_REFRESH_INTERVAL
           The refresh interval of the filter in milliseconds
private  Text filterField
           The favorites tree filter Text field
private  CLabel filterLabel
           The favorites tree filter CLabel
private  NewsFeedFavoritesTreeLabelProvider labelProvider
           The favorites tree label provider which converts or translates domain objects from the model layer to the gui layer by providing textual and visual representations of domain objects.
private  long lastFilterUpdate
           The timestamp of the last update to the filter
private  MainApplicationWindow mainWindow
           The Feed'n Read main window
private  MenuManager menuMgr
           The internal MenuManager used to create the context Menu
private  Tree newsFeedFavorites
           The favorites Tree itself
private  TreeViewerSorter sorter
           Default favorites tree sorter.
 
Constructor Summary
NewsFeedFavoritesTree(Composite parent, MainApplicationWindow mainWindow)
           Creates a new NewsFeedFavoritesTree instance and embeds it into the specified component.
 
Method Summary
 void collapseAll()
           Collapses all expanded elements in this NewsFeedFavoritesTree.
private  void createFavoritesPanel(Composite parent)
           Creates a panel holding a form that contains a header, the favorites tree itself and an attached toolbar.
private  void createFavoritesTree(Composite parent)
           Creates the favorites tree itself, creates the underlying model and adjusts its settings.
private  void createFilterBar(Composite parent)
           Creates the filter bar to hold an input field which allows an user input to filter the favorites tree.
private  void createMenuManager()
           Creates the internal MenuManager used to create the context menu of this NewsFeedFavoritesTree
 void defaultLanguageChanged(LanguageResourceChangeEvent lrce)
           Called whenever the default language changes.
 void dispose()
           Disposes all resources claimed by this NewsFeedFavoritesTree.
 void expand(ITreeElement element)
           Expands the specified ITreeElement.
 void expandAll()
           Expands all collapsed elements in this NewsFeedFavoritesTree.
 IMutableTreeElement getRoot()
           Gets the root of this favorites tree.
 IMutableTreeElement getSelection()
           Gets the current selection of the favorites tree.
 boolean isVisible()
           Gets the visibility status of this NewsFeedFavoritesTree component.
 void refresh()
           Refreshes this NewsFeedFavoritesTree.
private  void registerEventHandler()
           Creates and registers all event handlers required in this NewsFeedFavoritesTree context.
 void setSelection(IMutableTreeElement element)
           Sets the current selection of the favorites tree to the specified element.
 void setVisible(boolean visible)
           Sets the visibility status of this NewsFeedFavoritesTree component.
 void showElement(ITreeElement element)
           Shows the specified element by making sure that it's visible in the favorites tree.
private  void unregisterEventHandler()
           Unregisters all event handlers required in this NewsFeedFavoritesTree context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainWindow

private MainApplicationWindow mainWindow

The Feed'n Read main window


favoritesViewer

private TreeViewer favoritesViewer

The TreeViewer that manages the NewsFeedFavoritesTree


newsFeedFavorites

private Tree newsFeedFavorites

The favorites Tree itself


filterLabel

private CLabel filterLabel

The favorites tree filter CLabel


filterField

private Text filterField

The favorites tree filter Text field


clearFilterToolBar

private ToolBar clearFilterToolBar

The filter ToolBar


clearFilterButton

private ToolItem clearFilterButton

Button to clear the filter


FILTER_REFRESH_INTERVAL

private static final int FILTER_REFRESH_INTERVAL

The refresh interval of the filter in milliseconds

See Also:
Constant Field Values

contentProvider

private TreeViewerContentProvider contentProvider

The favorites tree content provider which delivers the data from the underlying model layer to the gui layer.


labelProvider

private NewsFeedFavoritesTreeLabelProvider labelProvider

The favorites tree label provider which converts or translates domain objects from the model layer to the gui layer by providing textual and visual representations of domain objects.


sorter

private TreeViewerSorter sorter

Default favorites tree sorter. By default Categories are weighted higher than Favorites.


filter

private TreeViewerFilter filter

Default favorites tree filter which allows filtering the complete favorites tree upon a filter keyword.


cellModifier

private TreeCellModifier cellModifier

Describes how to edit an element in the favorites tree by querying the corresponding value from the model and putting the updated value back into the model again.


expandedElements

private Object[] expandedElements

A backup structure for the currently expanded elements. This is needed whensoever the favorites tree is filtered by user interaction to store and restore the current expansion status of the tree.


lastFilterUpdate

private long lastFilterUpdate

The timestamp of the last update to the filter


menuMgr

private MenuManager menuMgr

The internal MenuManager used to create the context Menu


dndHandler

private TreeViewerDnDHandler dndHandler

DnD support for the favorites TreeViewer

Constructor Detail

NewsFeedFavoritesTree

public NewsFeedFavoritesTree(Composite parent,
                             MainApplicationWindow mainWindow)

Creates a new NewsFeedFavoritesTree instance and embeds it into the specified component.

Parameters:
parent - the component to embed this NewsFeedFavoritesTree into
mainWindow - the Feed'n Read main window
Method Detail

defaultLanguageChanged

public void defaultLanguageChanged(LanguageResourceChangeEvent lrce)

Called whenever the default language changes.

Specified by:
defaultLanguageChanged in interface ILanguageResourceChangeListener
Parameters:
lrce - the triggered LanguageResourceChangeEvent

dispose

public void dispose()

Disposes all resources claimed by this NewsFeedFavoritesTree.


setSelection

public void setSelection(IMutableTreeElement element)

Sets the current selection of the favorites tree to the specified element. This may either be a Category or a Favorite instance.

Parameters:
element - the IMutableTreeElement to select

getSelection

public IMutableTreeElement getSelection()

Gets the current selection of the favorites tree. This may either be a Category or a Favorite instance.

Returns:
the current selection

getRoot

public IMutableTreeElement getRoot()

Gets the root of this favorites tree. Note that the root is set invisible by default.

Returns:
the root of this favorites tree

showElement

public void showElement(ITreeElement element)

Shows the specified element by making sure that it's visible in the favorites tree. The current selection remains unchanged.

Parameters:
element - the element to make visible

expand

public void expand(ITreeElement element)

Expands the specified ITreeElement.

Parameters:
element - the ITreeElement to expand

expandAll

public void expandAll()

Expands all collapsed elements in this NewsFeedFavoritesTree.


collapseAll

public void collapseAll()

Collapses all expanded elements in this NewsFeedFavoritesTree.


setVisible

public void setVisible(boolean visible)

Sets the visibility status of this NewsFeedFavoritesTree component.

Parameters:
visible - true for visible; false for invisible

isVisible

public boolean isVisible()

Gets the visibility status of this NewsFeedFavoritesTree component.

Returns:
visible true if visible; false if invisible

refresh

public void refresh()

Refreshes this NewsFeedFavoritesTree.


createMenuManager

private void createMenuManager()

Creates the internal MenuManager used to create the context menu of this NewsFeedFavoritesTree


createFavoritesPanel

private void createFavoritesPanel(Composite parent)

Creates a panel holding a form that contains a header, the favorites tree itself and an attached toolbar.

Parameters:
parent - the component to embed the created favorites panel into

createFavoritesTree

private void createFavoritesTree(Composite parent)

Creates the favorites tree itself, creates the underlying model and adjusts its settings.

Parameters:
parent - the parent Composite to embed the created favorites Tree in

createFilterBar

private void createFilterBar(Composite parent)

Creates the filter bar to hold an input field which allows an user input to filter the favorites tree.

Parameters:
parent - the parent Composite to embed the created filter bar in

registerEventHandler

private void registerEventHandler()

Creates and registers all event handlers required in this NewsFeedFavoritesTree context.


unregisterEventHandler

private void unregisterEventHandler()

Unregisters all event handlers required in this NewsFeedFavoritesTree context.