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

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.AbstractNodeViewModel
              extended byedu.usc.cse.desi.model.view.ComponentViewModel
All Implemented Interfaces:
java.util.EventListener, org.eclipse.ui.views.properties.IPropertySource, java.beans.PropertyChangeListener, java.io.Serializable

public class ComponentViewModel
extends AbstractNodeViewModel

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

Field Summary
(package private)  int myNumExternalConnections
           
(package private)  AbstractNodeViewModel myParent
           
private  ComponentDataModel myXADLModel
           
 
Fields inherited from class edu.usc.cse.desi.model.view.AbstractNodeViewModel
C_DISPLAY_IMAGEDATA, C_DISPLAY_MODELDATA, myBGColor, myBorderWidth, myChildren, myConnections, myFigPosX, myFigPosY, myFigSizeH, myFigSizeW, P_DISPLAY_FIGLOCATION_X, P_DISPLAY_FIGLOCATION_Y, P_DISPLAY_FIGSIZE_H, P_DISPLAY_FIGSIZE_W, P_DISPLAY_NUMCHILDREN, P_DISPLAY_NUMCONNECTIONS, P_ID_FIGLOCATION_X, P_ID_FIGLOCATION_Y, P_ID_FIGSIZE_H, P_ID_FIGSIZE_W, P_ID_NUMCHILDREN, P_ID_NUMCONNECTIONS
 
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
ComponentViewModel()
           
ComponentViewModel(PropertyInitializer prop_init)
          THis constructor is for use when a data model does not already exist and you want to create one.
 
Method Summary
 void addComponent(ComponentViewModel comp)
          This is the public version of addComponent which adds a Sub Component to this component.
 void addConnection(LogicalLinkViewModel link)
          The public version of addConnection, this method should be called to when a logical link is connected.
 void addForbiddenCoLocationConstraint(ComponentViewModel comp)
           
 void addForbiddenLocationConstraint(HostViewModel host)
           
 void addRequiredCoLocationConstraint(ComponentViewModel comp)
           
 void colorLinksBlack()
          When called, this method will change the color of all attached links to black.
 void colorLinksRed()
          When called, this method will change the color of all attached links to red.
 void finalize()
          Just to make sure that nothing keeps this class as a listener after the object has been eliminated.
 java.util.List getForbiddenCoLocationComponents()
           
 java.util.List getForbiddenLocationHosts()
           
 AbstractNodeViewModel getMyParent()
          Gets the parent that contains this component.
 ComponentDataModel getMyXADLModel()
           
 java.util.List getRequiredCoLocationComponents()
           
 HostViewModel getRequiredLocationHost()
           
 void initialize(ComponentDataModel model)
          Initialize is to be called after the constuctor when a view model is being created on top of an existing data model.
private  void privateAddComponent(ComponentViewModel component)
          Adds a sub-component to this component, if it has not already been added.
private  void privateAddConnection(LogicalLinkViewModel link)
          Adds a new logical link to this component.
private  void privateRemoveComponent(ComponentViewModel component)
          Removes a sub-component from this component, if sub-component has not already been added.
private  void privateRemoveConnection(LogicalLinkViewModel link)
          Removes a connection from this component, if connection has already been added.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          On propertyChange, this class will respond to any additions or subtractions of components or connections by the ComponentDataModel.
 void reinitialize()
          Reinitialize all sub-components and connections.
 void removeComponent(ComponentViewModel comp)
          This is the public version of removeComponent which removes a Sub Component from this component.
 void removeConnection(LogicalLinkViewModel link)
          The public version of removeConnection, this method should be called to when a logical link is disconnected.
 void removeForbiddenCoLocationConstraint(ComponentViewModel comp)
           
 void removeForbiddenLocationConstraint(HostViewModel host)
           
 void removeRequiredCoLocationConstraint(ComponentViewModel comp)
           
 void removeRequiredLocationConstraint()
           
 void setMyParent(AbstractNodeViewModel model)
          Sets the parent of this component; the host or the super-component.
 void setMyXADLModel(ComponentDataModel myXADLModel)
          Set the xADL ComponentDataModel that is associated with this component.
 void setPropertyValue(java.lang.String prop_name, java.lang.Object value)
          I overrode this method:
 void setRequiredLocationConstraint(HostViewModel host)
           
 
Methods inherited from class edu.usc.cse.desi.model.view.AbstractNodeViewModel
addConnectedNode, getChildren, getConnectedLink, getConnectedNodes, getConnections, getEditableValue, getMyBGColor, getMyBorderWidth, getMyFigPosX, getMyFigPosY, getMyFigSizeH, getMyFigSizeW, getMyPropetyInitializer, getProperties, getPropertyDescriptors, getPropertyDisplayName, getPropertyValue, getPropertyValue, hasProperty, isConnectedToNode, isPropertySet, numOfConnectedNodes, removeConnectedNode, resetPropertyValue, setMyBGColor, setMyBorderWidth, setMyDataModel, setMyFigPosX, setMyFigPosY, setMyFigSizeH, setMyFigSizeW, setPropertyValue
 
Methods inherited from class edu.usc.cse.desi.model.view.AbstractViewModel
getMyDataModel
 
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

myParent

AbstractNodeViewModel myParent

myNumExternalConnections

int myNumExternalConnections

myXADLModel

private transient ComponentDataModel myXADLModel
Constructor Detail

ComponentViewModel

public ComponentViewModel(PropertyInitializer prop_init)
THis constructor is for use when a data model does not already exist and you want to create one.

Parameters:
prop_init -

ComponentViewModel

public ComponentViewModel()
Method Detail

initialize

public void initialize(ComponentDataModel model)
Initialize is to be called after the constuctor when a view model is being created on top of an existing data model. This method contains code that was previously in the constructor, but that had to be removed.

Parameters:
model -

reinitialize

public void reinitialize()
Reinitialize all sub-components and connections. Add yourself as a listener to your data model.

Overrides:
reinitialize in class AbstractNodeViewModel
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

colorLinksRed

public void colorLinksRed()
When called, this method will change the color of all attached links to red.


colorLinksBlack

public void colorLinksBlack()
When called, this method will change the color of all attached links to black.


propertyChange

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

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

privateAddConnection

private void privateAddConnection(LogicalLinkViewModel link)
Adds a new logical link to this component. The add will only take place if this link is not currently added to this component.

Parameters:
link - LogicalLinkViewModel

addConnection

public void addConnection(LogicalLinkViewModel link)
The public version of addConnection, this method should be called to when a logical link is connected. It will inform the underlying data model.

Parameters:
link -

privateRemoveConnection

private void privateRemoveConnection(LogicalLinkViewModel link)
Removes a connection from this component, if connection has already been added.

Parameters:
link - LogicalLinkViewModel

removeConnection

public void removeConnection(LogicalLinkViewModel link)
The public version of removeConnection, this method should be called to when a logical link is disconnected. It will inform the underlying data model.

Parameters:
link -

privateAddComponent

private void privateAddComponent(ComponentViewModel component)
Adds a sub-component to this component, if it has not already been added. Protected because we only want new components being added to the ComponentDataModel and then informing us of the change.

Parameters:
component - ComponentViewModel

addComponent

public void addComponent(ComponentViewModel comp)
This is the public version of addComponent which adds a Sub Component to this component. It will alert the underlying data model.

Parameters:
comp -

privateRemoveComponent

private void privateRemoveComponent(ComponentViewModel component)
Removes a sub-component from this component, if sub-component has not already been added. Protected because we only want new components being added to the ComponentDataModel and then informing us of the change.

Parameters:
component - ComponentViewModel

removeComponent

public void removeComponent(ComponentViewModel comp)
This is the public version of removeComponent which removes a Sub Component from this component. It will alert the underlying data model.

Parameters:
comp -

getMyParent

public AbstractNodeViewModel getMyParent()
Gets the parent that contains this component.

Returns:
AbstractNodeViewModel

setMyParent

public void setMyParent(AbstractNodeViewModel model)
Sets the parent of this component; the host or the super-component. This property should be kept accurate in order to ensure the visuals are correct.

Parameters:
model - AbstractNodeViewModel

setMyXADLModel

public void setMyXADLModel(ComponentDataModel myXADLModel)
Set the xADL ComponentDataModel that is associated with this component. This is only necessary if the simulation is running on to of a xADL File.

Parameters:
myXADLModel - The myXADLModel to set.

getMyXADLModel

public ComponentDataModel getMyXADLModel()
Returns:
Returns the myXADLModel.

setPropertyValue

public void setPropertyValue(java.lang.String prop_name,
                             java.lang.Object value)
                      throws PropertyNotFoundException,
                             java.lang.ClassCastException
I overrode this method:

Overrides:
setPropertyValue in class AbstractNodeViewModel
Throws:
PropertyNotFoundException
java.lang.ClassCastException
See Also:
AbstractViewModel.setPropertyValue(java.lang.String, java.lang.Object)

addForbiddenCoLocationConstraint

public void addForbiddenCoLocationConstraint(ComponentViewModel comp)

addRequiredCoLocationConstraint

public void addRequiredCoLocationConstraint(ComponentViewModel comp)

addForbiddenLocationConstraint

public void addForbiddenLocationConstraint(HostViewModel host)

getForbiddenCoLocationComponents

public java.util.List getForbiddenCoLocationComponents()

getForbiddenLocationHosts

public java.util.List getForbiddenLocationHosts()

getRequiredCoLocationComponents

public java.util.List getRequiredCoLocationComponents()

getRequiredLocationHost

public HostViewModel getRequiredLocationHost()

setRequiredLocationConstraint

public void setRequiredLocationConstraint(HostViewModel host)

removeForbiddenCoLocationConstraint

public void removeForbiddenCoLocationConstraint(ComponentViewModel comp)

removeRequiredCoLocationConstraint

public void removeRequiredCoLocationConstraint(ComponentViewModel comp)

removeForbiddenLocationConstraint

public void removeForbiddenLocationConstraint(HostViewModel host)

removeRequiredLocationConstraint

public void removeRequiredLocationConstraint()