com.lightdev.app.shtm
Class FrmMain

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by com.lightdev.app.shtm.FrmMain
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CaretListener, javax.swing.event.ChangeListener, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class FrmMain
extends javax.swing.JFrame
implements javax.swing.event.CaretListener, javax.swing.event.ChangeListener

Main window of application SimplyHTML.

This class constructs the main window and all of its GUI elements such as menus, etc.

It defines a set of inner classes creating actions which can be connected to menus, buttons or instantiated individually.

See Also:
Serialized Form

Nested Class Summary
 class FrmMain.AppendTableColAction
          append a new table col
 class FrmMain.AppendTableRowAction
          append a new table row
 class FrmMain.BoldAction
           
 class FrmMain.DeleteTableColAction
          delete a table col
 class FrmMain.DeleteTableRowAction
          delete a table row
 class FrmMain.DocumentTitleAction
          set the title of the currently active document
 class FrmMain.EditAnchorsAction
          action to edit anchors inside a document
 class FrmMain.EditLinkAction
          action to edit a link
 class FrmMain.EditNamedStyleAction
          action to change the paragraph style
 class FrmMain.FindReplaceAction
          action to find and replace a given text
 class FrmMain.FontAction
          Show a dialog to format fonts
 class FrmMain.FontFamilyAction
          change a font family setting
 class FrmMain.FontFamilyPicker
          a JComboBox for selecting a font family names from those available in the system.
 class FrmMain.FontSizeAction
          change a font size setting
 class FrmMain.FontSizePicker
          a JComboBox for selecting a font size
 class FrmMain.FormatImageAction
           
 class FrmMain.FormatListAction
          Change list formatting
 class FrmMain.FormatParaAction
          action to change the paragraph style
 class FrmMain.FormatTableAction
          format table attributes
 class FrmMain.GCAction
          force a garbage collection.
 class FrmMain.InsertImageAction
           
 class FrmMain.InsertTableAction
          insert a new table
 class FrmMain.InsertTableColAction
          insert a new table column
 class FrmMain.InsertTableRowAction
          insert a new table row
 class FrmMain.ItalicAction
           
 class FrmMain.NextTableCellAction
          action to move to the next cell in a table
 class FrmMain.PrevTableCellAction
          action to move to the previous cell in a table
 class FrmMain.RedoAction
          RedoAction for the edit menu
 class FrmMain.RepeatKeyWatcher
          watch for key events that are automatically repeated due to the user holding down a key.
 class FrmMain.SetDefaultStyleRefAction
          action to set a reference to the default style sheet (for being able to use an already existing style sheet without having to define named styles)
 class FrmMain.SetStyleAction
          action to set the style
 class FrmMain.SetTagAction
          action to set the tag type
 class FrmMain.ShowElementTreeAction
          Action that brings up a JFrame with a JTree showing the structure of the document in the currently active DocumentPane.
 class FrmMain.SHTMLEditCopyAction
          just adds a normal name to the superclasse's action
 class FrmMain.SHTMLEditCutAction
          just adds a normal name to the superclasse's action
 class FrmMain.SHTMLEditPasteAction
          just adds a normal name to the superclasse's action
 class FrmMain.SHTMLEditPrefsAction
           
 class FrmMain.SHTMLEditSelectAllAction
           
 class FrmMain.SHTMLFileCloseAction
          close a document.
 class FrmMain.SHTMLFileCloseAllAction
          close all documents currently shown.
 class FrmMain.SHTMLFileExitAction
          exit the application.
 class FrmMain.SHTMLFileNewAction
          create a new empty document and show it
 class FrmMain.SHTMLFileOpenAction
          open an existing document from file and show it
 class FrmMain.SHTMLFileSaveAction
          save a document
 class FrmMain.SHTMLFileSaveAllAction
           
 class FrmMain.SHTMLFileSaveAsAction
          save a document under a different name and/or location
 class FrmMain.SHTMLFileTestAction
          a slot for testing certain things conveniently during development
 class FrmMain.SHTMLHelpAppInfoAction
          show information about SimplyHTML in a dialog
 class FrmMain.ToggleAction
          action to toggle an attribute
 class FrmMain.ToggleListAction
          toggle list formatting for a given type of list on/off
 class FrmMain.UnderlineAction
           
 class FrmMain.UndoAction
          UndoAction for the edit menu
 class FrmMain.UndoHandler
          inner class for handling undoable edit events
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String ACTION_SELECTED
           
static java.lang.String ACTION_SELECTED_KEY
           
static java.lang.String ACTION_UNSELECTED
           
static java.lang.String APP_HELP_NAME
           
static java.lang.String APP_NAME
           
static java.lang.String APP_TEMP_DIR
           
static java.lang.String closeAction
           
static java.lang.String closeAllAction
           
static java.lang.String documentTitleAction
           
static DynamicResource dynRes
          single instance of a dynamic resource for use by all
 java.lang.String editPrefsAction
           
static java.lang.String FILE_LAST_OPEN
           
static java.lang.String FILE_LAST_SAVE
           
static java.lang.String findReplaceAction
           
 java.lang.String helpMenuId
          help menu ID
 java.lang.String helpTopicsAction
           
static java.lang.String IMAGE_DIR
           
static java.lang.String JAVA_HELP_EXT
           
static java.awt.Frame mainFrame
          static reference to this instance of class FrmMain
static java.lang.String newAction
          action names these have to correspond with the keys in the resource bundle to allow for dynamic menu creation and control
static java.lang.String nextTableCellAction
           
static java.lang.String openAction
           
static PluginManager pluginManager
          the plug-in manager of SimplyHTML
 java.lang.String pluginMenuId
          plugin menu ID
static java.lang.String prevTableCellAction
           
static java.util.ResourceBundle resources
          SimplyHTML's main resource bundle (plug-ins use their own)
static java.lang.String saveAllAction
           
static java.lang.String saveAsAction
           
static java.lang.String setDefaultStyleRefAction
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FrmMain()
          construct a new main application frame
 
Method Summary
 void addDocumentPaneListener(DocumentPane.DocumentPaneListener listener)
          add a DocumentPaneListener from the currently active DocumentPane (if any)
 void adjustDividers()
          adjust the divider sizes of SimplyHTML's SplitPanel according to visibility
 void caretUpdate(javax.swing.event.CaretEvent e)
          caret listener implementation to track format changes
 void clearDockPanels()
           
 javax.swing.JToolBar createToolBar(java.lang.String nm)
          Create a tool bar.
 void doSave(DocumentPane dp)
          save a document and catch possible errors this is shared by save and saveAs so we put it here to avoid redundancy
static void getActionProperties(javax.swing.Action action, java.lang.String cmd)
          get action properties from the associated resource bundle
 int getActiveTabNo()
           
static java.io.File getAppTempDir()
          get the temporary directory of SimplyHTML
 java.lang.String getCurrentDocName()
          get the name of the file for the document shown in the currently open DocumentPane
 DocumentPane getCurrentDocumentPane()
          get the DocumentPane object that is currently active
 java.io.File getCurrentFile()
          get the file object for the document shown in the currently open DocumentPane
 DynamicResource getDynRes()
          get the DynamicResource used in this instance of FrmMain
 SHTMLEditorPane getEditor()
           
static javax.help.HelpBroker getHelpBroker()
          get the HelpBroker of our application
static javax.swing.text.AttributeSet getMaxAttributes(javax.swing.text.Element e, javax.swing.text.html.StyleSheet s)
           
 javax.swing.text.AttributeSet getMaxAttributes(SHTMLEditorPane editor, java.lang.String elemName)
          Get all attributes that can be found in the element tree starting at the highest parent down to the character element at the current position in the document.
 java.util.ResourceBundle getResources()
          get the resource bundle of this instance of FrmMain
 void initPlugins()
          find plug-ins and load them accordingly, i.e.
protected  void processWindowEvent(java.awt.event.WindowEvent e)
          catch requests to close the application's main frame to ensure proper clean up before the application is actually terminated.
 void refreshPluginDisplay(SHTMLPlugin pi)
          refresh the display for a given plug-in
 void registerDocument()
          register FrmMain as an object which has interest in events from a given document pane
 void removeDocumentPaneListener(DocumentPane.DocumentPaneListener listener)
          remove a DocumentPaneListener from the currently active DocumentPane (if any)
 void stateChanged(javax.swing.event.ChangeEvent e)
          change listener to be applied to our tabbed pane so that always the currently active components are known
 void unregisterDocument()
          remove FrmMain as a registered object from a given document pane and its components remove all plug-ins owned by this FrmMain from SimplyHTML objects too
 void updateActions()
          update all actions
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, 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, paint, 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, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, 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, isOpaque, 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, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

APP_NAME

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

APP_HELP_NAME

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

APP_TEMP_DIR

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

IMAGE_DIR

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

JAVA_HELP_EXT

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

ACTION_SELECTED_KEY

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

ACTION_SELECTED

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

ACTION_UNSELECTED

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

FILE_LAST_OPEN

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

FILE_LAST_SAVE

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

mainFrame

public static java.awt.Frame mainFrame
static reference to this instance of class FrmMain


dynRes

public static DynamicResource dynRes
single instance of a dynamic resource for use by all


resources

public static java.util.ResourceBundle resources
SimplyHTML's main resource bundle (plug-ins use their own)


pluginManager

public static PluginManager pluginManager
the plug-in manager of SimplyHTML


pluginMenuId

public final java.lang.String pluginMenuId
plugin menu ID

See Also:
Constant Field Values

helpMenuId

public final java.lang.String helpMenuId
help menu ID

See Also:
Constant Field Values

newAction

public static final java.lang.String newAction
action names these have to correspond with the keys in the resource bundle to allow for dynamic menu creation and control

See Also:
Constant Field Values

openAction

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

closeAction

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

closeAllAction

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

saveAsAction

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

helpTopicsAction

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

nextTableCellAction

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

prevTableCellAction

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

editPrefsAction

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

saveAllAction

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

documentTitleAction

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

setDefaultStyleRefAction

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

findReplaceAction

public static final java.lang.String findReplaceAction
See Also:
Constant Field Values
Constructor Detail

FrmMain

public FrmMain()
construct a new main application frame

Method Detail

getDynRes

public DynamicResource getDynRes()
get the DynamicResource used in this instance of FrmMain

Returns:
the DynamicResource

getResources

public java.util.ResourceBundle getResources()
get the resource bundle of this instance of FrmMain

Returns:
the bundle of resources

getAppTempDir

public static java.io.File getAppTempDir()
get the temporary directory of SimplyHTML

Returns:
the temp dir

getCurrentFile

public java.io.File getCurrentFile()
get the file object for the document shown in the currently open DocumentPane

Returns:
the document file

getCurrentDocName

public java.lang.String getCurrentDocName()
get the name of the file for the document shown in the currently open DocumentPane

Returns:
the document name

getEditor

public SHTMLEditorPane getEditor()

getCurrentDocumentPane

public DocumentPane getCurrentDocumentPane()
get the DocumentPane object that is currently active

Returns:
the active DocumentPane

addDocumentPaneListener

public void addDocumentPaneListener(DocumentPane.DocumentPaneListener listener)
add a DocumentPaneListener from the currently active DocumentPane (if any)


removeDocumentPaneListener

public void removeDocumentPaneListener(DocumentPane.DocumentPaneListener listener)
remove a DocumentPaneListener from the currently active DocumentPane (if any)


initPlugins

public void initPlugins()
find plug-ins and load them accordingly, i.e. display / dock components and add plug-in menus.


adjustDividers

public void adjustDividers()
adjust the divider sizes of SimplyHTML's SplitPanel according to visibility


clearDockPanels

public void clearDockPanels()

refreshPluginDisplay

public void refreshPluginDisplay(SHTMLPlugin pi)
refresh the display for a given plug-in

Parameters:
pi - the plug-in to refresh

getHelpBroker

public static javax.help.HelpBroker getHelpBroker()
get the HelpBroker of our application

Returns:
the HelpBroker to be used for help display

updateActions

public void updateActions()
update all actions


processWindowEvent

protected void processWindowEvent(java.awt.event.WindowEvent e)
catch requests to close the application's main frame to ensure proper clean up before the application is actually terminated.

Overrides:
processWindowEvent in class javax.swing.JFrame

createToolBar

public javax.swing.JToolBar createToolBar(java.lang.String nm)
Create a tool bar. This reads the definition of a tool bar from the associated resource file.

Parameters:
nm - the name of the tool bar definition in the resource file
Returns:
the created tool bar

registerDocument

public void registerDocument()
register FrmMain as an object which has interest in events from a given document pane


unregisterDocument

public void unregisterDocument()
remove FrmMain as a registered object from a given document pane and its components remove all plug-ins owned by this FrmMain from SimplyHTML objects too


doSave

public void doSave(DocumentPane dp)
save a document and catch possible errors this is shared by save and saveAs so we put it here to avoid redundancy

Parameters:
dp - the document pane containing the document to save

getActionProperties

public static void getActionProperties(javax.swing.Action action,
                                       java.lang.String cmd)
get action properties from the associated resource bundle

Parameters:
action - the action to apply properties to
cmd - the name of the action to get properties for

getActiveTabNo

public int getActiveTabNo()

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
change listener to be applied to our tabbed pane so that always the currently active components are known

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

caretUpdate

public void caretUpdate(javax.swing.event.CaretEvent e)
caret listener implementation to track format changes

Specified by:
caretUpdate in interface javax.swing.event.CaretListener

getMaxAttributes

public javax.swing.text.AttributeSet getMaxAttributes(SHTMLEditorPane editor,
                                                      java.lang.String elemName)
Get all attributes that can be found in the element tree starting at the highest parent down to the character element at the current position in the document. Combine element attributes with attributes from the style sheet.

Parameters:
editor - the editor pane to combine attributes from
Returns:
the resulting set of combined attributes

getMaxAttributes

public static javax.swing.text.AttributeSet getMaxAttributes(javax.swing.text.Element e,
                                                             javax.swing.text.html.StyleSheet s)