com.levigo.jadice.demo.launcher
Class BasicDemoApplication

java.lang.Object
  extended by com.levigo.jadice.demo.launcher.BasicDemoApplication
Direct Known Subclasses:
EmbeddedDemoApplication

public class BasicDemoApplication
extends Object

This class is a base / default implementation of a demo application.

During initialization, the protected configuration methods are being called. It is possible for subclasses to provide a different behavior or other functions by overriding the protected methods.

The appearance of the demo is controlled by the DefaultMenuComponentFactory which will is passed in the Constructor (if none is passed, the default Factory will be used).

This class can also be used in conjunction with the JadiceDemoLauncher. See EmbeddedDemoApplication for an example of subclassing the BasicDemoApplication.


Field Summary
protected static String JADICE_NAME
           
 
Constructor Summary
BasicDemoApplication()
          Default constructor
BasicDemoApplication(DefaultMenuComponentFactory menuComponentFactory)
          Constructor which allows to set the desired MenuComponents.properties file to use.
BasicDemoApplication(DefaultMenuComponentFactory menuComponentFactory, String[] args)
          Full constructor
 
Method Summary
protected  void addMenuContributions(PopupMenuTool popupMenuTool)
          Adds contributions (functions) to the popupMenuTool.
 void close()
          Called when the window is about to close.
protected  void configureAreaSelectionTool(AreaSelectionTool areaSelectionTool, Context context)
          Configures the AreaSelectionTool.
protected  void configureDragAndDrop(BasicJadicePanel mainViewerPanel)
          Called during initialization.
protected  void configureImportExportHandlers(BasicJadicePanel mainViewerPanel, ToolManager tm)
          Is called during initialization.
protected  void configureKeyBindingsTool(KeyBindingsTool kbt, Context ctx)
          Configures an instance of KeyBindingsTool by adding a couple of actions to be invoked when specific KeyEvents occur.
protected  void configureStatusBar(StatusBar snapInStatusBar)
          Called during initialization to configure the status bar.
protected  void configureTextSelectionTool(TextSelectionTool textSelectionTool, Context context)
          Configures the TextSelectionTool.
protected  void configureToolManager(ToolManager tm)
          Is called during initialization and registers the available tools.
protected  BasicJadicePanel createBasicJadicePanel()
          Called during initialization to create the basic jadice panel.
protected  JFrame createFrame(BasicJadicePanel viewerPanel)
          Called during initialization to create the main Window.
protected  void doConfigureImportExportHandlers(ThumbnailView thumbnailView)
          Sets the Import / Export handlers for the given ThumbnailView.
protected static String getArgumentValue(String arg, String defVal, String[] args)
          Gets the String value of an argument from the String array supplied.
 BasicJadicePanel getBasicJadicePanel()
          Returns the BasicJadicePanel created by createBasicJadicePanel().
 JFrame getFrame()
          Returns the JFrame created by createFrame(BasicJadicePanel).
protected  List<PresentationRule> getPresentationRules()
          Returns a list of the presentation rules.
protected  String getRollingMessagePanelPosition()
          Returns the desired position of the rolling message panel.
protected  String getSorterToolbarPosition()
          Returns the desired sorter toolbar position.
protected  JPopupMenu getTrayPopupMenu()
          Called when the TrayIcon is being installed.
protected  void handleArgs(String[] args)
          Called after initialization.
 boolean hasTrayIcon()
          Checks if this BasicDemoApplication has a registered TrayIcon.
 void hideTrayPopupMenu()
          Hides the tray icon
protected static void init()
          Registers L&F and configures Jadice properties
 void installTrayIcon()
          Installs a tray icon, if there is no tray icon yet.
protected  boolean isTrayVisibilityToggle()
          When installing a system tray icon, this method is called to determine whether an ActionListener should be registered on the TrayIcon to toggle the visibility of the Frame.
static void main(String[] args)
          Starts the application.
protected  void postInitCallback(JFrame mainFrame, BasicJadicePanel mainViewerPanel)
          This method is called after the initialization, but before the main frame is visible.
protected  void registerContextListeners(JFrame mainFrame, BasicJadicePanel mainViewerPanel)
          Is called during initialization to register context listeners.
protected  void registerPropertyChangeListeners(JFrame mainFrame, BasicJadicePanel mainViewerPanel)
          Called during initialization to register PropertyChangeListeners.
 void removeTrayIcon()
          If this BasicDemoApplication already registered a TrayIcon, that TrayIcon will be removed.
 void showTrayPopupMenu(int x, int y)
          Shows a tray icon popup at the given x,y location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JADICE_NAME

protected static final String JADICE_NAME
Constructor Detail

BasicDemoApplication

public BasicDemoApplication()
Default constructor


BasicDemoApplication

public BasicDemoApplication(DefaultMenuComponentFactory menuComponentFactory)
Constructor which allows to set the desired MenuComponents.properties file to use.

Parameters:
menuComponentFactory - - the GUI configuration to use

BasicDemoApplication

public BasicDemoApplication(DefaultMenuComponentFactory menuComponentFactory,
                            String[] args)
Full constructor

Parameters:
menuComponentFactory - - the path of the menuComponentsProperties file to use
args - - command line args (may be null)
Method Detail

handleArgs

protected void handleArgs(String[] args)
Called after initialization. By default, this method accepts the "-open"-Parameter to directly open a file.

Parameters:
args - - the command line args

getFrame

public JFrame getFrame()
Returns the JFrame created by createFrame(BasicJadicePanel).

Returns:
- the frame for this Demo application

getBasicJadicePanel

public BasicJadicePanel getBasicJadicePanel()
Returns the BasicJadicePanel created by createBasicJadicePanel().

Returns:
- the jadice panel embedded in this demo application

createFrame

protected JFrame createFrame(BasicJadicePanel viewerPanel)
Called during initialization to create the main Window. By default, the window will use the given viewerPanel as ContentPane.

Parameters:
viewerPanel - - the viewer panel
Returns:
- the created frame

createBasicJadicePanel

protected BasicJadicePanel createBasicJadicePanel()
Called during initialization to create the basic jadice panel. By default, this will create the BasicJadicePanel with the passed "menuComponentsPropertiesFile" from the constructor (if any - if no file was specified in the constructor, the default will be used).

Returns:
- the BasicJadicePanel to use

configureDragAndDrop

protected void configureDragAndDrop(BasicJadicePanel mainViewerPanel)
Called during initialization. By default, this will add Drop-support to the viewer.

Parameters:
mainViewerPanel - - the main viewer panel

getSorterToolbarPosition

protected String getSorterToolbarPosition()
Returns the desired sorter toolbar position. Return null if the toggling sorter frame should be used instead of the sorter.

Returns:
a BorderLayout constraint (e.g. BorderLayout.NORTH) or null.

getRollingMessagePanelPosition

protected String getRollingMessagePanelPosition()
Returns the desired position of the rolling message panel. Return null if the info bar should not be added.

Returns:
a BorderLayout constraint (e.g. BorderLayout.NORTH) or null.

configureStatusBar

protected void configureStatusBar(StatusBar snapInStatusBar)
Called during initialization to configure the status bar.

Parameters:
snapInStatusBar - - the StatusBar to configure

registerContextListeners

protected void registerContextListeners(JFrame mainFrame,
                                        BasicJadicePanel mainViewerPanel)
Is called during initialization to register context listeners.

Parameters:
mainFrame - - the main frame
mainViewerPanel - - the BasicJadicePanel

registerPropertyChangeListeners

protected void registerPropertyChangeListeners(JFrame mainFrame,
                                               BasicJadicePanel mainViewerPanel)
Called during initialization to register PropertyChangeListeners.

Parameters:
mainFrame - - the main frame
mainViewerPanel - - the BasicJadicePanel

getPresentationRules

protected List<PresentationRule> getPresentationRules()
Returns a list of the presentation rules. By default, the list contains "SwitchToSinglePageOnFit" and "ApplyDynamicZoomRule"

Returns:
a list of the presentation rules

postInitCallback

protected void postInitCallback(JFrame mainFrame,
                                BasicJadicePanel mainViewerPanel)
This method is called after the initialization, but before the main frame is visible. By default it does nothing

Parameters:
mainFrame - - the main frame
mainViewerPanel - - the viewer panel

main

public static void main(String[] args)
Starts the application.

Parameters:
args - an array of command-line arguments

init

protected static void init()
Registers L&F and configures Jadice properties


configureToolManager

protected void configureToolManager(ToolManager tm)
Is called during initialization and registers the available tools.

Parameters:
tm - - the ToolManager

configureImportExportHandlers

protected void configureImportExportHandlers(BasicJadicePanel mainViewerPanel,
                                             ToolManager tm)
Is called during initialization. By default, this will register the Import/Export-Handlers for the sorter and LightBoxThumbnailTool.

Parameters:
mainViewerPanel - - the main viewer panel (a BasicJadicePanel)
tm - - the ToolManager

doConfigureImportExportHandlers

protected void doConfigureImportExportHandlers(ThumbnailView thumbnailView)
Sets the Import / Export handlers for the given ThumbnailView. This is by default called from configureImportExportHandlers(BasicJadicePanel, ToolManager)

Parameters:
thumbnailView - - the view to set the import/export handler

configureAreaSelectionTool

protected void configureAreaSelectionTool(AreaSelectionTool areaSelectionTool,
                                          Context context)
Configures the AreaSelectionTool.

Parameters:
areaSelectionTool - - the AreaSelectionTool to configure
context - - the Context

configureTextSelectionTool

protected void configureTextSelectionTool(TextSelectionTool textSelectionTool,
                                          Context context)
Configures the TextSelectionTool.

Parameters:
textSelectionTool - - the TextSelectionTool to configure
context - - the Context

configureKeyBindingsTool

protected void configureKeyBindingsTool(KeyBindingsTool kbt,
                                        Context ctx)
Configures an instance of KeyBindingsTool by adding a couple of actions to be invoked when specific KeyEvents occur.

Parameters:
kbt - the KeyBindingsTool to be configured
ctx - a Context object to be used for the actions bound to key bindings.

addMenuContributions

protected void addMenuContributions(PopupMenuTool popupMenuTool)
Adds contributions (functions) to the popupMenuTool.

Parameters:
popupMenuTool - - the PopupMenuTool

close

public void close()
Called when the window is about to close. By default, this will remove the TrayIcon and dispose the frame.


isTrayVisibilityToggle

protected boolean isTrayVisibilityToggle()
When installing a system tray icon, this method is called to determine whether an ActionListener should be registered on the TrayIcon to toggle the visibility of the Frame.

By default, this will return true.

Returns:
true: a click on the TrayIcon should toggle the Demo frame's visibility; false otherwise
See Also:
installTrayIcon()

installTrayIcon

public void installTrayIcon()
Installs a tray icon, if there is no tray icon yet.


showTrayPopupMenu

public void showTrayPopupMenu(int x,
                              int y)
Shows a tray icon popup at the given x,y location. There will be no validity check on the given coordinates, it is up to the caller of this method to provide an approbate position.

Parameters:
x - x location
y - y location

hideTrayPopupMenu

public void hideTrayPopupMenu()
Hides the tray icon


removeTrayIcon

public void removeTrayIcon()
If this BasicDemoApplication already registered a TrayIcon, that TrayIcon will be removed.


hasTrayIcon

public boolean hasTrayIcon()
Checks if this BasicDemoApplication has a registered TrayIcon.

Returns:
true: TrayIcon present; false otherwise

getTrayPopupMenu

protected JPopupMenu getTrayPopupMenu()
Called when the TrayIcon is being installed. By default, the popup will be created with the DefaultMenuComponentFactory, key="trayPopup".

Returns:
- the popup menu for the tray icon

getArgumentValue

protected static String getArgumentValue(String arg,
                                         String defVal,
                                         String[] args)
Gets the String value of an argument from the String array supplied. If the argument cannot be found, the default value will be returned. The equals sign '=' is used for tokenizing.

Parameters:
arg - the argument to whose value is required
defVal - the default value to return if the argument cannot be found
args - the String array to be searched
Returns:
the found string value or the default value if it is not found


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.