org.argouml.uml.ui
Class UMLComboBoxModel2

java.lang.Object
  |
  +--javax.swing.AbstractListModel
        |
        +--org.argouml.uml.ui.UMLComboBoxModel2
All Implemented Interfaces:
javax.swing.ComboBoxModel, java.util.EventListener, javax.swing.ListModel, ru.novosoft.uml.MElementListener, java.io.Serializable
Direct Known Subclasses:
UMLAssociationRoleBaseComboBoxModel, UMLExtendBaseComboBoxModel, UMLExtendExtensionComboBoxModel, UMLFeatureOwnerComboBoxModel, UMLGeneralizationPowertypeComboBoxModel, UMLIncludeAdditionComboBoxModel, UMLIncludeBaseComboBoxModel, UMLMessageActivatorComboBoxModel, UMLModelElementNamespaceComboBoxModel, UMLModelElementStereotypeComboBoxModel, UMLMultiplicityComboBoxModel, UMLReceptionSignalComboBoxModel, UMLStructuralFeatureTypeComboBoxModel, UMLSubmachineStateComboBoxModel

public abstract class UMLComboBoxModel2
extends javax.swing.AbstractListModel
implements ru.novosoft.uml.MElementListener, javax.swing.ComboBoxModel

ComboBoxmodel for UML modelelements. This implementation does not use reflection and seperates Model, View and Controller better then does UMLComboBoxModel. In the future UMLComboBoxModel and UMLComboBox will be replaced with this implementation to improve performance.

See Also:
Serialized Form

Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
UMLComboBoxModel2(java.lang.String propertySetName, boolean clearable)
          Constructs a model for a combobox.
 
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 o)
           
protected abstract  void buildModelList()
          Builds the list of elements and sets the selectedIndex to the currently selected item if there is one.
 boolean contains(java.lang.Object elem)
          Returns true if some object elem is contained by the list of choices
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(ru.novosoft.uml.MElementEvent e)
          Utility method to get the changed element from some event e
 java.lang.Object getElementAt(int index)
           
 int getIndexOf(java.lang.Object o)
           
 java.lang.Object getSelectedItem()
           
protected abstract  java.lang.Object getSelectedModelElement()
          Gets the modelelement that is selected in the NSUML model.
 int getSize()
           
protected  java.lang.Object getTarget()
          Utility method to get the target.
protected abstract  boolean isValidElement(java.lang.Object element)
          Returns true if the given element is valid, i.e. it may be added to the list of elements.
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)
          If the property that this comboboxmodel depicts is changed by the NSUML model, this method will make sure that it is changed in the comboboxmodel too.
 void recovered(ru.novosoft.uml.MElementEvent e)
           
protected  void removeAll(java.util.Collection col)
          Utility method to remove a collection of elements from the model
 void removeAllElements()
           
 void removed(ru.novosoft.uml.MElementEvent e)
           
 void removeElement(java.lang.Object o)
           
 void roleAdded(ru.novosoft.uml.MElementEvent e)
           
 void roleRemoved(ru.novosoft.uml.MElementEvent e)
           
protected  void setElements(java.util.Collection elements)
          Utility method to change all elements in the list with modelelements at once.
 void setSelectedItem(java.lang.Object o)
           
protected  void setTarget(java.lang.Object target)
          Sets the target.
 void targetChanged(java.lang.Object newTarget)
           
 void targetReasserted(java.lang.Object newTarget)
           
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Constructor Detail

UMLComboBoxModel2

public UMLComboBoxModel2(java.lang.String propertySetName,
                         boolean clearable)
Constructs a model for a combobox. The container given is used to retreive the target that is manipulated through this combobox. If clearable is true, the user can select null in the combobox and thereby clear the attribute in the model.
Parameters:
container -  
propertySetName - The name of the NSUML event that must be fired to set the selected item programmatically (via setting the NSUML model)
Throws:
java.lang.IllegalArgumentException - if one of the arguments is null
Method Detail

listRoleItemSet

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

propertySet

public void propertySet(ru.novosoft.uml.MElementEvent e)
If the property that this comboboxmodel depicts is changed by the NSUML model, this method will make sure that it is changed in the comboboxmodel too.
Specified by:
propertySet in interface ru.novosoft.uml.MElementListener
See Also:
MElementListener.propertySet(MElementEvent)

recovered

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

removed

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

roleAdded

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

roleRemoved

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

targetChanged

public void targetChanged(java.lang.Object newTarget)

targetReasserted

public void targetReasserted(java.lang.Object newTarget)

isValidElement

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

buildModelList

protected abstract void buildModelList()
Builds the list of elements and sets the selectedIndex to the currently selected item if there is one. Called from targetChanged every time the target of the proppanel is changed.

setElements

protected void setElements(java.util.Collection elements)
Utility method to change all elements in the list with modelelements at once.
Parameters:
elements -  

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

removeAll

protected void removeAll(java.util.Collection col)
Utility method to remove a collection of elements from the model
Parameters:
col -  

addAll

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

getChangedElement

protected java.lang.Object getChangedElement(ru.novosoft.uml.MElementEvent e)
Utility method to get the changed element from some event e
Parameters:
e -  
Returns:
Object

setTarget

protected 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 -  

getSelectedModelElement

protected abstract java.lang.Object getSelectedModelElement()
Gets the modelelement that is selected in the NSUML model. For example, say that this ComboBoxmodel contains all namespaces (as in UMLNamespaceComboBoxmodel) , this method should return the namespace that owns the target then.
Returns:
Object

getElementAt

public java.lang.Object getElementAt(int index)
Specified by:
getElementAt in interface javax.swing.ListModel
Overrides:
getElementAt in class javax.swing.AbstractListModel
See Also:
ListModel.getElementAt(int)

getSize

public int getSize()
Specified by:
getSize in interface javax.swing.ListModel
Overrides:
getSize in class javax.swing.AbstractListModel
See Also:
ListModel.getSize()

getIndexOf

public int getIndexOf(java.lang.Object o)

addElement

public void addElement(java.lang.Object o)

setSelectedItem

public void setSelectedItem(java.lang.Object o)
Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel

removeElement

public void removeElement(java.lang.Object o)

removeAllElements

public void removeAllElements()

getSelectedItem

public java.lang.Object getSelectedItem()
Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel

contains

public boolean contains(java.lang.Object elem)
Returns true if some object elem is contained by the list of choices
Parameters:
elem -  
Returns:
boolean

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 -  
Returns:
boolean

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 (c) 1996-2002
ArgoUML Project Home
ArgoUML Cookbook