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.data;
043:
044: import java.awt.Image;
045: import java.beans.BeanDescriptor;
046: import java.beans.BeanInfo;
047: import java.beans.EventSetDescriptor;
048: import java.beans.IntrospectionException;
049: import java.beans.MethodDescriptor;
050: import java.beans.PropertyDescriptor;
051: import java.beans.SimpleBeanInfo;
052: import javax.faces.model.DataModelListener;
053: import com.sun.rave.designtime.Constants;
054: import com.sun.rave.designtime.base.CategoryDescriptors;
055: import com.sun.rave.faces.data.RowSetDataModel;
056: import org.openide.util.Exceptions;
057:
058: public class RowSetDataModelBeanInfo extends SimpleBeanInfo {
059:
060: public RowSetDataModelBeanInfo() throws NoSuchMethodException {
061: }
062:
063: private BeanDescriptor beanDescriptor;
064:
065: public BeanDescriptor getBeanDescriptor() {
066: if (beanDescriptor == null) {
067: beanDescriptor = new BeanDescriptor(RowSetDataModel.class,
068: null);
069: //beanDescriptor.setValue(Constants.BeanDescriptor.TRAY_COMPONENT, Boolean.FALSE);
070: }
071: return beanDescriptor;
072: }
073:
074: //public int getDefaultEventIndex() {}
075:
076: public int getDefaultPropertyIndex() {
077: return 0;
078: }
079:
080: public EventSetDescriptor[] getEventSetDescriptors() {
081: try {
082: EventSetDescriptor[] eventSetDescriptors = new EventSetDescriptor[] { new EventSetDescriptor(
083: RowSetDataModel.class,
084: "dataModel", //NOI18N
085: DataModelListener.class,
086: new String[] { "rowSelected" }
087:
088: , //NOI18N
089: "addDataModelListener", "removeDataModelListener") //NOI18N
090: };
091:
092: return eventSetDescriptors;
093: } catch (IntrospectionException e) {
094: Exceptions.printStackTrace(e);
095: return null;
096: }
097: }
098:
099: public Image getIcon(int iconKind) {
100: switch (iconKind) {
101: case BeanInfo.ICON_COLOR_16x16:
102: return loadImage("RowSetDataModelIconColor16.png"); //NOI18N
103: case BeanInfo.ICON_COLOR_32x32:
104: return loadImage("RowSetDataModelIconColor32.gif"); //NOI18N
105: case BeanInfo.ICON_MONO_16x16:
106: return loadImage("RowSetDataModelIconMono16.gif"); //NOI18N
107: case BeanInfo.ICON_MONO_32x32:
108: return loadImage("RowSetDataModelIconMono32.gif"); //NOI18N
109: }
110: return null;
111: }
112:
113: public synchronized MethodDescriptor[] getMethodDescriptors() {
114: try {
115: MethodDescriptor[] methodDescriptors = new MethodDescriptor[] {
116: new MethodDescriptor(RowSetDataModel.class
117: .getMethod("clear", null)), //NOI18N
118: new MethodDescriptor(RowSetDataModel.class
119: .getMethod("commit", null)), //NOI18N
120: new MethodDescriptor(RowSetDataModel.class
121: .getMethod("reset", null)), //NOI18N
122: new MethodDescriptor(RowSetDataModel.class
123: .getMethod("rollback", null)), //NOI18N
124: };
125:
126: return methodDescriptors;
127: } catch (NoSuchMethodException e) {
128: Exceptions.printStackTrace(e);
129: return null;
130: }
131: }
132:
133: public synchronized PropertyDescriptor[] getPropertyDescriptors() {
134: try {
135: PropertyDescriptor[] propertyDescriptors;
136:
137: PropertyDescriptor dataCacheKey = new PropertyDescriptor(
138: "dataCacheKey", RowSetDataModel.class,
139: "getDataCacheKey", "setDataCacheKey"); // NOI18N
140: dataCacheKey.setValue(
141: Constants.PropertyDescriptor.CATEGORY,
142: CategoryDescriptors.DATA);
143:
144: PropertyDescriptor rowSet = new PropertyDescriptor(
145: "rowSet", RowSetDataModel.class, "getRowSet",
146: "setRowSet"); //NOI18N
147: rowSet.setValue(Constants.PropertyDescriptor.CATEGORY,
148: CategoryDescriptors.ADVANCED);
149:
150: PropertyDescriptor schemaName = new PropertyDescriptor(
151: "schemaName", RowSetDataModel.class,
152: "getSchemaName", "setSchemaName"); // NOI18N
153: schemaName.setValue(Constants.PropertyDescriptor.CATEGORY,
154: CategoryDescriptors.DATA);
155:
156: PropertyDescriptor tableName = new PropertyDescriptor(
157: "tableName", RowSetDataModel.class, "getTableName",
158: "setTableName"); // NOI18N
159: tableName.setValue(Constants.PropertyDescriptor.CATEGORY,
160: CategoryDescriptors.DATA);
161:
162: propertyDescriptors = new PropertyDescriptor[] {
163: dataCacheKey, rowSet, schemaName, tableName, };
164:
165: return propertyDescriptors;
166: } catch (IntrospectionException e) {
167: Exceptions.printStackTrace(e);
168: return null;
169: }
170: }
171: }
|