Class SlotHandle
- java.lang.Object
-
- org.eclipse.birt.report.model.api.ElementDetailHandle
-
- org.eclipse.birt.report.model.api.SlotHandle
-
public class SlotHandle extends ElementDetailHandle
Represents a "slot" within an element. A slot holds a collection of report items.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
slotID
The numeric identifier of the slot.-
Fields inherited from class org.eclipse.birt.report.model.api.ElementDetailHandle
elementHandle
-
-
Constructor Summary
Constructors Constructor Description SlotHandle(DesignElementHandle element, int slotID)
Constructs a handle for the slot with the given design element handle and the id of the slot.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(DesignElementHandle content)
Adds a report item to the slot with the given element handle.void
add(DesignElementHandle content, int newPos)
Adds a report item to the slot at the given position.void
add(org.eclipse.birt.report.model.core.DesignElement content)
Deprecated.by the methodadd(DesignElementHandle)
void
add(org.eclipse.birt.report.model.core.DesignElement content, int newPos)
Deprecated.by the methodadd(DesignElementHandle, int)
boolean
canContain(java.lang.String type)
Determines if the slot can contain an element with the type oftype
.boolean
canContain(DesignElementHandle content)
Determines if the given slot can contain thecontent
.void
drop(int posn)
Drops a content element at the given position from the slot, and unresolve any reference property which refers the element to drop.void
drop(DesignElementHandle content)
Drops a content element from the slot, and unresolve any reference property which refers the element to drop.void
dropAndClear(int posn)
Drops a content element at the given position from the slot, and clear any reference property which refers the element to drop.void
dropAndClear(DesignElementHandle content)
Drops a content element from the slot, and clear any reference property which refers the element to drop.int
findPosn(DesignElementHandle content)
Returns the position of the given content in this slot.DesignElementHandle
get(int posn)
Returns a handle to the content element at the given position.java.util.List<DesignElementHandle>
getContents()
Returns the a list with slot contents.Items are handles to the contents and in order by position.int
getCount()
Returns the number of elements in the slot.ISlotDefn
getDefn()
Returns the definition of the current slot.org.eclipse.birt.report.model.core.ContainerSlot
getSlot()
Returns the internal representation of the slot.int
getSlotID()
Returns the numeric identifier of the slot.java.util.Iterator<DesignElementHandle>
iterator()
Gets an iterator over the items in the slot.void
move(DesignElementHandle content, DesignElementHandle newContainer, int toSlot)
Moves a content element into a slot in another container element.void
move(DesignElementHandle content, DesignElementHandle newContainer, int toSlot, int newPos)
Moves a content element into a slot in another container element at the specified position.java.util.List
paste(IDesignElement content)
Pastes a report item to the slot.java.util.List
paste(IDesignElement content, int newPos)
Pastes a report item to the slot.java.util.List
paste(DesignElementHandle content)
Pastes a report item to the slot.java.util.List
paste(DesignElementHandle content, int newPos)
Pastes a report item to the slot.void
shift(DesignElementHandle content, int toPosn)
Moves the position of a content element within the slot.-
Methods inherited from class org.eclipse.birt.report.model.api.ElementDetailHandle
getDesign, getElement, getElementHandle, getModule
-
-
-
-
Constructor Detail
-
SlotHandle
public SlotHandle(DesignElementHandle element, int slotID)
Constructs a handle for the slot with the given design element handle and the id of the slot. The application generally does not create a slot handle directly. Instead, it calls thegetSlot( )
method on an element handle, or one of the specific methods on the handle for an element that is a container.- Parameters:
element
- handle to the report elementslotID
- the numeric identifier of the slot
-
-
Method Detail
-
add
public void add(DesignElementHandle content) throws ContentException, NameException
Adds a report item to the slot with the given element handle. The report item must not be newly created and not yet added to the design.- Parameters:
content
- handle to the newly created element- Throws:
ContentException
- if the element is not allowed in the slotNameException
- if the element has a duplicate or illegal name
-
add
public void add(DesignElementHandle content, int newPos) throws ContentException, NameException
Adds a report item to the slot at the given position. The item must not be newly created and not yet added to the design.- Parameters:
content
- handle to the newly created elementnewPos
- the position index at which the content to be inserted- Throws:
ContentException
- if the element is not allowed in the slotNameException
- if the element has a duplicate or illegal name
-
add
@Deprecated public void add(org.eclipse.birt.report.model.core.DesignElement content) throws ContentException, NameException
Deprecated.by the methodadd(DesignElementHandle)
Adds a report item to the slot. The item must not be newly created and not yet added to the design.- Parameters:
content
- the newly created element- Throws:
ContentException
- if the element is not allowed in the slotNameException
- if the element has a duplicate or illegal name
-
add
@Deprecated public void add(org.eclipse.birt.report.model.core.DesignElement content, int newPos) throws ContentException, NameException
Deprecated.by the methodadd(DesignElementHandle, int)
Adds a report item to the slot. The item must not be newly created and not yet added to the design.- Parameters:
content
- the newly created elementnewPos
- the position index at which the content to be inserted.- Throws:
ContentException
- if the element is not allowed in the slotNameException
- if the element has a duplicate or illegal name
-
paste
public java.util.List paste(DesignElementHandle content) throws ContentException, NameException
Pastes a report item to the slot. The item must be newly created and not yet added to the design.- Parameters:
content
- the newly created element handle- Returns:
- a list containing all errors for the pasted element
- Throws:
ContentException
- if the element is not allowed in the slotNameException
- if the element has a duplicate or illegal name
-
paste
public java.util.List paste(IDesignElement content) throws ContentException, NameException
Pastes a report item to the slot. The item must be newly created and not yet added to the design.- Parameters:
content
- the newly created element- Returns:
- a list containing all errors for the pasted element
- Throws:
ContentException
- if the element is not allowed in the slotNameException
- if the element has a duplicate or illegal name
-
paste
public java.util.List paste(DesignElementHandle content, int newPos) throws ContentException, NameException
Pastes a report item to the slot. The item must be newly created and not yet added to the design.- Parameters:
content
- the newly created element handlenewPos
- the position index at which the content to be inserted.- Returns:
- a list containing all errors for the pasted element
- Throws:
ContentException
- if the element is not allowed in the slotNameException
- if the element has a duplicate or illegal name
-
paste
public java.util.List paste(IDesignElement content, int newPos) throws ContentException, NameException
Pastes a report item to the slot. The item must be newly created and not yet added to the design.- Parameters:
content
- the newly created elementnewPos
- the position index at which the content to be inserted.- Returns:
- a list containing all errors for the pasted element
- Throws:
ContentException
- if the element is not allowed in the slotNameException
- if the element has a duplicate or illegal name
-
iterator
public java.util.Iterator<DesignElementHandle> iterator()
Gets an iterator over the items in the slot.- Returns:
- an iterator over the items in the slot. The iterator is of type
SlotIterator
and each item returned by the iterator'sgetNext( )
method is of typeDesignElementHandle
.
-
getContents
public java.util.List<DesignElementHandle> getContents()
Returns the a list with slot contents.Items are handles to the contents and in order by position.- Returns:
- a list with slot contents, items of the list are handles to the contents.
-
getCount
public int getCount()
Returns the number of elements in the slot.- Returns:
- the count of contents in the slot
-
get
public DesignElementHandle get(int posn)
Returns a handle to the content element at the given position.- Parameters:
posn
- the position within the slot- Returns:
- a handle to the content element
-
shift
public void shift(DesignElementHandle content, int toPosn) throws ContentException
Moves the position of a content element within the slot.- Parameters:
content
- handle to the content to movetoPosn
- the new position- Throws:
ContentException
- if the content is not in the slot, or if the to position is not valid.
-
move
public void move(DesignElementHandle content, DesignElementHandle newContainer, int toSlot) throws ContentException
Moves a content element into a slot in another container element.- Parameters:
content
- a handle to the element to movenewContainer
- a handle to the new container elementtoSlot
- the target slot ID where the element will be moved to.- Throws:
ContentException
- if the content is not in this slot or if the new container is not, in fact, a container, or if the content cannot go into the target slot.
-
move
public void move(DesignElementHandle content, DesignElementHandle newContainer, int toSlot, int newPos) throws ContentException
Moves a content element into a slot in another container element at the specified position.- Parameters:
content
- a handle to the element to movenewContainer
- a handle to the new container elementtoSlot
- the target slot ID where the element will be moved to.newPos
- the position to which the content will be moved. If it is greater than the current size of the target slot, the content will be appended at the end of the target slot.- Throws:
ContentException
- if the content is not in this slot or if the new container is not, in fact, a container, or if the content cannot go into the target slot.
-
dropAndClear
public void dropAndClear(DesignElementHandle content) throws SemanticException
Drops a content element from the slot, and clear any reference property which refers the element to drop.- Parameters:
content
- a handle to the content to drop- Throws:
SemanticException
- if the content is not within the slot
-
drop
public void drop(DesignElementHandle content) throws SemanticException
Drops a content element from the slot, and unresolve any reference property which refers the element to drop.- Parameters:
content
- a handle to the content to drop- Throws:
SemanticException
- if the content is not within the slot
-
dropAndClear
public void dropAndClear(int posn) throws SemanticException
Drops a content element at the given position from the slot, and clear any reference property which refers the element to drop.- Parameters:
posn
- the position of the content to drop- Throws:
SemanticException
- if the position is out of range
-
drop
public void drop(int posn) throws SemanticException
Drops a content element at the given position from the slot, and unresolve any reference property which refers the element to drop.- Parameters:
posn
- the position of the content to drop- Throws:
SemanticException
- if the position is out of range
-
getSlot
public org.eclipse.birt.report.model.core.ContainerSlot getSlot()
Returns the internal representation of the slot. Use this object only for reading: make all changes through this handle.- Returns:
- the internal representation of the slot
-
findPosn
public int findPosn(DesignElementHandle content)
Returns the position of the given content in this slot.- Parameters:
content
- the content to look up- Returns:
- Zero-based index of the element. Returns -1 if the content is not found
-
getSlotID
public int getSlotID()
Returns the numeric identifier of the slot.- Returns:
- The numeric identifier of the slot.
-
canContain
public boolean canContain(java.lang.String type)
Determines if the slot can contain an element with the type oftype
. Even return value istrue
, doesn't mean the element can be added/moved without exceptions.- Parameters:
type
- the name of the element type, like "Table", "List", etc.- Returns:
true
if the slot can contain the an element withtype
type, otherwisefalse
.
-
canContain
public boolean canContain(DesignElementHandle content)
Determines if the given slot can contain thecontent
. Even return value istrue
, doesn't mean the element can be added/moved without exceptions.- Parameters:
content
- the design element handle to check- Returns:
true
if the slot with the givenslotId
can contain thecontent
, otherwisefalse
.
-
getDefn
public ISlotDefn getDefn()
Returns the definition of the current slot.- Returns:
- the definition of the slot
-
-