Class XalWindow

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants, XalDocumentListener, XalDocumentView
Direct Known Subclasses:
AcceleratorWindow, DefaultXalWindow

public abstract class XalWindow extends JFrame implements XalDocumentView, XalDocumentListener
The base class for custom windows that are the main windows for documents. Subclasses need to define their custom views.
Author:
t6p
See Also:
  • Field Details

  • Constructor Details

    • XalWindow

      protected XalWindow(XalDocument aDocument)
      Creates a new instance of WindowAdaptor
    • XalWindow

      protected XalWindow(XalDocument aDocument, boolean displayToolbar)
  • Method Details

    • registerEvents

      public void registerEvents()
      Register the event handlers
    • makeFrame

      public void makeFrame()
      Make the frame and populate the menubar and toolbar.
    • makeCommander

      public Commander makeCommander()
      Subclasses should override this method to provide a custom Commander.
    • getToolBar

      public JToolBar getToolBar()
      Get the toolbar associated with this window.
      Specified by:
      getToolBar in interface XalDocumentView
      Returns:
      This window's toolbar or null if none was added.
    • customizeCommands

      public void customizeCommands(Commander commander)
      Override this method to register custom commands.
    • closeWindow

      public void closeWindow()
      Close this window. Check to see if the document has unsaved changes and if so warn the user and allow them to cancel the close operation.
    • captureAsImage

      public void captureAsImage()
      Capture the window content as a PNG. Present the user with a save dialog box so the image can be saved to a file.
      Specified by:
      captureAsImage in interface XalDocumentView
    • newWindowHandler

      public WindowListener newWindowHandler()
      Create a new window listener.
    • showWindow

      public void showWindow()
      Show this window. Make it visible (de-iconify if necessary) and bring it to the front.
      Specified by:
      showWindow in interface XalDocumentView
    • hideWindow

      public void hideWindow()
      Iconify this window.
      Specified by:
      hideWindow in interface XalDocumentView
    • userPermitsCloseWithUnsavedChanges

      public boolean userPermitsCloseWithUnsavedChanges()
      Query the user to see if it is okay to close the document given that unsaved changes exist.
      Returns:
      If the user allows the document to be closed.
    • releaseWindow

      public final void releaseWindow()
      Dispose of this window and remove its association with the document.
    • freeCustomResources

      public void freeCustomResources()
      Dispose of custom window resources. Subclasses should override this method to provide custom disposal of resources. The default implementation does nothing.
    • generateWindowTitle

      public void generateWindowTitle()
      Generate the title on the title bar to reflect the document state. The title displays the application name, the document title if any and an asterisk if the document has unsaved changes.
    • titleChanged

      public final void titleChanged(XalDocument document, String documentTitle)
      Implement XalDocumentListener and handle the event where the title has changed. Update the title on the title bar to reflect the new document title.
      Specified by:
      titleChanged in interface XalDocumentListener
      Parameters:
      document - The document initiating the title changed event.
      documentTitle - The new document title.
    • hasChangesChanged

      public void hasChangesChanged(XalDocument document, boolean newHasChangesStatus)
      Implement XalDocumentListener. Update the title on the title bar to reflect whether the document has changes that need saving.
      Specified by:
      hasChangesChanged in interface XalDocumentListener
      Parameters:
      document - The document initiating the event.
      newHasChangesStatus - The new status identifying whether the document has changes to be saved
      See Also:
    • documentWillClose

      public void documentWillClose(XalDocument document)
      Implement XalDocumentListener. Event indicating that the document will close. Closes the window in response.
      Specified by:
      documentWillClose in interface XalDocumentListener
      Parameters:
      document - The document that will close.
    • documentHasClosed

      public void documentHasClosed(XalDocument document)
      Implement XalDocumentListener. Does nothing.
      Specified by:
      documentHasClosed in interface XalDocumentListener
      Parameters:
      document - The document that has closed.
    • usesToolbar

      public boolean usesToolbar()
      Subclasses may override this method to not create the toolbar.
    • displayConfirmDialog

      public int displayConfirmDialog(String title, String message)
      Display a confirmation dialog with a title and message
      Specified by:
      displayConfirmDialog in interface XalDocumentView
      Parameters:
      title - The title of the dialog
      message - The message to display
      Returns:
      YES_OPTION or NO_OPTION
    • displayWarning

      public void displayWarning(String aTitle, String message)
      Display a warning dialog box and provide an audible alert.
      Specified by:
      displayWarning in interface XalDocumentView
      Parameters:
      aTitle - Title of the warning dialog box.
      message - The warning message to appear in the warning dialog box.
    • displayWarning

      public void displayWarning(Exception exception)
      Display a warning dialog box showing information about an exception that has been thrown and provide an audible alert.
      Specified by:
      displayWarning in interface XalDocumentView
      Parameters:
      exception - The exception whose description is being displayed.
    • displayWarning

      public void displayWarning(String aTitle, String prefix, Exception exception)
      Display a warning dialog box with information about the exception and provide an audible alert. This method allows clarification about the consequences of the exception (e.g. "Save Failed:").
      Specified by:
      displayWarning in interface XalDocumentView
      Parameters:
      aTitle - Title of the warning dialog box.
      prefix - Text that should appear in the dialog box before the exception message.
      exception - The exception about which the warning dialog is displayed.
    • displayError

      public void displayError(String aTitle, String message)
      Display an error dialog box and provide an audible alert.
      Specified by:
      displayError in interface XalDocumentView
      Parameters:
      aTitle - Title of the warning dialog box.
      message - The warning message to appear in the warning dialog box.
    • displayError

      public void displayError(Exception exception)
      Display an error dialog box with information about the exception and provide an audible alert.
      Specified by:
      displayError in interface XalDocumentView
      Parameters:
      exception - The exception about which the warning dialog is displayed.
    • displayError

      public void displayError(String aTitle, String prefix, Exception exception)
      Display an error dialog box with information about the exception and provide an audible alert. This method allows clarification about the consequences of the exception (e.g. "Save Failed:").
      Specified by:
      displayError in interface XalDocumentView
      Parameters:
      aTitle - Title of the warning dialog box.
      prefix - Text that should appear in the dialog box before the exception messasge.
      exception - The exception about which the warning dialog is displayed.