summaryrefslogtreecommitdiff
path: root/demos/composer
diff options
context:
space:
mode:
authorxue <>2006-01-12 03:22:03 +0000
committerxue <>2006-01-12 03:22:03 +0000
commite126c0067e9efee6542d08bf649588e2cf3a5924 (patch)
treee1b14841cfdf8f05ce307ff9d63e8d2a466999a7 /demos/composer
parenta06e326f247bff617191b1c87a7b004414495275 (diff)
Fixed several issues about viewstate handling. Prado Composer is nearly completed.
Diffstat (limited to 'demos/composer')
-rw-r--r--demos/composer/protected/pages/Home.page45
-rw-r--r--demos/composer/protected/pages/Home.php67
2 files changed, 67 insertions, 45 deletions
diff --git a/demos/composer/protected/pages/Home.page b/demos/composer/protected/pages/Home.page
index b446abd2..ae4149ee 100644
--- a/demos/composer/protected/pages/Home.page
+++ b/demos/composer/protected/pages/Home.page
@@ -2,30 +2,32 @@
<com:TContent ID="body" >
<com:TPanel GroupingText="Class Information">
-class <com:TTextBox ID="ClassName" CssClass="slTextBox"/>
-extends <com:TTextBox ID="ParentClass" CssClass="slTextBox"/>
+class
+<com:TTextBox ID="ClassName"
+ Text=<%#$this->Page->ClassDefinition->ClassName%>
+ CssClass="slTextBox"/>
+extends
+<com:TTextBox ID="ParentClass"
+ Text=<%#$this->Page->ClassDefinition->ParentClass%>
+ CssClass="slTextBox"/>
implements <com:TTextBox ID="Interfaces" CssClass="slTextBox"/>
</com:TPanel>
<com:TPanel GroupingText="Property Definitions">
<table>
<tr>
- <th>Accessibility</th>
<th>Name</th>
<th>Type</th>
<th>Default Value</th>
<th>Storage Mode</th>
+ <th>Accessibility</th>
<th>Comments</th>
<th>Actions</th>
</tr>
-<com:TRepeater ID="PropertyList">
+<com:TRepeater ID="PropertyList" ItemCommand="itemAction">
<prop:ItemTemplate>
<tr>
<td>
- <com:TCheckBox ID="IsProtected" Text="protected" Checked=<%# $this->Parent->DataItem->IsProtected %> />
- <com:TCheckBox ID="ReadOnly" Text="read-only" Checked=<%# $this->Parent->DataItem->ReadOnly %> />
- </td>
- <td>
<com:TTextBox ID="PropertyName" Text=<%# $this->Parent->DataItem->Name %> CssClass="slTextBox"/>
</td>
<td>
@@ -49,11 +51,21 @@ implements <com:TTextBox ID="Interfaces" CssClass="slTextBox"/>
</com:TDropDownList>
</td>
<td>
+ <com:TCheckBox ID="IsProtected" Text="protected" Checked=<%# $this->Parent->DataItem->IsProtected %> />
+ <com:TCheckBox ID="ReadOnly" Text="read-only" Checked=<%# $this->Parent->DataItem->ReadOnly %> />
+ </td>
+ <td>
<com:TTextBox ID="Comments" Text=<%# $this->Parent->DataItem->Comments %> CssClass="slTextBox"/>
</td>
<td>
- <com:TButton Text="Add" />
- <com:TButton Text="Remove" />
+ <com:TButton ID="AddButton"
+ Text="Add"
+ CommandName="add"
+ CommandParameter=<%# $this->Parent->ItemIndex %> />
+ <com:TButton ID="RemoveButton"
+ Text="Remove"
+ CommandName="remove"
+ CommandParameter=<%# $this->Parent->ItemIndex %> />
</td>
</tr>
</prop:ItemTemplate>
@@ -65,13 +77,18 @@ Event Definitions:
</com:TPanel>
<br/>
Comments
-(
-Author Name: <com:TTextBox ID="AuthorName" CssClass="slTextBox"/>
-Author Email: <com:TTextBox ID="AuthorEmail" CssClass="slTextBox"/>
-)
<br/>
<com:TTextBox ID="Comments" TextMode="MultiLine" Columns="80" Rows="6" />
<br/>
+Author Name
+<com:TTextBox ID="AuthorName"
+ Text=<%#$this->Page->ClassDefinition->Author%>
+ CssClass="slTextBox"/>
+Author Email
+<com:TTextBox ID="AuthorEmail"
+ Text=<%#$this->Page->ClassDefinition->Email%>
+ CssClass="slTextBox"/>
+<br/>
<com:TButton Text="Generate Code" Click="generateCode" />
<pre>
<com:TLiteral ID="SourceCode" />
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);