ix.iview
Class AbstractSetEditor

java.lang.Object
  extended by ix.iview.AbstractSetEditor
Direct Known Subclasses:
AbstractUISetEditor

public abstract class AbstractSetEditor
extends java.lang.Object

Support for editing sets of objects (e.g. constraints) Looks after adding/removing/editing the objects and keeping the set consistent. Handles overwrites, finding objects in the set, working out whether the set has changed.


Field Summary
protected static int ADD
           
protected  java.util.HashSet added
          list of Objects added to the set (unless removed).
protected static int CANCEL
          Constants for handling overwrite
protected  java.util.HashSet edited
          list of Objects edited in the set (unless added).
protected  java.lang.String label
           
 ObjectManager manager
           
protected  StableHashMap members
          List of objects in the editor.
protected static int NEWNAME
           
protected  java.util.HashMap originals
          original to copy map; note that new Objects do *not* appear
protected static int OVERWRITE
           
protected  java.util.HashSet removed
          list of Objects removed from the set (unless added).
 
Constructor Summary
AbstractSetEditor(ObjectManager manager, java.util.LinkedList objects)
           
 
Method Summary
 boolean addConstruct(java.lang.Object object)
          Adds a given construct to the set.
 void addedObject(java.lang.Object oo, java.lang.Object original)
           
 void clear()
           
abstract  java.lang.Object cloneConstruct(java.lang.Object o)
          Clones the given construct so as not to overwrite the original.
 java.util.List collectConstructChanges()
          Collects descriptions of any changes in constructs in the set.
 void ensureConstruct(java.lang.Object object)
          Adds a given construct to the set unless it is already there or undefined.
 java.lang.Object findOwnObject(java.lang.Object object)
          Finds an ownObject from the given Object by looking it up in the "originals" list.
 void fireConstructAdded(java.lang.Object object)
           
 void fireConstructEdited(java.lang.Object object)
           
 void fireConstructRemoved(java.lang.Object object)
           
 java.util.LinkedList getAllConstructs()
           
abstract  java.lang.String getName(java.lang.Object object)
          Gets a string representation of the object to identify it uniquely
 java.lang.Object getOriginal(java.lang.Object object)
          Finds the original version of the given object in the originals map
 java.util.LinkedList getOriginals()
          Gets all original objects from the originals map.
 java.lang.Object getOwnObject(java.lang.Object object)
           
abstract  java.lang.Object getStringObject(java.lang.String name)
          Finds a construct whose getName(Object) matches the given string.
 boolean handleNameClash(UIObject changeO, java.lang.String newName, java.lang.Object old)
          The two given named objects clash if changeO changes its name to newName.
 boolean hasChangedConstructs()
          Finds out whether any constructs in the set have changed.
 boolean hasChangedFromOriginal(java.lang.Object o)
           
 boolean hasOriginal(java.lang.Object object)
          Checks whether the given object has an original base object
 boolean isCurrentOwnObject(java.lang.Object o)
           
 boolean isEmpty()
          Checks whether there are objects in the set
abstract  boolean isEmpty(java.lang.Object object)
          Checks whether the given object is empty
 boolean isLoading()
           
abstract  boolean isOwnObject(java.lang.Object object)
          Checks whether the given object is one of this editor's own, e.g.
abstract  boolean isUndefined(java.lang.Object object)
          Checks whether the given object is undefined
abstract  java.util.LinkedList makeOriginalList()
          Makes a list of original objects
abstract  java.lang.Object makeOwnObject(java.lang.Object object)
          Makes an own object from the given one
 java.lang.Object newOwnObject(java.lang.Object object)
           
 java.lang.String print()
           
 java.lang.String printSet()
           
 void removeConstruct(java.lang.Object object)
           
 void resetEdits()
           
abstract  boolean sameConstruct(java.lang.Object one, java.lang.Object other)
          Checks whether the two given objects have the same specifications.
abstract  void setLegalName(java.lang.Object object, java.lang.String name)
          Sets a string representation of the object that identifies it uniquely
 void setManager(ObjectManager manager, java.util.LinkedList objects)
           
abstract  void setName(java.lang.Object object, java.lang.String name)
          Sets a string representation of the object that identifies it uniquely
 void setObjects(java.util.LinkedList objects)
           
 void setOverwrite(boolean onOff)
           
 void updateConstruct(java.lang.Object object)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manager

public ObjectManager manager

label

protected java.lang.String label

CANCEL

protected static final int CANCEL
Constants for handling overwrite

See Also:
Constant Field Values

ADD

protected static final int ADD
See Also:
Constant Field Values

OVERWRITE

protected static final int OVERWRITE
See Also:
Constant Field Values

NEWNAME

protected static final int NEWNAME
See Also:
Constant Field Values

members

protected StableHashMap members
List of objects in the editor. Needed to preserve input order.


added

protected java.util.HashSet added
list of Objects added to the set (unless removed).


edited

protected java.util.HashSet edited
list of Objects edited in the set (unless added).


removed

protected java.util.HashSet removed
list of Objects removed from the set (unless added).


originals

protected java.util.HashMap originals
original to copy map; note that new Objects do *not* appear

Constructor Detail

AbstractSetEditor

public AbstractSetEditor(ObjectManager manager,
                         java.util.LinkedList objects)
Method Detail

setManager

public void setManager(ObjectManager manager,
                       java.util.LinkedList objects)

setObjects

public void setObjects(java.util.LinkedList objects)

clear

public void clear()

resetEdits

public void resetEdits()

isLoading

public boolean isLoading()

setOverwrite

public void setOverwrite(boolean onOff)

isOwnObject

public abstract boolean isOwnObject(java.lang.Object object)
Checks whether the given object is one of this editor's own, e.g. UIRefinement


sameConstruct

public abstract boolean sameConstruct(java.lang.Object one,
                                      java.lang.Object other)
Checks whether the two given objects have the same specifications.


makeOwnObject

public abstract java.lang.Object makeOwnObject(java.lang.Object object)
Makes an own object from the given one


makeOriginalList

public abstract java.util.LinkedList makeOriginalList()
Makes a list of original objects


getName

public abstract java.lang.String getName(java.lang.Object object)
Gets a string representation of the object to identify it uniquely


setName

public abstract void setName(java.lang.Object object,
                             java.lang.String name)
Sets a string representation of the object that identifies it uniquely


setLegalName

public abstract void setLegalName(java.lang.Object object,
                                  java.lang.String name)
Sets a string representation of the object that identifies it uniquely


getStringObject

public abstract java.lang.Object getStringObject(java.lang.String name)
Finds a construct whose getName(Object) matches the given string.

Returns:
an Object if it exists, otherwise null.

isEmpty

public abstract boolean isEmpty(java.lang.Object object)
Checks whether the given object is empty


isUndefined

public abstract boolean isUndefined(java.lang.Object object)
Checks whether the given object is undefined


cloneConstruct

public abstract java.lang.Object cloneConstruct(java.lang.Object o)
                                         throws java.lang.CloneNotSupportedException
Clones the given construct so as not to overwrite the original.

Throws:
java.lang.CloneNotSupportedException

isCurrentOwnObject

public boolean isCurrentOwnObject(java.lang.Object o)

hasOriginal

public boolean hasOriginal(java.lang.Object object)
Checks whether the given object has an original base object


getOriginals

public java.util.LinkedList getOriginals()
Gets all original objects from the originals map. If this map is built in a lazy way (as for Refinements), make sure that this is overwiritten to look in the original domain.


getOriginal

public java.lang.Object getOriginal(java.lang.Object object)
Finds the original version of the given object in the originals map


isEmpty

public boolean isEmpty()
Checks whether there are objects in the set


ensureConstruct

public void ensureConstruct(java.lang.Object object)
Adds a given construct to the set unless it is already there or undefined. Checks originals, added and edited ones.


addConstruct

public boolean addConstruct(java.lang.Object object)
Adds a given construct to the set. Checks two things: whether the object is empty (nothing done), and whether it should overwrite an existing one with the same name.

Returns:
false if nothing done, true if added (inc mod)

handleNameClash

public boolean handleNameClash(UIObject changeO,
                               java.lang.String newName,
                               java.lang.Object old)
The two given named objects clash if changeO changes its name to newName. Offer choices: - change oldO name: legal-set changeO temporary name, get oldO name from user and set it on oldO, set newName in changeO - change newName: get name from user and setName that on changeO - or forget the new name and keep changeO's old name.

Returns:
true if changes are made, false for last option.

hasChangedFromOriginal

public boolean hasChangedFromOriginal(java.lang.Object o)

updateConstruct

public void updateConstruct(java.lang.Object object)

removeConstruct

public void removeConstruct(java.lang.Object object)

hasChangedConstructs

public boolean hasChangedConstructs()
Finds out whether any constructs in the set have changed. The set has not changed if there are no added/edited/removed notes


collectConstructChanges

public java.util.List collectConstructChanges()
Collects descriptions of any changes in constructs in the set.


newOwnObject

public java.lang.Object newOwnObject(java.lang.Object object)

getOwnObject

public java.lang.Object getOwnObject(java.lang.Object object)

findOwnObject

public java.lang.Object findOwnObject(java.lang.Object object)
Finds an ownObject from the given Object by looking it up in the "originals" list.

Returns:
- the ownObject found or null

addedObject

public void addedObject(java.lang.Object oo,
                        java.lang.Object original)

getAllConstructs

public java.util.LinkedList getAllConstructs()

fireConstructAdded

public void fireConstructAdded(java.lang.Object object)

fireConstructEdited

public void fireConstructEdited(java.lang.Object object)

fireConstructRemoved

public void fireConstructRemoved(java.lang.Object object)

print

public java.lang.String print()

printSet

public java.lang.String printSet()