2010-07-10 Marek Habersack <mhabersack@novell.com>
[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 #if NET_2_0
31
32 using System.Web;
33 using System.Web.UI;
34 using System.ComponentModel;
35 using System;
36
37 namespace System.Web.UI.WebControls.WebParts
38 {
39         [TypeConverterAttribute ("System.Web.UI.WebControls.WebParts.WebPartVerbConverter, System.Web")]
40         public class WebPartVerb : IStateManager
41         {
42                 string clientClickHandler;
43                 WebPartEventHandler serverClickHandler;
44                 StateBag stateBag;
45                 bool isChecked = false;
46                 string description = string.Empty;
47                 bool enabled = true;
48                 string imageUrl = string.Empty;
49                 string text = string.Empty;
50                 bool visible = true;
51                 string id;
52                 
53                 public string ID {
54                         get { return id;}
55                 }
56
57                 public WebPartVerb (string id, string clientHandler) {
58                         this.id = id;
59                         this.clientClickHandler = clientHandler;
60                         stateBag = new StateBag ();
61                         stateBag.Add ("clientClickHandler", clientHandler);
62                 }
63
64
65                 public WebPartVerb (string id, WebPartEventHandler serverClickHandler) {
66                         this.id = id;
67                         this.serverClickHandler = serverClickHandler;
68                         stateBag = new StateBag ();
69                         stateBag.Add ("serverClickHandler", serverClickHandler);
70                 }
71
72                 public WebPartVerb (string id, WebPartEventHandler serverClickHandler, string clientClickHandler) {
73                         this.id = id;
74                         this.serverClickHandler = serverClickHandler;
75                         this.clientClickHandler = clientClickHandler;
76                         stateBag = new StateBag ();
77                         stateBag.Add ("serverClickHandler", serverClickHandler);
78                         stateBag.Add ("clientClickHandler", clientClickHandler);
79                 }
80
81                 [MonoTODO("Not implemented")]
82                 protected virtual void LoadViewState (object savedState)
83                 {
84                         throw new NotImplementedException ();
85                 }
86
87                 [MonoTODO("Not implemented")]
88                 protected virtual object SaveViewState()
89                 {
90                         throw new NotImplementedException ();
91                 }
92
93                 [MonoTODO("Not implemented")]
94                 protected virtual void TrackViewState()
95                 {
96                         throw new NotImplementedException();
97                 }
98
99                 [MonoTODO("Not implemented")]
100                 void IStateManager.LoadViewState (object savedState)
101                 {
102                         throw new NotImplementedException ();
103                 }
104
105                 [MonoTODO("Not implemented")]
106                 object IStateManager.SaveViewState ()
107                 {
108                         throw new NotImplementedException ();
109                 }
110
111                 [MonoTODO("Not implemented")]
112                 void IStateManager.TrackViewState ()
113                 {
114                         throw new NotImplementedException ();
115                 }
116
117                 [MonoTODO("Not implemented")]
118                 bool IStateManager.IsTrackingViewState {
119                         get {
120                                 throw new NotImplementedException ();
121                         }
122                 }
123
124                 [WebSysDescriptionAttribute ("Denotes verb is checked or not."),
125                 DefaultValueAttribute (false),
126                 NotifyParentPropertyAttribute (true) ]
127                 public virtual bool Checked {
128                         get { return isChecked; }
129                         set { isChecked = value; }
130                 }
131
132                 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden),
133                  BrowsableAttribute (false)]
134                 public string ClientClickHandler {
135                         get { return clientClickHandler; }
136                 }
137
138                 [LocalizableAttribute (true),
139                  WebSysDescriptionAttribute ("Gives descriptive information about the verb"),
140                  NotifyParentPropertyAttribute (true)]
141                  //WebSysDefaultValueAttribute (string.Empty)]                  
142                 public virtual string Description {
143                         get { return description; }
144                         set { description = value; }
145                 }
146
147                 [NotifyParentPropertyAttribute (true),
148                  DefaultValueAttribute (true),
149                  WebSysDescriptionAttribute ("Determines whether verb is enabled.")]                    
150                 public virtual bool Enabled {
151                         get { return enabled; }
152                         set { enabled = value; }
153                 }
154
155                 [WebSysDescriptionAttribute ("Denotes URL of the image to be displayed for the verb"),
156                  EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design", 
157                                 "UITypeEditor, System.Drawing"),
158                  LocalizableAttribute (true), NotifyParentPropertyAttribute (true)]
159                 //UrlPropertyAttribute, DefaultValueAttribute (String.Empty)
160                 public string ImageUrl {
161                         get { return imageUrl; }
162                         set { imageUrl = value; }
163                 }
164
165                 protected virtual bool IsTrackingViewState {
166                         get { throw new NotImplementedException (); }
167                 }
168
169                 [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden),
170                  BrowsableAttribute (false)]
171                 public WebPartEventHandler ServerClickHandler
172                 {
173                         get { return serverClickHandler; }
174                 }
175
176                 [WebSysDescriptionAttribute ("Denotes text to be displayed for the verb"),
177                  LocalizableAttribute (true), NotifyParentPropertyAttribute (true)]
178                 //DefaultValueAttribute (String.Empty)
179                 public virtual string Text
180                 {
181                         get { return text; }
182                         set { text = value; }
183                 }
184
185                 protected StateBag ViewState {
186                         get { return stateBag; }
187                 }
188
189                 [DefaultValueAttribute (true),
190                  WebSysDescriptionAttribute ("Denotes whether the verb is visible"),
191                  LocalizableAttribute (true), NotifyParentPropertyAttribute (true)]
192                 public bool Visible
193                 {
194                         get { return visible; }
195                         set { visible = value; }
196                 }
197         }
198 }
199 #endif