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.websvcmgr.codegen;
043:
044: import com.sun.tools.ws.processor.model.java.JavaMethod;
045: import com.sun.tools.ws.processor.model.java.JavaParameter;
046: import com.sun.tools.ws.processor.model.java.JavaMethod; /*
047: import com.sun.xml.rpc.processor.model.java.JavaException;
048: import com.sun.xml.rpc.processor.model.java.JavaParameter;
049: import com.sun.xml.rpc.processor.model.java.JavaMethod;
050: */
051:
052: // SD import org.netbeans.modules.visualweb.xml.rpc.processor.model.java.JavaException;
053: // SD import org.netbeans.modules.visualweb.xml.rpc.processor.model.java.JavaMethod;
054: // SD import org.netbeans.modules.visualweb.xml.rpc.processor.model.java.JavaParameter;
055:
056: import java.io.OutputStreamWriter;
057: import java.io.PrintWriter;
058: import java.io.Writer;
059: import java.util.HashSet;
060: import java.util.Iterator;
061: import java.util.Set;
062:
063: /**
064: * A simple writer to write the Bean Info Class.
065: * @author Winston Prakash
066: */
067: public class WrapperClientBeanInfoWriter extends java.io.PrintWriter {
068:
069: private String className;
070: private String super ClassName;
071: private String packageName;
072:
073: private Set constructorStatements = new HashSet();
074:
075: public static String WEBSERVICE_ICON_FILENAME = "webservice.png";
076:
077: int indent = 0;
078:
079: /** Creates a new instance of JavaWriter */
080: public WrapperClientBeanInfoWriter(Writer writer) {
081: super (writer);
082: setSuperClass("SimpleBeanInfo");
083: }
084:
085: /** Set package name */
086: public void setPackage(String pkgName) {
087: packageName = pkgName;
088: }
089:
090: /** Set the name of the class */
091: public void setClassName(String name) {
092: className = name;
093: }
094:
095: /** Set the name of the super class this class would extends */
096: public void setSuperClass(String super Class) {
097: super ClassName = super Class;
098: }
099:
100: public void writeBeanInfo() {
101: // Write the Package name
102: println("package " + packageName + ";");
103: println();
104:
105: println("import java.awt.Image;");
106: println("import java.beans.BeanDescriptor;");
107: println("import java.beans.PropertyDescriptor;");
108: println("import java.beans.SimpleBeanInfo;");
109: println();
110:
111: // Write the class signature
112: print("public class " + className + "BeanInfo");
113: if (super ClassName != null)
114: print(" extends " + super ClassName + " ");
115: println(" {");
116: println();
117:
118: println(" private Class beanClass = " + className + ".class;");
119: println(" private String iconFileName = \""
120: + this .WEBSERVICE_ICON_FILENAME + "\";");
121: println(" private BeanDescriptor beanDescriptor = null;");
122: println(" private PropertyDescriptor[] propDescriptors = null;");
123:
124: println();
125:
126: println(" public BeanDescriptor getBeanDescriptor() {");
127: println(" if (beanDescriptor == null) {");
128: println(" beanDescriptor = new BeanDescriptor(beanClass);");
129: println(" beanDescriptor.setValue(\"trayComponent\", Boolean.TRUE);");
130: println(" }");
131: println(" return beanDescriptor;");
132: println(" }");
133:
134: println();
135:
136: println(" public PropertyDescriptor[] getPropertyDescriptors() {");
137: println(" if (propDescriptors == null) {");
138: println(" propDescriptors = new PropertyDescriptor[] {");
139: println(" ");
140: println(" };");
141: println(" }");
142: println(" return propDescriptors;");
143: println(" }");
144:
145: println();
146:
147: println(" public Image getIcon(int iconKind) {");
148: println(" return loadImage(iconFileName);");
149: println(" }");
150:
151: println("}");
152: }
153:
154: /**
155: * @param args the command line arguments
156: */
157: public static void main(String[] args) {
158: try {
159: WrapperClientBeanInfoWriter beanWriter = new WrapperClientBeanInfoWriter(
160: new OutputStreamWriter(System.out));
161: beanWriter.setPackage("untitled");
162: beanWriter.setClassName("WebserviceProxyClient");
163: beanWriter.writeBeanInfo();
164: beanWriter.flush();
165: beanWriter.close();
166: } catch (Exception exc) {
167: exc.printStackTrace();
168: }
169: }
170:
171: }
|