org.sourceforge.espro.gui
Class QuestionnaireManager

java.lang.Object
  extended by org.sourceforge.espro.gui.QuestionnaireManager

public class QuestionnaireManager
extends java.lang.Object

The QuestionnaireManager manges the questionnaires. It creates, saves and opens that. This works like a model, so the view can be updated on data changes. The questionnaire manager can handle many questionnaires at once, so we can have a buffer of questionnaires so more than one questionnaire can be opened at the same time.

This returns also Actions which can be used for gui creation.

Version:
2.0
Author:
Martin Kaffanke

Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a general Listener to the object.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Adds a listener to the object, which is only called if the property with the propertyName has changed.
 void cleanData()
          Removes all data from the actual questionnaire.
 void exportData()
          Exports the data from the current questionnaire.
 void exportData(java.io.File file)
          Exports the data to an csv file.
 Questionnaire getActualQuestionnaire()
          Returns the actual questionnaire.
 org.sourceforge.espro.gui.QuestionnaireManager.CleanDataAction getCleanDataAction()
          Returns the clean data action.
 org.sourceforge.espro.gui.QuestionnaireManager.ExportDataAction getExportDataAction()
          Returns the action for the export data method.
 org.sourceforge.espro.gui.QuestionnaireManager.FreezeQuestionnaireAction getFreezeQuestionnaireAction()
          DOCUMENT ME!
static QuestionnaireManager getInstance()
          This returns an object of the class.
 org.sourceforge.espro.gui.QuestionnaireManager.NewItemAction getNewItemAction()
          Returns the new item action.
 ModelInterface getNewQuestionnaire()
          Creates a new Questionnaire and sets this as actual questionnaire.
 org.sourceforge.espro.gui.QuestionnaireManager.NewQuestionnaireAction getNewQuestionnaireAction()
          This returns the action which is able to create a new questionnaire.
 org.sourceforge.espro.gui.QuestionnaireManager.OpenQuestionnaireAction getOpenQuestionnaireAction()
          This creates an openQuestionnaireAction and returns it.
 org.sourceforge.espro.gui.QuestionnaireManager.RemoveItemAction getRemoveItemAction()
          Returns the remove item action.
 org.sourceforge.espro.gui.QuestionnaireManager.SaveQuestionnaireAction getSaveQuestionnaireAction()
          This creates an saveQuestionnaireAction and returns it.
 org.sourceforge.espro.gui.QuestionnaireManager.SaveUnfrozenQuestionnaireAction getSaveUnfrozenQuestionnaireAction()
          DOCUMENT ME!
 ModelInterface openQuestionnaire(java.io.File file)
          Opens a questionnaire by the given file and sets this as actualQuestionnaire.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the given listener from the object.
 boolean saveQuestionnaire(java.io.File file)
          Saves the actual questionnaire to the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static QuestionnaireManager getInstance()
This returns an object of the class. The QuestionnaireManager is a singleton, which means, that only one object of that class exists within one application.

Returns:
The newly or before created instance of the QuestionnaireManager.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a general Listener to the object.

Parameters:
listener - the listener instance.

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Adds a listener to the object, which is only called if the property with the propertyName has changed.

Parameters:
propertyName - The name of the property to bind to.
listener - The listener.

cleanData

public void cleanData()
Removes all data from the actual questionnaire.


exportData

public void exportData()
Exports the data from the current questionnaire. This will first ask the user about a file and run exportData(File) afterwards.


exportData

public void exportData(java.io.File file)
Exports the data to an csv file.

Parameters:
file - The file to save the csv data.

getActualQuestionnaire

public Questionnaire getActualQuestionnaire()
Returns the actual questionnaire.

Returns:
the actualQuestionnaire

getCleanDataAction

public org.sourceforge.espro.gui.QuestionnaireManager.CleanDataAction getCleanDataAction()
Returns the clean data action. This is the action where we remove all recorded data from the questionnaire.

Returns:
The action.

getExportDataAction

public org.sourceforge.espro.gui.QuestionnaireManager.ExportDataAction getExportDataAction()
Returns the action for the export data method. This can be used for buttons the toolbar and the menu.

Returns:
The action.

getFreezeQuestionnaireAction

public org.sourceforge.espro.gui.QuestionnaireManager.FreezeQuestionnaireAction getFreezeQuestionnaireAction()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getNewItemAction

public org.sourceforge.espro.gui.QuestionnaireManager.NewItemAction getNewItemAction()
Returns the new item action.

Returns:
the new item action.

getNewQuestionnaire

public ModelInterface getNewQuestionnaire()
Creates a new Questionnaire and sets this as actual questionnaire.

This is done by the new questionnaire action. Fires the 'actualQuestionnaire' property change.

Returns:
the new created questionnaire.

getNewQuestionnaireAction

public org.sourceforge.espro.gui.QuestionnaireManager.NewQuestionnaireAction getNewQuestionnaireAction()
This returns the action which is able to create a new questionnaire.

Returns:
the NewQuestionnaireAction.

getOpenQuestionnaireAction

public org.sourceforge.espro.gui.QuestionnaireManager.OpenQuestionnaireAction getOpenQuestionnaireAction()
This creates an openQuestionnaireAction and returns it.

Returns:
the OpenQuestionnaireAction

getRemoveItemAction

public org.sourceforge.espro.gui.QuestionnaireManager.RemoveItemAction getRemoveItemAction()
Returns the remove item action. Performing this action results to remove the current item from the actual questionnaire.

Returns:
The action.

getSaveQuestionnaireAction

public org.sourceforge.espro.gui.QuestionnaireManager.SaveQuestionnaireAction getSaveQuestionnaireAction()
This creates an saveQuestionnaireAction and returns it.

Returns:
the saveQuestionnaireAction

getSaveUnfrozenQuestionnaireAction

public org.sourceforge.espro.gui.QuestionnaireManager.SaveUnfrozenQuestionnaireAction getSaveUnfrozenQuestionnaireAction()
DOCUMENT ME!

Returns:
DOCUMENT ME!

openQuestionnaire

public ModelInterface openQuestionnaire(java.io.File file)
Opens a questionnaire by the given file and sets this as actualQuestionnaire. This will normaly be used from the openQuestionnaireAction.

Fires the 'actualQuestionnaire' property change.

Parameters:
file - The file to open.
Returns:
The questionnaire or null if there was an error.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the given listener from the object.

Parameters:
listener - the listener to remove

saveQuestionnaire

public boolean saveQuestionnaire(java.io.File file)
Saves the actual questionnaire to the given file.

This is done by the save actual questionnaire action.

Parameters:
file - The file to save the questionnaire.
Returns:
true if it worked, false otherwise.