com.jgoodies.skeleton.model
Class MainModel

java.lang.Object
  extended by com.jgoodies.binding.beans.Model
      extended by com.jgoodies.skeleton.model.MainModel
All Implemented Interfaces:
com.jgoodies.binding.beans.Observable, com.jgoodies.uif.application.ExitListener, Serializable, EventListener

public final class MainModel
extends com.jgoodies.binding.beans.Model
implements com.jgoodies.uif.application.ExitListener

Provides bound bean properties for the project, navigation tree, navigation tree selection, selection type. Refers to the presentation settings and a submodel for the dynamic help.

Version:
$Revision: 1.33 $
Author:
Karsten Lentzsch
See Also:
NavigationModel, UISettingsModel, DynamicHelpModel, Serialized Form

Field Summary
static String ACTION_CLOSE_HELP_VIEW
           
static String ACTION_EXIT
           
static String ACTION_NEW_PROJECT
           
static String ACTION_OPEN_ABOUT_DIALOG
           
static String ACTION_OPEN_HELP_CONTENTS
           
static String ACTION_OPEN_PAGE_SETUP
           
static String ACTION_OPEN_PREFERENCES
           
static String ACTION_OPEN_PRINT_DIALOG
           
static String ACTION_OPEN_PROJECT
           
static String ACTION_OPEN_TIP_OF_THE_DAY
           
static String ACTION_PRINT
           
static String ACTION_SAVE
           
static String ACTION_SAVE_AS
           
static String PROPERTYNAME_PROJECT
           
 
Constructor Summary
MainModel()
          Constructs a MainModel that has no project set, no selection and no tree model.
 
Method Summary
 boolean applicationExitAllowed(EventObject event)
          Checks and answers whether we accept a close request.
 void applicationExiting()
          Stores this model's state if the application is closing.
 void checkForOpenTipOfTheDayDialog()
          Checks if we shall show a tip of the day: asks the TipOfTheDayDialog whether it is enabled, and the SetupManager, if we are not running for the first time.
 void closeHelpView(ActionEvent e)
           
 void exit(ActionEvent e)
           
 EditorModel getEditorModel()
          Returns the editor submodel.
 DynamicHelpModel getHelpModel()
          Returns the submodel that provides bound properties for the help tree model, selection, help page and help visibility.
 NavigationModel getNavigationModel()
          Returns the navigation submodel.
 Project getProject()
          Returns the current project.
 UISettingsModel getUiSettingsModel()
          Returns the UI related settings.
 boolean hasProject()
          Checks and answers if a project is loaded.
 boolean isProjectFilePathValid()
          Checks and answers whether the project's file path is valid.
 void newProject()
          Creates a new project and sets it in the main model.
 void openAboutDialog(ActionEvent e)
          Opens the about dialog.
 void openHelpContents(ActionEvent e)
           
 void openPageSetup(ActionEvent e)
           
 void openPreferences(ActionEvent e)
          Opens the preferences dialog.
 void openPrintDialog(ActionEvent e)
          Opens a print dialog, then prints a project summary to the choosen printer.
 void openProject(ActionEvent e)
          Opens a file chooser, loads a project from a file, and sets it in the main model.
 void openTipOfTheDay(ActionEvent e)
          Opens the tip-of-the-day dialog.
 void print(ActionEvent e)
          Prints a project summary.
 void restoreState()
          Restores the application state from the user preferences.
 void save(ActionEvent e)
          Saves the project to the current file.
 void saveAs(ActionEvent e)
          Asks the user for a file name and saves the project to that file.
 void setProject(Project newProject)
          Sets a new project.
 void storeState()
          Stores the application state to the user preferences.
 
Methods inherited from class com.jgoodies.binding.beans.Model
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTYNAME_PROJECT

public static final String PROPERTYNAME_PROJECT
See Also:
Constant Field Values

ACTION_NEW_PROJECT

public static final String ACTION_NEW_PROJECT
See Also:
Constant Field Values

ACTION_OPEN_PROJECT

public static final String ACTION_OPEN_PROJECT
See Also:
Constant Field Values

ACTION_SAVE

public static final String ACTION_SAVE
See Also:
Constant Field Values

ACTION_SAVE_AS

public static final String ACTION_SAVE_AS
See Also:
Constant Field Values

ACTION_OPEN_PAGE_SETUP

public static final String ACTION_OPEN_PAGE_SETUP
See Also:
Constant Field Values

ACTION_PRINT

public static final String ACTION_PRINT
See Also:
Constant Field Values

ACTION_OPEN_PRINT_DIALOG

public static final String ACTION_OPEN_PRINT_DIALOG
See Also:
Constant Field Values

ACTION_OPEN_PREFERENCES

public static final String ACTION_OPEN_PREFERENCES
See Also:
Constant Field Values

ACTION_EXIT

public static final String ACTION_EXIT
See Also:
Constant Field Values

ACTION_OPEN_TIP_OF_THE_DAY

public static final String ACTION_OPEN_TIP_OF_THE_DAY
See Also:
Constant Field Values

ACTION_OPEN_HELP_CONTENTS

public static final String ACTION_OPEN_HELP_CONTENTS
See Also:
Constant Field Values

ACTION_OPEN_ABOUT_DIALOG

public static final String ACTION_OPEN_ABOUT_DIALOG
See Also:
Constant Field Values

ACTION_CLOSE_HELP_VIEW

public static final String ACTION_CLOSE_HELP_VIEW
See Also:
Constant Field Values
Constructor Detail

MainModel

public MainModel()
Constructs a MainModel that has no project set, no selection and no tree model.

Method Detail

getNavigationModel

public NavigationModel getNavigationModel()
Returns the navigation submodel.

Returns:
the navigation submodel.

getEditorModel

public EditorModel getEditorModel()
Returns the editor submodel.

Returns:
the editor submodel.

getHelpModel

public DynamicHelpModel getHelpModel()
Returns the submodel that provides bound properties for the help tree model, selection, help page and help visibility.

Returns:
the submodel for the dynamic help

getUiSettingsModel

public UISettingsModel getUiSettingsModel()
Returns the UI related settings.

Returns:
the UI related settings

getProject

public Project getProject()
Returns the current project.

Returns:
the current project.

setProject

public void setProject(Project newProject)
Sets a new project.

Parameters:
newProject - the project to set
Throws:
NullPointerException - if the new project is null

hasProject

public boolean hasProject()
Checks and answers if a project is loaded.

Returns:
true if a project is loaded.

isProjectFilePathValid

public boolean isProjectFilePathValid()
Checks and answers whether the project's file path is valid.

Returns:
true if the project's file path is valid.

applicationExiting

public void applicationExiting()
Stores this model's state if the application is closing.

Specified by:
applicationExiting in interface com.jgoodies.uif.application.ExitListener

applicationExitAllowed

public boolean applicationExitAllowed(EventObject event)
Checks and answers whether we accept a close request. The default behavior just says: true = OK to close. You may ask: "Do you really want to close the application?".

TODO: Warn if the edited object is invalid and offer to cancel the exit operation.

Specified by:
applicationExitAllowed in interface com.jgoodies.uif.application.ExitListener
Returns:
true to accept the window close, false to reject it

newProject

@Action
public void newProject()
Creates a new project and sets it in the main model. Uses a sample project for demoing purposes.


openProject

@Action
public void openProject(ActionEvent e)
Opens a file chooser, loads a project from a file, and sets it in the main model. Uses a sample project in this demo.


save

@Action
public void save(ActionEvent e)
Saves the project to the current file.


saveAs

@Action
public void saveAs(ActionEvent e)
Asks the user for a file name and saves the project to that file.


openPageSetup

@Action
public void openPageSetup(ActionEvent e)

print

@Action
public void print(ActionEvent e)
Prints a project summary.


openPrintDialog

@Action
public void openPrintDialog(ActionEvent e)
Opens a print dialog, then prints a project summary to the choosen printer.


openPreferences

@Action
public void openPreferences(ActionEvent e)
Opens the preferences dialog.


exit

@Action
public void exit(ActionEvent e)

checkForOpenTipOfTheDayDialog

public void checkForOpenTipOfTheDayDialog()
Checks if we shall show a tip of the day: asks the TipOfTheDayDialog whether it is enabled, and the SetupManager, if we are not running for the first time. We don't want to disturb the user the first time, where we already have opened some extra panels from the setup process.

Opens the tip of the day dialog in the event dispatch thread.


openTipOfTheDay

@Action
public void openTipOfTheDay(ActionEvent e)
Opens the tip-of-the-day dialog. The ActionEvent may be null

Parameters:
e - the ActionEvent in user interaction, or null if invoked at application startup

openHelpContents

@Action
public void openHelpContents(ActionEvent e)

openAboutDialog

@Action
public void openAboutDialog(ActionEvent e)
Opens the about dialog.


closeHelpView

@Action
public void closeHelpView(ActionEvent e)

restoreState

public void restoreState()
Restores the application state from the user preferences.


storeState

public void storeState()
Stores the application state to the user preferences.



Copyright © 2002-2008 JGoodies Karsten Lentzsch. All Rights Reserved.