Class GroupElementHandle
- java.lang.Object
-
- org.eclipse.birt.report.model.api.GroupElementHandle
-
- Direct Known Subclasses:
EmptyGroupElementHandle,SimpleGroupElementHandle
public abstract class GroupElementHandle extends java.lang.ObjectThis class provides services to deal with a group of elements. It is mostly useful for some multiple-selection cases, elements of the same type(or share the same base type) can be handled as a whole. User can perform some operations on the collection of elements.For our ease-of-use purpose, we support multiple selections across type. Given a collection of elements, user can ask for their common properties(including user property definitions). Also, return a list of values that are identical for all items. Finally, return an indication of whether all elements are of the same type.
This class also supports a collection of elements contains some objects that are not a
DesignElementHandleor its subclass. For this case,getCommonPropertiesalways returns an empty list.For BIRT UI usage, the attributes view will go blank if the providing elements are not of the same type, the property sheet will show the common properties(including user property definitions).
This handle is mutable, it can be kept. The query results changed as the given elements themselves changed.
Note that the Model special handling of the case where all elements are the same type: in this case, by definition, all BIRT-defined properties are the same. (User-defined properties may differ.)
-
-
Constructor Summary
Constructors Constructor Description GroupElementHandle()Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleanallExtendedElements()Checks if all elements have extends parents or virtual parents.abstract voidclearLocalProperties()Clears values of all common properties(except the extends property) for the given collection of elements.abstract voidclearLocalPropertiesIncludeSubElement()Clears values of all common properties(except the extends property) for the given collection of elements.voidclearProperty(java.lang.String propName)Clears the value of a property on the given collection of elements if the property is a common property shared by each element.abstract java.util.ListgetCommonProperties()Returns the common properties shared by the given group of elements(including user properties).java.lang.StringgetDisplayProperty(java.lang.String propName)If the given property is a common property, value will be returned as a display value if all values within the group of elements are equal.abstract java.util.ListgetElements()Returns the list that contains the group of design elements.java.lang.StringgetLocalStringProperty(java.lang.String propName)If the given property is a common property, value will be returned as a string if all values within the group of elements are equal and one of them has a local value.abstract org.eclipse.birt.report.model.core.ModulegetModule()Returns the module.abstract ModuleHandlegetModuleHandle()Returns the handle of module.abstract GroupPropertyHandlegetPropertyHandle(java.lang.String propName)If property is shared by the group of elements, return the correspondingGroupPropertyHandle, otherwise, returnnull.java.lang.StringgetStringProperty(java.lang.String propName)If the given property is a common property, value will be returned as a string if all values within the group of elements are equal.booleanhasLocalPropertiesForExtendedElements()This method returnttruein following condition:booleanhasLocalPropertiesIncludeSubElement()This method returnttruein following condition:protected booleanhasLocalPropertiesIncludeSubElement(DesignElementHandle elementHandle)return true if the Element or subElement has local propertiesabstract booleanisExtendedElements()Returnstrueif each of the given collection of element extends has a parent.protected abstract booleanisInGroup(DesignElementHandle element)Checks whether theelementis a member ofGroupElementHandle.protected abstract booleanisPropertyReadOnly(java.lang.String propName)Checks whether a property is read-only in the property sheet.protected abstract booleanisPropertyVisible(java.lang.String propName)Checks whether a property is visible in the property sheet.abstract booleanisSameType()Indicates that if the given elements are of the same definition.java.util.IteratorpropertyIterator()Returns an iterator over the common properties.voidsetProperty(java.lang.String propName, java.lang.Object value)Set the value of a property on the given collection of elements.voidsetStringProperty(java.lang.String propName, java.lang.String value)Set the value of a property to a string .booleanshareSameValue(java.lang.String propName)Indicates whether the group of element share the same value for this property.abstract java.util.IteratorvisiblePropertyIterator()Returns an iterator over the common properties that are visible.
-
-
-
Method Detail
-
getElements
public abstract java.util.List getElements()
Returns the list that contains the group of design elements. Contents of it isDesignElementHandle- Returns:
- the list that contains the group of design elements.
-
getModule
public abstract org.eclipse.birt.report.model.core.Module getModule()
Returns the module.- Returns:
- the module
-
getModuleHandle
public abstract ModuleHandle getModuleHandle()
Returns the handle of module.- Returns:
- the handle of module
-
isSameType
public abstract boolean isSameType()
Indicates that if the given elements are of the same definition. Elements are considered of same type if their element definitions are identical.If elements have different definitions. Even the same element type, the return value is
false. For example, if the list contains anOdaDataSourceand aOdaDataSource, this method returnsfalse.- Returns:
trueif the given elements are of the same type; returnfalseif elements are of different element types, or the given list is empty, or the list contains any object that is not an instance ofDesignElementHandle.
-
getCommonProperties
public abstract java.util.List getCommonProperties()
Returns the common properties shared by the given group of elements(including user properties). Contents of the list is element property definitions. If elements do not share any common property, return an empty list.- Returns:
- the common properties shared by the given group of elements. If
elements do not share any common property, or the given list is
empty, or the list contains any item that is not an instance of
DesignElementHandle, return an empty list.
-
propertyIterator
public final java.util.Iterator propertyIterator()
Returns an iterator over the common properties. Contents of the iterator are handles to the common properties, type of them isGroupPropertyHandle. Note: remove is not support for the iterator.- Returns:
- an iterator over the common properties. Contents of the iterator are
handles to the common properties, type of them is
GroupPropertyHandle
-
visiblePropertyIterator
public abstract java.util.Iterator visiblePropertyIterator()
Returns an iterator over the common properties that are visible. Contents of the iterator are handles to the common properties, type of them isGroupPropertyHandle. Note: remove is not support for the iterator.- Returns:
- an iterator over the common properties. Contents of the iterator are
handles to the common properties, type of them is
GroupPropertyHandle
-
isPropertyVisible
protected abstract boolean isPropertyVisible(java.lang.String propName)
Checks whether a property is visible in the property sheet. The visible property is visible in allelements.- Parameters:
propName- the property name- Returns:
trueif it is visible. Otherwisefalse.
-
clearLocalProperties
public abstract void clearLocalProperties() throws SemanticExceptionClears values of all common properties(except the extends property) for the given collection of elements. Clearing a property removes any value set for the property on this element. After this, the element will now inherit the property from its parent element, style, or from the default value for the property. Note: this method clear the values of local properties ( not include sub element)- Throws:
SemanticException- if the property is not defined on this element
-
clearLocalPropertiesIncludeSubElement
public abstract void clearLocalPropertiesIncludeSubElement() throws SemanticExceptionClears values of all common properties(except the extends property) for the given collection of elements. Clearing a property removes any value set for the property on this element. After this, the element will now inherit the property from its parent element, style, or from the default value for the property. Note: this method clear all the values of local properties (include sub element)- Throws:
SemanticException- if the property is not defined on this element
-
isExtendedElements
public abstract boolean isExtendedElements()
Returnstrueif each of the given collection of element extends has a parent. Returnsfalseotherwise. If the collection has no elements, also returnfalse- Returns:
trueif each of the given collection of element extends has a parent. Returnsfalseotherwise. If the collection has no elements, also returnfalse
-
hasLocalPropertiesForExtendedElements
public final boolean hasLocalPropertiesForExtendedElements()
This method returnttruein following condition:1. The multi selected elements are same type.
2. And the multi selected elements have extends.
3. If any of the given elements has local properties.
- Returns:
trueif the conditions is met.
-
hasLocalPropertiesIncludeSubElement
public final boolean hasLocalPropertiesIncludeSubElement()
This method returnttruein following condition:1. The multi selected elements are same type.
2. And the multi selected elements have extends.
3. If any of the given elements or their subElement has local properties.
- Returns:
trueif the conditions is met.
-
hasLocalPropertiesIncludeSubElement
protected boolean hasLocalPropertiesIncludeSubElement(DesignElementHandle elementHandle)
return true if the Element or subElement has local properties- Parameters:
elementHandle-- Returns:
- true if the Element or his subElement has local properties
-
allExtendedElements
protected abstract boolean allExtendedElements()
Checks if all elements have extends parents or virtual parents.- Returns:
trueIf all elements have extend parents or virtual parents. Otherwisefalse;
-
isPropertyReadOnly
protected abstract boolean isPropertyReadOnly(java.lang.String propName)
Checks whether a property is read-only in the property sheet. The visible property is read-only in allelements.- Parameters:
propName- the property name- Returns:
trueif it is read-only. Otherwisefalse.
-
getPropertyHandle
public abstract GroupPropertyHandle getPropertyHandle(java.lang.String propName)
If property is shared by the group of elements, return the correspondingGroupPropertyHandle, otherwise, returnnull.- Parameters:
propName- name of the property needs to be handled.- Returns:
- If the property is a common property among the elements, return the
corresponding
GroupPropertyHandle; Otherwise returnnull.
-
getStringProperty
public final java.lang.String getStringProperty(java.lang.String propName)
If the given property is a common property, value will be returned as a string if all values within the group of elements are equal. If the property is not a common property, returnnull.- Parameters:
propName- name of the property.- Returns:
- the value as a string if the property is a common property and all the elements have the same value. Return null if the property is not a common property or elements have different values for this property.
- See Also:
GroupPropertyHandle.getStringValue()
-
getDisplayProperty
public final java.lang.String getDisplayProperty(java.lang.String propName)
If the given property is a common property, value will be returned as a display value if all values within the group of elements are equal. If the property is not a common property, returnnull.- Parameters:
propName- name of the property.- Returns:
- the value as a display value if the property is a common property and all the elements have the same value. Return null if the property is not a common property or elements have different values for this property.
- See Also:
GroupPropertyHandle#getDisplayProperty()
-
getLocalStringProperty
public final java.lang.String getLocalStringProperty(java.lang.String propName)
If the given property is a common property, value will be returned as a string if all values within the group of elements are equal and one of them has a local value. If the property is not a common property or none of them has a local value, returnnull.- Parameters:
propName- name of the property.- Returns:
- the value as a string if the property is a common property, all the elements have the same value and one of them has a local value. Return null if the property is not a common property or elements have different values for this property or none of them has a local value.
- See Also:
GroupPropertyHandle.getLocalStringValue()
-
shareSameValue
public final boolean shareSameValue(java.lang.String propName)
Indicates whether the group of element share the same value for this property.If all element has a
nullvalue for this property, it is considered that they share the same value.- Parameters:
propName- name of the property.- Returns:
trueif the group of element share the same value. Returnfalseif the property is not a common property or elements have different values for this property.
-
setProperty
public final void setProperty(java.lang.String propName, java.lang.Object value) throws SemanticExceptionSet the value of a property on the given collection of elements. If the property provided is not a common property then this method simply return; Otherwise, the value will be set on the group of elements.- Parameters:
propName- name of the property.value- value needs to set.- Throws:
SemanticException- if the value is invalid for the property, or the property is undefined on the elements.- See Also:
GroupPropertyHandle.setValue(Object)
-
clearProperty
public final void clearProperty(java.lang.String propName) throws SemanticExceptionClears the value of a property on the given collection of elements if the property is a common property shared by each element. Clearing a property removes any value set for the property on this element. After this, the element will now inherit the property from its parent element, style, or from the default value for the property.If the property provided is not a common property then this method simply return, else, the value will be cleared on the group of elements.
- Parameters:
propName- the name of the property to clear.- Throws:
SemanticException- if the property is not defined on this element
-
setStringProperty
public final void setStringProperty(java.lang.String propName, java.lang.String value) throws SemanticExceptionSet the value of a property to a string . If the property provided is not a common property then this method simply return; Else, the string value will be set on the group of element.- Parameters:
propName- name of the property.value- value needs to set.- Throws:
SemanticException- if the value is invalid for the property, or the property is undefined on the elements.
-
isInGroup
protected abstract boolean isInGroup(DesignElementHandle element)
Checks whether theelementis a member ofGroupElementHandle.- Parameters:
element- the element to check- Returns:
trueif the element is in the list, otherwisefalse.
-
-