Merge pull request #2034 from alexrp/ctx-cleanup
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls.WebParts / WebPartVerb.cs
1 //
2 // System.Web.UI.WebControls.WebParts.WebPartVerb.cs
3 //
4 // Authors:
5 //      Sanjay Gupta (gsanjay@novell.com)
6 //
7 // (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30
31 using System.Web;
32 using System.Web.UI;
33 using System.ComponentModel;
34 using System;
35
36 namespace System.Web.UI.WebControls.WebParts
37 {
38         [TypeConverterAttribute ("System.Web.UI.WebControls.WebParts.WebPartVerbConverter, System.Web")]
39         public class WebPartVerb : IStateManager
40         {
41                 string clientClickHandler;
42                 WebPartEventHandler serverClickHandler;
43                 StateBag stateBag;
44                 bool isChecked = false;
45                 string description = string.Empty;
46                 bool enabled = true;
47                 string imageUrl = string.Empty;
48                 string text = string.Empty;
49                 bool visible = true;
50                 string id;
51                 
52                 public string ID {
53                         get { return id;}
54                 }
55
56                 public WebPartVerb (string id, string clientHandler) {
57                         this.id = id;
58                         this.clientClickHandler = clientHandler;
59                         stateBag = new StateBag ();
60                         stateBag.Add ("clientClickHandler", clientHandler);
61                 }
62
63
64                 public WebPartVerb (string id, WebPartEventHandler serverClickHandler) {
65                         this.id = id;
66                         this.serverClickHandler = serverClickHandler;
67                         stateBag = new StateBag ();
68                         stateBag.Add ("serverClickHandler", serverClickHandler);
69                 }
70
71                 public WebPartVerb (string id, WebPartEventHandler serverClickHandler, string clientClickHandler) {
72                         this.id = id;
73                         this.serverClickHandler = serverClickHandler;
74                         this.clientClickHandler = clientClickHandler;
75                         stateBag = new StateBag ();
76                         stateBag.Add ("serverClickHandler", serverClickHandler);
77                         stateBag.Add ("clientClickHandler", clientClickHandler);
78                 }
79
80                 [MonoTODO("Not implemented")]
81                 protected virtual void LoadViewState (object savedState)
82                 {
83                         throw new NotImplementedException ();
84                 }
85
86                 [MonoTODO("Not implemented")]
87                 protected virtual object SaveViewState()
88                 {
89                         throw new NotImplementedException ();
90                 }
91
92                 [MonoTODO("Not implemented")]
93                 protected virtual void TrackViewState()
94                 {
95                         throw new NotImplementedException();
96                 }
97
98                 [MonoTODO("Not implemented")]
99                 void IStateManager.LoadViewState (object savedState)
100                 {
101                         throw new NotImplementedException ();
102                 }
103
104                 [MonoTODO("Not implemented")]
105                 object IStateManager.SaveViewState ()
106                 {
107                         throw new NotImplementedException ();
108                 }
109
110                 [MonoTODO("Not implemented")]
111                 void IStateManager.TrackViewState ()
112                 {
113                         throw new NotImplementedException ();
114                 }
115
116                 [MonoTODO("Not implemented")]
117                 bool IStateManager.IsTrackingViewState {
118                         get {
119                                 throw new NotImplementedException ();
120                         }
121                 }
122
123                 [WebSysDescriptionAttribute ("Denotes verb is checked or not."),
124                 DefaultValueAttribute (false),
125                 NotifyParentPropertyAttribute (true) ]
126                 public virtual bool Checked {
127                         get { return isChecked; }
128                         set { isChecked = value; }
129                 }
130
131                 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden),
132                  BrowsableAttribute (false)]
133                 public string ClientClickHandler {
134                         get { return clientClickHandler; }
135                 }
136
137                 [LocalizableAttribute (true),
138                  WebSysDescriptionAttribute ("Gives descriptive information about the verb"),
139                  NotifyParentPropertyAttribute (true)]
140                  //WebSysDefaultValueAttribute (string.Empty)]                  
141                 public virtual string Description {
142                         get { return description; }
143                         set { description = value; }
144                 }
145
146                 [NotifyParentPropertyAttribute (true),
147                  DefaultValueAttribute (true),
148                  WebSysDescriptionAttribute ("Determines whether verb is enabled.")]                    
149                 public virtual bool Enabled {
150                         get { return enabled; }
151                         set { enabled = value; }
152                 }
153
154                 [WebSysDescriptionAttribute ("Denotes URL of the image to be displayed for the verb"),
155                  EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design", 
156                                 "UITypeEditor, System.Drawing"),
157                  LocalizableAttribute (true), NotifyParentPropertyAttribute (true)]
158                 //UrlPropertyAttribute, DefaultValueAttribute (String.Empty)
159                 public string ImageUrl {
160                         get { return imageUrl; }
161                         set { imageUrl = value; }
162                 }
163
164                 protected virtual bool IsTrackingViewState {
165                         get { throw new NotImplementedException (); }
166                 }
167
168                 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden),
169                  BrowsableAttribute (false)]
170                 public WebPartEventHandler ServerClickHandler
171                 {
172                         get { return serverClickHandler; }
173                 }
174
175                 [WebSysDescriptionAttribute ("Denotes text to be displayed for the verb"),
176                  LocalizableAttribute (true), NotifyParentPropertyAttribute (true)]
177                 //DefaultValueAttribute (String.Empty)
178                 public virtual string Text
179                 {
180                         get { return text; }
181                         set { text = value; }
182                 }
183
184                 protected StateBag ViewState {
185                         get { return stateBag; }
186                 }
187
188                 [DefaultValueAttribute (true),
189                  WebSysDescriptionAttribute ("Denotes whether the verb is visible"),
190                  LocalizableAttribute (true), NotifyParentPropertyAttribute (true)]
191                 public bool Visible
192                 {
193                         get { return visible; }
194                         set { visible = value; }
195                 }
196         }
197 }