edu.usc.cse.desi.model.view
Class DESIViewModel

java.lang.Object
  extended byedu.usc.cse.desi.model.AbstractDESIModel
      extended byedu.usc.cse.desi.model.view.AbstractViewModel
          extended byedu.usc.cse.desi.model.view.DESIViewModel
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener, java.io.Serializable

public class DESIViewModel
extends AbstractViewModel
implements java.io.Serializable

The view model class that cooresponds with the DESIDataModel class. Pay special attention to the static fields and methods that are used to maintain mappings between view model object and data model objects.

Author:
Nels Started Feb 17, 2004
See Also:
Serialized Form

Field Summary
private  java.util.List myHosts
           
private  java.util.BitSet myPointBitSet
           
private static java.util.HashMap myViewModelMappings
           
private  DeSiDataModel myXADLModel
           
 
Fields inherited from class edu.usc.cse.desi.model.view.AbstractViewModel
myDataModel
 
Fields inherited from class edu.usc.cse.desi.model.AbstractDESIModel
listeners
 
Constructor Summary
DESIViewModel(DESIDataModel data)
          Take the passed-in model and ennumerate through all its children, creating associtated *View* objects for each *Data* object.
DESIViewModel(PropertyInitializer prop_init)
           
 
Method Summary
 void addHost(HostViewModel host)
          This is the public version of addHost.
static void createModelMapping(AbstractDataModel data_model, AbstractViewModel view_model)
          This method really should only be called by the reinitialize methods.
 java.lang.String debugOutput()
          This method will output a string that you can use to see the structure of the view model.
 void finalize()
          Just to make sure that nothing keeps this class as a listener after the object has been eliminated.
static AbstractDataModel getMappedDataModel(AbstractViewModel view_model, PropertyInitializer prop_init)
          This method is to be used when someone create an AbstractViewModel without passing it a AbstractDataModel.
static AbstractViewModel getMappedViewModel(AbstractDataModel data_model_object)
          This method is how the view classes examine their relationships with data model objects.
 java.util.List getMyHosts()
          Returns a list of HostViewModels.
 PropertyInitializer getMyPropertyInitializer()
           
 DeSiDataModel getMyXADLModel()
           
private  void privateAddHost(HostViewModel host)
          Adds new host and then updates all listeners.
private  void privateRemoveHost(HostViewModel host)
          Removes the given host and updates all listeners.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          On propertyChange, this class will respond to any additions or subtractions of Hosts by the DESIDataModel.
 void reinitialize()
          Must call reinitialize on the view model first, so that all view models will be able to add themselves as listeners.
 void removeHost(HostViewModel host)
          This is the public version of removeHost.
 void setMyXADLModel(DeSiDataModel myXADLModel)
          This method will attach a XADL model to this model.
 
Methods inherited from class edu.usc.cse.desi.model.view.AbstractViewModel
getMyDataModel, getMyPropetyInitializer, getProperties, getPropertyDisplayName, getPropertyValue, hasProperty, setPropertyValue
 
Methods inherited from class edu.usc.cse.desi.model.AbstractDESIModel
addPropertyChangeListener, firePropertyChange, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myViewModelMappings

private static java.util.HashMap myViewModelMappings

myHosts

private java.util.List myHosts

myPointBitSet

private java.util.BitSet myPointBitSet

myXADLModel

private transient DeSiDataModel myXADLModel
Constructor Detail

DESIViewModel

public DESIViewModel(PropertyInitializer prop_init)

DESIViewModel

public DESIViewModel(DESIDataModel data)
Take the passed-in model and ennumerate through all its children, creating associtated *View* objects for each *Data* object. In turn, make all *View* objects as a listener on their *Data* object.

Parameters:
data - DESIDataModel
Method Detail

reinitialize

public void reinitialize()
Must call reinitialize on the view model first, so that all view models will be able to add themselves as listeners.

Overrides:
reinitialize in class AbstractViewModel
See Also:
AbstractDESIModel.reinitialize()

finalize

public void finalize()
              throws java.lang.Throwable
Just to make sure that nothing keeps this class as a listener after the object has been eliminated.

Throws:
java.lang.Throwable

getMyPropertyInitializer

public PropertyInitializer getMyPropertyInitializer()
Returns:

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
On propertyChange, this class will respond to any additions or subtractions of Hosts by the DESIDataModel. It will then report the change to all listeners.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class AbstractDESIModel

getMyHosts

public java.util.List getMyHosts()
Returns a list of HostViewModels. There should always be the same amount of HostViewModels as HostDataModels.

Returns:
List

setMyXADLModel

public void setMyXADLModel(DeSiDataModel myXADLModel)
This method will attach a XADL model to this model. The reason this is necessary is because the methods for moving components in xADL are held in the DESIDataModel.

Parameters:
myXADLModel - The myXADLModel to set.

getMyXADLModel

public DeSiDataModel getMyXADLModel()
Returns:
Returns the myXADLModel.

privateAddHost

private void privateAddHost(HostViewModel host)
Adds new host and then updates all listeners. If this host is already contained, nothing happens. Protected because we only want this DESIViewModel to add or remove components when notified by the DESIDataModel.

Parameters:
host - HostViewModel

privateRemoveHost

private void privateRemoveHost(HostViewModel host)
Removes the given host and updates all listeners. Protected because we only want this DESIViewModel to add or remove components when notified by the DESIDataModel.

Parameters:
host - HostViewModel

addHost

public void addHost(HostViewModel host)
This is the public version of addHost. It will tell the underlying data model to add the host.

Parameters:
host -

removeHost

public void removeHost(HostViewModel host)
This is the public version of removeHost. It will tell the underlying data model to remove the host.

Parameters:
host - HostViewModel Host to remove.

getMappedViewModel

public static AbstractViewModel getMappedViewModel(AbstractDataModel data_model_object)
This method is how the view classes examine their relationships with data model objects. This is a very important method! This method works in a similar manner to a factory but not completely. When it is passed a data model objet, it will either return the view model object that that data model object is connected to, OR it will create a brand new view model object. The idea is that you won't know whether you're getting the new one which hopefull is unncessary.

Parameters:
data_model_object - AbstractDataModel - The data model object that you want to get the cooresponding view model object for.
Returns:
AbstractViewModel - The cooresponding view model object for the given data model object.

getMappedDataModel

public static AbstractDataModel getMappedDataModel(AbstractViewModel view_model,
                                                   PropertyInitializer prop_init)
This method is to be used when someone create an AbstractViewModel without passing it a AbstractDataModel. So now this method must create an AbstractDataModel to go with the view model, associate the two in the myViewModelMappings and then return the data model.

Parameters:
view_model -
prop_init -
Returns:

createModelMapping

public static void createModelMapping(AbstractDataModel data_model,
                                      AbstractViewModel view_model)
This method really should only be called by the reinitialize methods. When a system is deserialized from disk, the mappings between its view model objects and its data model objects need to be put back into the static data stucture. This method will do that. This method associates the given data model object with the view model object in myViewModelMappings.

Parameters:
data_model -
view_model -

debugOutput

public java.lang.String debugOutput()
This method will output a string that you can use to see the structure of the view model. I overrode this method:

See Also:
Object.toString()