summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TTable.php
diff options
context:
space:
mode:
authorxue <>2006-01-31 00:01:49 +0000
committerxue <>2006-01-31 00:01:49 +0000
commit01bc363ac789cfb9d644ce82a949da5cd7e1c220 (patch)
treea059046856645d59cf0cb1badee83eb5c73671e9 /framework/Web/UI/WebControls/TTable.php
parent265b7e85766ba403ca0a8b58648dd091e483cf38 (diff)
Modified TList and TMap implementation so that they can be more easily extended.
Diffstat (limited to 'framework/Web/UI/WebControls/TTable.php')
-rw-r--r--framework/Web/UI/WebControls/TTable.php83
1 files changed, 48 insertions, 35 deletions
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