From 01bc363ac789cfb9d644ce82a949da5cd7e1c220 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 31 Jan 2006 00:01:49 +0000 Subject: Modified TList and TMap implementation so that they can be more easily extended. --- framework/Web/UI/WebControls/TTable.php | 83 +++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 35 deletions(-) (limited to 'framework/Web/UI/WebControls/TTable.php') diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php index dab0fb60..fb70e66c 100644 --- a/framework/Web/UI/WebControls/TTable.php +++ b/framework/Web/UI/WebControls/TTable.php @@ -712,32 +712,38 @@ class TTableRowCollection extends TList } /** - * Only string or instance of TControl can be added into collection. - * @param mixed the item to be added + * Inserts an item at the specified position. + * This overrides the parent implementation by performing additional + * operations for each newly added table row. + * @param integer the speicified position. + * @param mixed new item + * @throws TInvalidDataTypeException if the item to be inserted is not a TTableRow object. */ - protected function canAddItem($item) + public function insertAt($index,$item) { - return ($item instanceof TTableRow); - } - - /** - * Overrides the parent implementation with customized processing of the newly added item. - * @param mixed the newly added item - */ - protected function addedItem($item) - { - if($this->_owner) - $this->_owner->getControls()->add($item); + if($item instanceof TTableRow) + { + parent::insertAt($index,$item); + if($this->_owner) + $this->_owner->getControls()->insertAt($index,$item); + } + else + throw new TInvalidDataTypeException('tablerowcollection_tablerow_required'); } /** - * Overrides the parent implementation with customized processing of the removed item. - * @param mixed the removed item + * Removes an item at the specified position. + * This overrides the parent implementation by performing additional + * cleanup work when removing a table row. + * @param integer the index of the item to be removed. + * @return mixed the removed item. */ - protected function removedItem($item) + public function removeAt($index) { - if($this->_owner) + $item=parent::removeAt($index); + if($item instanceof TTableRow) $this->_owner->getControls()->remove($item); + return $item; } } @@ -768,33 +774,40 @@ class TTableCellCollection extends TList $this->_owner=$owner; } - /** - * Only string or instance of TTableCell can be added into collection. - * @param mixed the item to be added - */ - protected function canAddItem($item) - { - return ($item instanceof TTableCell); - } /** - * Overrides the parent implementation with customized processing of the newly added item. - * @param mixed the newly added item + * Inserts an item at the specified position. + * This overrides the parent implementation by performing additional + * operations for each newly added table cell. + * @param integer the speicified position. + * @param mixed new item + * @throws TInvalidDataTypeException if the item to be inserted is not a TTableCell object. */ - protected function addedItem($item) + public function insertAt($index,$item) { - if($this->_owner) - $this->_owner->getControls()->add($item); + if($item instanceof TTableCell) + { + parent::insertAt($index,$item); + if($this->_owner) + $this->_owner->getControls()->insertAt($index,$item); + } + else + throw new TInvalidDataTypeException('tablecellcollection_tablecell_required'); } /** - * Overrides the parent implementation with customized processing of the removed item. - * @param mixed the removed item + * Removes an item at the specified position. + * This overrides the parent implementation by performing additional + * cleanup work when removing a table cell. + * @param integer the index of the item to be removed. + * @return mixed the removed item. */ - protected function removedItem($item) + public function removeAt($index) { - if($this->_owner) + $item=parent::removeAt($index); + if($item instanceof TTableCell) $this->_owner->getControls()->remove($item); + return $item; } } ?> \ No newline at end of file -- cgit v1.2.3