net.sourceforge.java.feednread.frontend.components.tabbar
Class NewsFeedTabBar

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

public class NewsFeedTabBar
extends Object
implements ILanguageResourceChangeListener

Displays NewsFeedView and InternalBrowser components in tabs. Supplementally adds a filter bar to perform filter operations on the NewsFeeds viewed in the tabs.

Author:
Sebastian Machhausen

Nested Class Summary
private  class NewsFeedTabBar.TabHandler
           Internal Event Handler to react on closing tabs.
 
Field Summary
private  ToolItem clearFilterButton
           The Button to clear the filter
private  MenuManager contextMenuMgr
           The internal MenuManager used to create the context menu
private  Text filterField
           The news filter Text field
private  CLabel filterLabel
           The news filter CLabel
private  ToolItem filterMenuItem
           The ToolItem to open the filter menu
private  MenuManager filterMenuMgr
           The internal MenuManager used to created the filter menu
private  MainApplicationWindow mainWindow
           The Feed'n Read main window
private  ToolItem maximizeButton
           The Button to maximize the NewsFeedTabBar
private  ViewForm newsFeedTabBarForm
           The ViewForm to place the CTabFolder in
private  CTabFolder newsTabFolder
           The CTabFolder to hold the newsfeed tabs
private  Composite newsTabFolderContainer
           The container to act as placeholder for the ViewForm
private  NewsFeedTabBar.TabHandler tabHandler
           Event handler to react on tab selection and close
private  TabManager tabManager
           The TabManager acts as bridge between tab model and tab gui
 
Constructor Summary
NewsFeedTabBar(Composite parent, MainApplicationWindow mainWindow)
           Creates a new NewsFeedTabBar instance and embeds it into the specified placeholder.
 
Method Summary
 void addBrowserTab(String url)
           Adds a new tab showing a browser page refering to the specified url.
 void addMessageTab(String title, Throwable throwable)
           Adds a new tab showing an error message using the specified Throwable.
 void addTab(Favorite favorite)
           Adds a new tab that displays the NewsFeed held by the specified Favorite.
 void addTab(Favorite[] favorites, AggregatedNewsFeed newsFeed)
           Adds a tab that displays the specified AggregatedNewsFeed and bound to the specified Favorites.
 void addTab(NewsFeed newsFeed)
           Adds a new tab that displays the specified NewsFeed.
 void addTab(Watch watch)
           Adds a tab that displays the specified Watch.
 void closeAllTabs()
           Closes all currently opened tabs in this NewsFeedTabBar.
 void closeSelectedTab()
           Closes the currently selected tab in this NewsFeedTabBar.
private  void createComponents(Composite parent)
           Creates all required gui components and setups the layout of this NewsFeedTabBar.
private  void createContextMenu()
           Creates the internal MenuManager used to create the context menu of this NewsFeedTabBar.
private  void createFilterBar()
           Creates the filter bar to hold an input field which allows an user input to filter news by a keyword.
private  Menu createFilterMenu()
           Creates the internal MenuManager used to create the filter menu of this NewsFeedTabBar.
 void defaultLanguageChanged(LanguageResourceChangeEvent lrce)
           Called whenever the default language changes.
 void dispose()
           Disposes all components and resources claimed by this NewsFeedTabBar.
 void dispose(CTabItem item)
           Disposes the specified CTabItem.
 CTabItem[] getBrowserTabs()
           Gets all tabs that display a web page in an InternalBrowser component.
 String getFilterText()
           Gets the currently set filter text; null if none set.
 CTabItem[] getNewsFeedTabs()
           Gets all tabs that display a NewsFeed.
 CTabItem getSelectedTab()
           Gets the currently selected CTabItem or null if no tab available.
 CTabItem getTab(NewsFeed newsFeed)
           Gets the CTabItem matching the specified NewsFeed or null if no such tab is currently open showing the specified NewsFeed.
 CTabItem getTab(Watch watch)
           Gets the CTabItem matching the specified Watch null if no such tab is currently open showing the specified Watch.
 int getTabCount()
           Gets the number of tabs currently held by this NewsFeedTabBar.
(package private)  CTabFolder getTabFolder()
           Gets the CTabFolder component used by this NewsFeedTabBar.
 boolean isOpen(AggregatedNewsFeed newsFeed)
           Verifies if the specified AggregatedNewsFeed is open in an aggregated newsfeed tab.
 boolean isOpen(NewsFeed newsFeed)
           Verifies if the specified NewsFeed is open in a plain newsfeed tab.
 boolean isOpen(Watch watch)
           Verifies if the specified Watch is open in a tab.
 boolean isVisible()
           Gets the visibility status of this NewsFeedTabBar component.
private  void registerEventHandler()
           Registers all event handlers required by this NewsFeedTabBar.
 void selectNextTab()
           Selects the tab next to the the currently selected tab in this NewsFeedTabBar.
 void selectPreviousTab()
           Selects the tab previous to the currently selected tab in this NewsFeedTabBar.
 void setSelectedTab(CTabItem item)
           Sets the currently selected CTabItem.
 void setVisible(boolean visible)
           Sets the visibility status of this NewsFeedTabBar component.
 void synchronizeFilterTab()
           Synchronizes the filtered news tab to show only news items from open news tabs.
private  void unregisterEventHandler()
           Unregisters all event handlers from by this NewsFeedTabBar.
 void updateAggregations(NewsFeed newsFeed)
           Updates all open aggregated newsfeed tabs to the updated version of the specified NewsFeed.
 void updateFilterTab(Favorite[] favorites, NewsFeed filteredFeed)
           Updates the filter tab with the specified filteredFeed.
 void updateTabReadStates()
           Updates the tab titles of all newsfeed tabs and the filter tab if it is currently visible.
 void updateTabReadStatus(CTabItem item)
           Updates the tab title of the specified CTabItem.
 void updateTabTitle(InternalBrowser browser, String title)
           Updates the title of the tab holding the specified InternalBrowser to the specified title.
 void updateWatches(NewsFeed updatedNewsFeed)
           Updates all open Watch tabs to the updated version of the specified NewsFeed.
 
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


newsFeedTabBarForm

private ViewForm newsFeedTabBarForm

The ViewForm to place the CTabFolder in


newsTabFolderContainer

private Composite newsTabFolderContainer

The container to act as placeholder for the ViewForm


newsTabFolder

private CTabFolder newsTabFolder

The CTabFolder to hold the newsfeed tabs


filterLabel

private CLabel filterLabel

The news filter CLabel


clearFilterButton

private ToolItem clearFilterButton

The Button to clear the filter


filterField

private Text filterField

The news filter Text field


maximizeButton

private ToolItem maximizeButton

The Button to maximize the NewsFeedTabBar


contextMenuMgr

private MenuManager contextMenuMgr

The internal MenuManager used to create the context menu


filterMenuMgr

private MenuManager filterMenuMgr

The internal MenuManager used to created the filter menu


filterMenuItem

private ToolItem filterMenuItem

The ToolItem to open the filter menu


tabManager

private TabManager tabManager

The TabManager acts as bridge between tab model and tab gui


tabHandler

private NewsFeedTabBar.TabHandler tabHandler

Event handler to react on tab selection and close

Constructor Detail

NewsFeedTabBar

public NewsFeedTabBar(Composite parent,
                      MainApplicationWindow mainWindow)

Creates a new NewsFeedTabBar instance and embeds it into the specified placeholder.

Parameters:
parent - the placeholder that this NewsFeedTabBar should be embedded in
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 components and resources claimed by this NewsFeedTabBar.


dispose

public void dispose(CTabItem item)

Disposes the specified CTabItem. This includes the disposal of the embedded Control and the removal of the associated TabItemData object.

Parameters:
item - the CTabItem to dispose of

setSelectedTab

public void setSelectedTab(CTabItem item)

Sets the currently selected CTabItem.

Parameters:
item - the CTabItem to select

getSelectedTab

public CTabItem getSelectedTab()

Gets the currently selected CTabItem or null if no tab available.

Returns:
the currently selected CTabItem or null if no tab available

selectNextTab

public void selectNextTab()

Selects the tab next to the the currently selected tab in this NewsFeedTabBar.


selectPreviousTab

public void selectPreviousTab()

Selects the tab previous to the currently selected tab in this NewsFeedTabBar.


closeSelectedTab

public void closeSelectedTab()

Closes the currently selected tab in this NewsFeedTabBar.


closeAllTabs

public void closeAllTabs()

Closes all currently opened tabs in this NewsFeedTabBar.


setVisible

public void setVisible(boolean visible)

Sets the visibility status of this NewsFeedTabBar component.

Parameters:
visible - true for visible; false for invisible

isVisible

public boolean isVisible()

Gets the visibility status of this NewsFeedTabBar component.

Returns:
visible true if visible; false if invisible

addMessageTab

public void addMessageTab(String title,
                          Throwable throwable)

Adds a new tab showing an error message using the specified Throwable.

Parameters:
title - the title of the message tab
throwable - the Throwable raised

addTab

public void addTab(NewsFeed newsFeed)

Adds a new tab that displays the specified NewsFeed. If a tab is yet open for the specified NewsFeed it is then updated and focussed.

Parameters:
newsFeed - the NewsFeed to create or update a tab for

addTab

public void addTab(Favorite favorite)

Adds a new tab that displays the NewsFeed held by the specified Favorite. If a tab is yet open for the NewsFeed held by the specified Favorite it is then updated and focussed.

Parameters:
favorite - the Favorite for which to create or update a tab

addTab

public void addTab(Favorite[] favorites,
                   AggregatedNewsFeed newsFeed)

Adds a tab that displays the specified AggregatedNewsFeed and bound to the specified Favorites. If a tab is yet open for the AggregatedNewsFeed it is then updated and focussed.

Parameters:
favorites - the Favorites to bind to the tab to create
newsFeed - the AggregatedNewsFeed to create or update a tab for

addTab

public void addTab(Watch watch)

Adds a tab that displays the specified Watch. If a tab is yet open for the Watch it is then updated and focussed.

Parameters:
watch - the Watchs to bind to the tab to create

addBrowserTab

public void addBrowserTab(String url)

Adds a new tab showing a browser page refering to the specified url.

Parameters:
url - the url to open in a new browser tab

updateFilterTab

public void updateFilterTab(Favorite[] favorites,
                            NewsFeed filteredFeed)

Updates the filter tab with the specified filteredFeed. If no filtering has been done yet the filter tab is created lazily.

Parameters:
filteredFeed - the NewsFeed holding all filtered news

updateAggregations

public void updateAggregations(NewsFeed newsFeed)

Updates all open aggregated newsfeed tabs to the updated version of the specified NewsFeed. Those which do not hold the specified NewsFeed are omited.

Parameters:
newsFeed - the updated version of the NewsFeed

updateWatches

public void updateWatches(NewsFeed updatedNewsFeed)

Updates all open Watch tabs to the updated version of the specified NewsFeed. Those which do not hold the specified NewsFeed are omited.

Parameters:
updatedNewsFeed - the updated version of the NewsFeed

getTabCount

public int getTabCount()

Gets the number of tabs currently held by this NewsFeedTabBar.

Returns:
the number of tabs currently held

isOpen

public boolean isOpen(NewsFeed newsFeed)

Verifies if the specified NewsFeed is open in a plain newsfeed tab.

Parameters:
newsFeed - the NewsFeed to verify
Returns:
true if the specified NewsFeed is open in a plain newsfeed tab; false otherwise
See Also:
isOpen(AggregatedNewsFeed), isOpen(Watch)

isOpen

public boolean isOpen(AggregatedNewsFeed newsFeed)

Verifies if the specified AggregatedNewsFeed is open in an aggregated newsfeed tab.

Parameters:
newsFeed - the AggregatedNewsFeed to verify
Returns:
true if the specified AggregatedNewsFeed is open in an aggregated newsfeed tab; false otherwise
See Also:
isOpen(NewsFeed), isOpen(Watch)

isOpen

public boolean isOpen(Watch watch)

Verifies if the specified Watch is open in a tab.

Parameters:
watch - the Watch to verify
Returns:
true if the specified Watch is open in a tab; false otherwise
See Also:
isOpen(NewsFeed), isOpen(AggregatedNewsFeed)

updateTabTitle

public void updateTabTitle(InternalBrowser browser,
                           String title)

Updates the title of the tab holding the specified InternalBrowser to the specified title.

Parameters:
browser - the InternalBrowser which is embedded in the tab to update the title for
title - the updated title

getNewsFeedTabs

public CTabItem[] getNewsFeedTabs()

Gets all tabs that display a NewsFeed.

Returns:
all tabs that display a NewsFeed

getBrowserTabs

public CTabItem[] getBrowserTabs()

Gets all tabs that display a web page in an InternalBrowser component.

Returns:
all tabs that display a web page in an InternalBrowser component

getFilterText

public String getFilterText()

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

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

updateTabReadStatus

public void updateTabReadStatus(CTabItem item)

Updates the tab title of the specified CTabItem.

Parameters:
item - the CTabItem to update the title for

updateTabReadStates

public void updateTabReadStates()

Updates the tab titles of all newsfeed tabs and the filter tab if it is currently visible.


getTab

public CTabItem getTab(NewsFeed newsFeed)

Gets the CTabItem matching the specified NewsFeed or null if no such tab is currently open showing the specified NewsFeed.

Parameters:
newsFeed - the NewsFeed to get the corresponding CTabItem for
Returns:
the tab showing the specified NewsFeed
See Also:
getTab(Watch)

getTab

public CTabItem getTab(Watch watch)

Gets the CTabItem matching the specified Watch null if no such tab is currently open showing the specified Watch.

Parameters:
watch - the Watch to get the corresponding CTabItem for
Returns:
the tab showing the specified Watch
See Also:
getTab(NewsFeed)

synchronizeFilterTab

public void synchronizeFilterTab()

Synchronizes the filtered news tab to show only news items from open news tabs. Call this method whenever a news tab is closed.


getTabFolder

CTabFolder getTabFolder()

Gets the CTabFolder component used by this NewsFeedTabBar.

Returns:
the CTabFolder component used by this NewsFeedTabBar

createComponents

private void createComponents(Composite parent)

Creates all required gui components and setups the layout of this NewsFeedTabBar.

Parameters:
parent - the placeholder that this NewsFeedTabBar should be placed in

createFilterBar

private void createFilterBar()

Creates the filter bar to hold an input field which allows an user input to filter news by a keyword.


createContextMenu

private void createContextMenu()

Creates the internal MenuManager used to create the context menu of this NewsFeedTabBar.


createFilterMenu

private Menu createFilterMenu()

Creates the internal MenuManager used to create the filter menu of this NewsFeedTabBar.

Returns:
the created SWT filter Menu

registerEventHandler

private void registerEventHandler()

Registers all event handlers required by this NewsFeedTabBar.


unregisterEventHandler

private void unregisterEventHandler()

Unregisters all event handlers from by this NewsFeedTabBar.