net.sourceforge.java.feednread.backend.model.newstable
Class NewsFeedTableContentProvider

java.lang.Object
  extended bynet.sourceforge.java.feednread.backend.model.newstable.NewsFeedTableContentProvider
All Implemented Interfaces:
EventListener, IContentProvider, ILanguageResourceChangeListener, IStructuredContentProvider, ITableContentProvider

public class NewsFeedTableContentProvider
extends Object
implements IStructuredContentProvider, ITableContentProvider, ILanguageResourceChangeListener

Takes a single NewsFeed model object to supply its contained NewsFeedEntries to a JFace TableViewer instance.

Author:
Sebastian Machhausen

Field Summary
static int AUTHOR_COLUMN
           The index of the column to display the news author
static int CATEGORY_COLUMN
           The index of the column to display the NewsFeed category
static String[] COLUMN_IDENTIFIERS
           The column identifiers used
static int ENCLOSURE_COLUMN
           The index of the enclosure column which shows an Image if a news has an enclosure
private  NewsFeed newsFeed
           The NewsFeed that this content provider queries to supply the data
static int NEWSFEED_COLUMN
           The index of the column to display the NewsFeed title
static int PUBLISHED_DATE_COLUMN
           The index of the column to display the publishing date of a news
static int READ_STATUS_COLUMN
           The index of the read status column which shows an Image representing a read/unread news
static int TAGGED_STATUS_COLUMN
           The index of the tagged status column which shows an image representing a tagged/untagged news
static int TITLE_COLUMN
           The index of the column to display the news title
 
Constructor Summary
NewsFeedTableContentProvider(NewsFeed newsFeed)
           Creates a new NewsFeedTableContentProvider instance using the specified newsfeed to collect the embedded news and store them in a table structure.
 
Method Summary
 void defaultLanguageChanged(LanguageResourceChangeEvent lrce)
           Called whenever the default language changes.
 void dispose()
          Disposes of this content provider.
 int getColumnCount()
           Gets the number of columns stored in this NewsFeedTableContentProvider.
 String getColumnName(int columnIndex)
           Gets the name of the column at the specified index.
 Object getColumnValue(Object value, int columnIndex)
           Gets the textual representation of a news column.
 Object[] getElements(Object inputElement)
           Returns the elements to display in the viewer when its input is set to the given element.
 NewsFeed getNewsFeed()
           Gets the NewsFeed that this NewsFeedTableContentProvider collects the news from
 NewsFeedEntry[] getNewsFeedEntries()
           Returns the NewsFeedEntry objects held by this NewsFeedTableContentProvider.
 NewsFeedEntry getNewsFeedEntry(int rowIndex)
           Gets the news at the specified row.
 String getNewsFeedTitle()
           Gets the title of the newsfeed represented by this NewsFeedTableContentProvider.
 String getNewsFeedType()
           Gets the type of the newsfeed represented by this NewsFeedTableContentProvider.
 int getRowCount()
           Gets the number of rows, i.e. news stored in this NewsFeedTableContentProvider.
 void inputChanged(Viewer viewer, Object oldInput, Object newInput)
          Notifies this content provider that the given viewer's input has been switched to a different element.
 void setNewsFeed(NewsFeed newsFeed)
           Sets the NewsFeed that this NewsFeedTableContentProvider collects the news from
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_STATUS_COLUMN

public static final int READ_STATUS_COLUMN

The index of the read status column which shows an Image representing a read/unread news

See Also:
Constant Field Values

TAGGED_STATUS_COLUMN

public static final int TAGGED_STATUS_COLUMN

The index of the tagged status column which shows an image representing a tagged/untagged news

See Also:
Constant Field Values

ENCLOSURE_COLUMN

public static final int ENCLOSURE_COLUMN

The index of the enclosure column which shows an Image if a news has an enclosure

See Also:
Constant Field Values

PUBLISHED_DATE_COLUMN

public static final int PUBLISHED_DATE_COLUMN

The index of the column to display the publishing date of a news

See Also:
Constant Field Values

TITLE_COLUMN

public static final int TITLE_COLUMN

The index of the column to display the news title

See Also:
Constant Field Values

AUTHOR_COLUMN

public static final int AUTHOR_COLUMN

The index of the column to display the news author

See Also:
Constant Field Values

CATEGORY_COLUMN

public static final int CATEGORY_COLUMN

The index of the column to display the NewsFeed category

See Also:
Constant Field Values

NEWSFEED_COLUMN

public static final int NEWSFEED_COLUMN

The index of the column to display the NewsFeed title

See Also:
Constant Field Values

COLUMN_IDENTIFIERS

public static final String[] COLUMN_IDENTIFIERS

The column identifiers used


newsFeed

private NewsFeed newsFeed

The NewsFeed that this content provider queries to supply the data

Constructor Detail

NewsFeedTableContentProvider

public NewsFeedTableContentProvider(NewsFeed newsFeed)

Creates a new NewsFeedTableContentProvider instance using the specified newsfeed to collect the embedded news and store them in a table structure.

Parameters:
newsFeed - the NewsFeed to collect the news from
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

setNewsFeed

public void setNewsFeed(NewsFeed newsFeed)

Sets the NewsFeed that this NewsFeedTableContentProvider collects the news from

Parameters:
newsFeed - the NewsFeed to collect the news from

getNewsFeed

public NewsFeed getNewsFeed()

Gets the NewsFeed that this NewsFeedTableContentProvider collects the news from

Returns:
the NewsFeed that this NewsFeedTableContentProvider collects the news from

getNewsFeedEntries

public NewsFeedEntry[] getNewsFeedEntries()

Returns the NewsFeedEntry objects held by this NewsFeedTableContentProvider.

Returns:
the NewsFeedEntry objects held by this NewsFeedTableContentProvider.

getNewsFeedTitle

public String getNewsFeedTitle()

Gets the title of the newsfeed represented by this NewsFeedTableContentProvider.

Returns:
String the newsfeed title

getNewsFeedType

public String getNewsFeedType()

Gets the type of the newsfeed represented by this NewsFeedTableContentProvider.

Currently the following syndication types are supported:

Returns:
String the newsfeed type

getRowCount

public int getRowCount()

Gets the number of rows, i.e. news stored in this NewsFeedTableContentProvider.

Returns:
int the number of rows, i.e. news stored

getNewsFeedEntry

public NewsFeedEntry getNewsFeedEntry(int rowIndex)

Gets the news at the specified row.

Parameters:
rowIndex - int the index of the row to get the news for
Returns:
NewsFeedEntry the news

getColumnCount

public int getColumnCount()

Gets the number of columns stored in this NewsFeedTableContentProvider.

Returns:
int the number of columns

getColumnName

public String getColumnName(int columnIndex)

Gets the name of the column at the specified index.

Parameters:
columnIndex - int the index of the column to query the name for
Returns:
String the column name

getColumnValue

public Object getColumnValue(Object value,
                             int columnIndex)

Gets the textual representation of a news column. The column indices are mapped to the internal data attributes of a single news.

Specified by:
getColumnValue in interface ITableContentProvider
Parameters:
value - Object the NewsFeedEntry news
columnIndex - int the index of the column to query the value for
Returns:
Object the textual representaion of the news column value

getElements

public Object[] getElements(Object inputElement)

Returns the elements to display in the viewer when its input is set to the given element. These elements can be presented as rows in a table, items in a list, etc. The result is not modified by the viewer.

Specified by:
getElements in interface IStructuredContentProvider
Parameters:
inputElement - the input element
Returns:
the array of elements to display in the viewer

dispose

public void dispose()
Disposes of this content provider. This is called by the viewer when it is disposed.

The viewer should not be updated during this call, as it is in the process of being disposed.

Specified by:
dispose in interface IContentProvider

inputChanged

public void inputChanged(Viewer viewer,
                         Object oldInput,
                         Object newInput)
Notifies this content provider that the given viewer's input has been switched to a different element.

A typical use for this method is registering the content provider as a listener to changes on the new input (using model-specific means), and deregistering the viewer from the old input. In response to these change notifications, the content provider should update the viewer (see the add, remove, update and refresh methods on the viewers).

The viewer should not be updated during this call, as it might be in the process of being disposed.

Specified by:
inputChanged in interface IContentProvider
Parameters:
viewer - the viewer
oldInput - the old input element, or null if the viewer did not previously have an input
newInput - the new input element, or null if the viewer does not have an input