2 using System
.Collections
;
3 using System
.ComponentModel
;
7 using System
.Web
.SessionState
;
9 using System
.Web
.UI
.WebControls
;
10 using System
.Web
.UI
.HtmlControls
;
11 using Castle
.Applications
.PestControl
.Model
;
12 using Castle
.Applications
.PestControl
.Services
.BuildSystems
;
13 using Castle
.Applications
.PestControl
.Services
.SourceControl
;
14 using Castle
.MonoRail
.Framework
;
16 namespace Castle
.Applications
.PestControl
.Web
.views
.project
19 /// Summary description for _new.
21 public class New
: System
.Web
.UI
.Page
, IControllerAware
23 protected System
.Web
.UI
.WebControls
.ValidationSummary ValidationSummary1
;
24 protected System
.Web
.UI
.WebControls
.TextBox name
;
25 protected System
.Web
.UI
.WebControls
.Button Save
;
26 protected System
.Web
.UI
.WebControls
.DropDownList sc
;
27 protected System
.Web
.UI
.WebControls
.DropDownList bs
;
28 protected System
.Web
.UI
.WebControls
.CheckBox isPublic
;
30 private SourceControlManager _sourceControlManager
;
31 protected System
.Web
.UI
.WebControls
.Repeater dynRep
;
32 private BuildSystemManager _buildSystemManager
;
33 private Controller _controller
;
35 private void Page_Load(object sender
, System
.EventArgs e
)
37 Save
.Click
+= new EventHandler(OnSave
);
39 ISourceControl
[] sourceControls
= SourceControlManager
.AvailableSourceControl();
43 SelectedSourceControl
= -1;
45 sc
.AutoPostBack
= true;
46 sc
.DataSource
= sourceControls
;
47 sc
.DataTextField
= "Name";
48 sc
.DataValueField
= "Key";
51 bs
.DataSource
= BuildSystemManager
.AvailableBuildSystems();
52 bs
.DataTextField
= "Name";
53 bs
.DataValueField
= "Key";
57 if (sc
.SelectedIndex
!= SelectedSourceControl
)
59 // If the user changed the combo, we rebind the
60 // properties for the selected source control
62 ISourceControl control
= sourceControls
[ sc
.SelectedIndex
];
64 SelectedSourceControl
= sc
.SelectedIndex
;
66 dynRep
.DataSource
= control
.ParametersDefinition
;
71 public int SelectedSourceControl
73 get { return (int) this.ViewState["SelectedSourceControl"]; }
74 set { this.ViewState["SelectedSourceControl"] = value; }
77 public SourceControlManager SourceControlManager
79 get { return _sourceControlManager; }
80 set { _sourceControlManager = value; }
83 public BuildSystemManager BuildSystemManager
85 get { return _buildSystemManager; }
86 set { _buildSystemManager = value; }
89 #region Web Form Designer generated code
90 override protected void OnInit(EventArgs e
)
93 // CODEGEN: This call is required by the ASP.NET Web Form Designer.
95 InitializeComponent();
100 /// Required method for Designer support - do not modify
101 /// the contents of this method with the code editor.
103 private void InitializeComponent()
105 this.dynRep
.ItemCommand
+= new System
.Web
.UI
.WebControls
.RepeaterCommandEventHandler(this.dynRep_ItemCommand
);
106 this.Load
+= new System
.EventHandler(this.Page_Load
);
111 private void dynRep_ItemCommand(object source
, System
.Web
.UI
.WebControls
.RepeaterCommandEventArgs e
)
116 private void OnSave(object sender
, EventArgs e
)
118 Hashtable properties
= new Hashtable();
120 foreach(RepeaterItem item
in dynRep
.Items
)
122 HtmlInputControl pKey
= (HtmlInputControl
) item
.FindControl("propKey");
123 TextBox pValue
= (TextBox
) item
.FindControl("propValue");
125 properties
.Add(pKey
.Value
, pValue
.Text
);
128 _controller
.PropertyBag
.Add("properties", properties
);
129 _controller
.PropertyBag
.Add("isPublic", isPublic
.Checked
);
130 _controller
.PropertyBag
.Add("ownerEmail", ((User
) Context
.User
).Email
);
132 _controller
.Send("insert");
135 #region IControllerAware Members
137 public void SetController(Controller controller
)
139 _controller
= controller
;