Package adams.gui.scripting
Class AbstractScriptingDialog
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Dialog
-
- javax.swing.JDialog
-
- adams.gui.core.BaseDialog
-
- adams.gui.scripting.AbstractScriptingDialog
-
- All Implemented Interfaces:
CleanUpHandler
,StatusMessageHandler
,DatabaseConnectionHandler
,DatabaseConnectionProvider
,DatabaseConnectionUser
,ScriptingInfoListener
,ScriptingEngineHandler
,ImageObserver
,MenuContainer
,Serializable
,Accessible
,RootPaneContainer
,WindowConstants
- Direct Known Subclasses:
ScriptingDialog
public abstract class AbstractScriptingDialog extends BaseDialog implements ScriptingEngineHandler, ScriptingInfoListener, StatusMessageHandler, DatabaseConnectionHandler, CleanUpHandler
A dialog for loading/saving and executing scripts.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
-
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
-
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static String
FILENAME
the name of the props file.protected BasePanel
m_BasePanel
the base panel this dialog should operate on.protected File
m_CurrentFile
the currently loaded file.protected AbstractDatabaseConnection
m_DatabaseConnection
the database connection to use.protected BaseFileChooser
m_FileChooser
for loading/saving the scripts.protected FilenameProposer
m_FilenameProposer
for proposing filenames for new flows.protected JMenuBar
m_Menu
the menu.protected JMenuItem
m_MenuItemEditAppendRecorded
the append recorded menu item.protected JMenuItem
m_MenuItemEditClear
the clear menu item.protected JMenuItem
m_MenuItemEditRedo
the redo menu item.protected JMenuItem
m_MenuItemEditUndo
the undo menu item.protected JMenuItem
m_MenuItemFileClose
the close menu item.protected JMenuItem
m_MenuItemFileLoad
the load menu item.protected JMenu
m_MenuItemFileLoadRecent
the load recent submenu.protected JMenuItem
m_MenuItemFileNew
the new menu item.protected JMenuItem
m_MenuItemFilePrint
the print menu item.protected JMenuItem
m_MenuItemFileSave
the save menu item.protected JMenuItem
m_MenuItemFileSaveAs
the save as menu item.protected JMenuItem
m_MenuItemHelp
the help menu item.protected JMenuItem
m_MenuItemScriptStart
the execute menu item.protected JMenuItem
m_MenuItemScriptStop
the stop menu item.protected JMenuItem
m_MenuItemViewWordWrap
the line wrap menu item.protected boolean
m_Modified
whether the current content was modified.protected Properties
m_Properties
the properties for scripting.protected RecentFilesHandler<JMenu>
m_RecentFilesHandler
the recent files handler.protected AbstractScriptingDialog
m_Self
the dialog itself.protected BaseStatusBar
m_StatusBar
the status.protected ScriptingTextEditorPanel
m_TextScript
the text panel with the loaded script.protected TitleGenerator
m_TitleGenerator
for generating the title.protected UndoManager
m_Undo
the undo manager for the text pane.static String
SESSION_FILE
the file to store the recent files in.-
Fields inherited from class adams.gui.core.BaseDialog
m_AfterHideActions, m_AfterShowActions, m_BeforeHideActions, m_BeforeShowActions, m_DisposeCalled, m_UISettingsApplied, m_UISettingsPrefix, m_UISettingsStored
-
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
-
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
-
Constructor Summary
Constructors Constructor Description AbstractScriptingDialog(Dialog owner, BasePanel panel)
Creates a non-modal dialog.AbstractScriptingDialog(Frame owner, BasePanel panel)
Creates a non-modal dialog.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
appendRecorded()
appends the recorded commands.protected boolean
checkForModified()
Returns whether we can proceed with the operation or not, depending on whether the user saved the script or discarded the changes.void
cleanUp()
Cleans up data structures, frees up memory.protected void
clear()
clears the input.protected void
close()
Closes the dialog.BasePanel
getBasePanel()
Returns the underlying base panel.AbstractDatabaseConnection
getDatabaseConnection()
Returns the currently used database connection object, can be null.protected abstract AbstractDatabaseConnection
getDefaultDatabaseConnection()
Returns the default database connection.abstract AbstractScriptingEngine
getScriptingEngine()
Returns the current scripting engine, can be null.protected String
getSessionFile()
Returns the name of the session file to use.TitleGenerator
getTitleGenerator()
Returns the title generator in use.boolean
getWordWrap()
Returns the wordwrap status.protected void
help()
Displays a help dialog.protected void
initGUI()
Initializes the GUI.protected void
initialize()
initializes member variables.protected void
load()
loads a script from a file.protected boolean
load(File file, boolean errorDlg)
Loads the specified file from disk, optionally shows an error dialog if an error is encountered.protected void
newScript()
Starts a new script.protected void
save()
saves the current script to a file.protected boolean
save(File file, boolean errorDlg)
Saves the current content to the specified file.protected void
saveAs()
saves the current script to a file.void
scriptingInfo(ScriptingInfoEvent e)
The scripting engine fired an event.void
setDatabaseConnection(AbstractDatabaseConnection value)
Sets the database connection object to use.protected void
setWordWrap(boolean wrap)
toggles the wordwrap.void
showStatus(String msg)
Displays a message.protected void
startExecution()
executes the currently loaded script.protected void
stopExecution()
stops the currently running script.protected void
updateMenu()
updates the state of the menu.protected void
updateTitle()
Updates the title of the dialog.-
Methods inherited from class adams.gui.core.BaseDialog
addAfterHideAction, addAfterShowAction, addBeforeHideAction, addBeforeShowAction, afterHide, afterShow, applyUISettings, beforeHide, beforeShow, dispose, executeAfterHideActions, executeAfterShowActions, executeBeforeHideActions, executeBeforeShowActions, finishInit, getUISettingsApplied, getUISettingsPrefix, pack, removeAfterHideAction, removeAfterShowAction, removeBeforeHideAction, removeBeforeShowAction, setLocationRelativeTo, setUISettingsPrefix, setUISettingsPrefix, setVisible, storeUISettings
-
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
-
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBack
-
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
FILENAME
public static final String FILENAME
the name of the props file.- See Also:
- Constant Field Values
-
SESSION_FILE
public static final String SESSION_FILE
the file to store the recent files in.- See Also:
- Constant Field Values
-
m_Self
protected AbstractScriptingDialog m_Self
the dialog itself.
-
m_TitleGenerator
protected TitleGenerator m_TitleGenerator
for generating the title.
-
m_FileChooser
protected BaseFileChooser m_FileChooser
for loading/saving the scripts.
-
m_Menu
protected JMenuBar m_Menu
the menu.
-
m_MenuItemFileNew
protected JMenuItem m_MenuItemFileNew
the new menu item.
-
m_MenuItemFileLoad
protected JMenuItem m_MenuItemFileLoad
the load menu item.
-
m_MenuItemFileLoadRecent
protected JMenu m_MenuItemFileLoadRecent
the load recent submenu.
-
m_MenuItemFileSave
protected JMenuItem m_MenuItemFileSave
the save menu item.
-
m_MenuItemFileSaveAs
protected JMenuItem m_MenuItemFileSaveAs
the save as menu item.
-
m_MenuItemFilePrint
protected JMenuItem m_MenuItemFilePrint
the print menu item.
-
m_MenuItemFileClose
protected JMenuItem m_MenuItemFileClose
the close menu item.
-
m_MenuItemEditUndo
protected JMenuItem m_MenuItemEditUndo
the undo menu item.
-
m_MenuItemEditRedo
protected JMenuItem m_MenuItemEditRedo
the redo menu item.
-
m_MenuItemEditClear
protected JMenuItem m_MenuItemEditClear
the clear menu item.
-
m_MenuItemEditAppendRecorded
protected JMenuItem m_MenuItemEditAppendRecorded
the append recorded menu item.
-
m_MenuItemScriptStart
protected JMenuItem m_MenuItemScriptStart
the execute menu item.
-
m_MenuItemScriptStop
protected JMenuItem m_MenuItemScriptStop
the stop menu item.
-
m_MenuItemViewWordWrap
protected JMenuItem m_MenuItemViewWordWrap
the line wrap menu item.
-
m_MenuItemHelp
protected JMenuItem m_MenuItemHelp
the help menu item.
-
m_TextScript
protected ScriptingTextEditorPanel m_TextScript
the text panel with the loaded script.
-
m_StatusBar
protected BaseStatusBar m_StatusBar
the status.
-
m_CurrentFile
protected File m_CurrentFile
the currently loaded file.
-
m_Modified
protected boolean m_Modified
whether the current content was modified.
-
m_Properties
protected Properties m_Properties
the properties for scripting.
-
m_Undo
protected UndoManager m_Undo
the undo manager for the text pane.
-
m_RecentFilesHandler
protected RecentFilesHandler<JMenu> m_RecentFilesHandler
the recent files handler.
-
m_BasePanel
protected BasePanel m_BasePanel
the base panel this dialog should operate on.
-
m_FilenameProposer
protected FilenameProposer m_FilenameProposer
for proposing filenames for new flows.
-
m_DatabaseConnection
protected AbstractDatabaseConnection m_DatabaseConnection
the database connection to use.
-
-
Method Detail
-
initialize
protected void initialize()
initializes member variables.- Overrides:
initialize
in classBaseDialog
-
getDefaultDatabaseConnection
protected abstract AbstractDatabaseConnection getDefaultDatabaseConnection()
Returns the default database connection.- Returns:
- the database connection
-
initGUI
protected void initGUI()
Initializes the GUI.- Overrides:
initGUI
in classBaseDialog
-
getBasePanel
public BasePanel getBasePanel()
Returns the underlying base panel.- Returns:
- the panel
-
setWordWrap
protected void setWordWrap(boolean wrap)
toggles the wordwrap.- Parameters:
wrap
- whether to wrap or not
-
getWordWrap
public boolean getWordWrap()
Returns the wordwrap status.- Returns:
- true if wordwrap is on
-
checkForModified
protected boolean checkForModified()
Returns whether we can proceed with the operation or not, depending on whether the user saved the script or discarded the changes.- Returns:
- true if safe to proceed
-
newScript
protected void newScript()
Starts a new script.
-
load
protected void load()
loads a script from a file.
-
load
protected boolean load(File file, boolean errorDlg)
Loads the specified file from disk, optionally shows an error dialog if an error is encountered. If successful the current filename is set to the one given here.- Parameters:
file
- the file to loaderrorDlg
- if true and an error is encountered an error dialog is displayed- Returns:
- true if successfully loaded.
- See Also:
m_CurrentFile
-
save
protected void save()
saves the current script to a file.
-
saveAs
protected void saveAs()
saves the current script to a file.
-
save
protected boolean save(File file, boolean errorDlg)
Saves the current content to the specified file. Sets the current file to the one given here.- Parameters:
file
- the file to save the content toerrorDlg
- if true shows an error dialog in case of an error- Returns:
- true if saving was successful
- See Also:
m_CurrentFile
-
close
protected void close()
Closes the dialog.
-
help
protected void help()
Displays a help dialog.
-
startExecution
protected void startExecution()
executes the currently loaded script.
-
stopExecution
protected void stopExecution()
stops the currently running script.
-
appendRecorded
protected void appendRecorded()
appends the recorded commands.
-
clear
protected void clear()
clears the input.
-
updateMenu
protected void updateMenu()
updates the state of the menu.
-
getTitleGenerator
public TitleGenerator getTitleGenerator()
Returns the title generator in use.- Returns:
- the generator
-
updateTitle
protected void updateTitle()
Updates the title of the dialog.
-
getScriptingEngine
public abstract AbstractScriptingEngine getScriptingEngine()
Returns the current scripting engine, can be null.- Specified by:
getScriptingEngine
in interfaceScriptingEngineHandler
- Returns:
- the current engine
-
getSessionFile
protected String getSessionFile()
Returns the name of the session file to use.- Returns:
- the filename (no path)
-
scriptingInfo
public void scriptingInfo(ScriptingInfoEvent e)
The scripting engine fired an event.- Specified by:
scriptingInfo
in interfaceScriptingInfoListener
- Parameters:
e
- the event
-
showStatus
public void showStatus(String msg)
Displays a message.- Specified by:
showStatus
in interfaceStatusMessageHandler
- Parameters:
msg
- the message to display
-
getDatabaseConnection
public AbstractDatabaseConnection getDatabaseConnection()
Returns the currently used database connection object, can be null.- Specified by:
getDatabaseConnection
in interfaceDatabaseConnectionProvider
- Returns:
- the current object
-
setDatabaseConnection
public void setDatabaseConnection(AbstractDatabaseConnection value)
Sets the database connection object to use.- Specified by:
setDatabaseConnection
in interfaceDatabaseConnectionHandler
- Parameters:
value
- the object to use
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-