com.objectwave.templateMerge.gui
Class TemplateGuiModel

java.lang.Object
  |
  +--com.objectwave.templateMerge.gui.TemplateGuiModel
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener, TemplateGuiVIF

public class TemplateGuiModel
extends java.lang.Object
implements TemplateGuiVIF, java.beans.PropertyChangeListener

The behavior of the core TemplateGui screen. This class could easily be used as a nonvisual component integrated into any system.

Version:
$Id: TemplateGuiModel.java,v 2.1 2001/10/19 14:21:00 dave_hoag Exp $
Author:
Dave Hoag
See Also:
TemplateGuiVIF, TemplateGui

Constructor Summary
TemplateGuiModel()
          KnownTemplates is a collection of known MergeTemplates.
TemplateGuiModel(KnownTemplates known)
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add yourself to be notified of property changes.
protected  void createTreeModel()
          Using the KnownMergeTemplates found in 'workingTemplates', create a TreeModel.
 void dumpToText(java.io.BufferedWriter buff)
          Write ascii code to the buffer containing the MergeTemplate definitions.
 void dumpToXML(java.io.BufferedWriter buff)
          Write the templates into the the buffer of an XML file.
 java.lang.String getBufferForTemplate(java.lang.String selection, boolean fullView)
          Useful when displaying the way a template will look.
 java.lang.String getSelectedTemplateName()
          The currently selected template.
protected  MergeTemplate getTemplateNamed(java.lang.String name)
          Find the template object with the given name.
 javax.swing.tree.TreeModel getTemplateTreeModel()
          Return the TreeModel.
 TokenProvider getTokenProvider()
          The tokenProvider contains all of the information tokens that can used in the templates.
 KnownTemplates getWorkingTemplates()
           
 void importFromText(java.io.BufferedReader buff)
          Read ascii code from the buffer containing the MergeTemplate definitions.
 void importFromXML(java.io.Reader xmlFile)
          Read ascii code from the buffer containing the MergeTemplate definitions.
 void loadModel()
          Load the model from an ObjectStream.
static void main(java.lang.String[] args)
          Used to generate serialized files from text template definitions.
 void newModel()
          Change the workingTemplatesInstance.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Only called when our knownSourceTemplates have been modified.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          No longer listen for property change events.
 void requestNewTemplate()
          Create a new template.
 void requestTemplateDelete()
          Edit the selected template.
 void requestTemplateEdit()
          Edit the selected template.
 void saveCurrentModel()
          Using serialization, save the current templates.
 void setSelectedTemplateName(java.lang.String val)
          Other operations will be selection dependent.
 void setTemplateGui(java.awt.Frame gui)
          Sets the TemplateGui attribute of the TemplateGuiVIF object
protected  void setTemplateTreeModel(javax.swing.tree.TreeModel mod)
          Used internally to change the model.
 void setTokenProvider(TokenProvider p)
          A token provider is the source of the InformationToken objects.
 void setWorkingTemplates(KnownTemplates workingTemplates)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateGuiModel

public TemplateGuiModel()
KnownTemplates is a collection of known MergeTemplates.


TemplateGuiModel

public TemplateGuiModel(KnownTemplates known)
Parameters:
known - KnownTemplates is a collection of known MergeTemplates.
Method Detail

main

public static void main(java.lang.String[] args)
Used to generate serialized files from text template definitions. Useful for command line builds. Changed by Zhou Cai Use importXML to get templates from an XML file

Parameters:
args - The command line arguments

setSelectedTemplateName

public void setSelectedTemplateName(java.lang.String val)
Other operations will be selection dependent.

Specified by:
setSelectedTemplateName in interface TemplateGuiVIF
Parameters:
val - The new SelectedTemplateName value
See Also:
requestTemplateEdit()

setTemplateGui

public void setTemplateGui(java.awt.Frame gui)
Description copied from interface: TemplateGuiVIF
Sets the TemplateGui attribute of the TemplateGuiVIF object

Specified by:
setTemplateGui in interface TemplateGuiVIF
Parameters:
gui - The new TemplateGui value

setTokenProvider

public void setTokenProvider(TokenProvider p)
A token provider is the source of the InformationToken objects.

Specified by:
setTokenProvider in interface TemplateGuiVIF
Parameters:
p - The new TokenProvider value

setWorkingTemplates

public void setWorkingTemplates(KnownTemplates workingTemplates)
Parameters:
workingTemplates - The new WorkingTemplates value

setTemplateTreeModel

protected void setTemplateTreeModel(javax.swing.tree.TreeModel mod)
Used internally to change the model. In addition to that it fires the property change event. It is the only property that will fire this event.

Parameters:
mod - The new TemplateTreeModel value

getBufferForTemplate

public java.lang.String getBufferForTemplate(java.lang.String selection,
                                             boolean fullView)
Useful when displaying the way a template will look.

Specified by:
getBufferForTemplate in interface TemplateGuiVIF
Parameters:
selection - The name of a known template.
fullView - Should subtemplates be expanded?
Returns:
The BufferForTemplate value

getSelectedTemplateName

public java.lang.String getSelectedTemplateName()
The currently selected template. This is used for template context operations.

Specified by:
getSelectedTemplateName in interface TemplateGuiVIF
Returns:
String a Known template name.

getTemplateTreeModel

public javax.swing.tree.TreeModel getTemplateTreeModel()
Return the TreeModel. This model was created via the 'createTreeModel' method.

Specified by:
getTemplateTreeModel in interface TemplateGuiVIF
Returns:
The TemplateTreeModel value
See Also:
createTreeModel()

getTokenProvider

public TokenProvider getTokenProvider()
The tokenProvider contains all of the information tokens that can used in the templates. This is useful for pick lists as well as converting a 'text' defined template into the actual objects.

Specified by:
getTokenProvider in interface TemplateGuiVIF
Returns:
The TokenProvider value

getWorkingTemplates

public KnownTemplates getWorkingTemplates()
Returns:
The knownTemplate collection that this model is building/managing.

getTemplateNamed

protected MergeTemplate getTemplateNamed(java.lang.String name)
Find the template object with the given name.

Parameters:
name -
Returns:
The TemplateNamed value

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add yourself to be notified of property changes. As of 11/12/97 this only occurred when setTemplateTreeModel().

Specified by:
addPropertyChangeListener in interface TemplateGuiVIF
Parameters:
l - The feature to be added to the PropertyChangeListener attribute
See Also:
setTemplateTreeModel(javax.swing.tree.TreeModel)

dumpToText

public void dumpToText(java.io.BufferedWriter buff)
                throws java.io.IOException
Write ascii code to the buffer containing the MergeTemplate definitions. Usefull if you don't want to rely upon serialized objects.

Specified by:
dumpToText in interface TemplateGuiVIF
Parameters:
buff - The output buffer upon which to write the ascii version of the templates.
Throws:
java.io.IOException - Any exceptions related to writing to the parameter.

dumpToXML

public void dumpToXML(java.io.BufferedWriter buff)
               throws ConfigurationException
Write the templates into the the buffer of an XML file. Usefull if you don't want to rely upon serialized objects.

Specified by:
dumpToXML in interface TemplateGuiVIF
Parameters:
buff - BufferedWriter The output buffer of an XML file
Throws:
ConfigurationException - Receive the exception from MergeTemplateWriter

importFromText

public void importFromText(java.io.BufferedReader buff)
                    throws java.io.IOException
Read ascii code from the buffer containing the MergeTemplate definitions. Usefull if you don't want to rely upon serialized objects.

Specified by:
importFromText in interface TemplateGuiVIF
Parameters:
buff -
Throws:
java.io.IOException
See Also:
dumpToText

importFromXML

public void importFromXML(java.io.Reader xmlFile)
                   throws ConfigurationException
Read ascii code from the buffer containing the MergeTemplate definitions. Usefull if you don't want to rely upon serialized objects.

Specified by:
importFromXML in interface TemplateGuiVIF
Parameters:
xmlFile - FileReader The input stream of XML file
Throws:
ConfigurationException - If any error happens in the XML file processing
See Also:
dumpToText

loadModel

public void loadModel()
Load the model from an ObjectStream. Relies on Java serialization.

Specified by:
loadModel in interface TemplateGuiVIF

newModel

public void newModel()
Change the workingTemplatesInstance.

Specified by:
newModel in interface TemplateGuiVIF

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Only called when our knownSourceTemplates have been modified.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt -

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
No longer listen for property change events.

Specified by:
removePropertyChangeListener in interface TemplateGuiVIF
Parameters:
l -

requestNewTemplate

public void requestNewTemplate()
Create a new template.

Specified by:
requestNewTemplate in interface TemplateGuiVIF

requestTemplateDelete

public void requestTemplateDelete()
Edit the selected template.

Specified by:
requestTemplateDelete in interface TemplateGuiVIF

requestTemplateEdit

public void requestTemplateEdit()
Edit the selected template.

Specified by:
requestTemplateEdit in interface TemplateGuiVIF

saveCurrentModel

public void saveCurrentModel()
Using serialization, save the current templates.

Specified by:
saveCurrentModel in interface TemplateGuiVIF

createTreeModel

protected void createTreeModel()
Using the KnownMergeTemplates found in 'workingTemplates', create a TreeModel. Often used by screens to display the model.