Adding the new style components to the GUI
As in previous stages actions are used to connect the new functionality to the GUI elements such as menus or the tool bar. There are three new actions and one changed action in class FrmMain
The actions are initialized in method initActions of class FrmMain and are added to FrmMain's dynamic resource.
FormatParaAction and EditNamedStyleAction
FormatParaAction and EditNamedStyleAction both create an instance of ParaStyleDialog. FormatParaAction uses the set of attributes returned by ParaStyleDialog and applies them to the currently selected paragraph(s). EditNamedStyleAction does nothing on return of ParastyleDialog, the dialog does all the work for manipulation of named styles.
SetStyleAction
SetStyleAction takes the class attribute returned by the StyleSelector component in the tool bar and applies it to the currently selected paragraph(s).
ToggleAction
ToggleAction applies the attribute returned by its getValue method to the current selection. Depending on the attribute key the action object represents attriubtes are applied to either on paragraph or character level. The action then sets a state indicator to allow a bound component such as a JToggleButton to reflect the state accordingly (selected or unselected).
New components
Besides the new StyleSelector component, in method createToolBar of class FrmMain, additional toggle buttons are created to toggle between different paragrpah alignments (left, center, right). A new tool bar button for setting a paragraph style is added too. In menu 'Format', new menu items are created for setting paragraph style, style sheet manipulation and paragraph alignment.
All new components are added by including their associated action names in the properties file of SimplyHTML as described in stage 2 and especially 'Adding an edit menu' as well as ' Dynamic resources' from stage 5.