public class BasicApp extends Object
BasicApp
can be used as a base class for applications which use a single main frame as user
interface.
This class provides several useful capabilites as there are:
And last but not least BasicApp
automatically stores the file pathes a user visited in open- or save
dialog boxes.
Command
,
ExecCommand
,
CommandGroup
,
CommandManager
Modifier and Type | Class and Description |
---|---|
static class |
BasicApp.MainFrame |
class |
BasicApp.ToolBarListener |
Modifier and Type | Field and Description |
---|---|
static String |
MESSAGE_STATUS_BAR_ITEM_KEY |
static String |
POSITION_STATUS_BAR_ITEM_KEY |
static String |
PROPERTY_KEY_APP_DEBUG_ENABLED |
static String |
PROPERTY_KEY_APP_LAST_OPEN_DIR |
static String |
PROPERTY_KEY_APP_LAST_OPEN_FORMAT |
static String |
PROPERTY_KEY_APP_LAST_SAVE_DIR |
static String |
PROPERTY_KEY_APP_LOG_ECHO |
static String |
PROPERTY_KEY_APP_LOG_ENABLED |
static String |
PROPERTY_KEY_APP_LOG_LEVEL |
static String |
PROPERTY_KEY_APP_LOG_PREFIX |
static String |
PROPERTY_KEY_APP_UI_FONT_NAME |
static String |
PROPERTY_KEY_APP_UI_FONT_SIZE |
static String |
PROPERTY_KEY_APP_UI_LAF |
static String |
PROPERTY_KEY_APP_UI_USE_SYSTEM_FONT_SETTINGS |
protected boolean |
uiDefaultsInitialized |
Modifier | Constructor and Description |
---|---|
|
BasicApp(ApplicationDescriptor applicationDescriptor) |
protected |
BasicApp(String appName,
String appSymbolicName,
String appVersion,
String appCopyrightInfo,
String appResource,
String appLoggerName)
Constructs a new application frame and creates the GUI.
|
Modifier and Type | Method and Description |
---|---|
void |
addHelp(ClassLoader classLoader,
String helpsetResourcePath)
Adds a new JavaHelp
HelpSet to the existing help. |
protected void |
applyLookAndFeelPreferences()
This method should be called after prefernces that affect the current look & feel have changed.
|
protected void |
applyPreferences() |
void |
center()
Centers this application frame within the screen area.
|
void |
clearStatusBarMessage()
Clears the status bar message.
|
protected void |
configureCommandsByResourceBundle() |
protected ImageIcon |
createFrameIcon()
Creates a default frame icon for this application.
|
protected JMenu |
createJMenu(String name,
String text,
char mnemonic,
String... cmdIds) |
protected com.jidesoft.action.CommandBar |
createMainMenuBar() |
protected JComponent |
createMainPane() |
protected com.jidesoft.action.CommandBar |
createMainToolBar() |
protected JMenu |
createNewMenu(String parent)
Create a new menu if the parent menu is not found
|
protected com.jidesoft.status.StatusBar |
createStatusBar() |
protected com.jidesoft.action.CommandBar |
createToolBar(String toolBarId,
String title) |
JMenu |
findMainMenu(String name) |
JMenu |
findMenu(String name) |
protected JMenu |
findMenu(String name,
boolean deepSearch) |
String |
getAppBuildInfo() |
String |
getAppCopyright() |
ApplicationDescriptor |
getApplicationDescriptor() |
String |
getAppName() |
String |
getAppSymbolicName() |
String |
getAppVersion() |
ActionListener |
getCloseHandler() |
CommandManager |
getCommandManager()
Returns the command manager used for this application.
|
CommandUIFactory |
getCommandUIFactory() |
protected String |
getDefaultLookAndFeelClassName() |
FileHistory |
getFileHistory() |
String |
getImageResourcePath() |
Logger |
getLogger() |
BasicApp.MainFrame |
getMainFrame() |
protected String |
getMainFrameTitle() |
com.jidesoft.action.CommandBar |
getMainToolBar() |
MouseListener |
getMouseOverActionHandler() |
PropertyMap |
getPreferences() |
File |
getPreferencesFile() |
ResourceBundle |
getResourceBundle()
Returns the resource bundle used by this application.
|
com.jidesoft.status.StatusBar |
getStatusBar() |
String |
getStatusBarMessage() |
SuppressibleOptionPane |
getSuppressibleOptionPane() |
com.jidesoft.action.CommandBar |
getToolBar(String toolBarId) |
String[] |
getToolBarGroups() |
protected void |
handleImminentExit()
Called by the
exit method. |
void |
handleUnknownException(Throwable e) |
protected void |
historyPush(File file) |
protected void |
initClient(com.bc.ceres.core.ProgressMonitor pm)
Starts up the client application.
|
protected void |
initClientUI(com.bc.ceres.core.ProgressMonitor pm)
Initializes the client user interface.
|
protected boolean |
initLookAndFeel() |
protected void |
insertCommandMenuItem(Command command) |
protected void |
insertCommandMenuItems() |
protected void |
insertCommandToolBarButtons(JToolBar toolbar) |
boolean |
isFrameBoundsRestored() |
boolean |
isShuttingDown() |
boolean |
isStartedUp() |
boolean |
isStatusBarVisible() |
boolean |
isToolBarVisible(String toolBarId) |
protected void |
loadJideExtension() |
protected void |
loadPreferences() |
boolean |
promptForOverwrite(File file)
Prompts a question dialog asking the user whether or not he/she wants to overwrite an existing file.
|
void |
registerJob(Object job)
Deprecated.
No longer used
|
void |
savePreferences() |
void |
setCloseHandler(ActionListener closeHandler) |
void |
setCommandManager(CommandManager commandManager)
Sets the command manager to be used for this application.
|
void |
setCurrentDocTitle(String currentDocTitle)
Sets the current document title which appears in this frame's title bar.
|
protected void |
setPreferences() |
protected void |
setShuttingDown(boolean shuttingDown) |
void |
setStatusBarMessage(String message)
Sets the status bar message to the given message string.
|
void |
setStatusBarVisible(boolean visible) |
void |
setToolBarVisible(String toolBarId,
boolean visbile) |
void |
showErrorDialog(String message) |
void |
showErrorDialog(String title,
String message) |
File |
showFileOpenDialog(String title,
boolean dirsOnly,
FileFilter fileFilter)
Opens a standard file-open dialog box.
|
File |
showFileOpenDialog(String title,
boolean dirsOnly,
FileFilter fileFilter,
String lastDirPropertyKey)
Opens a standard file-open dialog box.
|
File |
showFileSaveDialog(String title,
boolean dirsOnly,
FileFilter fileFilter,
String defaultExtension,
String fileName)
Opens a standard file-safe dialog box.
|
File |
showFileSaveDialog(String title,
boolean dirsOnly,
FileFilter fileFilter,
String defaultExtension,
String fileName,
String lastDirPropertyKey)
Opens a standard file-safe dialog box.
|
void |
showInfoDialog(String message,
String preferencesKey) |
void |
showInfoDialog(String title,
String message,
String preferencesKey) |
void |
showMessageDialog(String title,
String message,
int messageType,
String preferencesKey) |
void |
showOutOfMemoryErrorDialog(String message) |
int |
showQuestionDialog(String message,
String preferencesKey) |
int |
showQuestionDialog(String title,
String message,
boolean allowCancel,
String preferencesKey) |
int |
showQuestionDialog(String title,
String message,
String preferencesKey) |
void |
showWarningDialog(String message) |
void |
showWarningDialog(String title,
String message) |
void |
showWarningsDialog(String message,
String[] warnings) |
void |
shutDown()
Exits the application.
|
void |
startUp(com.bc.ceres.core.ProgressMonitor pm)
Starts up the application.
|
void |
unregisterJob(Object job)
Deprecated.
No longer used
|
protected void |
updateComponentTreeUI()
Called after the look & feel has changed.
|
void |
updateState()
Updates the appication's (UI-) state.
|
public static final String PROPERTY_KEY_APP_LAST_OPEN_DIR
public static final String PROPERTY_KEY_APP_LAST_OPEN_FORMAT
public static final String PROPERTY_KEY_APP_LAST_SAVE_DIR
public static final String PROPERTY_KEY_APP_LOG_ENABLED
public static final String PROPERTY_KEY_APP_LOG_PREFIX
public static final String PROPERTY_KEY_APP_LOG_LEVEL
public static final String PROPERTY_KEY_APP_LOG_ECHO
public static final String PROPERTY_KEY_APP_DEBUG_ENABLED
public static final String PROPERTY_KEY_APP_UI_LAF
public static final String PROPERTY_KEY_APP_UI_FONT_NAME
public static final String PROPERTY_KEY_APP_UI_FONT_SIZE
public static final String PROPERTY_KEY_APP_UI_USE_SYSTEM_FONT_SETTINGS
protected boolean uiDefaultsInitialized
public static final String MESSAGE_STATUS_BAR_ITEM_KEY
public static final String POSITION_STATUS_BAR_ITEM_KEY
public BasicApp(ApplicationDescriptor applicationDescriptor)
protected BasicApp(String appName, String appSymbolicName, String appVersion, String appCopyrightInfo, String appResource, String appLoggerName)
appName
- the application base name, appears in the frame's title barappSymbolicName
- the symbolic name of the applicationappVersion
- the version stringappCopyrightInfo
- the copyright information textappResource
- the resource path of the application's resource bundle, can be null
if the
application does not use resource bundlesappLoggerName
- the logger name for the application logging, can be null
if the application
does not use loggingResourceBundle
public ApplicationDescriptor getApplicationDescriptor()
public MouseListener getMouseOverActionHandler()
public boolean isFrameBoundsRestored()
public com.jidesoft.status.StatusBar getStatusBar()
public com.jidesoft.action.CommandBar getMainToolBar()
public File getPreferencesFile()
public Logger getLogger()
public boolean isStartedUp()
public boolean isShuttingDown()
protected void setShuttingDown(boolean shuttingDown)
public void startUp(com.bc.ceres.core.ProgressMonitor pm) throws Exception
The startup sequence is as follows:
createSplashScreen
is called. If it
returns non-nullloadPreferences
is called in
order to load user preferences.startUp
is called with the splash screen.
Clients can override this method in order to implement application specific initialisation code.applyPreferences
is called.pm
- a progress monitor, e.g. for splash-screenException
- if an error occurspublic String getAppCopyright()
protected boolean initLookAndFeel()
protected void loadJideExtension()
protected String getDefaultLookAndFeelClassName()
protected void handleImminentExit()
exit
method. The default implementation first saves the user preferences.
You should not call this method directly. If you override this method, make sure to call the base
class version as well.savePreferences()
protected com.jidesoft.action.CommandBar createMainToolBar()
protected JComponent createMainPane()
protected com.jidesoft.action.CommandBar createMainMenuBar()
protected com.jidesoft.status.StatusBar createStatusBar()
protected ImageIcon createFrameIcon()
null
if no icon is usedprotected void initClient(com.bc.ceres.core.ProgressMonitor pm) throws Exception
startUp(com.bc.ceres.core.ProgressMonitor)
before
initClientUI(com.bc.ceres.core.ProgressMonitor)
is called.
Clients should override this method in order to initialize non-UI components, e.g. load plugins.
The default implementation does nothing.pm
- a progress monitor, can be used to signal progressException
- if an error occursprotected void initClientUI(com.bc.ceres.core.ProgressMonitor pm) throws Exception
startUp(com.bc.ceres.core.ProgressMonitor)
after
initClient(com.bc.ceres.core.ProgressMonitor)
is called.
Clients should override this method in order to initialize their UI components.
The default implementation does nothing.pm
- a progress monitor, can be used to signal progressException
- if an error occurspublic BasicApp.MainFrame getMainFrame()
protected com.jidesoft.action.CommandBar createToolBar(String toolBarId, String title)
public com.jidesoft.action.CommandBar getToolBar(String toolBarId)
public boolean isToolBarVisible(String toolBarId)
public void setToolBarVisible(String toolBarId, boolean visbile)
public boolean isStatusBarVisible()
public void setStatusBarVisible(boolean visible)
public String getAppName()
public String getAppSymbolicName()
public String getAppVersion()
public String getAppBuildInfo()
public ResourceBundle getResourceBundle()
null
if a bundle does not existpublic String getImageResourcePath()
public CommandManager getCommandManager()
setCommandManager
with your alternative implementation.null
public void setCommandManager(CommandManager commandManager)
commandManager
- he command manager, must not be null
public CommandUIFactory getCommandUIFactory()
public final void updateState()
updateState
on each
registered command.public final void setStatusBarMessage(String message)
message
- the message to displaypublic void clearStatusBarMessage()
setStatusBarMessage(" Ready.")
.public final String getStatusBarMessage()
public final String[] getToolBarGroups()
protected final void insertCommandToolBarButtons(JToolBar toolbar)
protected void insertCommandMenuItems()
protected final void configureCommandsByResourceBundle()
protected final void insertCommandMenuItem(Command command)
protected JMenu createNewMenu(String parent)
parent
- nameprotected final JMenu createJMenu(String name, String text, char mnemonic, String... cmdIds)
public void shutDown()
The base class implementation calls setShuttingDown(true)
, calls
handleImminentExit()
and disposes the main frame.
When this method is overridden, this base class's implementation should always be called last. However, the
preferred way to change the shutdown behaviour is to override the handleImminentExit()
method.
protected final void loadPreferences()
public final void savePreferences()
protected final void setPreferences()
protected void applyPreferences()
protected final void applyLookAndFeelPreferences()
protected void updateComponentTreeUI()
SwingUtilities.updateComponentTreeUI(getMainFrame())
in order to reflect changes of the look-and-feel.
You might want to override this method in order to call SwingUtilities.updateComponentTreeUI()
on
other top-level containers beside the main frame.
public final void setCurrentDocTitle(String currentDocTitle)
currentDocTitle
- the titlepublic final void center()
public final File showFileOpenDialog(String title, boolean dirsOnly, FileFilter fileFilter)
title
- a dialog-box titledirsOnly
- whether or not to select only directoriesfileFilter
- the file filter to be used, can be null
null
if the user canceled file selectionpublic final File showFileOpenDialog(String title, boolean dirsOnly, FileFilter fileFilter, String lastDirPropertyKey)
title
- a dialog-box titledirsOnly
- whether or not to select only directoriesfileFilter
- the file filter to be used, can be null
lastDirPropertyKey
- the key under which the last directory the user visited is storednull
if the user canceled file selectionpublic final File showFileSaveDialog(String title, boolean dirsOnly, FileFilter fileFilter, String defaultExtension, String fileName)
title
- a dialog-box titledirsOnly
- whether or not to select only directoriesfileFilter
- the file filter to be used, can be null
defaultExtension
- the extension used as defaultfileName
- the initial filenamenull
if the user canceled file selectionpublic final File showFileSaveDialog(String title, boolean dirsOnly, FileFilter fileFilter, String defaultExtension, String fileName, String lastDirPropertyKey)
title
- a dialog-box titledirsOnly
- whether or not to select only directoriesfileFilter
- the file filter to be used, can be null
defaultExtension
- the extension used as defaultfileName
- the initial filenamelastDirPropertyKey
- the key under which the last directory the user visited is storednull
if the user canceled file selectionprotected void historyPush(File file)
public final void registerJob(Object job)
unregisterJob(java.lang.Object)
method.job
- any job-like objectpublic final void unregisterJob(Object job)
registerJob(java.lang.Object)
method have been deregistered.job
- any job-like objectpublic final void handleUnknownException(Throwable e)
public final SuppressibleOptionPane getSuppressibleOptionPane()
public final void showErrorDialog(String message)
public final void showWarningDialog(String message)
public final void showInfoDialog(String title, String message, String preferencesKey)
public final void showOutOfMemoryErrorDialog(String message)
public final void showMessageDialog(String title, String message, int messageType, String preferencesKey)
public final int showQuestionDialog(String title, String message, String preferencesKey)
public final int showQuestionDialog(String title, String message, boolean allowCancel, String preferencesKey)
public final boolean promptForOverwrite(File file)
file
- the file to check for existancetrue
if the user confirms the dialog with 'yes' or the given file does not exist.IllegalArgumentException
- if file
is null
public final PropertyMap getPreferences()
public final FileHistory getFileHistory()
public ActionListener getCloseHandler()
public void setCloseHandler(ActionListener closeHandler)
protected String getMainFrameTitle()
public final void addHelp(ClassLoader classLoader, String helpsetResourcePath)
HelpSet
to the existing help.
The helpset is as a resource path to the JavaHelp helpset XML file (*.hs).
The helpset and associated resources must be accessible by the given class-loader.
Note that you also can add help-set instances directly to the BEAM help system by using the
static HelpSys.add(javax.help.HelpSet)
method.
For more information on the JavaHelp architecture and API please refer to
the JavaHelp home page.
classLoader
- the class loader used to load the help resourceshelpsetResourcePath
- the resource path to the helpset file (*.hs)Copyright © 2002–2014 Brockmann Consult GmbH. All rights reserved.