Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
Prado::using('Application.pages.ClassDefinition');
4
 
5
class Home extends TPage
6
{
7
	private $_classDefinition=null;
8
 
9
	public function getClassDefinition()
10
	{
11
		if(!$this->_classDefinition)
12
			$this->_classDefinition=new ClassDefinition;
13
		return $this->_classDefinition;
14
	}
15
 
16
	public function onInit($param)
17
	{
18
		parent::onInit($param);
19
		if(!$this->IsPostBack)
20
		{
21
			$properties=$this->ClassDefinition->Properties;
22
			$properties[]=new PropertyDefinition;
23
			$properties[]=new PropertyDefinition;
24
			$properties[]=new PropertyDefinition;
25
			$this->PropertyList->DataSource=$properties;
26
			$this->dataBind();
27
		}
28
	}
29
 
30
	public function propertyAction($sender,$param)
31
	{
32
		if($param->CommandName==='add')
33
			$this->ClassDefinition->Properties->add(new PropertyDefinition);
34
		if($param->CommandName==='remove')
35
			$this->ClassDefinition->Properties->removeAt($param->CommandParameter);
36
		else if($param->CommandName==='up')
37
		{
38
			$property=$this->ClassDefinition->Properties->itemAt($param->CommandParameter);
39
			$this->ClassDefinition->Properties->removeAt($param->CommandParameter);
40
			$this->ClassDefinition->Properties->insertAt($param->CommandParameter-1,$property);
41
		}
42
		else if($param->CommandName==='down')
43
		{
44
			$property=$this->ClassDefinition->Properties->itemAt($param->CommandParameter);
45
			$this->ClassDefinition->Properties->removeAt($param->CommandParameter);
46
			$this->ClassDefinition->Properties->insertAt($param->CommandParameter+1,$property);
47
		}
48
		$this->PropertyList->DataSource=$this->ClassDefinition->Properties;
49
		$this->PropertyList->dataBind();
50
	}
51
 
52
	public function eventAction($sender,$param)
53
	{
54
		if($param->CommandName==='add')
55
			$this->ClassDefinition->Events->add(new EventDefinition);
56
		else if($param->CommandName==='remove')
57
			$this->ClassDefinition->Events->removeAt($param->CommandParameter);
58
		else if($param->CommandName==='up')
59
		{
60
			$property=$this->ClassDefinition->Events->itemAt($param->CommandParameter);
61
			$this->ClassDefinition->Events->removeAt($param->CommandParameter);
62
			$this->ClassDefinition->Events->insertAt($param->CommandParameter-1,$property);
63
		}
64
		else if($param->CommandName==='down')
65
		{
66
			$property=$this->ClassDefinition->Events->itemAt($param->CommandParameter);
67
			$this->ClassDefinition->Events->removeAt($param->CommandParameter);
68
			$this->ClassDefinition->Events->insertAt($param->CommandParameter+1,$property);
69
		}
70
		$this->EventList->DataSource=$this->ClassDefinition->Events;
71
		$this->EventList->dataBind();
72
	}
73
 
74
	public function onLoad($param)
75
	{
76
		parent::onLoad($param);
77
		//if($this->IsPostBack && $this->IsValid)
78
		if($this->IsPostBack)
79
		{
80
			$def=$this->ClassDefinition;
81
			$def->reset();
82
			$def->ClassName=$this->ClassName->Text;
83
			$def->ParentClass=$this->ParentClass->Text;
84
			$def->Interfaces=$this->Interfaces->Text;
85
			$def->Comments=$this->Comments->Text;
86
			$def->Author=$this->AuthorName->Text;
87
			$def->Email=$this->AuthorEmail->Text;
88
			foreach($this->PropertyList->Items as $item)
89
			{
90
				$property=new PropertyDefinition;
91
				$property->Name=$item->PropertyName->Text;
92
				$property->Type=$item->PropertyType->Text;
93
				$property->DefaultValue=$item->DefaultValue->Text;
94
				$property->ReadOnly=$item->ReadOnly->Checked;
95
				$property->IsProtected=$item->IsProtected->Checked;
96
				$property->Comments=$item->Comments->Text;
97
				$property->Storage=$item->Storage->Text;
98
				$def->Properties[]=$property;
99
			}
100
			foreach($this->EventList->Items as $item)
101
			{
102
				$event=new EventDefinition;
103
				$event->Name=$item->EventName->Text;
104
				$event->Comments=$item->Comments->Text;
105
				$def->Events[]=$event;
106
			}
107
		}
108
	}
109
 
110
	public function generateCode($sender,$param)
111
	{
112
		$writer=Prado::createComponent('TTextWriter');
113
		$this->ClassDefinition->render($writer);
114
		$this->SourceCode->Text=$writer->flush();
115
	}
116
}
117
 
118
?>