org.argouml.uml.ui
Class UMLModelElementListModel2

java.lang.Object
  extended byjavax.swing.AbstractListModel
      extended byjavax.swing.DefaultListModel
          extended byorg.argouml.uml.ui.UMLModelElementListModel2
All Implemented Interfaces:
EventListener, ListModel, ru.novosoft.uml.MElementListener, Serializable, TargetListener
Direct Known Subclasses:
UMLAssociationAssociationRoleListModel, UMLAssociationEndAssociationListModel, UMLAssociationEndRoleBaseListModel, UMLAssociationEndSpecificationListModel, UMLAssociationLinkListModel, UMLAssociationRoleMessageListModel, UMLAttributeInitialValueListModel, UMLClassifierAssociationEndListModel, UMLClassifierClassifierInStateListModel, UMLClassifierClassifierRoleListModel, UMLClassifierCollaborationListModel, UMLClassifierCreateActionListModel, UMLClassifierInstanceListModel, UMLClassifierObjectFlowStateListModel, UMLClassifierParticipantListModel, UMLClassifierPowertypeRangeListModel, UMLClassifierRoleAvailableContentsListModel, UMLClassifierRoleAvailableFeaturesListModel, UMLClassifierRoleBaseListModel, UMLClassifierStructuralFeatureListModel, UMLCollaborationConstrainingElementListModel, UMLCollaborationInteractionListModel, UMLCollaborationRepresentedClassifierListModel, UMLCollaborationRepresentedOperationListModel, UMLCommentAnnotatedElementListModel, UMLComponentResidentListModel, UMLCompositeStateSubvertexListModel, UMLContainerResidentListModel, UMLDependencyClientListModel, UMLDependencySupplierListModel, UMLEventParameterListModel, UMLEventTransitionListModel, UMLExtendExtensionPointListModel, UMLExtensionPointExtendListModel, UMLExtensionPointUseCaseListModel, UMLFeatureOwnerListModel, UMLGeneralizableElementGeneralizationListModel, UMLGeneralizableElementSpecializationListModel, UMLGeneralizationChildListModel, UMLGeneralizationParentListModel, UMLGuardTransitionListModel, UMLInstanceClassifierListModel, UMLInstanceLinkEndListModel, UMLInstanceReceiverStimulusListModel, UMLInstanceSenderStimulusListModel, UMLInteractionContextListModel, UMLInteractionMessagesListModel, UMLMessageActionListModel, UMLMessageInteractionListModel, UMLMessagePredecessorListModel, UMLMessageReceiverListModel, UMLMessageSenderListModel, UMLModelElementClientDependencyListModel, UMLModelElementConstraintListModel, UMLModelElementElementResidenceListModel, UMLModelElementElementResidenceListModel, UMLModelElementNamespaceListModel, UMLModelElementOrderedListModel2, UMLModelElementSourceFlowListModel, UMLModelElementSupplierDependencyListModel, UMLModelElementTargetFlowListModel, UMLNamespaceOwnedElementListModel, UMLOperationRaisedSignalsListModel, UMLParameterBehavioralFeatListModel, UMLPartitionContentsListModel, UMLSignalContextListModel, UMLStateDeferrableEventListModel, UMLStateDoActivityListModel, UMLStateEntryListModel, UMLStateExitListModel, UMLStateInternalTransition, UMLStateMachineContextListModel, UMLStateMachineSubmachineStateListModel, UMLStateMachineTopListModel, UMLStateMachineTransitionListModel, UMLStateVertexContainerListModel, UMLStateVertexIncomingListModel, UMLStateVertexOutgoingListModel, UMLStimulusReceiverListModel, UMLStimulusSenderListModel, UMLTransitionEffectListModel, UMLTransitionGuardListModel, UMLTransitionSourceListModel, UMLTransitionStateListModel, UMLTransitionStatemachineListModel, UMLTransitionTargetListModel, UMLTransitionTriggerListModel, UMLUseCaseExtendListModel, UMLUseCaseIncludeListModel

public abstract class UMLModelElementListModel2
extends DefaultListModel
implements TargetListener, ru.novosoft.uml.MElementListener

The model for a list that contains Mbases. The state of the MBase is still kept in the Mbase itself. This list is only to be used as the model for some GUI element like UMLLinkedList

Since:
Oct 2, 2002
See Also:
Serialized Form

Field Summary
private  boolean buildingModel
          Flag to indicate wether the model is being build
private  String eventName
           
private  boolean fireListEvents
          Flag to indicate wether list events should be fired
private  Object listTarget
           
 
Fields inherited from class javax.swing.DefaultListModel
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
UMLModelElementListModel2()
          Constructor to be used if the subclass does not depend on the MELementListener methods and setTarget method implemented in this class.
UMLModelElementListModel2(String name)
          Constructor for UMLModelElementListModel2.
 
Method Summary
protected  void addAll(Collection col)
          Utility method to add a collection of elements to the model
 void addElement(Object obj)
           
protected abstract  void buildModelList()
          Builds the list of elements.
 boolean buildPopup(JPopupMenu popup, int index)
          Override this if you want a popup menu.
 boolean contains(Object elem)
           
protected  void fireContentsChanged(Object source, int index0, int index1)
           
protected  void fireIntervalAdded(Object source, int index0, int index1)
           
protected  void fireIntervalRemoved(Object source, int index0, int index1)
           
protected  Object getChangedElement(ru.novosoft.uml.MElementEvent e)
          Utility method to get the changed element from some event e
(package private)  String getEventName()
          Returns the eventName.
protected  Object getTarget()
          Utility method to get the target.
protected abstract  boolean isValidElement(Object element)
          Returns true if the given element is valid, i.e.
protected  boolean isValidEvent(ru.novosoft.uml.MElementEvent e)
          Returns true if some event is valid.
 void listRoleItemSet(ru.novosoft.uml.MElementEvent e)
           
 void propertySet(ru.novosoft.uml.MElementEvent e)
           
 void recovered(ru.novosoft.uml.MElementEvent e)
           
 void removed(ru.novosoft.uml.MElementEvent e)
           
 void roleAdded(ru.novosoft.uml.MElementEvent e)
           
 void roleRemoved(ru.novosoft.uml.MElementEvent e)
           
protected  void setAllElements(Collection col)
          Utility method to set the elements of this list to the contents of the given collection.
protected  void setBuildingModel(boolean building)
           
protected  void setEventName(String theEventName)
          Sets the eventName.
protected  void setListTarget(Object t)
           
 void setTarget(Object theNewTarget)
          Sets the target.
 void targetAdded(TargetEvent e)
          Fired when a target is added to the list of targets.
 void targetRemoved(TargetEvent e)
          Fired when a target is removed from the list of targets
 void targetSet(TargetEvent e)
          Fired when a total new set of targets is set
 
Methods inherited from class javax.swing.DefaultListModel
add, capacity, clear, copyInto, elementAt, elements, ensureCapacity, firstElement, get, getElementAt, getSize, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeAllElements, removeElement, removeElementAt, removeRange, set, setElementAt, setSize, size, toArray, toString, trimToSize
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

eventName

private String eventName

listTarget

private Object listTarget

fireListEvents

private boolean fireListEvents
Flag to indicate wether list events should be fired


buildingModel

private boolean buildingModel
Flag to indicate wether the model is being build

Constructor Detail

UMLModelElementListModel2

public UMLModelElementListModel2()
Constructor to be used if the subclass does not depend on the MELementListener methods and setTarget method implemented in this class.


UMLModelElementListModel2

public UMLModelElementListModel2(String name)
Constructor for UMLModelElementListModel2.

Parameters:
name - the name of the event to listen to, which triggers us to update the list model from the UML data
Method Detail

setBuildingModel

protected void setBuildingModel(boolean building)
Parameters:
building - The buildingModel to set.

setListTarget

protected void setListTarget(Object t)
Parameters:
t - the list target to set

listRoleItemSet

public void listRoleItemSet(ru.novosoft.uml.MElementEvent e)
Specified by:
listRoleItemSet in interface ru.novosoft.uml.MElementListener
See Also:
MElementListener.listRoleItemSet( ru.novosoft.uml.MElementEvent)

propertySet

public void propertySet(ru.novosoft.uml.MElementEvent e)
Specified by:
propertySet in interface ru.novosoft.uml.MElementListener
See Also:
MElementListener.propertySet( ru.novosoft.uml.MElementEvent)

recovered

public void recovered(ru.novosoft.uml.MElementEvent e)
Specified by:
recovered in interface ru.novosoft.uml.MElementListener
See Also:
MElementListener.recovered( ru.novosoft.uml.MElementEvent)

removed

public void removed(ru.novosoft.uml.MElementEvent e)
Specified by:
removed in interface ru.novosoft.uml.MElementListener
See Also:
MElementListener.removed( ru.novosoft.uml.MElementEvent)

roleAdded

public void roleAdded(ru.novosoft.uml.MElementEvent e)
Specified by:
roleAdded in interface ru.novosoft.uml.MElementListener
See Also:
MElementListener.roleAdded( ru.novosoft.uml.MElementEvent)

roleRemoved

public void roleRemoved(ru.novosoft.uml.MElementEvent e)
Specified by:
roleRemoved in interface ru.novosoft.uml.MElementListener
See Also:
MElementListener.roleRemoved( ru.novosoft.uml.MElementEvent)

buildModelList

protected abstract void buildModelList()
Builds the list of elements. Called from targetChanged every time the target of the proppanel is changed.


setAllElements

protected void setAllElements(Collection col)
Utility method to set the elements of this list to the contents of the given collection.

Parameters:
col - the given collection

addAll

protected void addAll(Collection col)
Utility method to add a collection of elements to the model

Parameters:
col - the given collection

getTarget

protected Object getTarget()
Utility method to get the target. Sets the target if the target is null via the method setTarget().

Returns:
MModelElement

getChangedElement

protected Object getChangedElement(ru.novosoft.uml.MElementEvent e)
Utility method to get the changed element from some event e

Parameters:
e - the event
Returns:
Object the changed element

contains

public boolean contains(Object elem)
See Also:
DefaultListModel.contains(java.lang.Object)

setTarget

public void setTarget(Object theNewTarget)
Sets the target. If the old target is instanceof MBase, it also removes the model from the element listener list of the target. If the new target is instanceof MBase, the model is added as element listener to the new target.

Parameters:
theNewTarget - the new target

isValidElement

protected abstract boolean isValidElement(Object element)
Returns true if the given element is valid, i.e. it may be added to the list of elements.

Parameters:
element - the element to be tested
Returns:
true if valid

isValidEvent

protected boolean isValidEvent(ru.novosoft.uml.MElementEvent e)
Returns true if some event is valid. An event is valid if the element changed in the event is valid. This is determined via a call to isValidElement. This method can be overriden by subclasses if they cannot determine if it is a valid event just by checking the changed element.

Parameters:
e - the event
Returns:
boolean true if valid

addElement

public void addElement(Object obj)
See Also:
DefaultListModel.addElement(java.lang.Object)

getEventName

String getEventName()
Returns the eventName. This method is only here for testing goals.

Returns:
String

setEventName

protected void setEventName(String theEventName)
Sets the eventName. The eventName is the name of the MElementEvent to which the list should listen. The list is registred with UMLModelEventPump and only gets events that have a name like eventName. This method should be called in the constructor of every subclass.

Parameters:
theEventName - The eventName to set

targetAdded

public void targetAdded(TargetEvent e)
Description copied from interface: TargetListener
Fired when a target is added to the list of targets.

Specified by:
targetAdded in interface TargetListener
Parameters:
e - The targetevent, name will be TARGET_ADDED
See Also:
TargetListener.targetAdded(TargetEvent)

targetRemoved

public void targetRemoved(TargetEvent e)
Description copied from interface: TargetListener
Fired when a target is removed from the list of targets

Specified by:
targetRemoved in interface TargetListener
Parameters:
e - The targetevent, name will be TARGET_REMOVED
See Also:
TargetListener.targetRemoved(TargetEvent)

targetSet

public void targetSet(TargetEvent e)
Description copied from interface: TargetListener
Fired when a total new set of targets is set

Specified by:
targetSet in interface TargetListener
Parameters:
e - The targetevent, name will be TARGET_SET
See Also:
TargetListener.targetSet(TargetEvent)

fireContentsChanged

protected void fireContentsChanged(Object source,
                                   int index0,
                                   int index1)
See Also:
AbstractListModel.fireContentsChanged( Object, int, int)

fireIntervalAdded

protected void fireIntervalAdded(Object source,
                                 int index0,
                                 int index1)
See Also:
AbstractListModel.fireIntervalAdded( Object, int, int)

fireIntervalRemoved

protected void fireIntervalRemoved(Object source,
                                   int index0,
                                   int index1)
See Also:
AbstractListModel.fireIntervalRemoved( Object, int, int)

buildPopup

public boolean buildPopup(JPopupMenu popup,
                          int index)
Override this if you want a popup menu. See for an example UMLModelElementOrderedListModel2.

Parameters:
popup - the popup menu
index - the selected item in the list at the moment the mouse was clicked
Returns:
true if a popup menu is created, and needs to be shown


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook