From e126c0067e9efee6542d08bf649588e2cf3a5924 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 12 Jan 2006 03:22:03 +0000 Subject: Fixed several issues about viewstate handling. Prado Composer is nearly completed. --- demos/composer/protected/pages/Home.php | 67 ++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 31 deletions(-) (limited to 'demos/composer/protected/pages/Home.php') diff --git a/demos/composer/protected/pages/Home.php b/demos/composer/protected/pages/Home.php index 3c2b4d22..e0112fd7 100644 --- a/demos/composer/protected/pages/Home.php +++ b/demos/composer/protected/pages/Home.php @@ -20,24 +20,29 @@ class Home extends TPage $properties[]=new PropertyDefinition; $properties[]=new PropertyDefinition; $properties[]=new PropertyDefinition; - $this->PropertyList->setDataSource($properties); + $this->PropertyList->DataSource=$properties; $this->dataBind(); } } - /* - public function onLoad($param) + protected function refresh() { - parent::onLoad($param); - if(!$this->IsPostBack) + $this->PropertyList->DataSource=$this->ClassDefinition->Properties; + $this->dataBind(); + } + + public function itemAction($sender,$param) + { + if($param->CommandName==='remove') { - $this->PropertyList->setDataSource($this->getInitialProperties()); - $this->PropertyList->dataBind(); + $this->ClassDefinition->Properties->removeAt($param->CommandParameter); } - else - $this->PropertyList->ensureChildControls(); + else if($param->CommandName==='add') + { + $this->ClassDefinition->Properties->insert($param->CommandParameter+1,new PropertyDefinition); + } + $this->refresh(); } - */ public function onLoad($param) { @@ -45,32 +50,32 @@ class Home extends TPage //if($this->IsPostBack && $this->IsValid) if($this->IsPostBack) { - $this->PropertyList->ensureChildControls(); + $def=$this->ClassDefinition; + $def->reset(); + $def->ClassName=$this->ClassName->Text; + $def->ParentClass=$this->ParentClass->Text; + $def->Interfaces=$this->Interfaces->Text; + $def->Comments=$this->Comments->Text; + $def->Author=$this->AuthorName->Text; + $def->Email=$this->AuthorEmail->Text; + foreach($this->PropertyList->Items as $item) + { + $property=new PropertyDefinition; + $property->Name=$item->PropertyName->Text; + $property->Type=$item->PropertyType->Text; + $property->DefaultValue=$item->DefaultValue->Text; + $property->ReadOnly=$item->ReadOnly->Checked; + $property->IsProtected=$item->IsProtected->Checked; + $property->Comments=$item->Comments->Text; + $property->Storage=$item->Storage->Text; + $def->Properties[]=$property; + } } } public function generateCode($sender,$param) { - $def=$this->ClassDefinition; - $def->reset(); - $def->ClassName=$this->ClassName->Text; - $def->ParentClass=$this->ParentClass->Text; - $def->Interfaces=$this->Interfaces->Text; - $def->Comments=$this->Comments->Text; - $def->Author=$this->AuthorName->Text; - $def->Email=$this->AuthorEmail->Text; - foreach($this->PropertyList->Items as $item) - { - $property=new PropertyDefinition; - $property->Name=$item->PropertyName->Text; - $property->Type=$item->PropertyType->Text; - $property->DefaultValue=$item->DefaultValue->Text; - $property->ReadOnly=$item->ReadOnly->Checked; - $property->IsProtected=$item->IsProtected->Checked; - $property->Comments=$item->Comments->Text; - $property->Storage=$item->Storage->Text; - $def->Properties[]=$property; - } + $this->refresh(); $writer=Prado::createComponent('System.IO.TTextWriter'); $this->ClassDefinition->render($writer); $this->SourceCode->Text=highlight_string($writer->flush(),true); -- cgit v1.2.3