001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.visualweb.faces.dt_1_1.component.html;
043:
044: import com.sun.rave.designtime.Constants;
045: import com.sun.rave.designtime.base.CategoryDescriptors;
046: import com.sun.rave.designtime.markup.AttributeDescriptor;
047: import org.netbeans.modules.visualweb.faces.dt.PropertyDescriptorBase;
048: import java.beans.PropertyDescriptor;
049: import java.util.ArrayList;
050: import java.util.Collections;
051: import java.util.List;
052: import java.util.Locale;
053: import java.util.ResourceBundle;
054:
055: /**
056: * Utility class for generating common component properties.
057: */
058: class Properties {
059:
060: private static ResourceBundle resources = ResourceBundle
061: .getBundle(
062: "org.netbeans.modules.visualweb.faces.dt_1_1.component.html.Bundle-JSF",
063: Locale.getDefault(), Properties.class
064: .getClassLoader());
065:
066: static List<PropertyDescriptor> getVisualPropertyList(
067: Class beanClass) {
068:
069: try {
070: AttributeDescriptor attrib;
071:
072: PropertyDescriptor prop_style = new PropertyDescriptorBase(
073: "style", beanClass, "getStyle", "setStyle");
074: prop_style.setDisplayName(resources
075: .getString("Properties_style_DisplayName"));
076: prop_style.setShortDescription(resources
077: .getString("Properties_style_Description"));
078: prop_style
079: .setPropertyEditorClass(com.sun.rave.propertyeditors.css.CssStylePropertyEditor.class);
080: attrib = new AttributeDescriptor("style", false, null, true);
081: prop_style.setValue(
082: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
083: attrib);
084: prop_style.setValue(Constants.PropertyDescriptor.CATEGORY,
085: CategoryDescriptors.APPEARANCE);
086:
087: PropertyDescriptor prop_styleClass = new PropertyDescriptorBase(
088: "styleClass", beanClass, "getStyleClass",
089: "setStyleClass");
090: prop_styleClass.setDisplayName(resources
091: .getString("Properties_styleClass_DisplayName"));
092: prop_styleClass.setShortDescription(resources
093: .getString("Properties_styleClass_Description"));
094: prop_styleClass
095: .setPropertyEditorClass(com.sun.rave.propertyeditors.StyleClassPropertyEditor.class);
096: attrib = new AttributeDescriptor("styleClass", false, null,
097: true);
098: prop_styleClass.setValue(
099: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
100: attrib);
101: prop_styleClass.setValue(
102: Constants.PropertyDescriptor.CATEGORY,
103: CategoryDescriptors.APPEARANCE);
104:
105: List<PropertyDescriptor> propertyList = new ArrayList<PropertyDescriptor>();
106: propertyList.add(prop_style);
107: propertyList.add(prop_styleClass);
108: return propertyList;
109:
110: } catch (Exception e) {
111: e.printStackTrace();
112: }
113: return Collections.EMPTY_LIST;
114:
115: }
116:
117: static List<PropertyDescriptor> getMouseEventPropertyList(
118: Class beanClass) {
119:
120: try {
121: AttributeDescriptor attrib;
122: PropertyDescriptor prop_onmousedown = new PropertyDescriptorBase(
123: "onmousedown", beanClass, "getOnmousedown",
124: "setOnmousedown");
125: prop_onmousedown.setDisplayName(resources
126: .getString("Properties_onmousedown_DisplayName"));
127: prop_onmousedown.setShortDescription(resources
128: .getString("Properties_onmousedown_Description"));
129: prop_onmousedown
130: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
131: prop_onmousedown.setExpert(false);
132: prop_onmousedown.setHidden(false);
133: prop_onmousedown.setPreferred(false);
134: attrib = new AttributeDescriptor("onmousedown", false,
135: null, true);
136: prop_onmousedown.setValue(
137: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
138: attrib);
139: prop_onmousedown
140: .setValue(
141: Constants.PropertyDescriptor.CATEGORY,
142: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
143:
144: PropertyDescriptor prop_onmousemove = new PropertyDescriptorBase(
145: "onmousemove", beanClass, "getOnmousemove",
146: "setOnmousemove");
147: prop_onmousemove.setDisplayName(resources
148: .getString("Properties_onmousemove_DisplayName"));
149: prop_onmousemove.setShortDescription(resources
150: .getString("Properties_onmousemove_Description"));
151: prop_onmousemove
152: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
153: attrib = new AttributeDescriptor("onmousemove", false,
154: null, true);
155: prop_onmousemove.setValue(
156: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
157: attrib);
158: prop_onmousemove
159: .setValue(
160: Constants.PropertyDescriptor.CATEGORY,
161: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
162:
163: PropertyDescriptor prop_onmouseout = new PropertyDescriptorBase(
164: "onmouseout", beanClass, "getOnmouseout",
165: "setOnmouseout");
166: prop_onmouseout.setDisplayName(resources
167: .getString("Properties_onmouseout_DisplayName"));
168: prop_onmouseout.setShortDescription(resources
169: .getString("Properties_onmouseout_Description"));
170: prop_onmouseout
171: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
172: attrib = new AttributeDescriptor("onmouseout", false, null,
173: true);
174: prop_onmouseout.setValue(
175: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
176: attrib);
177: prop_onmouseout
178: .setValue(
179: Constants.PropertyDescriptor.CATEGORY,
180: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
181:
182: PropertyDescriptor prop_onmouseover = new PropertyDescriptorBase(
183: "onmouseover", beanClass, "getOnmouseover",
184: "setOnmouseover");
185: prop_onmouseover.setDisplayName(resources
186: .getString("Properties_onmouseover_DisplayName"));
187: prop_onmouseover.setShortDescription(resources
188: .getString("Properties_onmouseover_Description"));
189: prop_onmouseover
190: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
191: attrib = new AttributeDescriptor("onmouseover", false,
192: null, true);
193: prop_onmouseover.setValue(
194: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
195: attrib);
196: prop_onmouseover
197: .setValue(
198: Constants.PropertyDescriptor.CATEGORY,
199: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
200:
201: PropertyDescriptor prop_onmouseup = new PropertyDescriptorBase(
202: "onmouseup", beanClass, "getOnmouseup",
203: "setOnmouseup");
204: prop_onmouseup.setDisplayName(resources
205: .getString("Properties_onmouseup_DisplayName"));
206: prop_onmouseup.setShortDescription(resources
207: .getString("Properties_onmouseup_Description"));
208: prop_onmouseup
209: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
210: attrib = new AttributeDescriptor("onmouseup", false, null,
211: true);
212: prop_onmouseup.setValue(
213: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
214: attrib);
215: prop_onmouseup
216: .setValue(
217: Constants.PropertyDescriptor.CATEGORY,
218: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
219:
220: List<PropertyDescriptor> propertyList = new ArrayList<PropertyDescriptor>();
221: propertyList.add(prop_onmouseup);
222: propertyList.add(prop_onmousedown);
223: propertyList.add(prop_onmouseover);
224: propertyList.add(prop_onmouseout);
225: propertyList.add(prop_onmousemove);
226: return propertyList;
227:
228: } catch (Exception e) {
229: e.printStackTrace();
230: }
231: return Collections.EMPTY_LIST;
232:
233: }
234:
235: static List<PropertyDescriptor> getKeyEventPropertyList(
236: Class beanClass) {
237:
238: try {
239: AttributeDescriptor attrib;
240:
241: PropertyDescriptor prop_onkeydown = new PropertyDescriptorBase(
242: "onkeydown", beanClass, "getOnkeydown",
243: "setOnkeydown");
244: prop_onkeydown.setDisplayName(resources
245: .getString("Properties_onkeydown_DisplayName"));
246: prop_onkeydown.setShortDescription(resources
247: .getString("Properties_onkeydown_Description"));
248: prop_onkeydown
249: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
250: attrib = new AttributeDescriptor("onkeydown", false, null,
251: true);
252: prop_onkeydown.setValue(
253: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
254: attrib);
255: prop_onkeydown
256: .setValue(
257: Constants.PropertyDescriptor.CATEGORY,
258: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
259:
260: PropertyDescriptor prop_onkeypress = new PropertyDescriptorBase(
261: "onkeypress", beanClass, "getOnkeypress",
262: "setOnkeypress");
263: prop_onkeypress.setDisplayName(resources
264: .getString("Properties_onkeypress_DisplayName"));
265: prop_onkeypress.setShortDescription(resources
266: .getString("Properties_onkeypress_Description"));
267: prop_onkeypress
268: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
269: attrib = new AttributeDescriptor("onkeypress", false, null,
270: true);
271: prop_onkeypress.setValue(
272: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
273: attrib);
274: prop_onkeypress
275: .setValue(
276: Constants.PropertyDescriptor.CATEGORY,
277: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
278:
279: PropertyDescriptor prop_onkeyup = new PropertyDescriptorBase(
280: "onkeyup", beanClass, "getOnkeyup", "setOnkeyup");
281: prop_onkeyup.setDisplayName(resources
282: .getString("Properties_onkeyup_DisplayName"));
283: prop_onkeyup.setShortDescription(resources
284: .getString("Properties_onkeyup_Description"));
285: prop_onkeyup
286: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
287: attrib = new AttributeDescriptor("onkeyup", false, null,
288: true);
289: prop_onkeyup.setValue(
290: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
291: attrib);
292: prop_onkeyup
293: .setValue(
294: Constants.PropertyDescriptor.CATEGORY,
295: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
296:
297: List<PropertyDescriptor> propertyList = new ArrayList<PropertyDescriptor>();
298: propertyList.add(prop_onkeydown);
299: propertyList.add(prop_onkeypress);
300: propertyList.add(prop_onkeyup);
301: return propertyList;
302:
303: } catch (Exception e) {
304: e.printStackTrace();
305: }
306: return Collections.EMPTY_LIST;
307:
308: }
309:
310: static List<PropertyDescriptor> getClickEventPropertyList(
311: Class beanClass) {
312:
313: try {
314: AttributeDescriptor attrib;
315:
316: PropertyDescriptor prop_onclick = new PropertyDescriptorBase(
317: "onclick", beanClass, "getOnclick", "setOnclick");
318: prop_onclick.setDisplayName(resources
319: .getString("Properties_onclick_DisplayName"));
320: prop_onclick.setShortDescription(resources
321: .getString("Properties_onclick_Description"));
322: prop_onclick
323: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
324: attrib = new AttributeDescriptor("onclick", false, null,
325: true);
326: prop_onclick.setValue(
327: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
328: attrib);
329: prop_onclick
330: .setValue(
331: Constants.PropertyDescriptor.CATEGORY,
332: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
333:
334: PropertyDescriptor prop_ondblclick = new PropertyDescriptorBase(
335: "ondblclick", beanClass, "getOndblclick",
336: "setOndblclick");
337: prop_ondblclick.setDisplayName(resources
338: .getString("Properties_ondblclick_DisplayName"));
339: prop_ondblclick.setShortDescription(resources
340: .getString("Properties_ondblclick_Description"));
341: prop_ondblclick
342: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
343: attrib = new AttributeDescriptor("ondblclick", false, null,
344: true);
345: prop_ondblclick.setValue(
346: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
347: attrib);
348: prop_ondblclick
349: .setValue(
350: Constants.PropertyDescriptor.CATEGORY,
351: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
352:
353: List<PropertyDescriptor> propertyList = new ArrayList<PropertyDescriptor>();
354: propertyList.add(prop_onclick);
355: propertyList.add(prop_ondblclick);
356: return propertyList;
357:
358: } catch (Exception e) {
359: e.printStackTrace();
360: }
361: return Collections.EMPTY_LIST;
362:
363: }
364:
365: static List<PropertyDescriptor> getFocusEventPropertyList(
366: Class beanClass) {
367:
368: try {
369: AttributeDescriptor attrib;
370:
371: PropertyDescriptor prop_onblur = new PropertyDescriptorBase(
372: "onblur", beanClass, "getOnblur", "setOnblur");
373: prop_onblur.setDisplayName(resources
374: .getString("Properties_onblur_DisplayName"));
375: prop_onblur.setShortDescription(resources
376: .getString("Properties_onblur_Description"));
377: prop_onblur
378: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
379: attrib = new AttributeDescriptor("onblur", false, null,
380: true);
381: prop_onblur.setValue(
382: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
383: attrib);
384: prop_onblur
385: .setValue(
386: Constants.PropertyDescriptor.CATEGORY,
387: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
388:
389: PropertyDescriptor prop_onfocus = new PropertyDescriptorBase(
390: "onfocus", beanClass, "getOnfocus", "setOnfocus");
391: prop_onfocus.setDisplayName(resources
392: .getString("Properties_onfocus_DisplayName"));
393: prop_onfocus.setShortDescription(resources
394: .getString("Properties_onfocus_Description"));
395: prop_onfocus
396: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
397: attrib = new AttributeDescriptor("onfocus", false, null,
398: true);
399: prop_onfocus.setValue(
400: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
401: attrib);
402: prop_onfocus
403: .setValue(
404: Constants.PropertyDescriptor.CATEGORY,
405: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
406:
407: List<PropertyDescriptor> propertyList = new ArrayList<PropertyDescriptor>();
408: propertyList.add(prop_onfocus);
409: propertyList.add(prop_onblur);
410: return propertyList;
411:
412: } catch (Exception e) {
413: e.printStackTrace();
414: }
415: return Collections.EMPTY_LIST;
416:
417: }
418:
419: static List<PropertyDescriptor> getSelectEventPropertyList(
420: Class beanClass) {
421:
422: try {
423: AttributeDescriptor attrib;
424:
425: PropertyDescriptor prop_onselect = new PropertyDescriptorBase(
426: "onselect", beanClass, "getOnselect", "setOnselect");
427: prop_onselect.setDisplayName(resources
428: .getString("Properties_onselect_DisplayName"));
429: prop_onselect.setShortDescription(resources
430: .getString("Properties_onselect_Description"));
431: prop_onselect
432: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
433: attrib = new AttributeDescriptor("onselect", false, null,
434: true);
435: prop_onselect.setValue(
436: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
437: attrib);
438: prop_onselect
439: .setValue(
440: Constants.PropertyDescriptor.CATEGORY,
441: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
442:
443: List<PropertyDescriptor> propertyList = new ArrayList<PropertyDescriptor>();
444: propertyList.add(prop_onselect);
445: return propertyList;
446:
447: } catch (Exception e) {
448: e.printStackTrace();
449: }
450: return Collections.EMPTY_LIST;
451:
452: }
453:
454: static List<PropertyDescriptor> getChangeEventPropertyList(
455: Class beanClass) {
456:
457: try {
458: AttributeDescriptor attrib;
459:
460: PropertyDescriptor prop_onchange = new PropertyDescriptorBase(
461: "onchange", beanClass, "getOnchange", "setOnchange");
462: prop_onchange.setDisplayName(resources
463: .getString("Properties_onchange_DisplayName"));
464: prop_onchange.setShortDescription(resources
465: .getString("Properties_onchange_Description"));
466: prop_onchange
467: .setPropertyEditorClass(com.sun.rave.propertyeditors.JavaScriptPropertyEditor.class);
468: attrib = new AttributeDescriptor("onchange", false, null,
469: true);
470: prop_onchange.setValue(
471: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
472: attrib);
473: prop_onchange
474: .setValue(
475: Constants.PropertyDescriptor.CATEGORY,
476: com.sun.rave.designtime.base.CategoryDescriptors.JAVASCRIPT);
477:
478: List<PropertyDescriptor> propertyList = new ArrayList<PropertyDescriptor>();
479: propertyList.add(prop_onchange);
480: return propertyList;
481:
482: } catch (Exception e) {
483: e.printStackTrace();
484: }
485: return Collections.EMPTY_LIST;
486:
487: }
488: }
|