ix.iview.domain
Class UIDomain

java.lang.Object
  |
  +--ix.iview.domain.UIDomain
All Implemented Interfaces:
DomainListener, java.util.EventListener, Named, UIObject

public class UIDomain
extends java.lang.Object
implements UIObject, Named, DomainListener

Mirrors the Domain for safe editing and adds UI things and change management. A UIDomain maintains the link to a base domain. It keeps track of UIObjects that have been edited/added/removed and can publish these changes in the base domain. UIDomain also contains a link to the DomainEditor which is the one that keeps track of which uiDomain is current.


Field Summary
 Annotations annotations
          name of the original domain
protected  java.lang.String baseReference
           
 java.util.HashMap graphs
          list of graphs that apply to Refinements; should be UIRefinement slot
 boolean loading
           
 java.lang.String name
           
 
Constructor Summary
UIDomain(Domain baseDomain, DomainEditor editor)
           
UIDomain(DomainEditor editor)
           
UIDomain(java.lang.String name, DomainEditor editor)
           
 
Method Summary
 void addConstruct(UIObject object)
           
 void addedObject(UIObject uio, IXObject original)
           
 void addGraph(Named g)
           
 void addToDomain(Domain domain)
          Adds the contents of this UIObject to the domain (part of publish).
 void addUIDomainListener(UIDomainListener listener)
           
 void analyseDomain()
           
 void clear()
           
 void clearBase()
           
 void clearDraft()
          Clear all constructs in the draft domain.
 void clearThis()
           
 java.lang.Object clone()
           
 UIObject findUIObject(IXObject object)
           
 UIObject findUIObject(java.lang.String name)
           
 void fireConstructAdded(RefinementEvent e)
           
 void fireDomainCleared()
           
 void fireDomainEdited()
          The domain's own fields changed (currently only name)
 void fireDomainSet(Domain domain)
           
 void fireGraphAdded(java.lang.Object g)
           
 void fireUIConstructAdded(UIObject object)
           
 void fireUIConstructEdited(UIObject object)
           
 void fireUIConstructRemoved(UIObject object)
           
 void fullSaveToDomain()
           
 void fullSaveToDomain(java.lang.Object domainObject)
           
 java.util.List getAllConstructs()
           
 LList getAllGraphs()
           
 java.util.List getAllRefinements()
           
 Annotations getAnnotations()
           
 java.lang.Class getBaseClass()
          Gets the class of objects that can represent this one in the domain.
 IXObject getBaseObject()
          Gets the object that corresponds to this one in the domain.
 java.lang.Object getBaseReference()
          Gets the Id that can be used to identify the base object in the domain.
 Domain getDomain()
          Gets the base domain.
 java.io.File getDomainFile(java.io.File file)
           
 java.util.Set getMatchingRefinements(LList pattern)
           
 java.util.HashSet getMatchingUIRefinements(LList pattern, java.util.List domainMatches)
           
 java.lang.String getName()
           
 Named getNamedGraph(java.lang.String name)
           
 java.lang.Object getNamedRefinement(java.lang.String name)
           
 UIDomain getUIDomain()
          Gets the ui domain of which this object is part.
 UIObject getUIObject(IXObject object)
           
 boolean hasChanged()
          Finds out whether the domain has changed from the draft.
 boolean hasChanged(Domain domain)
          Finds out whether the domain has changed from the given one.
 boolean hasChangedAll()
          Finds out whether the domain and its constructs have changed from the draft.
 boolean hasChangedAll(Domain domain)
          Finds out whether anything in the domain (inc.
 boolean hasChangedAllFromOriginal()
          Finds out whether the domain and its constructs have changed from the original.
 boolean hasChangedConstructs(Domain domain)
          Finds out whether any constructs in the domain have changed from the given one.
 boolean hasChangedConstructsFromOriginal()
          Finds out whether the domain and its constructs have changed from the original.
 boolean hasChangedFromOriginal()
          Finds out whether the domain has changed from the published/original one.
 boolean hasOriginal()
          Determines whether the object has an original in the base domain.
 void insertDomain()
           
 boolean isEmpty()
          Determines whether the object has any information in it.
protected  boolean isMatchingRefinement(LList pattern, Refinement r)
          Checks whether the given refinement matches the pattern.
protected  boolean isMatchingRefinement(LList pattern, UIRefinement uir)
          Checks whether the given refinement matches the pattern.
 void loadDomain()
          Clears the draft domain (noting all of original domain as removed) and loads a domain-file into the draft domain.
 void loadFromDomain()
          Copy the name of the original domain
 void loadFromDomain(java.lang.Object domainObject)
          Loads the contents of this object from the given object.
 void loadFromOriginal()
          Loads the contents of this object from its original domain object.
 IXObject makeBaseObject()
          Makes an empty object of the right class that can represent this UIObject in the domain.
 void moveToUIDomain(UIDomain uiDomain)
          Move the object from its current UIDomain to the given one.
 boolean nameHasChanged(java.lang.Object nameThing)
          Determines whether the object's identifying fields have changed
 UIObject newUIObject(IXObject object)
           
 void noteChange()
          Get the UIDomain to note the change of this object.
 java.lang.String print()
           
 void publishToDomain()
           
 void refinementAdded(RefinementEvent e)
           
 void removeConstruct(IXObject object)
           
 void removeConstruct(UIObject object)
           
 void removeFromDomain(Domain domain)
          Removes the object's corresponding base object from the domain.
 void removeFromDomain(Domain domain, java.lang.Object o)
           
 void removeNamedGraph(java.lang.String name)
           
 void removeUIDomainListener(UIDomainListener listener)
           
 void revertToOriginal()
          Reverts the domain and all its construct to the last published domain.
 java.io.File saveDomain()
          Save the UIDomain to a local file - does not publish! If the domain has been saved before, it uses the previous file (warning about overwriting).
 java.io.File saveDomain(java.io.File file)
          Save the UIDomain to the given local file - does not publish! Assumes that this domain is up-to-date! Call this with a null argument for saveAs behaviour.
 java.io.File saveDomainAs()
          Save the UIDomain to a local file - does not publish! If the domain has been saved before, it uses the previous file (warning about overwriting).
 void saveToDomain()
          Saves the contents of this object into its corresponding domain object.
 void saveToDomain(java.lang.Object domainObject)
          Saves the contents of this object into the given object.
 void setAnnotations(Annotations annotations)
           
 void setBaseObject(IXObject object)
          Sets the object that will represent this one in the domain.
 void setBaseReference(java.lang.Object o)
          Sets the Id that can be used to identify the base object in the domain.
 UIDomain setDomain(Domain domain)
          Makes a new uiDomain which points to the given domain.
 void setDomainFile(java.io.File file)
           
 void setName(java.lang.String name)
           
 UIDomain setNewDomain(Domain domain)
          Makes a new uiDomain which points to the given domain.
 void setUIDomainListeners(java.util.HashSet listeners)
           
 java.lang.String toString()
           
 void updateConstruct(UIObject object)
           
 void updateInDomain(Domain domain)
          Updates the base object in the domain with the contents of this object.
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

loading

public boolean loading

name

public java.lang.String name

baseReference

protected java.lang.String baseReference

annotations

public Annotations annotations
name of the original domain

graphs

public java.util.HashMap graphs
list of graphs that apply to Refinements; should be UIRefinement slot
Constructor Detail

UIDomain

public UIDomain(Domain baseDomain,
                DomainEditor editor)

UIDomain

public UIDomain(DomainEditor editor)

UIDomain

public UIDomain(java.lang.String name,
                DomainEditor editor)
Method Detail

addConstruct

public void addConstruct(UIObject object)

updateConstruct

public void updateConstruct(UIObject object)

removeConstruct

public void removeConstruct(UIObject object)

removeConstruct

public void removeConstruct(IXObject object)

hasChanged

public boolean hasChanged(Domain domain)
Finds out whether the domain has changed from the given one. The domain has not changed if the domain's own fields (name) have not changed.

hasChanged

public boolean hasChanged()
Finds out whether the domain has changed from the draft.
Specified by:
hasChanged in interface UIObject

hasChangedFromOriginal

public boolean hasChangedFromOriginal()
Finds out whether the domain has changed from the published/original one.
Specified by:
hasChangedFromOriginal in interface UIObject

nameHasChanged

public boolean nameHasChanged(java.lang.Object nameThing)
Description copied from interface: UIObject
Determines whether the object's identifying fields have changed
Specified by:
nameHasChanged in interface UIObject

hasChangedAll

public boolean hasChangedAll(Domain domain)
Finds out whether anything in the domain (inc. constructs) have changed from the given one. The domain has not changed if there are no added/edited/removed notes and the domain's own fields have not changed.

hasChangedConstructs

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

hasChangedAll

public boolean hasChangedAll()
Finds out whether the domain and its constructs have changed from the draft.

hasChangedAllFromOriginal

public boolean hasChangedAllFromOriginal()
Finds out whether the domain and its constructs have changed from the original.

hasChangedConstructsFromOriginal

public boolean hasChangedConstructsFromOriginal()
Finds out whether the domain and its constructs have changed from the original.

refinementAdded

public void refinementAdded(RefinementEvent e)
Specified by:
refinementAdded in interface DomainListener

getAllRefinements

public java.util.List getAllRefinements()

getAllConstructs

public java.util.List getAllConstructs()

newUIObject

public UIObject newUIObject(IXObject object)

getNamedRefinement

public java.lang.Object getNamedRefinement(java.lang.String name)
Returns:
a UIRefinement, a Refinement, or null - depending on which exists.

getUIObject

public UIObject getUIObject(IXObject object)

findUIObject

public UIObject findUIObject(IXObject object)

findUIObject

public UIObject findUIObject(java.lang.String name)

addedObject

public void addedObject(UIObject uio,
                        IXObject original)

getMatchingRefinements

public java.util.Set getMatchingRefinements(LList pattern)

getMatchingUIRefinements

public java.util.HashSet getMatchingUIRefinements(LList pattern,
                                                  java.util.List domainMatches)

isMatchingRefinement

protected boolean isMatchingRefinement(LList pattern,
                                       UIRefinement uir)
Checks whether the given refinement matches the pattern. If it has been removed, it never matches. If it has been added or edited, it matches if the patterns match.

isMatchingRefinement

protected boolean isMatchingRefinement(LList pattern,
                                       Refinement r)
Checks whether the given refinement matches the pattern. It matches if the patterns match.

saveToDomain

public void saveToDomain()
Description copied from interface: UIObject
Saves the contents of this object into its corresponding domain object. This can be done without worries about the original because if the UIObject has a base object, it is always a clone of the original.
Specified by:
saveToDomain in interface UIObject

fullSaveToDomain

public void fullSaveToDomain()

saveToDomain

public void saveToDomain(java.lang.Object domainObject)
Description copied from interface: UIObject
Saves the contents of this object into the given object.
Specified by:
saveToDomain in interface UIObject

fullSaveToDomain

public void fullSaveToDomain(java.lang.Object domainObject)

publishToDomain

public void publishToDomain()

loadFromDomain

public void loadFromDomain()
Copy the name of the original domain
Specified by:
loadFromDomain in interface UIObject

loadFromDomain

public void loadFromDomain(java.lang.Object domainObject)
Description copied from interface: UIObject
Loads the contents of this object from the given object. The given object should be of the right class (same as the result of getBaseClass()).
Specified by:
loadFromDomain in interface UIObject

loadFromOriginal

public void loadFromOriginal()
Description copied from interface: UIObject
Loads the contents of this object from its original domain object.
Specified by:
loadFromOriginal in interface UIObject

revertToOriginal

public void revertToOriginal()
Reverts the domain and all its construct to the last published domain. If the domain has not been published, reverts to the original (usually an empty domain).

removeFromDomain

public void removeFromDomain(Domain domain,
                             java.lang.Object o)

addUIDomainListener

public void addUIDomainListener(UIDomainListener listener)

setUIDomainListeners

public void setUIDomainListeners(java.util.HashSet listeners)

removeUIDomainListener

public void removeUIDomainListener(UIDomainListener listener)

fireConstructAdded

public void fireConstructAdded(RefinementEvent e)

fireUIConstructAdded

public void fireUIConstructAdded(UIObject object)

fireUIConstructEdited

public void fireUIConstructEdited(UIObject object)

fireUIConstructRemoved

public void fireUIConstructRemoved(UIObject object)

fireDomainEdited

public void fireDomainEdited()
The domain's own fields changed (currently only name)

fireDomainCleared

public void fireDomainCleared()

fireDomainSet

public void fireDomainSet(Domain domain)

getDomain

public Domain getDomain()
Description copied from interface: UIObject
Gets the base domain.
Specified by:
getDomain in interface UIObject

getUIDomain

public UIDomain getUIDomain()
Description copied from interface: UIObject
Gets the ui domain of which this object is part.
Specified by:
getUIDomain in interface UIObject

setDomain

public UIDomain setDomain(Domain domain)
Makes a new uiDomain which points to the given domain. Transfers its own listeners to the new uiDomain and points the editor to the new uiDomain (which should free this domain to be deleted)

setNewDomain

public UIDomain setNewDomain(Domain domain)
Makes a new uiDomain which points to the given domain. Transfers its own listeners to the new uiDomain and points the editor to the new uiDomain (which should free this domain to be deleted)

hasOriginal

public boolean hasOriginal()
Description copied from interface: UIObject
Determines whether the object has an original in the base domain.
Specified by:
hasOriginal in interface UIObject

getBaseObject

public IXObject getBaseObject()
Description copied from interface: UIObject
Gets the object that corresponds to this one in the domain.
Specified by:
getBaseObject in interface UIObject

makeBaseObject

public IXObject makeBaseObject()
Description copied from interface: UIObject
Makes an empty object of the right class that can represent this UIObject in the domain.
Specified by:
makeBaseObject in interface UIObject

setBaseObject

public void setBaseObject(IXObject object)
Description copied from interface: UIObject
Sets the object that will represent this one in the domain.
Specified by:
setBaseObject in interface UIObject

getBaseReference

public java.lang.Object getBaseReference()
Description copied from interface: UIObject
Gets the Id that can be used to identify the base object in the domain.
Specified by:
getBaseReference in interface UIObject

setBaseReference

public void setBaseReference(java.lang.Object o)
Description copied from interface: UIObject
Sets the Id that can be used to identify the base object in the domain.
Specified by:
setBaseReference in interface UIObject

getBaseClass

public java.lang.Class getBaseClass()
Description copied from interface: UIObject
Gets the class of objects that can represent this one in the domain.
Specified by:
getBaseClass in interface UIObject

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object

isEmpty

public boolean isEmpty()
Description copied from interface: UIObject
Determines whether the object has any information in it.
Specified by:
isEmpty in interface UIObject

clearThis

public void clearThis()

clear

public void clear()

clearBase

public void clearBase()

clearDraft

public void clearDraft()
Clear all constructs in the draft domain. If there is a bas-domain, note that all its constructs are removed.

getName

public java.lang.String getName()
Specified by:
getName in interface Named

setName

public void setName(java.lang.String name)
Specified by:
setName in interface UIObject

getAnnotations

public Annotations getAnnotations()

setAnnotations

public void setAnnotations(Annotations annotations)

setDomainFile

public void setDomainFile(java.io.File file)

getDomainFile

public java.io.File getDomainFile(java.io.File file)

saveDomain

public java.io.File saveDomain()
Save the UIDomain to a local file - does not publish! If the domain has been saved before, it uses the previous file (warning about overwriting). Otherwise it will ask the user for a file.

saveDomainAs

public java.io.File saveDomainAs()
Save the UIDomain to a local file - does not publish! If the domain has been saved before, it uses the previous file (warning about overwriting). Otherwise it will ask the user for a file.

saveDomain

public java.io.File saveDomain(java.io.File file)
Save the UIDomain to the given local file - does not publish! Assumes that this domain is up-to-date! Call this with a null argument for saveAs behaviour.

analyseDomain

public void analyseDomain()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

print

public java.lang.String print()
Specified by:
print in interface UIObject

insertDomain

public void insertDomain()

loadDomain

public void loadDomain()
Clears the draft domain (noting all of original domain as removed) and loads a domain-file into the draft domain.

addGraph

public void addGraph(Named g)

fireGraphAdded

public void fireGraphAdded(java.lang.Object g)

getAllGraphs

public LList getAllGraphs()

getNamedGraph

public Named getNamedGraph(java.lang.String name)

removeNamedGraph

public void removeNamedGraph(java.lang.String name)

addToDomain

public void addToDomain(Domain domain)
Description copied from interface: UIObject
Adds the contents of this UIObject to the domain (part of publish).
Specified by:
addToDomain in interface UIObject

updateInDomain

public void updateInDomain(Domain domain)
Description copied from interface: UIObject
Updates the base object in the domain with the contents of this object.
Specified by:
updateInDomain in interface UIObject

removeFromDomain

public void removeFromDomain(Domain domain)
Description copied from interface: UIObject
Removes the object's corresponding base object from the domain.
Specified by:
removeFromDomain in interface UIObject

moveToUIDomain

public void moveToUIDomain(UIDomain uiDomain)
Description copied from interface: UIObject
Move the object from its current UIDomain to the given one.
Specified by:
moveToUIDomain in interface UIObject

noteChange

public void noteChange()
Description copied from interface: UIObject
Get the UIDomain to note the change of this object.
Specified by:
noteChange in interface UIObject