Making the GUI available to the user

As functionality and GUI for manipulation of image references as described in previous chapters is present, a way to use it is needed in addition.

Actions InsertImage and FormatImage

Similar to the procedure used in previous stages, two actions are added to class FrmMain as inner classes. The new actions are added to the DynamicResource instance of class FrmMain with method initActions (see the documentation of stage 2 and stage 5 for a detailed description of actions and dynamic resources).

Actions InsertImageAction and FormatImageAction both create an instance of class ImageDialog. FormatImageAction shows the dialog reflecting settings for an image currently selected in the editor to allow for attribute adjustments or to change the image file. InsertImageAction brings up the dialog to select a file from the image repository and adjust attributes.

How image settings are applied

When a selection is made in class ImageDialog InsertImageAction applies the settings with the help of method insertBeforeStart of class HTMLDocument. The chosen image from class ImageDialog is taken as HTML code got from method getImageHTML and passed to method insertBeforeStart.

When an existing image reference is changed with FormatImageAction, method getImageHTML is used to get the image settings as HTML code again. The HTML code is passed to method setOuterHTML of class HTMLDocument in this case, replacing the changed image reference.