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 StringFILENAMEthe name of the props file.protected BasePanelm_BasePanelthe base panel this dialog should operate on.protected Filem_CurrentFilethe currently loaded file.protected AbstractDatabaseConnectionm_DatabaseConnectionthe database connection to use.protected BaseFileChooserm_FileChooserfor loading/saving the scripts.protected FilenameProposerm_FilenameProposerfor proposing filenames for new flows.protected JMenuBarm_Menuthe menu.protected JMenuItemm_MenuItemEditAppendRecordedthe append recorded menu item.protected JMenuItemm_MenuItemEditClearthe clear menu item.protected JMenuItemm_MenuItemEditRedothe redo menu item.protected JMenuItemm_MenuItemEditUndothe undo menu item.protected JMenuItemm_MenuItemFileClosethe close menu item.protected JMenuItemm_MenuItemFileLoadthe load menu item.protected JMenum_MenuItemFileLoadRecentthe load recent submenu.protected JMenuItemm_MenuItemFileNewthe new menu item.protected JMenuItemm_MenuItemFilePrintthe print menu item.protected JMenuItemm_MenuItemFileSavethe save menu item.protected JMenuItemm_MenuItemFileSaveAsthe save as menu item.protected JMenuItemm_MenuItemHelpthe help menu item.protected JMenuItemm_MenuItemScriptStartthe execute menu item.protected JMenuItemm_MenuItemScriptStopthe stop menu item.protected JMenuItemm_MenuItemViewWordWrapthe line wrap menu item.protected booleanm_Modifiedwhether the current content was modified.protected Propertiesm_Propertiesthe properties for scripting.protected RecentFilesHandler<JMenu>m_RecentFilesHandlerthe recent files handler.protected AbstractScriptingDialogm_Selfthe dialog itself.protected BaseStatusBarm_StatusBarthe status.protected ScriptingTextEditorPanelm_TextScriptthe text panel with the loaded script.protected TitleGeneratorm_TitleGeneratorfor generating the title.protected UndoManagerm_Undothe undo manager for the text pane.static StringSESSION_FILEthe 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_LocationBeforeMaximize, m_SizeBeforeMaximize, 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 voidappendRecorded()appends the recorded commands.protected booleancheckForModified()Returns whether we can proceed with the operation or not, depending on whether the user saved the script or discarded the changes.voidcleanUp()Cleans up data structures, frees up memory.protected voidclear()clears the input.protected voidclose()Closes the dialog.BasePanelgetBasePanel()Returns the underlying base panel.AbstractDatabaseConnectiongetDatabaseConnection()Returns the currently used database connection object, can be null.protected abstract AbstractDatabaseConnectiongetDefaultDatabaseConnection()Returns the default database connection.abstract AbstractScriptingEnginegetScriptingEngine()Returns the current scripting engine, can be null.protected StringgetSessionFile()Returns the name of the session file to use.TitleGeneratorgetTitleGenerator()Returns the title generator in use.booleangetWordWrap()Returns the wordwrap status.protected voidhelp()Displays a help dialog.protected voidinitGUI()Initializes the GUI.protected voidinitialize()initializes member variables.protected voidload()loads a script from a file.protected booleanload(File file, boolean errorDlg)Loads the specified file from disk, optionally shows an error dialog if an error is encountered.protected voidnewScript()Starts a new script.protected voidsave()saves the current script to a file.protected booleansave(File file, boolean errorDlg)Saves the current content to the specified file.protected voidsaveAs()saves the current script to a file.voidscriptingInfo(ScriptingInfoEvent e)The scripting engine fired an event.voidsetDatabaseConnection(AbstractDatabaseConnection value)Sets the database connection object to use.protected voidsetWordWrap(boolean wrap)toggles the wordwrap.voidshowStatus(String msg)Displays a message.protected voidstartExecution()executes the currently loaded script.protected voidstopExecution()stops the currently running script.protected voidupdateMenu()updates the state of the menu.protected voidupdateTitle()Updates the title of the dialog.-
Methods inherited from class adams.gui.core.BaseDialog
addAfterHideAction, addAfterShowAction, addBeforeHideAction, addBeforeShowAction, afterHide, afterShow, applyUISettings, beforeHide, beforeShow, canMaximize, canMinimize, dispose, executeAfterHideActions, executeAfterShowActions, executeBeforeHideActions, executeBeforeShowActions, finishInit, getUISettingsApplied, getUISettingsPrefix, maximize, minimize, 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:
initializein classBaseDialog
-
getDefaultDatabaseConnection
protected abstract AbstractDatabaseConnection getDefaultDatabaseConnection()
Returns the default database connection.- Returns:
- the database connection
-
initGUI
protected void initGUI()
Initializes the GUI.- Overrides:
initGUIin 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:
getScriptingEnginein 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:
scriptingInfoin interfaceScriptingInfoListener- Parameters:
e- the event
-
showStatus
public void showStatus(String msg)
Displays a message.- Specified by:
showStatusin interfaceStatusMessageHandler- Parameters:
msg- the message to display
-
getDatabaseConnection
public AbstractDatabaseConnection getDatabaseConnection()
Returns the currently used database connection object, can be null.- Specified by:
getDatabaseConnectionin interfaceDatabaseConnectionProvider- Returns:
- the current object
-
setDatabaseConnection
public void setDatabaseConnection(AbstractDatabaseConnection value)
Sets the database connection object to use.- Specified by:
setDatabaseConnectionin interfaceDatabaseConnectionHandler- Parameters:
value- the object to use
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
-