org.argouml.uml.ui
Class UMLComboBoxModel

java.lang.Object
  |
  +--javax.swing.AbstractListModel
        |
        +--org.argouml.uml.ui.UMLComboBoxModel
All Implemented Interfaces:
java.awt.event.ActionListener, javax.swing.ComboBoxModel, java.util.EventListener, javax.swing.ListModel, java.io.Serializable, UMLUserInterfaceComponent
Direct Known Subclasses:
UMLClassifierComboBoxModel

Deprecated. as of ArgoUml 0.13.5 (10-may-2003), replaced by UMLComboBoxModel2, this class is part of the 'old'(pre 0.13.*) implementation of proppanels that used reflection a lot.

public class UMLComboBoxModel
extends javax.swing.AbstractListModel
implements javax.swing.ComboBoxModel, UMLUserInterfaceComponent, java.awt.event.ActionListener

A model for use with drop down combo boxes. Used to supply the correct model for the "type" and "stereotype" drop downs used on several of the property panels, as well as others.

Warning. This is implemented by TreeSet, a set class, that therefore does not permit duplicates. If two entries in the drop down have the same fully qualified name, then they will appear only once in the list. This causes problems for example with lists of objects in diagrams, where default naming means newly created objects have the same name.

See Also:
Serialized Form

Field Summary
protected  boolean _addElementsFromProfileModel
          Deprecated. Flag to indicate that the drop down should include elements from the model included within the profile.
protected  boolean _allowVoid
          Deprecated. Flag to indicate that an empty entry should be included (first) in the drop down list.
protected  UMLUserInterfaceContainer _container
          Deprecated. The container (PropPanel) in which we are used.
protected  java.lang.reflect.Method _filter
          Deprecated. A method returning a boolean, to indicate whether a specific ru.novosoft.uml.foundation.core.MModelElement should be allowed in the combo box.
protected  java.lang.reflect.Method _getMethod
          Deprecated. A method which gets the specific value currently associated with this combo box (the selected value) from the target NSUML object associated with the container.
protected  java.lang.String _property
          Deprecated. The name of the NSUML event that affects our data model.
protected  java.lang.Object _selectedItem
          Deprecated. The currently selected object in the combo box (displayed when the drop-down is not being shown).
protected  java.util.TreeSet _set
          Deprecated. The set of objects that are displayed in the drop down.
protected  java.lang.reflect.Method _setMethod
          Deprecated. A method which sets the specific value currently associated with this combo box (the selected value) in the target NSUML object associated with the container.
private static Logger cat
          Deprecated. logger
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
UMLComboBoxModel(UMLUserInterfaceContainer container, java.lang.String filter, java.lang.String property, java.lang.String getMethod, java.lang.String setMethod, boolean allowVoid, java.lang.Class elementType, boolean addElementsFromProfileModel)
          Deprecated. This method creates a UMLComboBoxModel.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Deprecated. Called when an "action" is performed.
protected  boolean addElementsFromProfileModel()
          Deprecated. Return a flag indicating if elements from the model associated with the profile are also to be used in the drop down.
protected  boolean allowVoid()
          Deprecated. Return a flag indicating if the drop down should have an empty entry (as first element).
 void collectElements(java.lang.Object ns, Profile profile, boolean isPhantom)
          Deprecated. A method to run over the current model (or part thereof), collecting all elements that meet the criteria of the filter method.
 void deleteElement(java.lang.Object removedElement)
          Deprecated. Remove an entry if it is currently in the drop down.
protected  UMLUserInterfaceContainer getContainer()
          Deprecated. Return the container (PropPanel) in which this combo box is used.
 java.lang.Object getElementAt(int index)
          Deprecated. Provide the element at a specific index in the drop down list.
protected  java.lang.reflect.Method getGetMethod()
          Deprecated. Return the method of the container, which is used to get the NSUML element associated with this comb box.
 java.lang.Object getSelectedItem()
          Deprecated. Get the selected item.
protected  java.util.TreeSet getSet()
          Deprecated. Return the sorted set of elements that are shown in the drop down of the combo box.
protected  java.lang.reflect.Method getSetMethod()
          Deprecated. Return the method of the container, which is used to set the NSUML element associated with this comb box.
 int getSize()
          Deprecated. Return the number of elements in the drop down list.
private  boolean isAcceptible(java.lang.Object element)
          Deprecated. Use the supplied filter method to identify if the supplied model element should be included in the drop down list.
 void listRoleItemSet(MElementEvent event)
          Deprecated. Invoked if a listened to NSUML element has an entry changed in a component with multiplicity.
 void propertySet(MElementEvent event)
          Deprecated. Invoked if a listened to NSUML object has an entry without multiplicity set (or an entry with multiplicity completely reset.
 void recovered(MElementEvent event)
          Deprecated. Invoked if a listened to NSUML element has been restored (by an NSUML internal method), having been removed.
 void removed(MElementEvent event)
          Deprecated. Invoked if a listened to NSUML element is deleted.
 void roleAdded(MElementEvent event)
          Deprecated. Invoked if a listened to NSUML element has an entry added to a component with multiplicity.
 void roleRemoved(MElementEvent event)
          Deprecated. Invoked if a listened to NSUML element has an entry removed from a component with multiplicity.
 void setSelectedItem(java.lang.Object selection)
          Deprecated. Set the given item as the selected item.
 void targetChanged()
          Deprecated. Invoked when the target associated with the container is changed.
 void targetReasserted()
          Deprecated. Called when navigation may have changed.
 void updateElement(java.lang.Object addedElement)
          Deprecated. Check that an entry is in the set for the drop down, and add it if it is not.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, 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
 

Field Detail

cat

private static Logger cat
Deprecated. 
logger


_container

protected UMLUserInterfaceContainer _container
Deprecated. 
The container (PropPanel) in which we are used.


_property

protected java.lang.String _property
Deprecated. 
The name of the NSUML event that affects our data model.


_filter

protected java.lang.reflect.Method _filter
Deprecated. 
A method returning a boolean, to indicate whether a specific ru.novosoft.uml.foundation.core.MModelElement should be allowed in the combo box. If the method is non-existent has the value null.


_getMethod

protected java.lang.reflect.Method _getMethod
Deprecated. 
A method which gets the specific value currently associated with this combo box (the selected value) from the target NSUML object associated with the container. Returns a ru.novosoft.uml.foundation.core.MModelElement. If the method is non-existent has the value null.


_setMethod

protected java.lang.reflect.Method _setMethod
Deprecated. 
A method which sets the specific value currently associated with this combo box (the selected value) in the target NSUML object associated with the container. Takes a ru.novosoft.uml.foundation.core.MModelElement as argument. If the method is non-existent has the value null.


_set

protected java.util.TreeSet _set
Deprecated. 
The set of objects that are displayed in the drop down.


_selectedItem

protected java.lang.Object _selectedItem
Deprecated. 
The currently selected object in the combo box (displayed when the drop-down is not being shown).


_allowVoid

protected boolean _allowVoid
Deprecated. 
Flag to indicate that an empty entry should be included (first) in the drop down list.


_addElementsFromProfileModel

protected boolean _addElementsFromProfileModel
Deprecated. 
Flag to indicate that the drop down should include elements from the model included within the profile.

Constructor Detail

UMLComboBoxModel

public UMLComboBoxModel(UMLUserInterfaceContainer container,
                        java.lang.String filter,
                        java.lang.String property,
                        java.lang.String getMethod,
                        java.lang.String setMethod,
                        boolean allowVoid,
                        java.lang.Class elementType,
                        boolean addElementsFromProfileModel)
Deprecated. 
This method creates a UMLComboBoxModel.

Parameters:
container - The container (PropPanel) that contains the ComboBox and provides access to target, formatting etc.
filter - Name of method on container that takes a ru.novosoft.uml.foundation.core.MModelElement and returns true if the element should be in the combo box list, false otherwise. Note. The supplied model element may be null.
property - Name of the NSUML event that would indicate that the selected value for the combo box has changed.
getMethod - Name of a method of the container which will get the value associated with this combo box. Returns an object of type elementType (see below).
setMethod - Name of a method of the container which will set the value associated with this combo box. Takes as argument an object of type elementType (see below).
allowVoid - A flag to indicate that the drop down list should include (in first position) an empty entry.
elementType - The base type for all elements in the combo box.
addElementsFromProfileModel - A flag to indicate that elements from the model associated with the profile should be included in the drop down list.
Method Detail

getSet

protected java.util.TreeSet getSet()
Deprecated. 
Return the sorted set of elements that are shown in the drop down of the combo box.

Returns:
The set of elements shown in the drop down.

addElementsFromProfileModel

protected boolean addElementsFromProfileModel()
Deprecated. 
Return a flag indicating if elements from the model associated with the profile are also to be used in the drop down.

Returns:
true if elements should be used from the model associated with the profile, false otherwise.

getContainer

protected UMLUserInterfaceContainer getContainer()
Deprecated. 
Return the container (PropPanel) in which this combo box is used.

Returns:
The container

allowVoid

protected boolean allowVoid()
Deprecated. 
Return a flag indicating if the drop down should have an empty entry (as first element).

Returns:
true if the drop down should have an empty entry, false otherwise.

getGetMethod

protected java.lang.reflect.Method getGetMethod()
Deprecated. 
Return the method of the container, which is used to get the NSUML element associated with this comb box.

Returns:
The method which will get the NSUML element, or null if no method is provided.

getSetMethod

protected java.lang.reflect.Method getSetMethod()
Deprecated. 
Return the method of the container, which is used to set the NSUML element associated with this comb box.

Returns:
The method which will set the NSUML element, or null if no method is provided.

setSelectedItem

public void setSelectedItem(java.lang.Object selection)
Deprecated. 
Set the given item as the selected item.

Provided to comply with the ComboBoxModel interface.

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
Parameters:
selection - The object that should be used as the selected item in the combo box.

getSelectedItem

public java.lang.Object getSelectedItem()
Deprecated. 
Get the selected item.

Provided to comply with the ComboBoxModel interface.

Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel
Returns:
The object that is currently to be used as the selected item in the combo box.

getSize

public int getSize()
Deprecated. 
Return the number of elements in the drop down list.

Provided to comply with the ListModel interface (the parent of ComboBoxModel).

Specified by:
getSize in interface javax.swing.ListModel
Returns:
The number of elements in the drop down list.

getElementAt

public java.lang.Object getElementAt(int index)
Deprecated. 
Provide the element at a specific index in the drop down list.

Provided to comply with the ListModel interface (the parent of ComboBoxModel).

Specified by:
getElementAt in interface javax.swing.ListModel
Parameters:
index - The index of the desired element.
Returns:
The element at that index, or null if index exceeds the number of elements in the set.

collectElements

public void collectElements(java.lang.Object ns,
                            Profile profile,
                            boolean isPhantom)
Deprecated. 
A method to run over the current model (or part thereof), collecting all elements that meet the criteria of the filter method.

Find all the elements in the namespace supplied. Then recurse on any of those elements that are themselves namespaces. The result is built up in _set.

Parameters:
ns - The namespace of the model (or part of the model) we are to examine.
profile - The profile to be used for additional elements and supplying formatting methods.
isPhantom - A flag which seems to indicate an entry that should not normally be displayed. This is typically used for entries in the profile model, which are only displayed when they start being used in the "real" model. A combo box entry is created for these, but they are not added to the set if there is already an element with the same "short" (i.e. formatted) name.

isAcceptible

private boolean isAcceptible(java.lang.Object element)
Deprecated. 
Use the supplied filter method to identify if the supplied model element should be included in the drop down list.

Parameters:
element - The model element to test.
Returns:
true if the element should be included in the drop down list, false otherwise.

targetChanged

public void targetChanged()
Deprecated. 
Invoked when the target associated with the container is changed.

Recompute the membership of the drop down and its selected component.

Provided to comply with the UMLUserInterfaceComponent interface.

Specified by:
targetChanged in interface UMLUserInterfaceComponent

targetReasserted

public void targetReasserted()
Deprecated. 
Called when navigation may have changed.

Null implementation provided here.

Provided to comply with the UMLUserInterfaceComponent interface.

Specified by:
targetReasserted in interface UMLUserInterfaceComponent

updateElement

public void updateElement(java.lang.Object addedElement)
Deprecated. 
Check that an entry is in the set for the drop down, and add it if it is not.

Used to support the NSUML roleAdded event, where an element is added to the namespace.

Parameters:
addedElement - The model element that should be in the set (if it has an acceptable type).

deleteElement

public void deleteElement(java.lang.Object removedElement)
Deprecated. 
Remove an entry if it is currently in the drop down.

Used to support the NSUML roleRemoved event, where an element is removed from the namespace.

Parameters:
removedElement - The model element that should no longer be in the set (if it is currently there).

roleAdded

public void roleAdded(MElementEvent event)
Deprecated. 
Invoked if a listened to NSUML element has an entry added to a component with multiplicity.

We are only interested in the "ownedElement" event name, which indicates an object has been added to a namespace.

Provided for compliance with the ru.novosoft.uml.MElementListener interface.

Parameters:
event - The event which triggered this method.

roleRemoved

public void roleRemoved(MElementEvent event)
Deprecated. 
Invoked if a listened to NSUML element has an entry removed from a component with multiplicity.

We're only interested in the case where the name is "ownedElement", indicating an element has been removed from the namespace.

Parameters:
event - The event which triggered this method.
See Also:
ru.novosoft.uml.MElementListener#roleRemoved(MElementEvent)

recovered

public void recovered(MElementEvent event)
Deprecated. 
Invoked if a listened to NSUML element has been restored (by an NSUML internal method), having been removed.

Null implementation in this case.

Parameters:
event - The event which triggered this method.
See Also:
ru.novosoft.uml.MElementListener#recovered(MElementEvent)

listRoleItemSet

public void listRoleItemSet(MElementEvent event)
Deprecated. 
Invoked if a listened to NSUML element has an entry changed in a component with multiplicity.

Null implementation in this case.

Parameters:
event - The event which triggered this method.
See Also:
ru.novosoft.uml.MElementListener#listRoleItemSet(MElementEvent)

removed

public void removed(MElementEvent event)
Deprecated. 
Invoked if a listened to NSUML element is deleted.

We must remove it from the set if it is there.

Parameters:
event - The event which triggered this method.
See Also:
ru.novosoft.uml.MElementListener#removed(MElementEvent)

propertySet

public void propertySet(MElementEvent event)
Deprecated. 
Invoked if a listened to NSUML object has an entry without multiplicity set (or an entry with multiplicity completely reset.

We are interested in changes to "name" fields, since they may appear in our set.

Warning. This only works if setNameEventListener is enabled to listen for name changes on NSUML elements other than the target.

Parameters:
event - The event which triggered this method.
See Also:
ru.novosoft.uml.MElementListener#propertySet(MElementEvent)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Deprecated. 
Called when an "action" is performed.

Called when a new selected item is chosen from the drop down list. We try to set the associated model element accordingly.

Provided to comply with the ActionListener interface, which provides for general listening support.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The event that triggered us.


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