net.sourceforge.java.feednread.frontend
Class MainApplicationWindow

java.lang.Object
  extended byorg.eclipse.jface.window.Window
      extended byorg.eclipse.jface.window.ApplicationWindow
          extended bynet.sourceforge.java.feednread.frontend.MainApplicationWindow
All Implemented Interfaces:
EventListener, ILanguageResourceChangeListener, IRunnableContext, IShellProvider

public class MainApplicationWindow
extends ApplicationWindow
implements ILanguageResourceChangeListener

The Feed'n Read main window holding all accessible application components.

Author:
Sebastian Machhausen

Nested Class Summary
private  class MainApplicationWindow.CoolBarResizeHandler
           Handles the resize of the enclosing Shell if the visual CoolBar representation of the CoolBarManager is resized due to rearrangements.
private  class MainApplicationWindow.ShellHandler
           Handles ShellEvents to map the application's tray behaviour.
 
Nested classes inherited from class org.eclipse.jface.window.ApplicationWindow
 
Nested classes inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
 
Field Summary
private  NewsFeedAddressBar addressBar
           The address bar to enter a newsfeed url
private  MenuManager aggregateMenu
           Aggregate menu
private  MainApplicationWindow.CoolBarResizeHandler coolBarResizeHandler
           Handles resize events in the CoolBar
private  MenuManager editMenu
           Edit menu
private  EventCentral eventCentral
          

private  MenuManager exportMenu
           Export menu
private  MenuManager extrasMenu
           Extras menu
private  PShelfItem favoritesSideBarItem
           The favorites tree sidebar item
private  SashForm feedViewDivider
           The sash dividing the NewsFeedTabBar and the NewsContentView
private  MenuManager fileMenu
           File menu
private  MenuManager helpMenu
           Help menu
private  MenuManager importMenu
           Import menu
private  Composite mainContainer
           The container holding all application components
private  MenuManager mainMenu
           Main menu
private  SashForm mainViewDivider
           The sash dividing the news area (NewsFeedTabBar + NewsContentView) and the NewsFeedFavoritesTree
static int MAXIMIZED_NEWS_VIEW
           Constant for the maximized news view (NewsFeedTabBar + NewsContentView)
private  MenuManager newMenu
           New menu
static int NEWS_CONTENT_VIEW
           Constant for the NewsContentView component
private  NewsContentView newsContent
           The component showing the currently selected news content
static int NEWSFEED_TAB_BAR
           Constant for the NewsFeedTabBar component
private  NewsFeedFavoritesTree newsFeedFavoritesTree
           The tree holding all favorite newsfeeds
private  NewsFeedWatchesTree newsFeedWatchesTree
           The tree holding all newsfeed watches
private  NewsFeedTabBar newsTabBar
           The tab bar to hold the single newsfeed, browser and filter tabs
static int NOTIFICATION_BAR
           Constant for the NotificationBar component
private  NotificationBar notificationBar
           The component to show user notifications, i.e. progress and logging messages
private  SashForm outputViewDivider
           The sash dividing the news area (NewsFeedTabBar + NewsContentView) and the NotificationBar
private  MainApplicationWindow.ShellHandler shellHandler
           Handles ShellEvents in the Shell
private  SideBar sideBar
           The sidebar to select from the various side bar items
static int SIDEBAR
           Constant for the SideBar component
private  ExtendedStatusLineManager statusLineMgr
           The StatusLineManager extension
private  TrayHandler trayHandler
           The TrayHandler of this application: Manages the system tray
private  TrayNotificationHandler trayNotificationHandler
           The TrayNotificationHandler of this application: Manages notifications displayed in the system tray
private  MenuManager viewMenu
          View menu
private  PShelfItem watchesSideBarItem
           The newsfeed watches sidebar item
 
Fields inherited from class org.eclipse.jface.window.ApplicationWindow
seperator1
 
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK
 
Constructor Summary
MainApplicationWindow(SplashScreen splash)
           Creates the MainApplicationWindow and disposes the specified SplasScreen when finished.
 
Method Summary
protected  boolean canHandleShellCloseEvent()
           Returns false if ConfigurationManager.SEND_TO_TRAY_ON_CLOSE_KEY is set to true.
 boolean close()
           Closes this window, disposes its shell, and removes this window from its window manager (if it has one).
protected  void configureShell(Shell shell)
           Configures the enclosed Shell of this MainApplicationWindow.
protected  void createComponents()
           Creates the components used by this MainApplicationWindow.
protected  Control createContents(Composite parent)
           Creates the contents of this MainApplicationWindow.
protected  CoolBarManager createCoolBarManager(int style)
           Creates the CoolBarManager of this MainApplicationWindow.
protected  MenuManager createMenuManager()
           Creates the MenuManager of this MainApplicationWindow.
protected  StatusLineManager createStatusLineManager()
           Creates the StatusLineManager of this MainApplicationWindow.
private  void createTray()
           Creates the tray control and notification handler.
protected  void createTrimWidgets(Shell shell)
           Creates the trim widgets around the content area of this MainApplicationWindow
 void defaultLanguageChanged(LanguageResourceChangeEvent lrce)
           Called whenever the default language changes.
private  void dispose()
           Disposes all resources claimed by this MainApplicationWindow.
protected  Control getCoolBarControl()
           Returns the control for this MainApplicationWindow 's coolbar.
 EventCentral getEventCentral()
           Gets the EventCentral which grants access to all Actions defined by this application.
protected  Point getInitialLocation(Point initialSize)
           Gets the initial location of this MainApplicationWindow.
protected  Point getInitialSize()
           Gets the initial size of this MainApplicationWindow.
 Composite getMainContainer()
           Gets the main container Composite which holds the content area of this MainApplicationWindow.
 Display getMainDisplay()
           Gets the main Display that this MainApplicationWindow is show in.
 NewsContentView getNewsContentView()
           Gets the NewsContentView component.
 NewsFeedAddressBar getNewsFeedAddressBar()
           Gets the NewsFeedAddressBar component.
 NewsFeedFavoritesTree getNewsFeedFavoritesTree()
           Gets the NewsFeedFavoritesTree component.
 NewsFeedTabBar getNewsFeedTabBar()
           Gets the NewsFeedTabBar component.
 NewsFeedWatchesTree getNewsFeedWatchesTree()
           Gets the NewsFeedWatchesTree component.
 NotificationBar getNotificationBar()
           Gets the NotificationBar component.
 ProgressMonitor getProgressMonitor()
           Gets the ProgressMonitor used by this MainApplicationWindow to show the progress of a long running task.
protected  Control getToolBarControl()
           Returns the control for this MainApplicationWindow 's toolbar.
 TrayNotificationHandler getTrayNotificationHandler()
           Gets the TrayNotificationHandler of this application.
private  void importTrees(SplashScreen splash)
           Imports the NewsFeedFavoritesTree and NewsFeedWatchesTree structures.
 boolean isMinimized()
           Returns true if the Shell that this MainApplicationWindow is displayed in is minimized.
 boolean isNewsFeedFavoritesTreeSelected()
           Returns true if the NewsFeedFavoritesTree component is currently selected in the SideBar component.
 boolean isNewsFeedWatchesTreeSelected()
           Returns true if the NewsFeedWatchesTree component is currently selected in the SideBar component.
static void main(String[] args)
           Feed'n Read Startup method.
 void maximize(int component)
           Maxmimizes the specified component(s).
 int open()
           Opens this window, creating it first if it has not yet been created.
private  void registerEventHandler()
           Registers all event handlers required in this MainApplicationWindow context.
 void restore(int component)
           Restores the specified component(s).
private  void restoreSettings()
           Restores the settings for this MainApplicationWindow from the underlying configuration.
private  void runEventLoop(Shell loopShell)
           Runs the event loop for the given Shell.
 void showNewsFeedFavoritesTree()
           Shows the NewsFeedFavoritesTree, i.e. makes it visible in the SideBar.
 void showNewsFeedWatchesTree()
           Shows the NewsFeedWatchesTree, i.e. makes it visible in the SideBar.
private  void storeSettings()
           Stores the settings of this MainApplicationWindow in the underlying configuration.
private  void unregisterEventHandler()
           Unregisters all event handlers from this MainApplicationWindow.
private  void updateBrowserToolBarActions(LanguageResource resource)
           Updates the browser toolbar Actions to reflect a change in the current LanguageResource.
private  void updateCoolBarManager(LanguageResource resource)
           Updates the CoolBarManager to reflect a change in the current LanguageResource.
private  void updateMenuManager(LanguageResource resource)
           Updates the MenuManager to reflect a change in the current LanguageResource.
 
Methods inherited from class org.eclipse.jface.window.ApplicationWindow
addCoolBar, addMenuBar, addStatusLine, addToolBar, coolBarChildrenExist, createCoolBarControl, createCoolBarManager2, createStatusLine, createToolBarControl, createToolBarManager, createToolBarManager2, getCoolBarManager, getCoolBarManager2, getFont, getLayout, getMenuBarManager, getSeperator1, getStatusLineManager, getSymbolicFontName, getToolBarManager, getToolBarManager2, run, setStatus, showTopSeperator, toolBarChildrenExist
 
Methods inherited from class org.eclipse.jface.window.Window
constrainShellSize, create, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, initializeBounds, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIDEBAR

public static final int SIDEBAR

Constant for the SideBar component

See Also:
Constant Field Values

NEWSFEED_TAB_BAR

public static final int NEWSFEED_TAB_BAR

Constant for the NewsFeedTabBar component

See Also:
Constant Field Values

NEWS_CONTENT_VIEW

public static final int NEWS_CONTENT_VIEW

Constant for the NewsContentView component

See Also:
Constant Field Values

MAXIMIZED_NEWS_VIEW

public static final int MAXIMIZED_NEWS_VIEW

Constant for the maximized news view (NewsFeedTabBar + NewsContentView)

See Also:
Constant Field Values

NOTIFICATION_BAR

public static final int NOTIFICATION_BAR

Constant for the NotificationBar component

See Also:
Constant Field Values

mainContainer

private Composite mainContainer

The container holding all application components


outputViewDivider

private SashForm outputViewDivider

The sash dividing the news area (NewsFeedTabBar + NewsContentView) and the NotificationBar


feedViewDivider

private SashForm feedViewDivider

The sash dividing the NewsFeedTabBar and the NewsContentView


mainViewDivider

private SashForm mainViewDivider

The sash dividing the news area (NewsFeedTabBar + NewsContentView) and the NewsFeedFavoritesTree


addressBar

private NewsFeedAddressBar addressBar

The address bar to enter a newsfeed url


sideBar

private SideBar sideBar

The sidebar to select from the various side bar items


favoritesSideBarItem

private PShelfItem favoritesSideBarItem

The favorites tree sidebar item


watchesSideBarItem

private PShelfItem watchesSideBarItem

The newsfeed watches sidebar item


newsFeedFavoritesTree

private NewsFeedFavoritesTree newsFeedFavoritesTree

The tree holding all favorite newsfeeds


newsFeedWatchesTree

private NewsFeedWatchesTree newsFeedWatchesTree

The tree holding all newsfeed watches


newsTabBar

private NewsFeedTabBar newsTabBar

The tab bar to hold the single newsfeed, browser and filter tabs


newsContent

private NewsContentView newsContent

The component showing the currently selected news content


notificationBar

private NotificationBar notificationBar

The component to show user notifications, i.e. progress and logging messages


trayHandler

private TrayHandler trayHandler

The TrayHandler of this application: Manages the system tray


trayNotificationHandler

private TrayNotificationHandler trayNotificationHandler

The TrayNotificationHandler of this application: Manages notifications displayed in the system tray


mainMenu

private MenuManager mainMenu

Main menu


fileMenu

private MenuManager fileMenu

File menu


newMenu

private MenuManager newMenu

New menu


viewMenu

private MenuManager viewMenu

View menu


extrasMenu

private MenuManager extrasMenu

Extras menu


helpMenu

private MenuManager helpMenu

Help menu


editMenu

private MenuManager editMenu

Edit menu


aggregateMenu

private MenuManager aggregateMenu

Aggregate menu


importMenu

private MenuManager importMenu

Import menu


exportMenu

private MenuManager exportMenu

Export menu


statusLineMgr

private ExtendedStatusLineManager statusLineMgr

The StatusLineManager extension


eventCentral

private EventCentral eventCentral


shellHandler

private MainApplicationWindow.ShellHandler shellHandler

Handles ShellEvents in the Shell


coolBarResizeHandler

private MainApplicationWindow.CoolBarResizeHandler coolBarResizeHandler

Handles resize events in the CoolBar

Constructor Detail

MainApplicationWindow

public MainApplicationWindow(SplashScreen splash)

Creates the MainApplicationWindow and disposes the specified SplasScreen when finished.

Parameters:
splash - the SplashScreen instance to dispose if the creation of this MainApplicationWindow is finished
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

getMainDisplay

public Display getMainDisplay()

Gets the main Display that this MainApplicationWindow is show in.

Returns:
he main Display that this MainApplicationWindow is show in

getMainContainer

public Composite getMainContainer()

Gets the main container Composite which holds the content area of this MainApplicationWindow.

Returns:
the main container Composite which holds the content area of this MainApplicationWindow.

getNewsFeedAddressBar

public NewsFeedAddressBar getNewsFeedAddressBar()

Gets the NewsFeedAddressBar component.

Returns:
the NewsFeedAddressBar component

getNewsFeedFavoritesTree

public NewsFeedFavoritesTree getNewsFeedFavoritesTree()

Gets the NewsFeedFavoritesTree component.

Returns:
the NewsFeedFavoritesTree component

getNewsFeedWatchesTree

public NewsFeedWatchesTree getNewsFeedWatchesTree()

Gets the NewsFeedWatchesTree component.

Returns:
the NewsFeedWatchesTree component

getNewsFeedTabBar

public NewsFeedTabBar getNewsFeedTabBar()

Gets the NewsFeedTabBar component.

Returns:
the NewsFeedTabBar component

getNewsContentView

public NewsContentView getNewsContentView()

Gets the NewsContentView component.

Returns:
the NewsContentView component

getNotificationBar

public NotificationBar getNotificationBar()

Gets the NotificationBar component.

Returns:
the NotificationBar component

getEventCentral

public EventCentral getEventCentral()

Gets the EventCentral which grants access to all Actions defined by this application.

Returns:
the EventCentral

getTrayNotificationHandler

public TrayNotificationHandler getTrayNotificationHandler()

Gets the TrayNotificationHandler of this application. It is used to create notifications in the system tray.

Returns:
the TrayNotificationHandler; null if the system the application is running on does not support a system tray

showNewsFeedFavoritesTree

public void showNewsFeedFavoritesTree()

Shows the NewsFeedFavoritesTree, i.e. makes it visible in the SideBar.


showNewsFeedWatchesTree

public void showNewsFeedWatchesTree()

Shows the NewsFeedWatchesTree, i.e. makes it visible in the SideBar.


isNewsFeedFavoritesTreeSelected

public boolean isNewsFeedFavoritesTreeSelected()

Returns true if the NewsFeedFavoritesTree component is currently selected in the SideBar component.

Returns:
true if the NewsFeedFavoritesTree component is currently selected in the SideBar component; false otherwise
See Also:
isNewsFeedWatchesTreeSelected()

isNewsFeedWatchesTreeSelected

public boolean isNewsFeedWatchesTreeSelected()

Returns true if the NewsFeedWatchesTree component is currently selected in the SideBar component.

Returns:
true if the NewsFeedWatchesTree component is currently selected in the SideBar component; false otherwise
See Also:
isNewsFeedFavoritesTreeSelected()

isMinimized

public boolean isMinimized()

Returns true if the Shell that this MainApplicationWindow is displayed in is minimized.

Returns:
true if the Shell that this MainApplicationWindow is displayed in is minimized: false otherwise

maximize

public void maximize(int component)

Maxmimizes the specified component(s).

Parameters:
component - a constant for the component(s) to maximize; the constants can be bitwise ored (combined with the | [OR] operator) to maximize several components at the same time.
See Also:
SIDEBAR, NEWSFEED_TAB_BAR, NEWS_CONTENT_VIEW

restore

public void restore(int component)

Restores the specified component(s).

Parameters:
component - a constant for the component(s) to restore; the constants can be bitwise ored (combined with the | [OR] operator) to restore several components at the same time.
See Also:
SIDEBAR, NEWSFEED_TAB_BAR, NEWS_CONTENT_VIEW

getProgressMonitor

public ProgressMonitor getProgressMonitor()

Gets the ProgressMonitor used by this MainApplicationWindow to show the progress of a long running task.

Returns:
the ProgressMonitor used by this MainApplicationWindow to show the progress of a long running task

open

public int open()

Opens this window, creating it first if it has not yet been created. If this window has been configured to block on open ( setBlockOnOpen), this method waits until the window is closed by the end user, and then it returns the window's return code; otherwise, this method returns immediately. A window's return codes are window-specific, although two standard return codes are predefined: OK and CANCEL.

Returns:
the return code
See Also:
Window.create()

close

public boolean close()

Closes this window, disposes its shell, and removes this window from its window manager (if it has one). Saves the NewsFeedFavoritesTree to the default OPML file and disposes all resources claimed.

Returns:
true if the window is (or was already) closed, and false if it is still open

canHandleShellCloseEvent

protected boolean canHandleShellCloseEvent()

Returns false if ConfigurationManager.SEND_TO_TRAY_ON_CLOSE_KEY is set to true. In this case the shell close event is not handled, i.e. the application stays open as long as not being closed from the menu in the application system tray item.

Returns:
false if ConfigurationManager.SEND_TO_TRAY_ON_CLOSE_KEY is set to true; true otherwise

getCoolBarControl

protected Control getCoolBarControl()

Returns the control for this MainApplicationWindow 's coolbar.

Returns:
the control for this MainApplicationWindow 's coolbar
See Also:
ApplicationWindow.getToolBarControl()

getToolBarControl

protected Control getToolBarControl()

Returns the control for this MainApplicationWindow 's toolbar.

Returns:
the control for this MainApplicationWindow 's toolbar
See Also:
ApplicationWindow.getToolBarControl()

configureShell

protected void configureShell(Shell shell)

Configures the enclosed Shell of this MainApplicationWindow.

See Also:
Window.configureShell(org.eclipse.swt.widgets.Shell)

getInitialSize

protected Point getInitialSize()

Gets the initial size of this MainApplicationWindow.

Returns:
the initial size of this MainApplicationWindow
See Also:
Window.getInitialSize()

getInitialLocation

protected Point getInitialLocation(Point initialSize)

Gets the initial location of this MainApplicationWindow. Tries to query the configuration for the window location. If no setting is found it centers the MainApplicationWindow horizontally and vertically relative Monitor's client area. Otherwise the location is set back to the setting found in the configuration.

Parameters:
initialSize - the initial size of the shell, as returned by getInitialSize.
Returns:
the initial location of the Shell

createMenuManager

protected MenuManager createMenuManager()

Creates the MenuManager of this MainApplicationWindow.

See Also:
ApplicationWindow.createMenuManager()

createStatusLineManager

protected StatusLineManager createStatusLineManager()

Creates the StatusLineManager of this MainApplicationWindow.

See Also:
ApplicationWindow.createStatusLineManager()

createCoolBarManager

protected CoolBarManager createCoolBarManager(int style)

Creates the CoolBarManager of this MainApplicationWindow.

See Also:
ApplicationWindow.createCoolBarManager(int)

createTrimWidgets

protected void createTrimWidgets(Shell shell)

Creates the trim widgets around the content area of this MainApplicationWindow

Parameters:
shell - the shell
See Also:
ApplicationWindow.createTrimWidgets(org.eclipse.swt.widgets.Shell)

createContents

protected Control createContents(Composite parent)

Creates the contents of this MainApplicationWindow.

Parameters:
parent - the parent component to embed the created contents into
Returns:
the created Control holding the contents of this MainApplicationWindow
See Also:
Window.createContents(org.eclipse.swt.widgets.Composite)

createComponents

protected void createComponents()

Creates the components used by this MainApplicationWindow.


dispose

private void dispose()

Disposes all resources claimed by this MainApplicationWindow.


storeSettings

private void storeSettings()

Stores the settings of this MainApplicationWindow in the underlying configuration.


restoreSettings

private void restoreSettings()

Restores the settings for this MainApplicationWindow from the underlying configuration.


createTray

private void createTray()

Creates the tray control and notification handler.


runEventLoop

private void runEventLoop(Shell loopShell)

Runs the event loop for the given Shell.

Parameters:
loopShell - the Shell for which to run the event loop

updateMenuManager

private void updateMenuManager(LanguageResource resource)

Updates the MenuManager to reflect a change in the current LanguageResource.

Parameters:
resource - the changed LanguageResource

updateCoolBarManager

private void updateCoolBarManager(LanguageResource resource)

Updates the CoolBarManager to reflect a change in the current LanguageResource.

Parameters:
resource - the changed LanguageResource

updateBrowserToolBarActions

private void updateBrowserToolBarActions(LanguageResource resource)

Updates the browser toolbar Actions to reflect a change in the current LanguageResource.

Parameters:
resource - the changed LanguageResource

importTrees

private void importTrees(SplashScreen splash)

Imports the NewsFeedFavoritesTree and NewsFeedWatchesTree structures.

Parameters:
splash - the SplashScreen to display the import progress in

registerEventHandler

private void registerEventHandler()

Registers all event handlers required in this MainApplicationWindow context.


unregisterEventHandler

private void unregisterEventHandler()

Unregisters all event handlers from this MainApplicationWindow.


main

public static void main(String[] args)

Feed'n Read Startup method.

Parameters:
args - the arguments handed over to the application