Class TableHandle

  • All Implemented Interfaces:
    IReportItemMethodContext, org.eclipse.birt.report.model.elements.interfaces.IDesignElementModel, org.eclipse.birt.report.model.elements.interfaces.IInternalReportItemModel, org.eclipse.birt.report.model.elements.interfaces.IListingElementModel, org.eclipse.birt.report.model.elements.interfaces.IReportItemModel, org.eclipse.birt.report.model.elements.interfaces.IStyledElementModel, org.eclipse.birt.report.model.elements.interfaces.ITableItemModel

    public class TableHandle
    extends ListingHandle
    implements org.eclipse.birt.report.model.elements.interfaces.ITableItemModel
    Represents a table element. A table has a localized caption and can repeat its heading at the top of each page. The table is a list that is structured into a rows and columns. The columns are defined for the entire table. Rows are clustered into a set of groups.

    To get the layout of a table, it is recommended to use LayoutTableModel.

    See Also:
    TableItem, LayoutTableModel
    • Constructor Detail

      • TableHandle

        public TableHandle​(org.eclipse.birt.report.model.core.Module module,
                           org.eclipse.birt.report.model.core.DesignElement element)
        Constructs a handle for the table with the given design and element. The application generally does not create handles directly. Instead, it uses one of the navigation methods available on other element handles.
        Parameters:
        module - the module
        element - the model representation of the element
    • Method Detail

      • getColumns

        public SlotHandle getColumns()
        Returns the column slot. The column slot represents a list of Column elements that describe the table columns.
        Returns:
        a handle to the detail slot
        See Also:
        SlotHandle
      • getColumnCount

        public int getColumnCount()
        Returns the number of columns in the table. The number is defined as 1) the sum of columns described in the "column" slot, or 2) the widest row defined in the detail, header or footer slots if column slot is empty.
        Returns:
        the number of columns in the table
      • getCaption

        public java.lang.String getCaption()
        Returns the caption text of this table.
        Returns:
        the caption text
      • setCaption

        public void setCaption​(java.lang.String caption)
                        throws SemanticException
        Sets the caption text of this table.
        Parameters:
        caption - the caption text
        Throws:
        SemanticException - if the property is locked.
      • getSummary

        public java.lang.String getSummary()
        Returns the value of the summary.
        Returns:
        the value of summary
      • setSummary

        public void setSummary​(java.lang.String summary)
                        throws SemanticException
        Sets the value of summary.
        Parameters:
        summary - the value of summary
        Throws:
        SemanticException
      • getCaptionKey

        public java.lang.String getCaptionKey()
        Returns the resource key of the caption.
        Returns:
        the resource key of the caption
      • setCaptionKey

        public void setCaptionKey​(java.lang.String captionKey)
                           throws SemanticException
        Sets the resource key of the caption.
        Parameters:
        captionKey - the resource key of the caption
        Throws:
        SemanticException - if the caption resource-key property is locked.
      • canCopyColumn

        public boolean canCopyColumn​(int columnIndex)
        Copies a column and cells under it with the given column number.
        Parameters:
        columnIndex - the column position indexing from 1.
        Returns:
        true if this column band can be copied. Otherwise false.
      • canPasteColumn

        public boolean canPasteColumn​(ColumnBandData data,
                                      int columnIndex,
                                      boolean inForce)
        Checks whether the paste operation can be done with the given copied column band data, the column index and the operation flag.
        Parameters:
        data - the column band data to paste
        columnIndex - the column index from 1 to the number of columns in the table
        inForce - true indicates to paste the column regardless of the different layout of cells. false indicates not.
        Returns:
        true indicates the paste operation can be done. Otherwise false.
      • canCopyRow

        public boolean canCopyRow​(RowOperationParameters parameters)
        Checks whether the copy operation can be done with the given parameters.
        Parameters:
        parameters - parameters needed by insert operation.
        Returns:
        true if this row band can be copied. Otherwise false.
      • canPasteRow

        public boolean canPasteRow​(IDesignElement copiedRow,
                                   RowOperationParameters parameters)
        Checks whether the paste operation can be done with the given parameters.
        Parameters:
        copiedRow - the copied table row
        parameters - parameters needed by insert operation.
        Returns:
        true indicates the paste operation can be done. Otherwise false.
      • canInsertRow

        public boolean canInsertRow​(RowOperationParameters parameters)
        Checks whether inserting an empty table row can be done with the given parameters.
        Parameters:
        parameters - parameters needed by insert operation.
        Returns:
        true indicates the insert operation can be done. Otherwise false.
      • canInsertAndPasteRow

        public boolean canInsertAndPasteRow​(IDesignElement copiedRow,
                                            RowOperationParameters parameters)
        Checks whether the inserting and paste table row to the given destination row with the given parameters.
        Parameters:
        copiedRow - the copied table row
        parameters - parameters needed by insert operation.
        Returns:
        true indicates the insert and paste operation can be done. Otherwise false.
      • canShiftRow

        public boolean canShiftRow​(RowOperationParameters parameters)
        Checks whether the shift operation can be done with the given the given parameters.
        Parameters:
        parameters - parameters needed by insert operation.
        Returns:
        true indicates the shift operation can be done. Otherwise false.
      • copyColumn

        public ColumnBandData copyColumn​(int columnIndex)
                                  throws SemanticException
        Copies a column and cells under it with the given column number.
        Parameters:
        columnIndex - the column number
        Returns:
        a new ColumnBandAdapter instance
        Throws:
        SemanticException - if the cell layout of the column is invalid.
      • pasteColumn

        public void pasteColumn​(ColumnBandData data,
                                int columnNumber,
                                boolean inForce)
                         throws SemanticException
        Pastes a column with its cells to the given column number.
        Parameters:
        data - the data of a column band to paste
        columnNumber - the column index from 1 to the number of columns in the table
        inForce - true if pastes the column regardless of the warning. Otherwise false.
        Throws:
        SemanticException
      • copyRow

        public IDesignElement copyRow​(RowOperationParameters parameters)
                               throws SemanticException
        Copies table row with the given parameters.
        Parameters:
        parameters - parameters needed by insert operation.
        Returns:
        a new TableRow instance
        Throws:
        SemanticException - throw if paste operation is forbidden
        java.lang.IllegalArgumentException - throw if the input parameters are not valid
      • pasteRow

        public void pasteRow​(IDesignElement copiedRow,
                             RowOperationParameters parameters)
                      throws SemanticException
        Pastes table row to destination row with the given parameters.
        Parameters:
        copiedRow - the copied table row
        parameters - parameters needed by insert operation.
        Throws:
        SemanticException - throw if paste operation is forbidden
        java.lang.IllegalArgumentException - throw if the input parameters are not valid
      • insertRow

        public void insertRow​(RowOperationParameters parameters)
                       throws SemanticException
        Inserts table row to the given destination row with the given parameters.
        Parameters:
        parameters - parameters needed by insert operation.
        Throws:
        SemanticException - throw if paste operation is forbidden
        java.lang.IllegalArgumentException - throw if the input parameters are not valid
      • insertAndPasteRow

        public void insertAndPasteRow​(IDesignElement copiedRow,
                                      RowOperationParameters parameters)
                               throws SemanticException
        Inserts and paste table row to the given destination row with the given parameters.
        Parameters:
        copiedRow - the copied table row
        parameters - parameters needed by insert operation.
        Throws:
        SemanticException - throw if paste operation is forbidden
        java.lang.IllegalArgumentException - throw if the input parameters are not valid
      • shiftRow

        public void shiftRow​(RowOperationParameters parameters)
                      throws SemanticException
        Shifts table row to the given destination row with the given parameters.
        Parameters:
        parameters - parameters needed by insert operation.
        Throws:
        SemanticException - throw if paste operation is forbidden
        java.lang.IllegalArgumentException - throw if the input parameters are not valid
      • insertAndPasteColumn

        public void insertAndPasteColumn​(ColumnBandData data,
                                         int columnNumber)
                                  throws SemanticException
        Inserts and pastes a column with its cells to the given column number.
        Parameters:
        data - the data of a column band to paste
        columnNumber - the column index from 0 to the number of columns in the table
        Throws:
        SemanticException
      • canInsertAndPasteColumn

        public boolean canInsertAndPasteColumn​(ColumnBandData data,
                                               int columnIndex)
        Checks whether the insert and paste operation can be done with the given copied column band data, the column index and the operation flag. This is different from canPasteColumn since this action creates an extra column for the table.
        Parameters:
        data - the column band data to paste
        columnIndex - the column index from 0 to the number of columns in the table
        Returns:
        true indicates the paste operation can be done. Otherwise false.
      • shiftColumn

        public void shiftColumn​(int sourceColumn,
                                int destColumn)
                         throws SemanticException
        Moves the column from sourceColumn to destIndex .
        Parameters:
        sourceColumn - the source column ranging from 1 to the column number
        destColumn - the target column ranging from 0 to the column number
        Throws:
        SemanticException - if the chosen column band is forbidden to shift
      • canShiftColumn

        public boolean canShiftColumn​(int sourceColumn,
                                      int destColumn)
        Moves the column from sourceColumn to destColumn.
        Parameters:
        sourceColumn - the source column ranging from 1 to the column number
        destColumn - the target column ranging from 0 to the column number
        Returns:
        true if the chosen column band is legal to shift. Otherwise false.
      • getLayoutModel

        public LayoutTableModel getLayoutModel()
        Returns the layout model of the table.
        Returns:
        the layout model of the table
      • insertColumn

        public void insertColumn​(int columnNumber,
                                 int positionFlag)
                          throws SemanticException
        Inserts a column to the table. This includes inserting a table column and corresponding table cells to the table item.

        The insert action cannot be finished succesfully for cases like this:

                                                        <cell colSpan="1/><cell colSpan="1/>
                                                        <cell colSpan="2/>
         
        if the user want to insert a column with cells to the column 2.
        Parameters:
        columnNumber - The 1-based column number.
        positionFlag - The column insert sign. 1 insert after position. -1 insert before position
        Throws:
        SemanticException - if the given position is occupied by any cell with a column span equal or greater than 1.
      • getCell

        protected CellHandle getCell​(int row,
                                     int column)
        Gets the cell at the position where the given row and column intersect regardless of slot information. The table is viewed as be constructed by a set of flattened rows.
        Parameters:
        row - the row position indexing from 1
        column - the column position indexing from 1
        Returns:
        the cell handle at the position if the cell exists, otherwise null
      • getCell

        public CellHandle getCell​(int slotId,
                                  int groupLevel,
                                  int row,
                                  int column)
        Gets the cell at the position where the given row and column intersect within the given slot. The first row in the slot is count as 1. And so on.

        If groupLevel is less or equal than 0, then retrieve cell from header/detail/footer. If not, return the cell from the given group.

        Parameters:
        slotId - the slot id
        groupLevel - the group level indexing from 1. Or -1 if to get the cell from header/detail/footer.
        row - the row position indexing from 1
        column - the column position indexing from 1
        Returns:
        the cell handle at the position if the cell exists, otherwise null
      • findColumn

        public ColumnHandle findColumn​(int columnIndex)
        Figures out the column according to the index of the column.
        Parameters:
        columnIndex - the 1-based column index
        Returns:
        the handle of the column at the specified position, or null if not found.
      • getFilters

        public java.util.List<FilterConditionHandle> getFilters​(int colIndex)
        Returns a list containing filters applied to the column at position of colIndex.
        Parameters:
        colIndex - the column index ranging from 0 to columnCount - 1
        Returns:
        a list containing matched filter conditions
      • isSummaryTable

        public boolean isSummaryTable()
        Returns if the table is a summary table. A summary table should not allow adding any detail rows.
        Returns:
        true if the table is a summary table.Otherwise false.
      • setIsSummaryTable

        public void setIsSummaryTable​(boolean isSummaryTable)
                               throws SemanticException
        Sets the flag to control whether the table is a summary table. If the flag is checked, there should be no detail rows added for this table allowed.
        Parameters:
        isSummaryTable - the flag to set
        Throws:
        SemanticException
      • setWidthToFitColumns

        public void setWidthToFitColumns()
                                  throws SemanticException
        Sets the width of the table to fit columns' widths with default dpi value. The new width value will be the sum of the columns' widths.
        Throws:
        SemanticException - when width of the table cannot be calculated.
      • setWidthToFitColumns

        public void setWidthToFitColumns​(int dpi)
                                  throws SemanticException
        Sets the width of the table to fit columns' widths with the given dpi value. The new width value will be the sum of the columns' widths.
        Parameters:
        dpi - the dpi value
        Throws:
        SemanticException - when width of the table cannot be calculated.