pl.edu.agh.cast.data.model.visual
Class VisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>

java.lang.Object
  extended by pl.edu.agh.cast.data.model.property.PropertyContainer
      extended by pl.edu.agh.cast.data.model.AbstractDataSet<T>
          extended by pl.edu.agh.cast.data.model.visual.VisualDataSet<T,M>
Type Parameters:
T - type of visual element which can be in specific visual data set
M - type of wrapped presentation data set
All Implemented Interfaces:
Serializable, Observer, IDisposable, IValidatable, IDataSet<T>, Identifiable, IPropertyChangeProvider, IPropertyContainer, IVisualDataSet<T,M>
Direct Known Subclasses:
VisualSchemaDataSet

public abstract class VisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
extends AbstractDataSet<T>
implements IVisualDataSet<T,M>

Abstract implementation of IVisualDataSet.

Author:
AGH CAST Team
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface pl.edu.agh.cast.data.model.visual.IVisualDataSet
IVisualDataSet.Events
 
Nested classes/interfaces inherited from interface pl.edu.agh.cast.data.model.IDataSet
IDataSet.Properties
 
Field Summary
 
Fields inherited from interface pl.edu.agh.cast.data.model.visual.IVisualDataSet
ACCEPTED_TYPES, TYPE
 
Constructor Summary
protected VisualDataSet(VisualDataSetDescriptor descriptor)
           
protected VisualDataSet(VisualDataSetDescriptor descriptor, M model)
          Initializes data set with its descriptor and a newly created MetaPropertyManager.
protected VisualDataSet(VisualDataSetDescriptor descriptor, M model, MetaPropertyManager metaPropertyManager)
          Initializes data set with its descriptor and MetaPropertyManager.
 
Method Summary
protected  VisualDataSetDescriptor acquireDescriptor()
          Returns the non-null descriptor of this data set.
 void addPropertyChangeListener(PropertyChangeListener l)
          Add a property change listener to the object.
protected  VisualDataSetDescriptor createNewDescriptor()
          Returns new, uninitialized instance of descriptor.
protected  void firePropertyChange(String property, Object oldValue, Object newValue)
          Fires the property change event.
 Collection<Type> getAcceptedTypes()
          Returns collection of types of IElements this data set is able to accept.
 String getAllPropertiesMarkedAsLabel()
          Gets serialized map of properties marked as labels for types of elements in the data set.
 VisualDataSetDescriptor getDescriptor()
          Returns the descriptor of this data set.
 M getPresentationDataSet()
          Gets wrapped presentation data set.
 Collection<PresentationPropertyDescriptor> getPropertiesMarkedAsLabel(Type type)
          Gets collection of descriptors describing properties which should be included in label returned by IVisualElement.getVisualLabel().
protected  boolean isDescriptorValid(DataSetDescriptor descriptor)
          Checks if the descriptor is valid for the data set.
 boolean isLayoutInitialized()
          Tells if a data set has already initialized by a layout.
 boolean isSuppressLocationChangeEvents()
          Returns suppress locations change events flag.
 void markLayoutInitialized()
          Marks that a layout has been just initialized.
 void markPropertyAsLabel(Type type, PresentationPropertyDescriptor descriptor, boolean flag)
           Marks given property as label for given type.
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove a property change listener to the object.
 void setAllPropertiesMarkedAsLabel(String value)
          Sets map of of properties marked as labels for types of elements in the data set.
protected  void setLayoutInitialized(boolean value)
           
protected  void setPresentationDataSet(M pds)
          Sets the reference to the presentation data set wrapped by this visual data set.
 void setSuppressAllEvents(boolean flag)
          Sets suppress all events flag.
 void setSuppressLocationChangeEvents(boolean suppressLocationChangeEvents)
          Sets suppress location change events flag.
 
Methods inherited from class pl.edu.agh.cast.data.model.AbstractDataSet
addElement, addElements, addElements, addMetaPropertyManager, addMetaPropertyManager, addMetaPropertyManagersForAcceptedTypes, afterAddElement, afterRemoveElement, afterSetMetaPropertyManager, beforeAddElement, beforeRemoveElement, checkIfValid, equals, getAssignableElements, getCreationDate, getDescString, getElement, getElementCount, getElements, getElements, getElementTypes, getId, getMetaPropertyManager, getMetaPropertyManagers, getName, getRegisteredTypes, getType, hashCode, isElementValid, isValid, removeElement, removeElement, removeElements, removeElements, setCreationDate, setDescriptor, setElements, setId, setName, setType, toString
 
Methods inherited from class pl.edu.agh.cast.data.model.property.PropertyContainer
addProperty, createProperty, dispose, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, initializeProperties, matches, removeProperty, setMetaPropertyManager, setProperty, update
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface pl.edu.agh.cast.data.model.IDataSet
addElement, addElements, addElements, addMetaPropertyManager, addMetaPropertyManagersForAcceptedTypes, getAssignableElements, getCreationDate, getElement, getElementCount, getElements, getElements, getElementTypes, getMetaPropertyManager, getMetaPropertyManagers, getName, getRegisteredTypes, removeElement, removeElement, removeElements, removeElements, setCreationDate, setElements, setName
 
Methods inherited from interface pl.edu.agh.cast.data.model.Identifiable
getId, getType
 
Methods inherited from interface pl.edu.agh.cast.data.model.property.IPropertyContainer
addProperty, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, matches, removeProperty, setProperty
 
Methods inherited from interface java.util.Observer
update
 
Methods inherited from interface pl.edu.agh.cast.common.IValidatable
isValid
 
Methods inherited from interface pl.edu.agh.cast.common.IDisposable
dispose
 

Constructor Detail

VisualDataSet

protected VisualDataSet(VisualDataSetDescriptor descriptor)

VisualDataSet

protected VisualDataSet(VisualDataSetDescriptor descriptor,
                        M model)
Initializes data set with its descriptor and a newly created MetaPropertyManager.

Parameters:
descriptor - the visual data set descriptor
model - the presentation data set wrapped by this visual data set
Throws:
IllegalArgumentException - if any of the arguments is null

VisualDataSet

protected VisualDataSet(VisualDataSetDescriptor descriptor,
                        M model,
                        MetaPropertyManager metaPropertyManager)
Initializes data set with its descriptor and MetaPropertyManager.

Parameters:
descriptor - the visual data set descriptor
model - the presentation data set wrapped by this visual data set
metaPropertyManager - manager of data set's meta properties
Throws:
IllegalArgumentException - if any of the arguments is null
Method Detail

isDescriptorValid

protected final boolean isDescriptorValid(DataSetDescriptor descriptor)
Checks if the descriptor is valid for the data set.

This method is called by the AbstractDataSet.setDescriptor(DataSetDescriptor) method. By default it always returns true, however it can be overridden in order to define new descriptor validation rules. In such case the implementation from base class should be called inside the overridden method in order to preserve data consistency.

Overrides:
isDescriptorValid in class AbstractDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>>
Parameters:
descriptor - the descriptor to validate
Returns:
true if given descriptor is valid, false otherwise
See Also:
AbstractDataSet.isDescriptorValid(pl.edu.agh.cast.data.model.DataSetDescriptor)

createNewDescriptor

protected final VisualDataSetDescriptor createNewDescriptor()
Returns new, uninitialized instance of descriptor.

This method may be overridden in order to provide

Overrides:
createNewDescriptor in class AbstractDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>>
Returns:
new instance of data set descriptor
See Also:
AbstractDataSet.createNewDescriptor()

acquireDescriptor

protected final VisualDataSetDescriptor acquireDescriptor()
Returns the non-null descriptor of this data set. If the descriptor has not been defined yet, a new instance is created and assigned to this data set.

Overrides:
acquireDescriptor in class AbstractDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>>
Returns:
the (non-null) descriptor of this data set
See Also:
AbstractDataSet.acquireDescriptor()

getDescriptor

public final VisualDataSetDescriptor getDescriptor()
Returns the descriptor of this data set.

Specified by:
getDescriptor in interface IDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>>
Specified by:
getDescriptor in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Overrides:
getDescriptor in class AbstractDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>>
Returns:
the descriptor of this data set
See Also:
AbstractDataSet.getDescriptor()

getAcceptedTypes

public Collection<Type> getAcceptedTypes()
Returns collection of types of IElements this data set is able to accept.

This method should be overridden by all concrete subclasses.

Returns collection of types of elements this data set is able to accept.

Specified by:
getAcceptedTypes in interface IDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>>
Overrides:
getAcceptedTypes in class AbstractDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>>
Returns:
collection of element types this data set is able to accept
See Also:
AbstractDataSet.getAcceptedTypes()

getPresentationDataSet

public M getPresentationDataSet()
Gets wrapped presentation data set.

Specified by:
getPresentationDataSet in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Returns:
wrapped data set
See Also:
IVisualDataSet.getPresentationDataSet()

setPresentationDataSet

protected void setPresentationDataSet(M pds)
Sets the reference to the presentation data set wrapped by this visual data set.

Parameters:
pds - reference to presentation data set
Throws:
IllegalArgumentException - if given presentation data set is null
ModelException - if a presentation data set is already defined for this visual element

isLayoutInitialized

public boolean isLayoutInitialized()
Tells if a data set has already initialized by a layout.

Specified by:
isLayoutInitialized in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Returns:
true if data set has a layout, false otherwise
See Also:
IVisualDataSet.isLayoutInitialized()

markLayoutInitialized

public void markLayoutInitialized()
Marks that a layout has been just initialized.

Specified by:
markLayoutInitialized in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
See Also:
IVisualDataSet.markLayoutInitialized()

setLayoutInitialized

protected void setLayoutInitialized(boolean value)

getPropertiesMarkedAsLabel

public Collection<PresentationPropertyDescriptor> getPropertiesMarkedAsLabel(Type type)
Gets collection of descriptors describing properties which should be included in label returned by IVisualElement.getVisualLabel(). This method can return null, therefore the visual element is responsible for providing default property to label.

Specified by:
getPropertiesMarkedAsLabel in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Parameters:
type - sub-type of IVisualDataSet.ACCEPTED_TYPES for which properties should be returned
Returns:
collection of properties descriptor
See Also:
IVisualDataSet.getPropertiesMarkedAsLabel(pl.edu.agh.cast.data.model.Type)

markPropertyAsLabel

public void markPropertyAsLabel(Type type,
                                PresentationPropertyDescriptor descriptor,
                                boolean flag)

Marks given property as label for given type. The type must be a sub-type of IVisualDataSet.ACCEPTED_TYPES.

Note: This method does not verify if the given property name is correct.

Specified by:
markPropertyAsLabel in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Parameters:
type - type of element for which given property is marked as label
descriptor - descriptor which describes property to be marked as label
flag - true if property will be treated as label, false otherwise
See Also:
pl.edu.agh.cast.data.model.visual.IVisualDataSet#markPropertyAsLabel(pl.edu.agh.cast.data.model.Type, pl.edu.agh.cast.data.model.presentation.PresentationPropertyDescriptor)

getAllPropertiesMarkedAsLabel

public String getAllPropertiesMarkedAsLabel()
Gets serialized map of properties marked as labels for types of elements in the data set.

Note: This method is introduced only for persistence layer and should not be used elsewhere.

Specified by:
getAllPropertiesMarkedAsLabel in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Returns:
serialized map
See Also:
IVisualDataSet.getAllPropertiesMarkedAsLabel()

setAllPropertiesMarkedAsLabel

public void setAllPropertiesMarkedAsLabel(String value)
Sets map of of properties marked as labels for types of elements in the data set. The string value is deserialized to map.

Note: This method is introduced only for persistence layer and should not be used elsewhere.

Specified by:
setAllPropertiesMarkedAsLabel in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Parameters:
value - serialized map
See Also:
IVisualDataSet.setAllPropertiesMarkedAsLabel(java.lang.String)

isSuppressLocationChangeEvents

public boolean isSuppressLocationChangeEvents()
Returns suppress locations change events flag. If true, that any location change won't generate property change event.

Specified by:
isSuppressLocationChangeEvents in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Returns:
see description
See Also:
IVisualDataSet.isSuppressLocationChangeEvents()

setSuppressLocationChangeEvents

public void setSuppressLocationChangeEvents(boolean suppressLocationChangeEvents)
Sets suppress location change events flag. If set to true, any location change won't generate property change event.

Specified by:
setSuppressLocationChangeEvents in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Parameters:
suppressLocationChangeEvents - the flag
See Also:
IVisualDataSet.setSuppressLocationChangeEvents(boolean)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Add a property change listener to the object.

Specified by:
addPropertyChangeListener in interface IPropertyChangeProvider
Parameters:
l - property change listener
See Also:
#addPropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Remove a property change listener to the object.

Specified by:
removePropertyChangeListener in interface IPropertyChangeProvider
Parameters:
l - property change listener
See Also:
#removePropertyChangeListener(java.beans.PropertyChangeListener)

firePropertyChange

protected final void firePropertyChange(String property,
                                        Object oldValue,
                                        Object newValue)
Fires the property change event.

Parameters:
property - the name of the property
oldValue - the old value of the property
newValue - the new value of the property
See Also:
PropertyChangeProviderHelper.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)

setSuppressAllEvents

public void setSuppressAllEvents(boolean flag)
Sets suppress all events flag. If flag set to true all events will be ignored.

Specified by:
setSuppressAllEvents in interface IVisualDataSet<T extends IVisualElement<? extends IPresentationElement<? extends IElement>>,M extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>>
Parameters:
flag - suppress all events flag
See Also:
IVisualDataSet.setSuppressAllEvents(boolean)


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.