net.sourceforge.java.feednread.frontend.components.newstable
Class NewsFeedTable

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

public class NewsFeedTable
extends Object
implements ILanguageResourceChangeListener

Display a NewsFeed in a TableViewer.

Author:
Sebastian Machhausen

Nested Class Summary
private  class NewsFeedTable.NewsClickHandler
           Event handler that attends to open a new browser tab showing the double clicked NewsFeedEntry.
private  class NewsFeedTable.SelectionHandler
           Event handler that attends to set the read status of a news depending on user selections.
private  class NewsFeedTable.SortListener
           Handles changes in the sorting column and/or direction.
 
Field Summary
private  NewsFeedTableContentProvider contentProvider
           
private  List eventListener
           
private  NewsFeedTableViewerFilter keywordFilter
           
private  NewsFeedTableLabelProvider labelProvider
           
private  MainApplicationWindow mainWindow
           
private  MenuManager menuMgr
           
private  NewsFeedTable.NewsClickHandler newsClickHandler
           
private  Table newsTable
           
private  NewsFeedTable.SelectionHandler selectionHandler
           
private  TableViewerSorter sorter
           
private  NewsFeedTable.SortListener sortListener
           
private  TableViewer tableViewer
           
private  NewsFeedTableViewerTaggedFilter taggedFilter
           
private  NewsFeedTableViewerUnreadFilter unreadFilter
           
 
Constructor Summary
NewsFeedTable(Composite parent, MainApplicationWindow mainWindow, NewsFeed newsFeed)
           Creates a new NewsFeedTable holding the news of the newsfeed at the specified url and embeds it into the given Composite.
 
Method Summary
 void addNewsFeedTableStatusListener(INewsFeedTableStatusListener listener)
           Adds the specified NewsFeedTableStatusListener to the list of registered listeners.
private  void createMenuManager()
           Creates the internal MenuManager used to create the context menu of this NewsFeedTable
 void defaultLanguageChanged(LanguageResourceChangeEvent lrce)
           Called whenever the default language changes.
 void dispose()
           Disposes this NewsFeedTable and all of its components and allocated resources.
 NewsFeedEntry[] filter(String filterText)
           Filters the entries in the underlying NewsFeedTableContentProvider that match the specified filterText keyword.
private  void fireClosing()
           Notifies all registered NewsFeedTableStatusListener instances that this NewsFeedTable is about to be closed.
private  void fireStatusChanged()
           Notifies all registered NewsFeedTableStatusListener instances that the status of this NewsFeedTable has changed.
 NewsFeedTableContentProvider getContentProvider()
           Gets the content provider used by this NewsTable.
 String getFilterText()
           Gets the currently set filter text; null if none set.
 NewsFeed getNewsFeed()
           Gets the NewsFeed displayed in this NewsFeedTable
 Table getNewsTable()
           Gets the news table gui component.
 NewsFeedEntry getSelectedNews()
           Gets the selected news or null if none selected.
 int getVisibleEntries()
           Gets the number of currently visible NewsFeedEntries according to the current filter settings in this NewsFeedTable.
private  void initializeColumns()
           Initializes the table columns by setting their widths and adjusting their settings.
private  void initializeEventListener()
           Initializes the internal event listener list structure.
private  void initializeTable(Composite parent, NewsFeed newsFeed)
           Initializes this NewsFeedTable by creating the required models and adjusting its gui specific settings.
 void markAllRead()
           Marks all news as read.
 void markAllUnread()
           Marks all news as unread.
 void markAsRead(NewsFeedEntry entry)
           Marks the specified news as read.
 void markAsUnread(NewsFeedEntry entry)
           Marks the specified news as unread.
 void packColumns()
           Packs the newsfeed table columns to adopt the width of their respective widest item.
 void refresh()
           Refreshes this NewsFeedTable.
private  void registerEventHandler()
           Creates and registers the required event handler for this NewsFeedTable.
 void removeNewsFeedTableStatusListener(INewsFeedTableStatusListener listener)
           Removes the specified NewsFeedTableStatusListener from the list of registered listeners.
 void selectNextNews()
           Selects the next news in this NewsFeedTable.
 void selectNextUnreadNews()
           Selects the next unread news in this NewsFeedTable.
 void setFilterText(String filterText)
           Sets the filter to the specified filterText.
 void setNewsFeed(NewsFeed newsFeed)
           Sets the NewsFeed displayed in this NewsFeedTable.
 void setNewsTagged(NewsFeedEntry entry, boolean tagged)
           Sets the tagged status of the specified NewsFeedEntry to tagged where a value of true means tagged, false untagged.
 void setTaggedFilterEnabled(boolean enabled)
           Sets the enabled status of the tagged news filter.
 void setUnreadFilterEnabled(boolean enabled)
           Sets the enabled status of the unread news filter.
private  void unregisterEventHandler()
           Unregisters all Event Handler from this NewsFeedTable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainWindow

private MainApplicationWindow mainWindow

newsTable

private Table newsTable

tableViewer

private TableViewer tableViewer

labelProvider

private NewsFeedTableLabelProvider labelProvider

contentProvider

private NewsFeedTableContentProvider contentProvider

sorter

private TableViewerSorter sorter

keywordFilter

private NewsFeedTableViewerFilter keywordFilter

unreadFilter

private NewsFeedTableViewerUnreadFilter unreadFilter

taggedFilter

private NewsFeedTableViewerTaggedFilter taggedFilter

menuMgr

private MenuManager menuMgr

sortListener

private NewsFeedTable.SortListener sortListener

selectionHandler

private NewsFeedTable.SelectionHandler selectionHandler

newsClickHandler

private NewsFeedTable.NewsClickHandler newsClickHandler

eventListener

private List eventListener
Constructor Detail

NewsFeedTable

public NewsFeedTable(Composite parent,
                     MainApplicationWindow mainWindow,
                     NewsFeed newsFeed)

Creates a new NewsFeedTable holding the news of the newsfeed at the specified url and embeds it into the given Composite.

Parameters:
parent - the parent to hold this NewsFeedTable
mainWindow - the Feed'n Read main window
newsFeed - the newsfeed to display
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 this NewsFeedTable and all of its components and allocated resources.


setNewsFeed

public void setNewsFeed(NewsFeed newsFeed)

Sets the NewsFeed displayed in this NewsFeedTable.

Parameters:
newsFeed - the NewsFeed to display

getNewsFeed

public NewsFeed getNewsFeed()

Gets the NewsFeed displayed in this NewsFeedTable

Returns:
the NewsFeed displayed in this NewsFeedTable

getContentProvider

public NewsFeedTableContentProvider getContentProvider()

Gets the content provider used by this NewsTable.

Returns:
the used content provider

getNewsTable

public Table getNewsTable()

Gets the news table gui component.

Returns:
he used news table gui component.

filter

public NewsFeedEntry[] filter(String filterText)

Filters the entries in the underlying NewsFeedTableContentProvider that match the specified filterText keyword.

Parameters:
filterText - the keyword to use for filtering
Returns:
the filtered newsfeed entries matching the specified filterText keyword

setFilterText

public void setFilterText(String filterText)

Sets the filter to the specified filterText. A null value clears the filter.

Parameters:
filterText - the text to use as filter; null to clear the filter

getFilterText

public String getFilterText()

Gets the currently set filter text; null if none set.

Returns:
the currently set filter text; null if none set

refresh

public void refresh()

Refreshes this NewsFeedTable.


getSelectedNews

public NewsFeedEntry getSelectedNews()

Gets the selected news or null if none selected.

Returns:
the selected news or null if none selected

getVisibleEntries

public int getVisibleEntries()

Gets the number of currently visible NewsFeedEntries according to the current filter settings in this NewsFeedTable.

Returns:
the number of currently visible NewsFeedEntries

markAsRead

public void markAsRead(NewsFeedEntry entry)

Marks the specified news as read.

Parameters:
entry - the news to mark as read

markAsUnread

public void markAsUnread(NewsFeedEntry entry)

Marks the specified news as unread.

Parameters:
entry - the news to mark as unread

markAllRead

public void markAllRead()

Marks all news as read.


markAllUnread

public void markAllUnread()

Marks all news as unread.


setNewsTagged

public void setNewsTagged(NewsFeedEntry entry,
                          boolean tagged)

Sets the tagged status of the specified NewsFeedEntry to tagged where a value of true means tagged, false untagged.

Parameters:
entry - the NewsFeedEntry to set the tagged status for
tagged - true to tag; false to untag

selectNextNews

public void selectNextNews()

Selects the next news in this NewsFeedTable.


selectNextUnreadNews

public void selectNextUnreadNews()

Selects the next unread news in this NewsFeedTable.


packColumns

public void packColumns()

Packs the newsfeed table columns to adopt the width of their respective widest item.


addNewsFeedTableStatusListener

public void addNewsFeedTableStatusListener(INewsFeedTableStatusListener listener)

Adds the specified NewsFeedTableStatusListener to the list of registered listeners.

Parameters:
listener - the listener to add

removeNewsFeedTableStatusListener

public void removeNewsFeedTableStatusListener(INewsFeedTableStatusListener listener)

Removes the specified NewsFeedTableStatusListener from the list of registered listeners.

Parameters:
listener - the listener to remove

setUnreadFilterEnabled

public void setUnreadFilterEnabled(boolean enabled)

Sets the enabled status of the unread news filter. If enabled only unread news otherwise all news are shown.

Parameters:
enabled - true to enable the unread news filter; false to disable it

setTaggedFilterEnabled

public void setTaggedFilterEnabled(boolean enabled)

Sets the enabled status of the tagged news filter. If enabled only tagged news otherwise all news are shown.

Parameters:
enabled - true to enable the tagged news filter; false to disable it

createMenuManager

private void createMenuManager()

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


initializeEventListener

private void initializeEventListener()

Initializes the internal event listener list structure.


fireStatusChanged

private void fireStatusChanged()

Notifies all registered NewsFeedTableStatusListener instances that the status of this NewsFeedTable has changed.


fireClosing

private void fireClosing()

Notifies all registered NewsFeedTableStatusListener instances that this NewsFeedTable is about to be closed.


initializeTable

private void initializeTable(Composite parent,
                             NewsFeed newsFeed)

Initializes this NewsFeedTable by creating the required models and adjusting its gui specific settings.

Parameters:
parent - the parent to hold this NewsFeedTable
newsFeed - the newsfeed to display

initializeColumns

private void initializeColumns()

Initializes the table columns by setting their widths and adjusting their settings.


registerEventHandler

private void registerEventHandler()

Creates and registers the required event handler for this NewsFeedTable.


unregisterEventHandler

private void unregisterEventHandler()

Unregisters all Event Handler from this NewsFeedTable.