org.argouml.uml.ui
Class UMLModelElementListModel2

java.lang.Object
  |
  +--javax.swing.AbstractListModel
        |
        +--javax.swing.DefaultListModel
              |
              +--org.argouml.uml.ui.UMLModelElementListModel2
All Implemented Interfaces:
java.util.EventListener, javax.swing.ListModel, java.io.Serializable, TargetListener
Direct Known Subclasses:
UMLAssociationAssociationRoleListModel, UMLAssociationConnectionListModel, UMLAssociationEndAssociationListModel, UMLAssociationEndRoleBaseListModel, UMLAssociationEndSpecificationListModel, UMLAssociationLinkListModel, UMLAssociationRoleAssociationEndRoleListModel, UMLAssociationRoleMessageListModel, UMLAttributeInitialValueListModel, UMLCallEventOperationListModel, UMLClassAttributeListModel, UMLClassifierAssociationEndListModel, UMLClassifierClassifierInStateListModel, UMLClassifierClassifierRoleListModel, UMLClassifierCollaborationListModel, UMLClassifierCreateActionListModel, UMLClassifierFeatureListModel, UMLClassifierInstanceListModel, UMLClassifierObjectFlowStateListModel, UMLClassifierParameterListModel, UMLClassifierParticipantListModel, UMLClassifierPowertypeRangeListModel, UMLClassifierRoleAvailableContentsListModel, UMLClassifierRoleAvailableFeaturesListModel, UMLClassifierRoleBaseListModel, UMLClassifierStructuralFeatureListModel, UMLClassOperationListModel, UMLCollaborationConstrainingElementListModel, UMLCollaborationInteractionListModel, UMLCollaborationRepresentedClassifierListModel, UMLCollaborationRepresentedOperationListModel, UMLCompositeStateSubvertexListModel, UMLDependencyClientListModel, UMLDependencySupplierListModel, UMLEventParameterListModel, UMLExtendExtensionPointListModel, UMLExtensionPointExtendListModel, UMLExtensionPointUseCaseListModel, UMLFeatureOwnerListModel, UMLGeneralizableElementGeneralizationListModel, UMLGeneralizableElementSpecializationListModel, UMLGuardTransitionListModel, UMLInteractionContextListModel, UMLInteractionMessagesListModel, UMLMessageActionListModel, UMLMessageInteractionListModel, UMLMessagePredecessorListModel, UMLMessageReceiverListModel, UMLMessageSenderListModel, UMLModelElementClientDependencyListModel, UMLModelElementConstraintListModel, UMLModelElementElementResidenceListModel, UMLModelElementNamespaceListModel, UMLModelElementSourceFlowListModel, UMLModelElementSupplierDependencyListModel, UMLModelElementTargetFlowListModel, UMLNamespaceOwnedElementListModel, UMLStateDeferrableEventListModel, UMLStateDoActivityListModel, UMLStateEntryListModel, UMLStateExitListModel, UMLStateInternalTransition, UMLStateMachineContextListModel, UMLStateMachineSubmachineStateListModel, UMLStateMachineTopListModel, UMLStateMachineTransitionListModel, UMLStateVertexContainerListModel, UMLStateVertexIncomingListModel, UMLStateVertexOutgoingListModel, UMLTransitionEffectListModel, UMLTransitionGuardListModel, UMLTransitionSourceListModel, UMLTransitionStateListModel, UMLTransitionStatemachineListModel, UMLTransitionTargetListModel, UMLTransitionTriggerListModel, UMLUseCaseExtendListModel, UMLUseCaseExtensionPointListModel, UMLUseCaseIncludeListModel

public abstract class UMLModelElementListModel2
extends javax.swing.DefaultListModel
implements TargetListener

The model for a list that Mbases contains. 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
protected  boolean _buildingModel
          Flag to indicate wether the model is being build
protected  boolean _fireListEvents
          Flag to indicate wether list events should be fired
protected  java.lang.Object _target
           
 
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(java.lang.String eventName)
          Constructor for UMLModelElementListModel2.
 
Method Summary
protected  void addAll(java.util.Collection col)
          Utility method to add a collection of elements to the model
 void addElement(java.lang.Object obj)
           
protected abstract  void buildModelList()
          Builds the list of elements.
 boolean contains(java.lang.Object elem)
           
protected  void fireContentsChanged(java.lang.Object source, int index0, int index1)
           
protected  void fireIntervalAdded(java.lang.Object source, int index0, int index1)
           
protected  void fireIntervalRemoved(java.lang.Object source, int index0, int index1)
           
protected  java.lang.Object getChangedElement(MElementEvent e)
          Utility method to get the changed element from some event e
protected  java.lang.Object getTarget()
          Utility method to get the target.
protected abstract  boolean isValidElement(MBase element)
          Returns true if the given element is valid, i.e. it may be added to the list of elements.
protected  boolean isValidEvent(MElementEvent e)
          Returns true if some event is valid.
 void listRoleItemSet(MElementEvent e)
           
 void propertySet(MElementEvent e)
           
 void recovered(MElementEvent e)
           
 void removed(MElementEvent e)
           
 void roleAdded(MElementEvent e)
           
 void roleRemoved(MElementEvent e)
           
protected  void setAllElements(java.util.Collection col)
          Utility method to set the elements of this list to the contents of the given collection.
protected  void setEventName(java.lang.String eventName)
          Sets the eventName.
 void setTarget(java.lang.Object target)
          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

_target

protected java.lang.Object _target

_fireListEvents

protected boolean _fireListEvents
Flag to indicate wether list events should be fired


_buildingModel

protected boolean _buildingModel
Flag to indicate wether the model is being build

Constructor Detail

UMLModelElementListModel2

public UMLModelElementListModel2(java.lang.String eventName)
Constructor for UMLModelElementListModel2.


UMLModelElementListModel2

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

Method Detail

listRoleItemSet

public void listRoleItemSet(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#listRoleItemSet(ru.novosoft.uml.MElementEvent)

propertySet

public void propertySet(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#propertySet(ru.novosoft.uml.MElementEvent)

recovered

public void recovered(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#recovered(ru.novosoft.uml.MElementEvent)

removed

public void removed(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#removed(ru.novosoft.uml.MElementEvent)

roleAdded

public void roleAdded(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#roleAdded(ru.novosoft.uml.MElementEvent)

roleRemoved

public void roleRemoved(MElementEvent e)
See Also:
ru.novosoft.uml.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(java.util.Collection col)
Utility method to set the elements of this list to the contents of the given collection.

Parameters:
col -

addAll

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

Parameters:
col -

getTarget

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

Returns:
MModelElement

getChangedElement

protected java.lang.Object getChangedElement(MElementEvent e)
Utility method to get the changed element from some event e

Parameters:
e -
Returns:
Object

contains

public boolean contains(java.lang.Object elem)
Overrides:
contains in class javax.swing.DefaultListModel
See Also:
DefaultListModel.contains(java.lang.Object)

setTarget

public void setTarget(java.lang.Object target)
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:
target -

isValidElement

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

Parameters:
element -

isValidEvent

protected boolean isValidEvent(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 -
Returns:
boolean

addElement

public void addElement(java.lang.Object obj)
Overrides:
addElement in class javax.swing.DefaultListModel
See Also:
DefaultListModel.addElement(java.lang.Object)

setEventName

protected void setEventName(java.lang.String eventName)
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:
eventName - 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(org.argouml.ui.targetmanager.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(org.argouml.ui.targetmanager.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(org.argouml.ui.targetmanager.TargetEvent)

fireContentsChanged

protected void fireContentsChanged(java.lang.Object source,
                                   int index0,
                                   int index1)
Overrides:
fireContentsChanged in class javax.swing.AbstractListModel
See Also:
AbstractListModel.fireContentsChanged(java.lang.Object, int, int)

fireIntervalAdded

protected void fireIntervalAdded(java.lang.Object source,
                                 int index0,
                                 int index1)
Overrides:
fireIntervalAdded in class javax.swing.AbstractListModel
See Also:
AbstractListModel.fireIntervalAdded(java.lang.Object, int, int)

fireIntervalRemoved

protected void fireIntervalRemoved(java.lang.Object source,
                                   int index0,
                                   int index1)
Overrides:
fireIntervalRemoved in class javax.swing.AbstractListModel
See Also:
AbstractListModel.fireIntervalRemoved(java.lang.Object, int, int)


ArgoUML © 1996-2003 (20030919)ArgoUML Project HomeArgoUML Cookbook