chemaxon.alchemist
Class AlchemistApplication

java.lang.Object
  extended by chemaxon.alchemist.AlchemistApplication

public class AlchemistApplication
extends java.lang.Object


Nested Class Summary
static class AlchemistApplication.ExitApplicationAction
          Default Exit Application Action
static class AlchemistApplication.LicenseManagerAction
          Default License Manager Action
static class AlchemistApplication.NewDocumentAction
          Default New Doucment Action
static class AlchemistApplication.OpenDocumentAction
          Default Open Document Action
static class AlchemistApplication.SaveDocumentAction
          Default Save Document Action
static class AlchemistApplication.SaveDocumentAsAction
          Default Save Document As Action
 
Field Summary
protected static java.lang.String DOCUMENT_CHANGED
          document changed indicator
protected  AlchemistFileChooser fileChooser
          the file chooser of the application
protected  chemaxon.marvin.uif.module.GUIModule guiModule
          GUIModule for menus and toolbars
protected  chemaxon.alchemist.utils.menu.AlchemistAction LICENSE_MANAGER_CLOSE_ACTION
          license dialog close action
protected static java.lang.String NO_DOCUMENT
          no document indicator
protected static java.lang.String PROPERTY_KEY_APP_INSTANCE
          the application instance
static java.lang.String PROPERTY_KEY_CONTENT_ENABLED
           
static java.lang.String PROPERTY_VALUE_CONTENT_DISABLED
           
static java.lang.String PROPERTY_VALUE_CONTENT_DISABLED_WITH_ANIMATION
           
static java.lang.String PROPERTY_VALUE_CONTENT_ENABLED
           
 
Constructor Summary
AlchemistApplication()
          Constructor.
AlchemistApplication(java.lang.String appTitle)
          Constructor.
 
Method Summary
protected  void createDisabledImage()
           
protected  void disableContent(boolean showWaitAnim)
           
protected  void enableContent()
           
protected  void exitProgramActionHandler()
          Raises confirmation dialog and exits application if it is confirmed, and application is not in disabled state
protected  boolean frameClosing()
          This function is being called when frame is about to close.
 javax.swing.JFrame getApplicationFrame()
          This method returns the application frame instance The contentPane should not be modified, components should be handled via getContentPane()
 AlchemistState getApplicationState()
          This function returns the main state object of the application
protected  java.lang.String getApplicationTitle()
          Returns the application title
 AlchemistBanner getBanner()
          This function returns a banner instance for this application.
 java.awt.Container getContentPane()
          This function returns the content pane of the AlchemistApplication
protected  java.awt.Dimension getDefaultWindowSize()
          This function returns the default application frame size Default implementation returns null, indicating frame size will be the 80% of the screen
protected  java.lang.String getDocumentFormat()
          Returns the format of current document, or null
protected  java.lang.String getDocumentPath()
          Returns the path of current document, or null
protected  int getMinimumWindowHeight()
          This function returns the minimum height of the application frame Default implementation returns 600
protected  int getMinimumWindowWidth()
          This function returns the minimum width of the application frame Default implementation returns 800
protected  java.lang.String getOpenFileChooserTitle()
          This function returns the title of the open file chooser, or null for default JFileChooser title
protected  javax.swing.filechooser.FileFilter[] getOpenFileFilters()
          This function returns the FileFilters used in open file dialogs.
protected  java.lang.String getPropertyFilePath()
          This function returns the path to property file.
protected  java.lang.String getSaveFileChooserTitle()
          This function returns the title of the save file chooser, or null for default JFileChooser title
protected  javax.swing.filechooser.FileFilter[] getSaveFileFilters()
          This function returns the FileFilters used in save file dialogs.
protected  javax.swing.filechooser.FileFilter getSaveFilter()
          Returns the last save file filter selected, or null if last save call canceled
protected  java.lang.String getSaveFilterFormat()
          Returns the format of last save filter selected, or null if filter is not a MolFileFilter or XMLFileFilter instance
protected  javax.swing.JToolBar getToolbar(java.lang.String toolBarID)
          Returns a toolbar instance with specified id
 void hide()
          This method hides the application frame
 void hideInnerDialog()
          Disposes the inner dialog previously set by showInnerDialog.
 void hideProgressBar()
          This method replaces progress bar with bottom text Releases progress monitor associated with progress bar (if any)
protected  boolean[] isActionsEnabled(java.lang.String[] actionIDs)
          Returns if the specified actions are enabled
protected  boolean isDocumentChanged()
          Returns the dirty bit of current document
protected  boolean isDocumentPathInFrameTitle()
          Returns if doucment path in frame title is shown
protected  void licenseManagerActionHandler()
          Default License Manager Action Handler Raises an inner dialog with license handler
protected  void licenseManagerClosed()
          Invoked when license manager is closed.
protected  void newDocumentActionHandler()
          Invoked by new document action Default implementation resets document file path document format, and dirty bit
protected  void openDocumentActionHandler(java.lang.String path)
          Invoked by open document action
protected  void refreshDocumentHeader()
           
protected  void restoreToolbar()
          Restore action states on toolbar from previous suspend
protected  void saveDocumentActionHandler()
          Invoked by save document action Default implementation clears dirty bit
protected  void saveDocumentAsActionHandler()
          Invoked by save document as action Default implementation opens save dialog, if file accepted sets path and format, and calls saveDocumentActionHandler
protected  void setActionEnabled(java.lang.String actionID, boolean enabled)
          Sets the action enabled status for the specific action
protected  void setActionsEnabled(java.lang.String[] actionIDs, boolean enabled)
          Sets the action enabled status for an array of actions
protected  void setActionsEnabled(java.lang.String[] actionIDs, boolean[] enabled)
          Sets the action enabled status for an array of actions
 void setBanner(AlchemistBanner banner)
          This method sets a banner for the application
 void setCustomWaitAnimation(java.lang.String path)
          This method sets a custom animation as loading animation Passing null removes custom animation
protected  void setDocumentChanged(boolean changed)
          Sets the dirty bit of current document
protected  void setDocumentFormat(java.lang.String format)
          Sets the format of current document
protected  void setDocumentPath(java.lang.String path)
          Sets the path of current document
protected  void setDocumentPathInFrameTitle(boolean value)
          Sets if document path is shown in header
static void setLookAndFeel()
          This method tries to set the look and feel to com.jgoodies.looks.plastic.PlasticXPLookAndFeel with SkyBluer theme (falls back to system default)
protected  void setMenubar()
          Deprecated. This method is no longer need to be called. Menu will automatically added when calling setMenuResources
protected  void setMenuResources(java.lang.String configPath)
          Sets the menu resources and initializes inner GUIModule instance
protected  void setMenuResources(java.lang.String configPath, java.lang.String bundleBaseName)
          Sets the menu resources and initializes inner GUIModule instance
protected  void setMenuResources(java.lang.String configPath, java.lang.String bundleBaseName, chemaxon.alchemist.utils.menu.AlchemistActionConfigurer configurer)
          Sets the menu resources and initializes inner GUIModule instance
 void setProgressBarText(java.lang.String progressLabelText)
          This method sets the displayed progress bar text
 void show()
          This method shows the application frame
protected  void showError(java.lang.String message, java.lang.Exception exception)
          Shows an error message dialog
 void showInnerDialog(AlchemistPage page)
          Shows a modal inner dialog
 void showInnerDialog(javax.swing.JPanel panel)
          Shows a modal inner dialog
 java.lang.String showOpenDialog()
          This function pops up the open file dialog in single file selection mode, and returns the path of selected file
 java.lang.String showOpenDialog(java.lang.String function)
          This function pops up the open file dialog in single file selection mode, and returns the path of selected file
 java.lang.String[] showOpenDialogMultiSel()
          This function pops up the open file dialog in multiple file selection mode, and returns the array of selected files' path
 java.lang.String[] showOpenDialogMultiSel(java.lang.String function)
          This function pops up the open file dialog in multiple file selection mode, and returns the array of selected files' path
 void showProgressBar(AlchemistProgressMonitor monitor)
          This method replaces bottom text with a progress bar
 void showProgressBar(AlchemistProgressMonitor monitor, javax.swing.Action cancelAction)
          This method replaces bottom text with a progress bar NOTE: this method resets progress bar value
 java.lang.String showSaveDialog()
          This function pops up the save file dialog and returns the file path selected for save
 java.lang.String showSaveDialog(java.lang.String function)
          This function pops up the save file dialog and returns the file path selected for save
protected  void suspendedToolbar(java.lang.String[] excludedActions)
          Suspends all actions on toolbar, but the excluded actions NOTE: can not suspend a toolbar until previous suspend not restored
protected  void suspendToolbar()
          Suspends all actions on toolbar NOTE: can not suspend a toolbar until previous suspend not restored
protected  void suspendToolbar(java.lang.String excludedAction)
          Suspends all actions on toolbar, but the excluded action NOTE: can not suspend a toolbar until previous suspend not restored
 void updateProgressBar(int percent)
          This method updates progress bar to the given percent NOTE: calling showProgressBar(String progressLabelText) resets value
protected  void virtualHide()
          Moves application window offscreen
protected  void virtualShow()
          Moves application center screen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_KEY_APP_INSTANCE

protected static final java.lang.String PROPERTY_KEY_APP_INSTANCE
the application instance

See Also:
Constant Field Values

PROPERTY_KEY_CONTENT_ENABLED

public static final java.lang.String PROPERTY_KEY_CONTENT_ENABLED
See Also:
Constant Field Values

PROPERTY_VALUE_CONTENT_ENABLED

public static final java.lang.String PROPERTY_VALUE_CONTENT_ENABLED
See Also:
Constant Field Values

PROPERTY_VALUE_CONTENT_DISABLED

public static final java.lang.String PROPERTY_VALUE_CONTENT_DISABLED
See Also:
Constant Field Values

PROPERTY_VALUE_CONTENT_DISABLED_WITH_ANIMATION

public static final java.lang.String PROPERTY_VALUE_CONTENT_DISABLED_WITH_ANIMATION
See Also:
Constant Field Values

NO_DOCUMENT

protected static final java.lang.String NO_DOCUMENT
no document indicator

See Also:
Constant Field Values

DOCUMENT_CHANGED

protected static final java.lang.String DOCUMENT_CHANGED
document changed indicator

See Also:
Constant Field Values

fileChooser

protected AlchemistFileChooser fileChooser
the file chooser of the application


guiModule

protected chemaxon.marvin.uif.module.GUIModule guiModule
GUIModule for menus and toolbars


LICENSE_MANAGER_CLOSE_ACTION

protected chemaxon.alchemist.utils.menu.AlchemistAction LICENSE_MANAGER_CLOSE_ACTION
license dialog close action

Constructor Detail

AlchemistApplication

public AlchemistApplication()
Constructor. Creates a new instance of AlchemistApplication


AlchemistApplication

public AlchemistApplication(java.lang.String appTitle)
Constructor. Creates a new instance of AlchemistApplication

Parameters:
appTitle - is the title of the application
Method Detail

getApplicationFrame

public javax.swing.JFrame getApplicationFrame()
This method returns the application frame instance The contentPane should not be modified, components should be handled via getContentPane()

Returns:
the application frame instance
See Also:
getContentPane()

getContentPane

public java.awt.Container getContentPane()
This function returns the content pane of the AlchemistApplication

Returns:
the content pane

frameClosing

protected boolean frameClosing()
This function is being called when frame is about to close. Default implementation raises a JOptionPane for close confirmation

Returns:
true when closig is allowed, false if frame will not close

getPropertyFilePath

protected java.lang.String getPropertyFilePath()
This function returns the path to property file. Default implementation returns null, indicating no property file needed.

Returns:
path to property file, or null if no property file needed.

showOpenDialog

public java.lang.String showOpenDialog(java.lang.String function)
This function pops up the open file dialog in single file selection mode, and returns the path of selected file

Parameters:
function - is the name of custom function this open dialog used by Last open dialog path and selected extesion will be restored and stored under this function name
Returns:
selected file path, or null if no file selected

showOpenDialog

public java.lang.String showOpenDialog()
This function pops up the open file dialog in single file selection mode, and returns the path of selected file

Returns:
selected file path, or null if no file selected

showOpenDialogMultiSel

public java.lang.String[] showOpenDialogMultiSel(java.lang.String function)
This function pops up the open file dialog in multiple file selection mode, and returns the array of selected files' path

Parameters:
function - is the name of custom function this open dialog used by Last open dialog path and selected extesion will be restored and stored under this function name
Returns:
array of selected files' path, or null if no files selected

showOpenDialogMultiSel

public java.lang.String[] showOpenDialogMultiSel()
This function pops up the open file dialog in multiple file selection mode, and returns the array of selected files' path

Returns:
array of selected files' path, or null if no files selected

showSaveDialog

public java.lang.String showSaveDialog(java.lang.String function)
This function pops up the save file dialog and returns the file path selected for save

Parameters:
function - is the name of custom function this save dialog used by Last save dialog path and selected extesion will be restored and stored under this function name
Returns:
the path of selcted file

showSaveDialog

public java.lang.String showSaveDialog()
This function pops up the save file dialog and returns the file path selected for save

Returns:
the path of selcted file

getSaveFilter

protected javax.swing.filechooser.FileFilter getSaveFilter()
Returns the last save file filter selected, or null if last save call canceled

Returns:
the last save file filter selected, or null if last save call canceled

getSaveFilterFormat

protected java.lang.String getSaveFilterFormat()
Returns the format of last save filter selected, or null if filter is not a MolFileFilter or XMLFileFilter instance

Returns:
the format of last save filter selected, or null if filter is not a MolFileFilter or XMLFileFilter instance

showProgressBar

public void showProgressBar(AlchemistProgressMonitor monitor)
This method replaces bottom text with a progress bar

Parameters:
monitor - is the progress monitor associated with progress bar

showProgressBar

public void showProgressBar(AlchemistProgressMonitor monitor,
                            javax.swing.Action cancelAction)
This method replaces bottom text with a progress bar NOTE: this method resets progress bar value

Parameters:
monitor - is the progress monitor associated with progress bar
cancelAction - is the action will be fired when pressing cancel button

setProgressBarText

public void setProgressBarText(java.lang.String progressLabelText)
This method sets the displayed progress bar text

Parameters:
progressLabelText - is the new text

hideProgressBar

public void hideProgressBar()
This method replaces progress bar with bottom text Releases progress monitor associated with progress bar (if any)


updateProgressBar

public void updateProgressBar(int percent)
This method updates progress bar to the given percent NOTE: calling showProgressBar(String progressLabelText) resets value

Parameters:
percent - is the new percentage
See Also:
showProgressBar(AlchemistProgressMonitor), showProgressBar(AlchemistProgressMonitor, Action)

getOpenFileFilters

protected javax.swing.filechooser.FileFilter[] getOpenFileFilters()
This function returns the FileFilters used in open file dialogs. Default implementation returns the default open file filters

Returns:
array of FileFilters

getSaveFileFilters

protected javax.swing.filechooser.FileFilter[] getSaveFileFilters()
This function returns the FileFilters used in save file dialogs. Default implementation returns the default save file filters

Returns:
array of FileFilters

getOpenFileChooserTitle

protected java.lang.String getOpenFileChooserTitle()
This function returns the title of the open file chooser, or null for default JFileChooser title

Returns:
the title

getApplicationTitle

protected java.lang.String getApplicationTitle()
Returns the application title

Returns:
the application title

getSaveFileChooserTitle

protected java.lang.String getSaveFileChooserTitle()
This function returns the title of the save file chooser, or null for default JFileChooser title

Returns:
the title

getMinimumWindowWidth

protected int getMinimumWindowWidth()
This function returns the minimum width of the application frame Default implementation returns 800

Returns:
the minimum width

getMinimumWindowHeight

protected int getMinimumWindowHeight()
This function returns the minimum height of the application frame Default implementation returns 600

Returns:
the minimum height

getDefaultWindowSize

protected java.awt.Dimension getDefaultWindowSize()
This function returns the default application frame size Default implementation returns null, indicating frame size will be the 80% of the screen

Returns:
the default window dimension

getBanner

public AlchemistBanner getBanner()
This function returns a banner instance for this application.

Returns:
the banner for the application or null, if no banner set

setBanner

public void setBanner(AlchemistBanner banner)
This method sets a banner for the application

Parameters:
banner - is the banner instance

show

public void show()
This method shows the application frame


hide

public void hide()
This method hides the application frame


createDisabledImage

protected void createDisabledImage()

disableContent

protected void disableContent(boolean showWaitAnim)

enableContent

protected void enableContent()

setCustomWaitAnimation

public void setCustomWaitAnimation(java.lang.String path)
This method sets a custom animation as loading animation Passing null removes custom animation

Parameters:
path - is the path to animated image file (gif)

getApplicationState

public AlchemistState getApplicationState()
This function returns the main state object of the application

Returns:
the main state object of the application

showInnerDialog

public void showInnerDialog(javax.swing.JPanel panel)
Shows a modal inner dialog

Parameters:
panel - is the JPanel object will be shown as dialog

showInnerDialog

public void showInnerDialog(AlchemistPage page)
Shows a modal inner dialog

Parameters:
page - is the AlchemistPage object will be shown as dialog

hideInnerDialog

public void hideInnerDialog()
Disposes the inner dialog previously set by showInnerDialog.

See Also:
showInnerDialog(AlchemistPage), showInnerDialog(JPanel panel)

virtualHide

protected void virtualHide()
Moves application window offscreen


virtualShow

protected void virtualShow()
Moves application center screen


setLookAndFeel

public static void setLookAndFeel()
This method tries to set the look and feel to com.jgoodies.looks.plastic.PlasticXPLookAndFeel with SkyBluer theme (falls back to system default)


setMenuResources

protected void setMenuResources(java.lang.String configPath,
                                java.lang.String bundleBaseName,
                                chemaxon.alchemist.utils.menu.AlchemistActionConfigurer configurer)
Sets the menu resources and initializes inner GUIModule instance

Parameters:
configPath - is the path to configuration xml
bundleBaseName - is the path to bundle basename
configurer - is an optional configurer

setMenuResources

protected void setMenuResources(java.lang.String configPath,
                                java.lang.String bundleBaseName)
Sets the menu resources and initializes inner GUIModule instance

Parameters:
configPath - is the path to configuration xml
bundleBaseName - is the path to bundle basename

setMenuResources

protected void setMenuResources(java.lang.String configPath)
Sets the menu resources and initializes inner GUIModule instance

Parameters:
configPath - is the path to configuration xml

setMenubar

protected void setMenubar()
Deprecated. This method is no longer need to be called. Menu will automatically added when calling setMenuResources

See Also:
setMenuResources(String), setMenuResources(String, String), setMenuResources(String, String, AlchemistActionConfigurer)

getToolbar

protected javax.swing.JToolBar getToolbar(java.lang.String toolBarID)
Returns a toolbar instance with specified id

Parameters:
toolBarID - is the toolbar id
Returns:
a JToolBar instance with specified id

setActionEnabled

protected void setActionEnabled(java.lang.String actionID,
                                boolean enabled)
Sets the action enabled status for the specific action

Parameters:
actionID - is the id of the action
enabled - is the new value

setActionsEnabled

protected void setActionsEnabled(java.lang.String[] actionIDs,
                                 boolean enabled)
Sets the action enabled status for an array of actions

Parameters:
actionIDs - is an array of action id-s
enabled - is the new value

setActionsEnabled

protected void setActionsEnabled(java.lang.String[] actionIDs,
                                 boolean[] enabled)
Sets the action enabled status for an array of actions

Parameters:
actionIDs - is an array of action id-s
enabled - is the array of new value

suspendToolbar

protected void suspendToolbar()
Suspends all actions on toolbar NOTE: can not suspend a toolbar until previous suspend not restored

See Also:
restoreToolbar()

suspendToolbar

protected void suspendToolbar(java.lang.String excludedAction)
Suspends all actions on toolbar, but the excluded action NOTE: can not suspend a toolbar until previous suspend not restored

Parameters:
excludedAction - will not be suspended
See Also:
restoreToolbar()

suspendedToolbar

protected void suspendedToolbar(java.lang.String[] excludedActions)
Suspends all actions on toolbar, but the excluded actions NOTE: can not suspend a toolbar until previous suspend not restored

Parameters:
excludedActions - will not be suspended
See Also:
restoreToolbar()

restoreToolbar

protected void restoreToolbar()
Restore action states on toolbar from previous suspend

See Also:
suspendToolbar()

isActionsEnabled

protected boolean[] isActionsEnabled(java.lang.String[] actionIDs)
Returns if the specified actions are enabled

Parameters:
actionIDs - is an array of action id-s
Returns:
boolean array with values

newDocumentActionHandler

protected void newDocumentActionHandler()
Invoked by new document action Default implementation resets document file path document format, and dirty bit


openDocumentActionHandler

protected void openDocumentActionHandler(java.lang.String path)
Invoked by open document action

Parameters:
path - is the path of file to be opened Default implementation sets the document path, and clears dirty bit

refreshDocumentHeader

protected void refreshDocumentHeader()

saveDocumentActionHandler

protected void saveDocumentActionHandler()
Invoked by save document action Default implementation clears dirty bit


saveDocumentAsActionHandler

protected void saveDocumentAsActionHandler()
Invoked by save document as action Default implementation opens save dialog, if file accepted sets path and format, and calls saveDocumentActionHandler


licenseManagerActionHandler

protected void licenseManagerActionHandler()
Default License Manager Action Handler Raises an inner dialog with license handler


exitProgramActionHandler

protected void exitProgramActionHandler()
Raises confirmation dialog and exits application if it is confirmed, and application is not in disabled state


licenseManagerClosed

protected void licenseManagerClosed()
Invoked when license manager is closed. Default implementation does nothing.


setDocumentChanged

protected void setDocumentChanged(boolean changed)
Sets the dirty bit of current document

Parameters:
changed -

isDocumentChanged

protected boolean isDocumentChanged()
Returns the dirty bit of current document

Returns:
true dirty bit is true

getDocumentPath

protected java.lang.String getDocumentPath()
Returns the path of current document, or null

Returns:
the path of current document, or null

setDocumentPath

protected void setDocumentPath(java.lang.String path)
Sets the path of current document

Parameters:
path - is the new path

getDocumentFormat

protected java.lang.String getDocumentFormat()
Returns the format of current document, or null

Returns:
the format of current document, or null

setDocumentFormat

protected void setDocumentFormat(java.lang.String format)
Sets the format of current document

Parameters:
format - is the new path

setDocumentPathInFrameTitle

protected void setDocumentPathInFrameTitle(boolean value)
Sets if document path is shown in header

Parameters:
value -

isDocumentPathInFrameTitle

protected boolean isDocumentPathInFrameTitle()
Returns if doucment path in frame title is shown

Returns:
if doucment path in frame title is shown

showError

protected void showError(java.lang.String message,
                         java.lang.Exception exception)
Shows an error message dialog

Parameters:
message - is the human readable error message
exception - is the exception