Dead module.
1.1 --- a/clazz/build.xml Fri Sep 17 18:36:33 2010 -0400
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,48 +0,0 @@
1.4 -<?xml version="1.0" encoding="UTF-8"?>
1.5 -<!--
1.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1.7 -
1.8 -Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
1.9 -
1.10 -
1.11 -The contents of this file are subject to the terms of either the GNU
1.12 -General Public License Version 2 only ("GPL") or the Common
1.13 -Development and Distribution License("CDDL") (collectively, the
1.14 -"License"). You may not use this file except in compliance with the
1.15 -License. You can obtain a copy of the License at
1.16 -http://www.netbeans.org/cddl-gplv2.html
1.17 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
1.18 -specific language governing permissions and limitations under the
1.19 -License. When distributing the software, include this License Header
1.20 -Notice in each file and include the License file at
1.21 -nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
1.22 -particular file as subject to the "Classpath" exception as provided
1.23 -by Sun in the GPL Version 2 section of the License file that
1.24 -accompanied this code. If applicable, add the following below the
1.25 -License Header, with the fields enclosed by brackets [] replaced by
1.26 -your own identifying information:
1.27 -"Portions Copyrighted [year] [name of copyright owner]"
1.28 -
1.29 -Contributor(s):
1.30 -
1.31 -The Original Software is NetBeans. The Initial Developer of the Original
1.32 -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
1.33 -Microsystems, Inc. All Rights Reserved.
1.34 -
1.35 -If you wish your version of this file to be governed by only the CDDL
1.36 -or only the GPL Version 2, indicate your decision by adding
1.37 -"[Contributor] elects to include this software in this distribution
1.38 -under the [CDDL or GPL Version 2] license." If you do not indicate a
1.39 -single choice of license, a recipient has the option to distribute
1.40 -your version of this file under either the CDDL, the GPL Version 2 or
1.41 -to extend the choice of license to its licensees as provided above.
1.42 -However, if you add GPL Version 2 code and therefore, elected the GPL
1.43 -Version 2 license, then the option applies only if the new code is
1.44 -made subject to such option by the copyright holder.
1.45 --->
1.46 -
1.47 -<project name="contrib/clazz" default="netbeans" basedir=".">
1.48 -
1.49 - <import file="../../nbbuild/templates/projectized.xml"/>
1.50 -
1.51 -</project>
2.1 --- a/clazz/l10n.list Fri Sep 17 18:36:33 2010 -0400
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,1 +0,0 @@
2.4 -clazz/src/**/Bundle*.properties
3.1 --- a/clazz/manifest.mf Fri Sep 17 18:36:33 2010 -0400
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,9 +0,0 @@
3.4 -Manifest-Version: 1.0
3.5 -OpenIDE-Module-Layer: org/netbeans/modules/clazz/resources/mf-layer.xml
3.6 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/clazz/Bundle.properties
3.7 -OpenIDE-Module-Specification-Version: 1.20
3.8 -OpenIDE-Module: org.netbeans.modules.clazz/1
3.9 -
3.10 -Name: org/netbeans/modules/clazz/ClassDataLoader.class
3.11 -OpenIDE-Module-Class: Loader
3.12 -
4.1 --- a/clazz/nbproject/project.properties Fri Sep 17 18:36:33 2010 -0400
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,38 +0,0 @@
4.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4.5 -#
4.6 -# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
4.7 -#
4.8 -# The contents of this file are subject to the terms of either the GNU
4.9 -# General Public License Version 2 only ("GPL") or the Common
4.10 -# Development and Distribution License("CDDL") (collectively, the
4.11 -# "License"). You may not use this file except in compliance with the
4.12 -# License. You can obtain a copy of the License at
4.13 -# http://www.netbeans.org/cddl-gplv2.html
4.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
4.15 -# specific language governing permissions and limitations under the
4.16 -# License. When distributing the software, include this License Header
4.17 -# Notice in each file and include the License file at
4.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
4.19 -# particular file as subject to the "Classpath" exception as provided
4.20 -# by Sun in the GPL Version 2 section of the License file that
4.21 -# accompanied this code. If applicable, add the following below the
4.22 -# License Header, with the fields enclosed by brackets [] replaced by
4.23 -# your own identifying information:
4.24 -# "Portions Copyrighted [year] [name of copyright owner]"
4.25 -#
4.26 -# Contributor(s):
4.27 -#
4.28 -# The Original Software is NetBeans. The Initial Developer of the Original
4.29 -# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
4.30 -# Microsystems, Inc. All Rights Reserved.
4.31 -#
4.32 -# If you wish your version of this file to be governed by only the CDDL
4.33 -# or only the GPL Version 2, indicate your decision by adding
4.34 -# "[Contributor] elects to include this software in this distribution
4.35 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
4.36 -# single choice of license, a recipient has the option to distribute
4.37 -# your version of this file under either the CDDL, the GPL Version 2 or
4.38 -# to extend the choice of license to its licensees as provided above.
4.39 -# However, if you add GPL Version 2 code and therefore, elected the GPL
4.40 -# Version 2 license, then the option applies only if the new code is
4.41 -# made subject to such option by the copyright holder.
5.1 --- a/clazz/nbproject/project.xml Fri Sep 17 18:36:33 2010 -0400
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,141 +0,0 @@
5.4 -<?xml version="1.0" encoding="UTF-8"?>
5.5 -<!--
5.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5.7 -
5.8 -Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5.9 -
5.10 -
5.11 -The contents of this file are subject to the terms of either the GNU
5.12 -General Public License Version 2 only ("GPL") or the Common
5.13 -Development and Distribution License("CDDL") (collectively, the
5.14 -"License"). You may not use this file except in compliance with the
5.15 -License. You can obtain a copy of the License at
5.16 -http://www.netbeans.org/cddl-gplv2.html
5.17 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
5.18 -specific language governing permissions and limitations under the
5.19 -License. When distributing the software, include this License Header
5.20 -Notice in each file and include the License file at
5.21 -nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
5.22 -particular file as subject to the "Classpath" exception as provided
5.23 -by Sun in the GPL Version 2 section of the License file that
5.24 -accompanied this code. If applicable, add the following below the
5.25 -License Header, with the fields enclosed by brackets [] replaced by
5.26 -your own identifying information:
5.27 -"Portions Copyrighted [year] [name of copyright owner]"
5.28 -
5.29 -Contributor(s):
5.30 -
5.31 -The Original Software is NetBeans. The Initial Developer of the Original
5.32 -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
5.33 -Microsystems, Inc. All Rights Reserved.
5.34 -
5.35 -If you wish your version of this file to be governed by only the CDDL
5.36 -or only the GPL Version 2, indicate your decision by adding
5.37 -"[Contributor] elects to include this software in this distribution
5.38 -under the [CDDL or GPL Version 2] license." If you do not indicate a
5.39 -single choice of license, a recipient has the option to distribute
5.40 -your version of this file under either the CDDL, the GPL Version 2 or
5.41 -to extend the choice of license to its licensees as provided above.
5.42 -However, if you add GPL Version 2 code and therefore, elected the GPL
5.43 -Version 2 license, then the option applies only if the new code is
5.44 -made subject to such option by the copyright holder.
5.45 --->
5.46 -<project xmlns="http://www.netbeans.org/ns/project/1">
5.47 - <type>org.netbeans.modules.apisupport.project</type>
5.48 - <configuration>
5.49 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
5.50 - <code-name-base>org.netbeans.modules.clazz</code-name-base>
5.51 - <module-dependencies>
5.52 - <dependency>
5.53 - <code-name-base>org.netbeans.api.java</code-name-base>
5.54 - <build-prerequisite/>
5.55 - <compile-dependency/>
5.56 - <run-dependency>
5.57 - <release-version>1</release-version>
5.58 - <specification-version>1.18</specification-version>
5.59 - </run-dependency>
5.60 - </dependency>
5.61 - <dependency>
5.62 - <code-name-base>org.netbeans.api.java.classpath</code-name-base>
5.63 - <build-prerequisite/>
5.64 - <compile-dependency/>
5.65 - <run-dependency>
5.66 - <release-version>1</release-version>
5.67 - <specification-version>1.0</specification-version>
5.68 - </run-dependency>
5.69 - </dependency>
5.70 - <dependency>
5.71 - <code-name-base>org.netbeans.modules.classfile</code-name-base>
5.72 - <build-prerequisite/>
5.73 - <compile-dependency/>
5.74 - <run-dependency>
5.75 - <release-version>1</release-version>
5.76 - </run-dependency>
5.77 - </dependency>
5.78 - <dependency>
5.79 - <code-name-base>org.openide.filesystems</code-name-base>
5.80 - <build-prerequisite/>
5.81 - <compile-dependency/>
5.82 - <run-dependency>
5.83 - <specification-version>7.19</specification-version>
5.84 - </run-dependency>
5.85 - </dependency>
5.86 - <dependency>
5.87 - <code-name-base>org.openide.util</code-name-base>
5.88 - <build-prerequisite/>
5.89 - <compile-dependency/>
5.90 - <run-dependency>
5.91 - <specification-version>6.2</specification-version>
5.92 - </run-dependency>
5.93 - </dependency>
5.94 - <dependency>
5.95 - <code-name-base>org.openide.nodes</code-name-base>
5.96 - <build-prerequisite/>
5.97 - <compile-dependency/>
5.98 - <run-dependency>
5.99 - <specification-version>6.2</specification-version>
5.100 - </run-dependency>
5.101 - </dependency>
5.102 - <dependency>
5.103 - <code-name-base>org.openide.explorer</code-name-base>
5.104 - <build-prerequisite/>
5.105 - <compile-dependency/>
5.106 - <run-dependency>
5.107 - <specification-version>6.8</specification-version>
5.108 - </run-dependency>
5.109 - </dependency>
5.110 - <dependency>
5.111 - <code-name-base>org.openide.awt</code-name-base>
5.112 - <build-prerequisite/>
5.113 - <compile-dependency/>
5.114 - <run-dependency>
5.115 - <specification-version>6.2</specification-version>
5.116 - </run-dependency>
5.117 - </dependency>
5.118 - <dependency>
5.119 - <code-name-base>org.openide.dialogs</code-name-base>
5.120 - <build-prerequisite/>
5.121 - <compile-dependency/>
5.122 - <run-dependency>
5.123 - <specification-version>6.2</specification-version>
5.124 - </run-dependency>
5.125 - </dependency>
5.126 - <dependency>
5.127 - <code-name-base>org.openide.actions</code-name-base>
5.128 - <build-prerequisite/>
5.129 - <compile-dependency/>
5.130 - <run-dependency>
5.131 - <specification-version>6.2</specification-version>
5.132 - </run-dependency>
5.133 - </dependency>
5.134 - <dependency>
5.135 - <code-name-base>org.openide.loaders</code-name-base>
5.136 - <build-prerequisite/>
5.137 - <compile-dependency/>
5.138 - <run-dependency/>
5.139 - </dependency>
5.140 - </module-dependencies>
5.141 - <public-packages/>
5.142 - </data>
5.143 - </configuration>
5.144 -</project>
6.1 --- a/clazz/src/org/netbeans/modules/clazz/Bundle.properties Fri Sep 17 18:36:33 2010 -0400
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,91 +0,0 @@
6.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
6.5 -#
6.6 -# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6.7 -#
6.8 -# The contents of this file are subject to the terms of either the GNU
6.9 -# General Public License Version 2 only ("GPL") or the Common
6.10 -# Development and Distribution License("CDDL") (collectively, the
6.11 -# "License"). You may not use this file except in compliance with the
6.12 -# License. You can obtain a copy of the License at
6.13 -# http://www.netbeans.org/cddl-gplv2.html
6.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
6.15 -# specific language governing permissions and limitations under the
6.16 -# License. When distributing the software, include this License Header
6.17 -# Notice in each file and include the License file at
6.18 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
6.19 -# particular file as subject to the "Classpath" exception as provided
6.20 -# by Sun in the GPL Version 2 section of the License file that
6.21 -# accompanied this code. If applicable, add the following below the
6.22 -# License Header, with the fields enclosed by brackets [] replaced by
6.23 -# your own identifying information:
6.24 -# "Portions Copyrighted [year] [name of copyright owner]"
6.25 -#
6.26 -# Contributor(s):
6.27 -#
6.28 -# The Original Software is NetBeans. The Initial Developer of the Original
6.29 -# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
6.30 -# Microsystems, Inc. All Rights Reserved.
6.31 -#
6.32 -# If you wish your version of this file to be governed by only the CDDL
6.33 -# or only the GPL Version 2, indicate your decision by adding
6.34 -# "[Contributor] elects to include this software in this distribution
6.35 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
6.36 -# single choice of license, a recipient has the option to distribute
6.37 -# your version of this file under either the CDDL, the GPL Version 2 or
6.38 -# to extend the choice of license to its licensees as provided above.
6.39 -# However, if you add GPL Version 2 code and therefore, elected the GPL
6.40 -# Version 2 license, then the option applies only if the new code is
6.41 -# made subject to such option by the copyright holder.
6.42 -
6.43 -
6.44 -# Localizable manifest entries
6.45 -OpenIDE-Module-Name=Sourceless Java Classes
6.46 -OpenIDE-Module-Short-Description=Supports work with Java class files without source.
6.47 -OpenIDE-Module-Long-Description=The Sourceless Java Classes module enables you to work with class files that are without their corresponding source file. It also supports serialized JavaBeans components.
6.48 -OpenIDE-Module-Display-Category=Java
6.49 -
6.50 -# ClassDataObject properties
6.51 -PROP_isInterface=Is Interface
6.52 -PROP_isApplet=Is Applet
6.53 -PROP_isJavaBean=Is Bean
6.54 -PROP_isExecutable=Is Executable
6.55 -PROP_superclass=Superclass
6.56 -PROP_modifiers=Modifiers
6.57 -PROP_className=Class Name
6.58 -# ClassDataObject messages
6.59 -TXT_NoSources=Source file for {0} not found.
6.60 -
6.61 -HINT_isInterface=Is this an interface or a class?
6.62 -HINT_isApplet=Is this class an applet?
6.63 -HINT_isJavaBean=Is this class a bean?
6.64 -HINT_isExecutable=Is this class executable?
6.65 -HINT_superclass=Superclass of this class.
6.66 -HINT_modifiers=Java modifiers of this element.
6.67 -HINT_className=Class name.
6.68 -
6.69 -# ClassDataLoaderBeanInfo
6.70 -PROP_Extensions=Extensions
6.71 -HINT_Extensions=A set of possible extensions for classes.
6.72 -
6.73 -PROP_ClassLoader_Name=Class Objects
6.74 -
6.75 -CTL_Rewrite=Rewrite
6.76 -CTL_Rename=Rename
6.77 -CTL_Cancel=Cancel
6.78 -# {0} = filename, {1} = folder name
6.79 -MSG_SerExists=File {0} already exists in the {1} directory.
6.80 -
6.81 -#ClassElementNodeFactory
6.82 -CTL_Class_name_format={C}
6.83 -
6.84 -#ClassDataNode
6.85 -FMT_ErrorHint=Errors introspecting class: {0}
6.86 -
6.87 -# ElementImpls and descendants
6.88 -MSG_CantModify=Changes to sourceless elements are not supported.
6.89 -MSG_INVName=Invalid serialized class name.
6.90 -
6.91 -# SerStructureNode
6.92 -LBL_ser_stream=Serialized stream
6.93 -# {0} - class name
6.94 -LBL_instance_of=instance of {0}
7.1 --- a/clazz/src/org/netbeans/modules/clazz/ClassDataLoader.java Fri Sep 17 18:36:33 2010 -0400
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,180 +0,0 @@
7.4 -/*
7.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
7.6 - *
7.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
7.8 - *
7.9 - * The contents of this file are subject to the terms of either the GNU
7.10 - * General Public License Version 2 only ("GPL") or the Common
7.11 - * Development and Distribution License("CDDL") (collectively, the
7.12 - * "License"). You may not use this file except in compliance with the
7.13 - * License. You can obtain a copy of the License at
7.14 - * http://www.netbeans.org/cddl-gplv2.html
7.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
7.16 - * specific language governing permissions and limitations under the
7.17 - * License. When distributing the software, include this License Header
7.18 - * Notice in each file and include the License file at
7.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
7.20 - * particular file as subject to the "Classpath" exception as provided
7.21 - * by Sun in the GPL Version 2 section of the License file that
7.22 - * accompanied this code. If applicable, add the following below the
7.23 - * License Header, with the fields enclosed by brackets [] replaced by
7.24 - * your own identifying information:
7.25 - * "Portions Copyrighted [year] [name of copyright owner]"
7.26 - *
7.27 - * Contributor(s):
7.28 - *
7.29 - * The Original Software is NetBeans. The Initial Developer of the Original
7.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
7.31 - * Microsystems, Inc. All Rights Reserved.
7.32 - *
7.33 - * If you wish your version of this file to be governed by only the CDDL
7.34 - * or only the GPL Version 2, indicate your decision by adding
7.35 - * "[Contributor] elects to include this software in this distribution
7.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
7.37 - * single choice of license, a recipient has the option to distribute
7.38 - * your version of this file under either the CDDL, the GPL Version 2 or
7.39 - * to extend the choice of license to its licensees as provided above.
7.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
7.41 - * Version 2 license, then the option applies only if the new code is
7.42 - * made subject to such option by the copyright holder.
7.43 - */
7.44 -
7.45 -package org.netbeans.modules.clazz;
7.46 -
7.47 -import java.io.IOException;
7.48 -
7.49 -import org.openide.filesystems.FileObject;
7.50 -import org.openide.loaders.*;
7.51 -import org.openide.util.NbBundle;
7.52 -
7.53 -
7.54 -/** The DataLoader for ClassDataObjects.
7.55 -* This class is final only for performance reasons,
7.56 -* can be happily unfinaled if desired.
7.57 -*
7.58 -* @author Jan Jancura, Ian Formanek, Dafe Simonek
7.59 -*/
7.60 -public final class ClassDataLoader extends MultiFileLoader {
7.61 -
7.62 - /** Extension constants */
7.63 - private static final String SER_EXT = "ser"; // NOI18N
7.64 - private static final String CLASS_EXT = "class"; // NOI18N
7.65 - private static final String REPRESENTATION_CLASS_NAME =
7.66 - "org.netbeans.modules.clazz.ClassDataObject"; // NOI18N
7.67 -
7.68 - private static final char INNER_CLASS_DIVIDER = '$';
7.69 -
7.70 - /** List of extensions recognized by this loader */
7.71 - private static ExtensionList extensions;
7.72 -
7.73 - static final long serialVersionUID =3149080169747384034L;
7.74 -
7.75 - /** Creates a new ClassDataLoader */
7.76 - public ClassDataLoader () {
7.77 - super(REPRESENTATION_CLASS_NAME);
7.78 - }
7.79 -
7.80 - protected String defaultDisplayName() {
7.81 - return NbBundle.getMessage (ClassDataLoader.class, "PROP_ClassLoader_Name");
7.82 - }
7.83 -
7.84 - protected String actionsContext () {
7.85 - return "Loaders/application/x-java-class/Actions/"; //NOI18N
7.86 - }
7.87 -
7.88 - /** For a given file finds a primary file.
7.89 - * @param fo the file to find primary file for
7.90 - *
7.91 - * @return the primary file for the file or null if the file is not
7.92 - * recognized by this loader
7.93 - */
7.94 - protected FileObject findPrimaryFile (FileObject fo) {
7.95 - // never recognize folders.
7.96 - if (fo.isFolder())
7.97 - return null;
7.98 - if (SER_EXT.equals(fo.getExt())) {
7.99 - // serialized file, return itself
7.100 - try {
7.101 - return fo.getFileSystem().isDefault() ? null : fo;
7.102 - } catch (org.openide.filesystems.FileStateInvalidException ex) {
7.103 - return null;
7.104 - }
7.105 - }
7.106 - if (CLASS_EXT.equals(fo.getExt())) {
7.107 - // class file
7.108 - return findPrimaryForClass(fo);
7.109 - }
7.110 - // not recognized
7.111 - return null;
7.112 - }
7.113 -
7.114 - /** Creates the right data object for given primary file.
7.115 - * It is guaranteed that the provided file is realy primary file
7.116 - * returned from the method findPrimaryFile.
7.117 - *
7.118 - * @param primaryFile the primary file
7.119 - * @return the data object for this file
7.120 - * @exception DataObjectExistsException if the primary file already has data object
7.121 - */
7.122 - protected MultiDataObject createMultiObject (FileObject primaryFile)
7.123 - throws DataObjectExistsException, IOException {
7.124 - if (SER_EXT.equals(primaryFile.getExt())) {
7.125 - // serialized file, return bean data object
7.126 - // moved to ClassDataObject class for performance reasons
7.127 - return ClassDataObject.createSerDataObject (primaryFile, this);
7.128 - }
7.129 - if (CLASS_EXT.equals(primaryFile.getExt())) {
7.130 - // class file, return class data object
7.131 - // moved to ClassDataObject class for performance reasons
7.132 - return ClassDataObject.createCompiledDataObject (primaryFile, this);
7.133 - }
7.134 - // otherwise
7.135 - return null;
7.136 - }
7.137 -
7.138 - /** Creates the right primary entry for given primary file.
7.139 - *
7.140 - * @param primaryFile primary file recognized by this loader
7.141 - * @return primary entry for that file
7.142 - */
7.143 - protected MultiDataObject.Entry createPrimaryEntry (MultiDataObject obj, FileObject primaryFile) {
7.144 - return new FileEntry(obj, primaryFile);
7.145 - }
7.146 -
7.147 - /** Creates right secondary entry for given file. The file is said to
7.148 - * belong to an object created by this loader.
7.149 - *
7.150 - * @param secondaryFile secondary file for which we want to create entry
7.151 - * @return the entry
7.152 - */
7.153 - protected MultiDataObject.Entry createSecondaryEntry (MultiDataObject obj, FileObject secondaryFile) {
7.154 - return new FileEntry(obj, secondaryFile);
7.155 - }
7.156 -
7.157 - /** Utility method, finds primary class file for given class file.
7.158 - * (input class file can be innerclass class file) */
7.159 - private FileObject findPrimaryForClass (final FileObject fo) {
7.160 - final String name = fo.getName();
7.161 - final int index = name.indexOf(INNER_CLASS_DIVIDER);
7.162 - if (index > 0) {
7.163 - // could be innerclass class file - try to find outer class file
7.164 - FileObject outer =
7.165 - fo.getParent().getFileObject(name.substring(0, index), CLASS_EXT);
7.166 - if (outer != null) return outer;
7.167 - }
7.168 - return fo;
7.169 - }
7.170 -
7.171 - /** @return The list of extensions this loader recognizes
7.172 - * (default list constains class, ser extensions)
7.173 - */
7.174 - public ExtensionList getExtensions () {
7.175 - if (extensions == null) {
7.176 - extensions = new ExtensionList();
7.177 - extensions.addExtension(CLASS_EXT);
7.178 - extensions.addExtension(SER_EXT);
7.179 - }
7.180 - return extensions;
7.181 - }
7.182 -}
7.183 -
8.1 --- a/clazz/src/org/netbeans/modules/clazz/ClassDataLoaderBeanInfo.java Fri Sep 17 18:36:33 2010 -0400
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,102 +0,0 @@
8.4 -/*
8.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8.6 - *
8.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
8.8 - *
8.9 - * The contents of this file are subject to the terms of either the GNU
8.10 - * General Public License Version 2 only ("GPL") or the Common
8.11 - * Development and Distribution License("CDDL") (collectively, the
8.12 - * "License"). You may not use this file except in compliance with the
8.13 - * License. You can obtain a copy of the License at
8.14 - * http://www.netbeans.org/cddl-gplv2.html
8.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
8.16 - * specific language governing permissions and limitations under the
8.17 - * License. When distributing the software, include this License Header
8.18 - * Notice in each file and include the License file at
8.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
8.20 - * particular file as subject to the "Classpath" exception as provided
8.21 - * by Sun in the GPL Version 2 section of the License file that
8.22 - * accompanied this code. If applicable, add the following below the
8.23 - * License Header, with the fields enclosed by brackets [] replaced by
8.24 - * your own identifying information:
8.25 - * "Portions Copyrighted [year] [name of copyright owner]"
8.26 - *
8.27 - * Contributor(s):
8.28 - *
8.29 - * The Original Software is NetBeans. The Initial Developer of the Original
8.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
8.31 - * Microsystems, Inc. All Rights Reserved.
8.32 - *
8.33 - * If you wish your version of this file to be governed by only the CDDL
8.34 - * or only the GPL Version 2, indicate your decision by adding
8.35 - * "[Contributor] elects to include this software in this distribution
8.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
8.37 - * single choice of license, a recipient has the option to distribute
8.38 - * your version of this file under either the CDDL, the GPL Version 2 or
8.39 - * to extend the choice of license to its licensees as provided above.
8.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
8.41 - * Version 2 license, then the option applies only if the new code is
8.42 - * made subject to such option by the copyright holder.
8.43 - */
8.44 -
8.45 -package org.netbeans.modules.clazz;
8.46 -
8.47 -import java.beans.*;
8.48 -import java.awt.Image;
8.49 -import java.util.ResourceBundle;
8.50 -
8.51 -import org.openide.loaders.MultiFileLoader;
8.52 -import org.openide.ErrorManager;
8.53 -import org.openide.util.NbBundle;
8.54 -import org.openide.util.Utilities;
8.55 -
8.56 -
8.57 -/** BeanInfo for class loader.
8.58 -*
8.59 -* @author Dafe Simonek
8.60 -*/
8.61 -public final class ClassDataLoaderBeanInfo extends SimpleBeanInfo {
8.62 -
8.63 - public BeanInfo[] getAdditionalBeanInfo () {
8.64 - try {
8.65 - return new BeanInfo[] { Introspector.getBeanInfo (MultiFileLoader.class) };
8.66 - } catch (IntrospectionException ie) {
8.67 - ErrorManager.getDefault().notify(ie);
8.68 - return null;
8.69 - }
8.70 - }
8.71 -
8.72 -
8.73 -
8.74 - /**
8.75 - * @return Returns an array of PropertyDescriptors
8.76 - * describing the editable properties supported by this bean.
8.77 - */
8.78 - public PropertyDescriptor[] getPropertyDescriptors () {
8.79 - final ResourceBundle bundle =
8.80 - NbBundle.getBundle(ClassDataLoaderBeanInfo.class);
8.81 - try {
8.82 - PropertyDescriptor[] descriptors = new PropertyDescriptor[] {
8.83 - new PropertyDescriptor ("extensions", ClassDataLoader.class, // NOI18N
8.84 - "getExtensions", null) // NOI18N
8.85 - };
8.86 - descriptors[0].setDisplayName(bundle.getString("PROP_Extensions"));
8.87 - descriptors[0].setShortDescription(bundle.getString("HINT_Extensions"));
8.88 - return descriptors;
8.89 - } catch (IntrospectionException e) {
8.90 - ErrorManager.getDefault().notify(e);
8.91 - return null;
8.92 - }
8.93 - }
8.94 -
8.95 - /** @param type Desired type of the icon
8.96 - * @return returns the Txt loader's icon
8.97 - */
8.98 - public Image getIcon(final int type) {
8.99 - if ((type == BeanInfo.ICON_COLOR_16x16) || (type == BeanInfo.ICON_MONO_16x16)) {
8.100 - return Utilities.loadImage("org/netbeans/modules/clazz/resources/class.gif"); // NOI18N
8.101 - } else {
8.102 - return Utilities.loadImage ("org/netbeans/modules/clazz/resources/class32.gif"); // NOI18N
8.103 - }
8.104 - }
8.105 -}
9.1 --- a/clazz/src/org/netbeans/modules/clazz/ClassDataNode.java Fri Sep 17 18:36:33 2010 -0400
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,293 +0,0 @@
9.4 -/*
9.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
9.6 - *
9.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
9.8 - *
9.9 - * The contents of this file are subject to the terms of either the GNU
9.10 - * General Public License Version 2 only ("GPL") or the Common
9.11 - * Development and Distribution License("CDDL") (collectively, the
9.12 - * "License"). You may not use this file except in compliance with the
9.13 - * License. You can obtain a copy of the License at
9.14 - * http://www.netbeans.org/cddl-gplv2.html
9.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
9.16 - * specific language governing permissions and limitations under the
9.17 - * License. When distributing the software, include this License Header
9.18 - * Notice in each file and include the License file at
9.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
9.20 - * particular file as subject to the "Classpath" exception as provided
9.21 - * by Sun in the GPL Version 2 section of the License file that
9.22 - * accompanied this code. If applicable, add the following below the
9.23 - * License Header, with the fields enclosed by brackets [] replaced by
9.24 - * your own identifying information:
9.25 - * "Portions Copyrighted [year] [name of copyright owner]"
9.26 - *
9.27 - * Contributor(s):
9.28 - *
9.29 - * The Original Software is NetBeans. The Initial Developer of the Original
9.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
9.31 - * Microsystems, Inc. All Rights Reserved.
9.32 - *
9.33 - * If you wish your version of this file to be governed by only the CDDL
9.34 - * or only the GPL Version 2, indicate your decision by adding
9.35 - * "[Contributor] elects to include this software in this distribution
9.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
9.37 - * single choice of license, a recipient has the option to distribute
9.38 - * your version of this file under either the CDDL, the GPL Version 2 or
9.39 - * to extend the choice of license to its licensees as provided above.
9.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
9.41 - * Version 2 license, then the option applies only if the new code is
9.42 - * made subject to such option by the copyright holder.
9.43 - */
9.44 -
9.45 -package org.netbeans.modules.clazz;
9.46 -
9.47 -import java.awt.Image;
9.48 -import java.beans.PropertyChangeEvent;
9.49 -import java.beans.PropertyChangeListener;
9.50 -import java.lang.reflect.*;
9.51 -import java.util.ResourceBundle;
9.52 -import java.io.*;
9.53 -import java.text.MessageFormat;
9.54 -
9.55 -import org.openide.nodes.*;
9.56 -import org.openide.loaders.DataNode;
9.57 -import org.openide.util.NbBundle;
9.58 -import org.openide.util.WeakListeners;
9.59 -import org.openide.src.*;
9.60 -import org.openide.src.nodes.SourceChildren;
9.61 -import org.openide.cookies.SourceCookie;
9.62 -import org.openide.ErrorManager;
9.63 -import org.openide.util.RequestProcessor;
9.64 -
9.65 -/** Represents ClassDataObject. Common base for CompiledDataNode (.class)
9.66 -* and SerDataNode (.ser and other serialized extensions)
9.67 -* @author Ales Novak, Ian Formanek, Jan Jancura, Dafe Simonek
9.68 -*/
9.69 -abstract class ClassDataNode extends DataNode
9.70 - implements Runnable, PropertyChangeListener {
9.71 - /** generated Serialized Version UID */
9.72 - static final long serialVersionUID = -1543899241509520203L;
9.73 -
9.74 - /** Properties */
9.75 - private final static String PROP_CLASS_NAME = "className"; // NOI18N
9.76 - private final static String PROP_IS_JAVA_BEAN = "isJavaBean"; // NOI18N
9.77 - private final static String PROP_IS_APPLET = "isApplet"; // NOI18N
9.78 -
9.79 - /** a flag whether the children of this object are only items declared
9.80 - * by this class, or all items (incl. inherited)
9.81 - */
9.82 - private boolean showDeclaredOnly = true; // [PENDING - get default value from somewhere ?]
9.83 -
9.84 - /** The flag indicating whether right icon has been already found */
9.85 - transient boolean iconResolved = false;
9.86 -
9.87 - /** Holds error message shown in node tooltip */
9.88 - transient String errorMsg;
9.89 -
9.90 - transient boolean initialized;
9.91 -
9.92 - private static final RequestProcessor iconResolver = new RequestProcessor("clazz icon resolver", 1); // NOI18N
9.93 - // -----------------------------------------------------------------------
9.94 - // constructor
9.95 -
9.96 - /** @param obj is a ClassDataObject that is to be represented
9.97 - */
9.98 - ClassDataNode(final ClassDataObject obj) {
9.99 - /* Changed for multiple factories
9.100 - super(obj, new SourceChildren(ClassElementNodeFactory.getInstance()));
9.101 - */
9.102 - this(obj, new LazySourceChildren( obj, ClassDataObject.getExplorerFactory()) );
9.103 - }
9.104 -
9.105 - protected ClassDataNode(ClassDataObject obj, Children ch) {
9.106 - super(obj, ch);
9.107 - initialize();
9.108 - }
9.109 -
9.110 - protected SourceChildren getSourceChildren() {
9.111 - return (SourceChildren)getChildren();
9.112 - }
9.113 -
9.114 - /** Returns icon base string which should be used for
9.115 - * icon inicialization. Subclasses can ovveride this method
9.116 - * to provide their own icon base string.
9.117 - */
9.118 - protected abstract String initialIconBase ();
9.119 -
9.120 - protected abstract void resolveIcons();
9.121 -
9.122 - protected abstract void requestResolveIcon();
9.123 -
9.124 - private void initialize () {
9.125 -
9.126 - setIconBase(initialIconBase());
9.127 - /* Disable the icon resolution - for now.
9.128 - *
9.129 - // icons...
9.130 - RequestProcessor.postRequest(this, 200);
9.131 - */
9.132 - }
9.133 -
9.134 - /**
9.135 - * If the image is not known, returns the basic (classfile) one and
9.136 - * requests image resolution. After the image is known, it returns the
9.137 - * cached image.
9.138 - */
9.139 - public Image getIcon(int type) {
9.140 - ensureIconResolved();
9.141 - return super.getIcon(type);
9.142 - }
9.143 -
9.144 - public Image getOpenedIcon(int type) {
9.145 - ensureIconResolved();
9.146 - return super.getOpenedIcon(type);
9.147 - }
9.148 -
9.149 - private void ensureIconResolved() {
9.150 - if (iconResolved)
9.151 - return;
9.152 - iconResolver.post(new Runnable() {
9.153 - public void run() {
9.154 - requestResolveIcon();
9.155 - }
9.156 - });
9.157 - }
9.158 -
9.159 - /** Creates property set for this node */
9.160 - protected Sheet createSheet () {
9.161 - Sheet s = super.createSheet();
9.162 - ResourceBundle bundle = NbBundle.getBundle(ClassDataNode.class);
9.163 - final ClassDataObject obj=(ClassDataObject)getDataObject();
9.164 - Sheet.Set ps = s.get(Sheet.PROPERTIES);
9.165 - ps.put(new PropertySupport.ReadOnly (
9.166 - PROP_CLASS_NAME,
9.167 - String.class,
9.168 - bundle.getString("PROP_className"),
9.169 - bundle.getString("HINT_className")
9.170 - ) {
9.171 - public Object getValue () throws InvocationTargetException {
9.172 - return obj.getClassName();
9.173 - }
9.174 - });
9.175 - ps.put(new PropertySupport.ReadOnly (
9.176 - ElementProperties.PROP_MODIFIERS,
9.177 - String.class,
9.178 - bundle.getString ("PROP_modifiers"),
9.179 - bundle.getString ("HINT_modifiers")
9.180 - ) {
9.181 - public Object getValue () throws InvocationTargetException {
9.182 - Object result = null;
9.183 - try {
9.184 - result = obj.getModifiers();
9.185 - } catch (IOException ex) {
9.186 - // ignore - return null
9.187 - } catch (ClassNotFoundException ex) {
9.188 - // ignore - return null
9.189 - }
9.190 - return result;
9.191 - }
9.192 - });
9.193 - ps.put(new PropertySupport.ReadOnly (
9.194 - ElementProperties.PROP_SUPERCLASS,
9.195 - String.class,
9.196 - bundle.getString ("PROP_superclass"),
9.197 - bundle.getString ("HINT_superclass")
9.198 - ) {
9.199 - public Object getValue () throws InvocationTargetException {
9.200 - return obj.getSuperclass();
9.201 - }
9.202 - });
9.203 - ps.put(new PropertySupport.ReadOnly (
9.204 - ElementProperties.PROP_CLASS_OR_INTERFACE,
9.205 - Boolean.TYPE,
9.206 - bundle.getString ("PROP_isInterface"),
9.207 - bundle.getString ("HINT_isInterface")
9.208 - ) {
9.209 - public Object getValue () throws InvocationTargetException {
9.210 - return obj.isInterface() ? Boolean.TRUE : Boolean.FALSE;
9.211 - }
9.212 - });
9.213 - ps.put(new PropertySupport.ReadOnly (
9.214 - PROP_IS_APPLET,
9.215 - Boolean.TYPE,
9.216 - bundle.getString ("PROP_isApplet"),
9.217 - bundle.getString ("HINT_isApplet")
9.218 - ) {
9.219 - public Object getValue () throws InvocationTargetException {
9.220 - return obj.isApplet() ? Boolean.TRUE : Boolean.FALSE;
9.221 - }
9.222 - });
9.223 - ps.put(new PropertySupport.ReadOnly (
9.224 - PROP_IS_JAVA_BEAN,
9.225 - Boolean.TYPE,
9.226 - bundle.getString ("PROP_isJavaBean"),
9.227 - bundle.getString ("HINT_isJavaBean")
9.228 - ) {
9.229 - public Object getValue () throws InvocationTargetException {
9.230 - return obj.isJavaBean() ? Boolean.TRUE : Boolean.FALSE;
9.231 - }
9.232 - });
9.233 - return s;
9.234 - }
9.235 -
9.236 - /** The implementation of the Runnable interface
9.237 - * (initialization tasks in separate thread)
9.238 - */
9.239 - public void run () {
9.240 - // set right source element to our children
9.241 - SourceCookie sc =
9.242 - (SourceCookie)getDataObject().getCookie(SourceCookie.class);
9.243 - if (sc != null) {
9.244 - if (!initialized)
9.245 - sc.getSource().addPropertyChangeListener(
9.246 - WeakListeners.propertyChange(this, sc.getSource()));
9.247 - initialized = true;
9.248 - }
9.249 - resolveIcons();
9.250 - }
9.251 -
9.252 - public void propertyChange(PropertyChangeEvent ev) {
9.253 - if (ElementProperties.PROP_STATUS.equals(ev.getPropertyName()))
9.254 - Util.getClassProcessor().post(this, 200);
9.255 - }
9.256 -
9.257 - // --------------------------------------------------------------------
9.258 - // private methods
9.259 -
9.260 -
9.261 - /** Sets error tooltip based on given exception message.
9.262 - * @param exc Exception which describes the failure.
9.263 - */
9.264 - protected void setErrorToolTip (Exception exc) {
9.265 - String errMsg = findErrorMessage(exc);
9.266 - errorMsg = NbBundle.getMessage(ClassDataNode.class, "FMT_ErrorHint",
9.267 - errMsg
9.268 - );
9.269 - setShortDescription(errorMsg);
9.270 - }
9.271 -
9.272 - private String findErrorMessage(Throwable t) {
9.273 - if (t == null) {
9.274 - return null;
9.275 - }
9.276 -
9.277 - ErrorManager.Annotation[] ann = ErrorManager.getDefault().findAnnotations(t);
9.278 - if (ann == null)
9.279 - return t.getLocalizedMessage();
9.280 - for (int i = 0; i < ann.length; i++) {
9.281 - String normal = ann[i].getMessage();
9.282 - String localized = ann[i].getLocalizedMessage();
9.283 - if (localized != null)
9.284 - return localized;
9.285 - Throwable t2 = ann[i].getStackTrace();
9.286 - if (t2 == null)
9.287 - continue;
9.288 - localized = t2.getLocalizedMessage();
9.289 - if (localized != null) {
9.290 - if (!localized.equals(normal))
9.291 - return localized;
9.292 - }
9.293 - }
9.294 - return t.getLocalizedMessage();
9.295 - }
9.296 -}
10.1 --- a/clazz/src/org/netbeans/modules/clazz/ClassDataObject.java Fri Sep 17 18:36:33 2010 -0400
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,778 +0,0 @@
10.4 -/*
10.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
10.6 - *
10.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
10.8 - *
10.9 - * The contents of this file are subject to the terms of either the GNU
10.10 - * General Public License Version 2 only ("GPL") or the Common
10.11 - * Development and Distribution License("CDDL") (collectively, the
10.12 - * "License"). You may not use this file except in compliance with the
10.13 - * License. You can obtain a copy of the License at
10.14 - * http://www.netbeans.org/cddl-gplv2.html
10.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
10.16 - * specific language governing permissions and limitations under the
10.17 - * License. When distributing the software, include this License Header
10.18 - * Notice in each file and include the License file at
10.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
10.20 - * particular file as subject to the "Classpath" exception as provided
10.21 - * by Sun in the GPL Version 2 section of the License file that
10.22 - * accompanied this code. If applicable, add the following below the
10.23 - * License Header, with the fields enclosed by brackets [] replaced by
10.24 - * your own identifying information:
10.25 - * "Portions Copyrighted [year] [name of copyright owner]"
10.26 - *
10.27 - * Contributor(s):
10.28 - *
10.29 - * The Original Software is NetBeans. The Initial Developer of the Original
10.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
10.31 - * Microsystems, Inc. All Rights Reserved.
10.32 - *
10.33 - * If you wish your version of this file to be governed by only the CDDL
10.34 - * or only the GPL Version 2, indicate your decision by adding
10.35 - * "[Contributor] elects to include this software in this distribution
10.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
10.37 - * single choice of license, a recipient has the option to distribute
10.38 - * your version of this file under either the CDDL, the GPL Version 2 or
10.39 - * to extend the choice of license to its licensees as provided above.
10.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
10.41 - * Version 2 license, then the option applies only if the new code is
10.42 - * made subject to such option by the copyright holder.
10.43 - */
10.44 -
10.45 -package org.netbeans.modules.clazz;
10.46 -
10.47 -import java.beans.PropertyChangeEvent;
10.48 -import java.beans.PropertyChangeListener;
10.49 -import java.io.BufferedInputStream;
10.50 -import java.io.IOException;
10.51 -import java.io.InputStream;
10.52 -import java.io.ObjectInputStream;
10.53 -import java.io.ObjectStreamClass;
10.54 -import java.lang.ref.Reference;
10.55 -import java.lang.ref.WeakReference;
10.56 -import java.lang.reflect.Modifier;
10.57 -import java.text.MessageFormat;
10.58 -import java.util.Collection;
10.59 -import java.util.HashSet;
10.60 -import java.util.LinkedList;
10.61 -import javax.jmi.reflect.InvalidObjectException;
10.62 -import org.netbeans.api.java.classpath.ClassPath;
10.63 -import org.netbeans.api.java.queries.SourceForBinaryQuery;
10.64 -import org.netbeans.modules.classfile.ClassFile;
10.65 -import org.netbeans.spi.java.classpath.support.ClassPathSupport;
10.66 -import org.openide.ErrorManager;
10.67 -import org.openide.awt.StatusDisplayer;
10.68 -import org.openide.cookies.InstanceCookie;
10.69 -import org.openide.cookies.SourceCookie;
10.70 -import org.openide.cookies.OpenCookie;
10.71 -import org.openide.filesystems.FileChangeAdapter;
10.72 -import org.openide.filesystems.FileEvent;
10.73 -import org.openide.filesystems.FileObject;
10.74 -import org.openide.filesystems.FileStateInvalidException;
10.75 -import org.openide.filesystems.FileUtil;
10.76 -import org.openide.loaders.DataFolder;
10.77 -import org.openide.loaders.DataObject;
10.78 -import org.openide.loaders.DataObjectExistsException;
10.79 -import org.openide.loaders.DataObjectNotFoundException;
10.80 -import org.openide.loaders.InstanceSupport;
10.81 -import org.openide.loaders.MultiDataObject;
10.82 -import org.openide.loaders.MultiFileLoader;
10.83 -import org.openide.nodes.CookieSet.Factory;
10.84 -import org.openide.nodes.CookieSet;
10.85 -import org.openide.nodes.Node.Cookie;
10.86 -import org.openide.src.ClassElement;
10.87 -import org.openide.src.ConstructorElement;
10.88 -import org.openide.src.Identifier;
10.89 -import org.openide.src.SourceElement;
10.90 -import org.openide.src.Type;
10.91 -import org.openide.src.nodes.ElementNodeFactory;
10.92 -import org.openide.src.nodes.FilterFactory;
10.93 -import org.openide.util.NbBundle;
10.94 -
10.95 -/** This DataObject loads sourceless classes and provides a common framework
10.96 - * for presenting them in the IDE.
10.97 - * The descendants define specific behaviour, restrictions and operations.<P>
10.98 - * <B>Note:</B> The previous version of ClassDataObject has become CompiledDataObject.
10.99 - * Because ClassDataObject was public, the name was retained for compatibility reasons.
10.100 - * Method behaviour specific to compiled classes was moved to CompiledDataObject and
10.101 - * the behaviour specific to serialized objects was moved into SerDataObject.
10.102 - *
10.103 - * @author sdedic
10.104 - */
10.105 -public class ClassDataObject extends MultiDataObject implements Factory, SourceCookie {
10.106 - public static final String PROP_CLASS_LOADING_ERROR = "classLoadingError"; // NOI18N
10.107 - /**
10.108 - * Holds an exception that occured during an attempt to create the class.
10.109 - */
10.110 - private Throwable classLoadingError;
10.111 -
10.112 - /** The generic type */
10.113 - protected static final int UNDECIDED = 0;
10.114 -
10.115 - /** The DataObject contains an applet */
10.116 - protected static final int APPLET = 1;
10.117 -
10.118 - /** The DataObject is an application. */
10.119 - protected static final int APPLICATION = 2;
10.120 -
10.121 - /** CHANGE!!! */
10.122 - static final long serialVersionUID = -1;
10.123 -
10.124 - /** Support for working with class */
10.125 - transient private InstanceSupport instanceSupport;
10.126 -
10.127 - transient private boolean sourceCreated;
10.128 -
10.129 - transient PropL propL;
10.130 -
10.131 - transient Reference srcEl = new WeakReference(null);
10.132 -
10.133 - transient private ClassFile mainClass; // don't access directly, use getMainClass() instead
10.134 -
10.135 - /** Creates a new sourceless DataObject.
10.136 - */
10.137 - public ClassDataObject(final FileObject fo, final MultiFileLoader loader) throws DataObjectExistsException {
10.138 - super(fo, loader);
10.139 - }
10.140 -
10.141 - static ClassDataObject createSerDataObject(FileObject fo, ClassDataLoader dl)
10.142 - throws DataObjectExistsException, IOException {
10.143 - return new SerDataObject(fo, dl);
10.144 - }
10.145 -
10.146 - static ClassDataObject createCompiledDataObject(FileObject fo, ClassDataLoader dl)
10.147 - throws DataObjectExistsException, IOException {
10.148 - return new CompiledDataObject(fo, dl);
10.149 - }
10.150 -
10.151 - private class PropL extends FileChangeAdapter implements Runnable, PropertyChangeListener {
10.152 - public void propertyChange(PropertyChangeEvent ev) {
10.153 - String prop = ev.getPropertyName();
10.154 - if (PROP_PRIMARY_FILE.equals(prop)) {
10.155 - FileObject p = getPrimaryFile();
10.156 - p.addFileChangeListener(FileUtil.weakFileChangeListener(this, getPrimaryFile()));
10.157 - postReload();
10.158 - }
10.159 - }
10.160 -
10.161 - public void fileChanged(FileEvent ev) {
10.162 - postReload();
10.163 - }
10.164 -
10.165 - public void run() {
10.166 - forceReload();
10.167 - }
10.168 -
10.169 - private void postReload() {
10.170 - Util.getClassProcessor().post(this, 100);
10.171 - }
10.172 - }
10.173 -
10.174 - protected void initCookies() {
10.175 - CookieSet cs = getCookieSet();
10.176 - cs.add(new Class[] {
10.177 - SourceCookie.class,
10.178 - }, this);
10.179 - cs.add(OpenCookie.class,this);
10.180 - }
10.181 -
10.182 - /**
10.183 - * Creates InstanceSupport for the primary .class file.
10.184 - */
10.185 - protected InstanceSupport createInstanceSupport() {
10.186 - if (instanceSupport != null)
10.187 - return instanceSupport;
10.188 - synchronized (this) {
10.189 - if (instanceSupport == null) {
10.190 - instanceSupport = new ClazzInstanceSupport(getPrimaryEntry());
10.191 - if (propL == null) {
10.192 - propL = new PropL();
10.193 - FileObject p = getPrimaryFile();
10.194 - p.addFileChangeListener(FileUtil.weakFileChangeListener(propL, p));
10.195 - }
10.196 - }
10.197 - }
10.198 - return instanceSupport;
10.199 - }
10.200 -
10.201 - public SourceElement getSource() {
10.202 - SourceElement s;
10.203 -
10.204 - s = (SourceElement)srcEl.get();
10.205 - if (s != null)
10.206 - return s;
10.207 - synchronized (this) {
10.208 - s = (SourceElement)srcEl.get();
10.209 - if (s != null)
10.210 - return s;
10.211 - sourceCreated = true;
10.212 - s = new SourceElement(new SourceElementImpl(this));
10.213 - srcEl = new WeakReference(s);
10.214 - }
10.215 - return s;
10.216 - }
10.217 -
10.218 - public Cookie createCookie(Class desired) {
10.219 - if (desired == InstanceCookie.class) {
10.220 - return createInstanceSupport();
10.221 - }
10.222 - else if (OpenCookie.class.isAssignableFrom(desired)) {
10.223 - return new OpenSourceCookie ();
10.224 - }
10.225 - return null;
10.226 - }
10.227 -
10.228 - protected Throwable getClassLoadingError() {
10.229 - getClassFile();
10.230 - return classLoadingError;
10.231 - }
10.232 -
10.233 - /**
10.234 - * Forces reload of the class and the whole instance support.
10.235 - */
10.236 - protected void forceReload() {
10.237 - CookieSet s = getCookieSet();
10.238 - InstanceCookie prevCookie;
10.239 -
10.240 - prevCookie = instanceSupport;
10.241 - synchronized (this) {
10.242 - instanceSupport = null;
10.243 - mainClass = null;
10.244 - }
10.245 - // if the previous support was != null, it recreates the cookie
10.246 - // (and fires PROP_COOKIE change).
10.247 - if (prevCookie != null) {
10.248 - s.remove(prevCookie);
10.249 - s.add(new Class[] {
10.250 - InstanceCookie.class
10.251 - }, this);
10.252 - }
10.253 -
10.254 - if (sourceCreated) {
10.255 - SourceCookie sc = (SourceCookie)getCookie(SourceCookie.class);
10.256 - SourceElementImpl impl = (SourceElementImpl)sc.getSource().getCookie(SourceElement.Impl.class);
10.257 - if (impl != null)
10.258 - impl.setResource(null);
10.259 - }
10.260 - }
10.261 -
10.262 - /**
10.263 - * Returns the "main" class for this DataObject, or null if the class
10.264 - * cannot be loaded. In such case, it records the error trace into
10.265 - * {@link #classLoadingError} variable.
10.266 - */
10.267 - protected ClassFile getClassFile() {
10.268 - if (mainClass==null) {
10.269 - Throwable t = this.classLoadingError;
10.270 - classLoadingError = null;
10.271 - try {
10.272 - mainClass = loadClassFile();
10.273 - } catch (RuntimeException ex) {
10.274 - classLoadingError = ex;
10.275 - } catch (IOException ex) {
10.276 - classLoadingError = ex;
10.277 - } catch (ClassNotFoundException ex) {
10.278 - classLoadingError = ex;
10.279 - }
10.280 - if (classLoadingError != null)
10.281 - firePropertyChange(PROP_CLASS_LOADING_ERROR, t, classLoadingError);
10.282 - }
10.283 - return mainClass;
10.284 - }
10.285 -
10.286 - protected ClassElement getMainClass() {
10.287 - ClassElement ce[]=getSource().getClasses();
10.288 -
10.289 - if (ce.length==0)
10.290 - return null;
10.291 - return ce[0];
10.292 - }
10.293 -
10.294 - protected ClassFile loadClassFile() throws IOException,ClassNotFoundException {
10.295 - InputStream stream=getPrimaryEntry().getFile().getInputStream();
10.296 -
10.297 - if (stream==null)
10.298 - return null;
10.299 - try {
10.300 - return new ClassFile(stream,false);
10.301 - } finally {
10.302 - stream.close();
10.303 - }
10.304 - }
10.305 -
10.306 - // DataObject implementation .............................................
10.307 -
10.308 - /** Getter for copy action.
10.309 - * @return true if the object can be copied
10.310 - */
10.311 - public boolean isCopyAllowed () {
10.312 - return true;
10.313 - }
10.314 -
10.315 - public boolean isMoveAllowed() {
10.316 - return getPrimaryFile().canWrite();
10.317 - }
10.318 -
10.319 - public boolean isRenameAllowed() {
10.320 - return getPrimaryFile().canWrite();
10.321 - }
10.322 -
10.323 - // =======================================================================
10.324 - // Various properties describing the file although it is questionable to
10.325 - // put them at the file level. At least JavaBean and Applet are properties
10.326 - // of a class, not a file or serialized object.
10.327 - public boolean isJavaBean () {
10.328 - return createInstanceSupport().isJavaBean();
10.329 - }
10.330 -
10.331 - public boolean isApplet () {
10.332 - return createInstanceSupport().isApplet ();
10.333 - }
10.334 -
10.335 - public boolean isInterface () {
10.336 - return createInstanceSupport().isInterface ();
10.337 - }
10.338 -
10.339 - public String getSuperclass () {
10.340 - ClassElement ce=getMainClass();
10.341 -
10.342 - if (ce==null)
10.343 - return "";
10.344 - Identifier id = ce.getSuperclass();
10.345 - return id == null ? "" : id.getFullName();
10.346 - }
10.347 -
10.348 - public String getModifiers () throws IOException, ClassNotFoundException {
10.349 - ClassElement ce=getMainClass();
10.350 -
10.351 - if (ce==null)
10.352 - throw new ClassNotFoundException();
10.353 - return Modifier.toString(ce.getModifiers());
10.354 - }
10.355 -
10.356 - public String getClassName () {
10.357 - return createInstanceSupport().instanceName ();
10.358 - }
10.359 -
10.360 - public Class getBeanClass () throws IOException, ClassNotFoundException {
10.361 - return createInstanceSupport().instanceClass ();
10.362 - }
10.363 -
10.364 - // =============== The mechanism for regeisteing node factories ==============
10.365 -
10.366 - // =============== The mechanism for regeisteing node factories ==============
10.367 -
10.368 - private static NodeFactoryPool explorerFactories;
10.369 - private static NodeFactoryPool browserFactories;
10.370 - private static ElementNodeFactory basicBrowser;
10.371 - private static ElementNodeFactory basicExplorer;
10.372 -
10.373 - /**
10.374 - * DO NOT USE THIS METHOD!!! <P>
10.375 - * This method is intended to be called only during initialization of java
10.376 - * module-provided node factories from the installation layer. It won't
10.377 - * be maintained for compatibility reasons.
10.378 - */
10.379 - synchronized static ElementNodeFactory createBasicExplorerFactory() {
10.380 - if (basicExplorer == null) {
10.381 - basicExplorer = new ClassElementNodeFactory();
10.382 - }
10.383 - return basicExplorer;
10.384 - }
10.385 -
10.386 - /**
10.387 - * DO NOT USE THIS METHOD!!! <P>
10.388 - * This method is intended to be called only during initialization of java
10.389 - * module-provided node factories from the installation layer. It won't
10.390 - * be maintained for compatibility reasons.
10.391 - */
10.392 - synchronized static ElementNodeFactory createBasicBrowserFactory() {
10.393 - if (basicBrowser == null) {
10.394 - basicBrowser = new ClassElementNodeFactory();
10.395 - ((ClassElementNodeFactory)basicBrowser).setGenerateForTree (true);
10.396 - }
10.397 - return basicBrowser;
10.398 - }
10.399 -
10.400 - public static ElementNodeFactory getExplorerFactory() {
10.401 - NodeFactoryPool pool = createExplorerFactory();
10.402 - ElementNodeFactory f = null;
10.403 -
10.404 - if (pool != null)
10.405 - f = pool.getHead();
10.406 - if (f == null)
10.407 - f = createBasicExplorerFactory();
10.408 - return f;
10.409 - }
10.410 -
10.411 - public static ElementNodeFactory getBrowserFactory() {
10.412 - NodeFactoryPool pool = createBrowserFactory();
10.413 - ElementNodeFactory f = null;
10.414 -
10.415 - if (pool != null)
10.416 - f = pool.getHead();
10.417 - if (f == null)
10.418 - f = createBasicBrowserFactory();
10.419 - return f;
10.420 - }
10.421 -
10.422 - static NodeFactoryPool createFactoryPool(String folderName, ElementNodeFactory def) {
10.423 - FileObject f = FileUtil.getConfigFile(folderName);
10.424 - if (f == null)
10.425 - return null;
10.426 - try {
10.427 - DataFolder folder = (DataFolder)DataObject.find(f).getCookie(DataFolder.class);
10.428 - return new NodeFactoryPool(folder, def);
10.429 - } catch (DataObjectNotFoundException ex) {
10.430 - return null;
10.431 - }
10.432 - }
10.433 -
10.434 - synchronized static NodeFactoryPool createBrowserFactory() {
10.435 - if (browserFactories != null)
10.436 - return browserFactories;
10.437 - browserFactories = createFactoryPool("/NodeFactories/clazz/objectbrowser", createBasicBrowserFactory()); // NOI18N
10.438 - return browserFactories;
10.439 - }
10.440 -
10.441 - synchronized static NodeFactoryPool createExplorerFactory() {
10.442 - if (explorerFactories != null)
10.443 - return explorerFactories;
10.444 - explorerFactories = createFactoryPool("/NodeFactories/clazz/explorer", createBasicExplorerFactory()); // NOI18N
10.445 - return explorerFactories;
10.446 - }
10.447 -
10.448 - /**
10.449 - * @deprecated use installation layer for registering a factory for the the whole
10.450 - * time a module is installed. Note: This feature will be dropped in the next
10.451 - * release.
10.452 - */
10.453 - public static void addExplorerFilterFactory( FilterFactory factory ) {
10.454 - NodeFactoryPool p = createExplorerFactory();
10.455 - if (p != null)
10.456 - p.addFactory(factory);
10.457 - }
10.458 -
10.459 - /**
10.460 - * @deprecated use installation layer for registering a factory for the the whole
10.461 - * time a module is installed. Note: This feature will be dropped in the next
10.462 - * release.
10.463 - */
10.464 - public static void removeExplorerFilterFactory( FilterFactory factory ) {
10.465 - NodeFactoryPool p = createExplorerFactory();
10.466 - if (p != null)
10.467 - p.removeFactory(factory);
10.468 - }
10.469 -
10.470 - /**
10.471 - * @deprecated use installation layer for registering a factory for the the whole
10.472 - * time a module is installed. Note: This feature will be dropped in the next
10.473 - * release.
10.474 - */
10.475 - public static void addBrowserFilterFactory(FilterFactory factory) {
10.476 - NodeFactoryPool p = createBrowserFactory();
10.477 - if (p != null)
10.478 - p.addFactory(factory);
10.479 - }
10.480 -
10.481 - /**
10.482 - * @deprecated use installation layer for registering a factory for the the whole
10.483 - * time a module is installed. Note: This feature will be dropped in the next
10.484 - * release.
10.485 - */
10.486 - public static void removeBrowserFilterFactory( FilterFactory factory ) {
10.487 - NodeFactoryPool p = createBrowserFactory();
10.488 - if (p != null)
10.489 - p.removeFactory(factory);
10.490 - }
10.491 -
10.492 - protected final class ClazzInstanceSupport extends InstanceSupport {
10.493 -
10.494 - /** the class is bean */
10.495 - private Boolean bean;
10.496 -
10.497 - /** the class is executable */
10.498 - private Boolean executable;
10.499 -
10.500 - ClazzInstanceSupport(MultiDataObject.Entry entry) {
10.501 - super(entry);
10.502 - }
10.503 -
10.504 - public Class instanceClass() throws IOException, ClassNotFoundException {
10.505 - try {
10.506 - Class c = super.instanceClass();
10.507 - return c;
10.508 - } catch (RuntimeException ex) {
10.509 - // convert RuntimeExceptions -> CNFE
10.510 - ClassDataObject.this.classLoadingError = ex;
10.511 - throw new ClassNotFoundException(ex.getMessage());
10.512 - }
10.513 - }
10.514 -
10.515 - /**
10.516 - * Creates class loader that permits <<ALL FILES>> and all properties to be read,
10.517 - * and is based on a reference file.
10.518 - */
10.519 - protected ClassLoader createClassLoader(FileObject ref) {
10.520 - Collection c = new HashSet ();
10.521 - ClassPath cp = ClassPath.getClassPath(ref, ClassPath.COMPILE);
10.522 - if (cp != null) {
10.523 - c.add (cp);
10.524 - }
10.525 - cp = ClassPath.getClassPath(ref, ClassPath.EXECUTE);
10.526 - if (cp != null) {
10.527 - c.add (cp);
10.528 - }
10.529 - if (c.size()>0) {
10.530 - cp = ClassPathSupport.createProxyClassPath((ClassPath[])c.toArray(new ClassPath[c.size()]));
10.531 - return cp.getClassLoader(true);
10.532 - }
10.533 - else {
10.534 - return null;
10.535 - }
10.536 - }
10.537 -
10.538 - /** Is this a JavaBean?
10.539 - * @return <code>true</code> if this class represents JavaBean (is public and has a public default constructor).
10.540 - */
10.541 - public boolean isJavaBean() {
10.542 - if (bean != null) return bean.booleanValue ();
10.543 -
10.544 - // if from ser file => definitely it is a java bean
10.545 - if (isSerialized ()) {
10.546 - bean = Boolean.TRUE;
10.547 - return true;
10.548 - }
10.549 -
10.550 - // try to find out...
10.551 - try {
10.552 - ClassElement clazz = getMainClass();
10.553 -
10.554 - if (clazz==null) return false;
10.555 - int modif = clazz.getModifiers();
10.556 - if (!Modifier.isPublic(modif) || Modifier.isAbstract(modif)) {
10.557 - bean = Boolean.FALSE;
10.558 - return false;
10.559 - }
10.560 - ConstructorElement c=clazz.getConstructor(new Type[0]);
10.561 - if ((c == null) || !Modifier.isPublic(c.getModifiers())) {
10.562 - bean = Boolean.FALSE;
10.563 - return false;
10.564 - }
10.565 - // check: if the class is an inner class, all outer classes have
10.566 - // to be public and in the static context:
10.567 -
10.568 - for (ClassElement outer = clazz.getDeclaringClass(); outer != null; outer = outer.getDeclaringClass()) {
10.569 - // check if the enclosed class is static
10.570 - if (!Modifier.isStatic(modif)) {
10.571 - bean = Boolean.FALSE;
10.572 - return false;
10.573 - }
10.574 - modif = outer.getModifiers();
10.575 - // ... and the enclosing class is public
10.576 - if (!Modifier.isPublic(modif)) {
10.577 - bean = Boolean.FALSE;
10.578 - return false;
10.579 - }
10.580 - }
10.581 - } catch (InvalidObjectException ioe) {
10.582 - bean = Boolean.FALSE;
10.583 - return false;
10.584 - } catch (RuntimeException ex) {
10.585 - throw ex;
10.586 - } catch (ThreadDeath t) {
10.587 - throw t;
10.588 - } catch (Throwable t) {
10.589 - // false when other errors occur (NoClassDefFoundError etc...)
10.590 - bean = Boolean.FALSE;
10.591 - return false;
10.592 - }
10.593 - // okay, this is bean...
10.594 - // return isBean = java.io.Serializable.class.isAssignableFrom (clazz);
10.595 - bean = Boolean.TRUE;
10.596 - return true;
10.597 - }
10.598 -
10.599 - /** Is this an interface?
10.600 - * @return <code>true</code> if the class is an interface
10.601 - */
10.602 - public boolean isInterface() {
10.603 - ClassElement ce=getMainClass();
10.604 -
10.605 - return (ce==null)?false:ce.isInterface();
10.606 - }
10.607 -
10.608 - public String instanceName() {
10.609 - ClassElement ce=getMainClass();
10.610 -
10.611 - if (ce==null)
10.612 - return super.instanceName();
10.613 - return ce.getName().getFullName();
10.614 - }
10.615 -
10.616 - /*Query to found out if the object created by this cookie is
10.617 - * instance of given type.
10.618 - * @param type the class type we want to check
10.619 - * @return true if this cookie can produce object of given type
10.620 - */
10.621 - public boolean instanceOf(Class type) {
10.622 - String className=type.getName();
10.623 - ClassElement ce=getMainClass();
10.624 -
10.625 - if (ce == null)
10.626 - return false;
10.627 - boolean isClassType = !type.isInterface();
10.628 - String typename = type.getName().replace('$', '.');
10.629 - Identifier id;
10.630 - LinkedList l = new LinkedList();
10.631 -
10.632 - do {
10.633 - if (ce.getName().getFullName().equals(typename))
10.634 - return true;
10.635 - id = ce.getSuperclass();
10.636 - Identifier[] itfs = ce.getInterfaces();
10.637 - for (int i = 0; i < itfs.length; i++) {
10.638 - l.addLast(itfs[i]);
10.639 - }
10.640 - if (id == null) {
10.641 - if (l.isEmpty())
10.642 - return false;
10.643 - else
10.644 - id = (Identifier)l.removeFirst();
10.645 - }
10.646 - ce = ClassElement.forName(id.getFullName(), ClassDataObject.this.getPrimaryFile());
10.647 - while (ce == null && !l.isEmpty())
10.648 - ce = ClassElement.forName(((Identifier)l.removeFirst()).getFullName(),
10.649 - ClassDataObject.this.getPrimaryFile());
10.650 - } while (ce != null);
10.651 - return false;
10.652 - }
10.653 -
10.654 - /** Is this a standalone executable?
10.655 - * @return <code>true</code> if this class has main method
10.656 - * (e.g., <code>public static void main (String[] arguments)</code>).
10.657 - */
10.658 - public boolean isExecutable() {
10.659 - try {
10.660 - if (executable == null) {
10.661 - ClassElement ce=getMainClass();
10.662 -
10.663 - executable = ((ce==null) ? false : ce.hasMainMethod()) ? Boolean.TRUE : Boolean.FALSE;
10.664 - }
10.665 - } catch (InvalidObjectException ioe) {
10.666 - executable = Boolean.FALSE;
10.667 - }
10.668 - return executable.booleanValue();
10.669 - }
10.670 -
10.671 - /** Test whether the instance represents serialized version of a class
10.672 - * or not.
10.673 - * @return true if the file entry extension is ser
10.674 - */
10.675 - private boolean isSerialized () {
10.676 - return instanceOrigin().getExt().equals("ser"); // NOI18N
10.677 - }
10.678 -
10.679 - public Object instanceCreate() throws java.io.IOException, ClassNotFoundException {
10.680 - try {
10.681 - if (isSerialized()) {
10.682 - // create from ser file
10.683 - BufferedInputStream bis = new BufferedInputStream(instanceOrigin().getInputStream(), 1024);
10.684 - ClassLoader classLoader = createClassLoader(instanceOrigin());
10.685 - if (classLoader == null) {
10.686 - throw new ClassNotFoundException ();
10.687 - }
10.688 - CMObjectInputStream cis = new CMObjectInputStream(bis,classLoader);
10.689 - Object o = null;
10.690 - try {
10.691 - o = cis.readObject();
10.692 - } finally {
10.693 - cis.close();
10.694 - }
10.695 - return o;
10.696 - } else {
10.697 - return super.instanceCreate();
10.698 - }
10.699 - } catch (IOException ex) {
10.700 - // [PENDING] annotate with localized message
10.701 - ErrorManager.getDefault().annotate(ex, instanceName());
10.702 - throw ex;
10.703 - } catch (ClassNotFoundException ex) {
10.704 - throw ex;
10.705 - } catch (Exception e) {
10.706 - // turn other throwables into class not found ex.
10.707 - throw new ClassNotFoundException(e.toString(), e);
10.708 - } catch (LinkageError e) {
10.709 - throw new ClassNotFoundException(e.toString(), e);
10.710 -
10.711 - }
10.712 - }
10.713 -
10.714 - private final class CMObjectInputStream extends ObjectInputStream {
10.715 -
10.716 - private ClassLoader loader;
10.717 -
10.718 - protected CMObjectInputStream(InputStream s, ClassLoader cl) throws IOException {
10.719 - super(s);
10.720 - loader=cl;
10.721 - }
10.722 -
10.723 - protected Class resolveClass(ObjectStreamClass s) throws IOException, ClassNotFoundException {
10.724 - return Class.forName(s.getName(), false, loader);
10.725 - }
10.726 -
10.727 - }
10.728 - }
10.729 -
10.730 - private class OpenSourceCookie implements OpenCookie {
10.731 -
10.732 - public void open() {
10.733 - try {
10.734 - FileObject fo = getPrimaryFile();
10.735 - FileObject binaryRoot = null;
10.736 - String resourceName = null;
10.737 - ClassPath cp = ClassPath.getClassPath (fo, ClassPath.COMPILE);
10.738 - if (cp == null || (binaryRoot = cp.findOwnerRoot (fo))==null) {
10.739 - cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE);
10.740 - if (cp != null) {
10.741 - binaryRoot = cp.findOwnerRoot (fo);
10.742 - resourceName = cp.getResourceName(fo,'/',false); //NOI18N
10.743 - }
10.744 - }
10.745 - else if (binaryRoot != null) {
10.746 - resourceName = cp.getResourceName(fo,'/',false); //NOI18N
10.747 - }
10.748 - FileObject[] sourceRoots = null;
10.749 - if (binaryRoot != null) {
10.750 - sourceRoots = SourceForBinaryQuery.findSourceRoots (binaryRoot.getURL()).getRoots();
10.751 - }
10.752 - FileObject resource = null;
10.753 - if (sourceRoots != null && sourceRoots.length>0) {
10.754 - cp = ClassPathSupport.createClassPath(sourceRoots);
10.755 - resource = cp.findResource (resourceName+ ".java"); //NOI18N
10.756 - }
10.757 - if (resource !=null ) {
10.758 - DataObject sourceFile = DataObject.find(resource);
10.759 - OpenCookie oc = (OpenCookie) sourceFile.getCookie(OpenCookie.class);
10.760 - if (oc != null) {
10.761 - oc.open();
10.762 - }
10.763 - else {
10.764 - ErrorManager.getDefault().log ("SourceFile: "+resource.getPath()+" has no OpenCookie"); //NOI18N
10.765 - }
10.766 - }
10.767 - else {
10.768 - if (resourceName == null)
10.769 - resourceName = fo.getName();
10.770 - StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(ClassDataObject.class,"TXT_NoSources",
10.771 - resourceName.replace('/','.'))); //NOI18N
10.772 - }
10.773 - } catch (FileStateInvalidException e) {
10.774 - ErrorManager.getDefault().notify(e);
10.775 - }
10.776 - catch (DataObjectNotFoundException nf) {
10.777 - ErrorManager.getDefault().notify(nf);
10.778 - }
10.779 - }
10.780 - }
10.781 -}
11.1 --- a/clazz/src/org/netbeans/modules/clazz/ClassElementImpl.java Fri Sep 17 18:36:33 2010 -0400
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,561 +0,0 @@
11.4 -/*
11.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
11.6 - *
11.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
11.8 - *
11.9 - * The contents of this file are subject to the terms of either the GNU
11.10 - * General Public License Version 2 only ("GPL") or the Common
11.11 - * Development and Distribution License("CDDL") (collectively, the
11.12 - * "License"). You may not use this file except in compliance with the
11.13 - * License. You can obtain a copy of the License at
11.14 - * http://www.netbeans.org/cddl-gplv2.html
11.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
11.16 - * specific language governing permissions and limitations under the
11.17 - * License. When distributing the software, include this License Header
11.18 - * Notice in each file and include the License file at
11.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
11.20 - * particular file as subject to the "Classpath" exception as provided
11.21 - * by Sun in the GPL Version 2 section of the License file that
11.22 - * accompanied this code. If applicable, add the following below the
11.23 - * License Header, with the fields enclosed by brackets [] replaced by
11.24 - * your own identifying information:
11.25 - * "Portions Copyrighted [year] [name of copyright owner]"
11.26 - *
11.27 - * Contributor(s):
11.28 - *
11.29 - * The Original Software is NetBeans. The Initial Developer of the Original
11.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
11.31 - * Microsystems, Inc. All Rights Reserved.
11.32 - *
11.33 - * If you wish your version of this file to be governed by only the CDDL
11.34 - * or only the GPL Version 2, indicate your decision by adding
11.35 - * "[Contributor] elects to include this software in this distribution
11.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
11.37 - * single choice of license, a recipient has the option to distribute
11.38 - * your version of this file under either the CDDL, the GPL Version 2 or
11.39 - * to extend the choice of license to its licensees as provided above.
11.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
11.41 - * Version 2 license, then the option applies only if the new code is
11.42 - * made subject to such option by the copyright holder.
11.43 - */
11.44 -
11.45 -package org.netbeans.modules.clazz;
11.46 -
11.47 -import org.netbeans.modules.classfile.ClassFile;
11.48 -import org.netbeans.modules.classfile.InnerClass;
11.49 -import org.openide.src.*;
11.50 -import java.lang.ref.SoftReference;
11.51 -import java.util.*;
11.52 -import org.netbeans.api.mdr.MDRepository;
11.53 -import org.netbeans.jmi.javamodel.Constructor;
11.54 -import org.netbeans.jmi.javamodel.Feature;
11.55 -import org.netbeans.jmi.javamodel.Field;
11.56 -import org.netbeans.jmi.javamodel.JavaClass;
11.57 -import org.netbeans.jmi.javamodel.Method;
11.58 -import org.netbeans.jmi.javamodel.NamedElement;
11.59 -import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
11.60 -import org.openide.util.RequestProcessor;
11.61 -
11.62 -/** The implementation of the class element for
11.63 -* class objects. Presents data about the class -
11.64 -* uses java reflection to obtain needed information.
11.65 -*
11.66 -* @author Dafe Simonek
11.67 -*/
11.68 -public final class ClassElementImpl extends MemberElementImpl implements ClassElement.Impl, ElementProperties {
11.69 - /** Empty array of initializers - constant to return from getInitializers() */
11.70 - private static final InitializerElement[] EMPTY_INITIALIZERS =
11.71 - new InitializerElement[0];
11.72 - private static final Object[] EMPTY_ARRAY = new Object[0];
11.73 -
11.74 - /** Identifier of superclass of this class element,
11.75 - * can be empty */
11.76 - private Identifier superClass;
11.77 - /** Array of identifiers for interfaces */
11.78 - private Identifier[] interfaces;
11.79 -
11.80 - /** Fields of this class element */
11.81 - private SoftReference fields;
11.82 - /** Inner classes of this class element */
11.83 - private SoftReference inners;
11.84 - /** Contructors of this class element */
11.85 - private SoftReference constructors;
11.86 - /** Methods of this class element */
11.87 - private SoftReference methods;
11.88 -
11.89 - /* InnerClass attribute of a associeted with this classfile */
11.90 - private InnerClass innerclass;
11.91 -
11.92 - private boolean isClassInited = false;
11.93 - private boolean isClass;
11.94 -
11.95 - /** One JavaDoc empty implementation for all objects */
11.96 - private static final ClassJavaDocImpl.Class CLASS_JAVADOC_IMPL = new ClassJavaDocImpl.Class ();
11.97 -
11.98 - private static final Identifier NO_SUPERCLASS = Identifier.create(""); // NOI18N
11.99 -
11.100 - static final long serialVersionUID =-8717988834353784544L;
11.101 - /** Default constructor.
11.102 - */
11.103 - public ClassElementImpl (final ClassFile data) {
11.104 - super(data);
11.105 - }
11.106 -
11.107 - ClassElementImpl(JavaClass data) {
11.108 - super(data);
11.109 - }
11.110 -
11.111 - private ClassElementImpl (final ClassFile data,InnerClass inner) {
11.112 - this(data);
11.113 - innerclass=inner;
11.114 - }
11.115 -
11.116 - public void initializeData() {
11.117 - super.initializeData();
11.118 - getSuperclass();
11.119 - isClassOrInterface();
11.120 - getInterfaces();
11.121 - ClassElement[] classes = getClasses();
11.122 - for (int x = 0; x < classes.length; x++) {
11.123 - ClassElementImpl impl = (ClassElementImpl) classes[x].getCookie(org.openide.src.Element.Impl.class);
11.124 - impl.initializeData();
11.125 - }
11.126 - FieldElement[] fields = getFields();
11.127 - for (int x = 0; x < fields.length; x++) {
11.128 - FieldElementImpl impl = (FieldElementImpl) fields[x].getCookie(org.openide.src.Element.Impl.class);
11.129 - impl.initializeData();
11.130 - }
11.131 - MethodElement[] methods = getMethods();
11.132 - for (int x = 0; x < methods.length; x++) {
11.133 - MethodElementImpl impl = (MethodElementImpl) methods[x].getCookie(org.openide.src.Element.Impl.class);
11.134 - impl.initializeData();
11.135 - }
11.136 - ConstructorElement[] cons = getConstructors();
11.137 - for (int x = 0; x < cons.length; x++) {
11.138 - ConstructorElementImpl impl = (ConstructorElementImpl) cons[x].getCookie(org.openide.src.Element.Impl.class);
11.139 - impl.initializeData();
11.140 - }
11.141 - }
11.142 -
11.143 - /** Not supported. Throws source exception */
11.144 - public void setSuperclass(Identifier superClass) throws SourceException {
11.145 - throwReadOnlyException();
11.146 - }
11.147 -
11.148 - JavaClass getClazz() {
11.149 - return (JavaClass)data;
11.150 - }
11.151 -
11.152 - public Identifier getSuperclass() {
11.153 - if (superClass == NO_SUPERCLASS)
11.154 - return null;
11.155 - if (superClass != null)
11.156 - return superClass;
11.157 -
11.158 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
11.159 - repo.beginTrans(false);
11.160 - try {
11.161 - if (!isValid()) {
11.162 - return Identifier.create(""); // NOI18N
11.163 - }
11.164 - if (superClass == null) {
11.165 - JavaClass c = getClazz();
11.166 - JavaClass tid = c.getSuperClass();
11.167 - if (tid == null)
11.168 - superClass = NO_SUPERCLASS;
11.169 - else
11.170 - superClass = Identifier.create(Util.createClassName(tid.getName()));
11.171 - }
11.172 - if (superClass == NO_SUPERCLASS)
11.173 - return null;
11.174 - else
11.175 - return superClass;
11.176 - } finally {
11.177 - repo.endTrans();
11.178 - }
11.179 - }
11.180 -
11.181 - protected Identifier createName(Object data) {
11.182 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
11.183 - repo.beginTrans(false);
11.184 - try {
11.185 - if (!isValid()) {
11.186 - return Identifier.create(""); // NOI18N
11.187 - }
11.188 - String fqn=getClazz().getName();
11.189 - String simpleName;
11.190 - int lastDot=fqn.lastIndexOf('.');
11.191 -
11.192 - if (lastDot!=-1)
11.193 - simpleName=fqn.substring(lastDot+1);
11.194 - else
11.195 - simpleName=fqn;
11.196 - return Identifier.create(fqn, simpleName);
11.197 - } finally {
11.198 - repo.endTrans();
11.199 - }
11.200 - }
11.201 -
11.202 - /** Not supported. Throws Source Exception */
11.203 - public void setClassOrInterface(boolean isClass) throws SourceException {
11.204 - throwReadOnlyException();
11.205 - }
11.206 -
11.207 - public boolean isClassOrInterface() {
11.208 - if (isClassInited)
11.209 - return isClass;
11.210 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
11.211 - repo.beginTrans(false);
11.212 - try {
11.213 - if (!isValid()) {
11.214 - return true;
11.215 - }
11.216 - isClassInited = true;
11.217 - return isClass = !getClazz().isInterface();
11.218 - } finally {
11.219 - repo.endTrans();
11.220 - }
11.221 - }
11.222 -
11.223 - /** Not supported. Throws SourceException.
11.224 - */
11.225 - public void changeInitializers (InitializerElement[] elems, int action) throws SourceException {
11.226 - throwReadOnlyException();
11.227 - }
11.228 -
11.229 - /** Not available. Always returns empty array */
11.230 - public InitializerElement[] getInitializers () {
11.231 - return EMPTY_INITIALIZERS;
11.232 - }
11.233 -
11.234 - /** Changes set of elements.
11.235 - * @param elems elements to change
11.236 - * @exception SourceException if the action cannot be handled
11.237 - */
11.238 - public void changeFields (FieldElement[] elems, int action) throws SourceException {
11.239 - throwReadOnlyException();
11.240 - }
11.241 -
11.242 - public FieldElement[] getFields () {
11.243 - Map fieldsMap = (fields == null) ? null : (Map)fields.get();
11.244 - if (fieldsMap == null) {
11.245 - // soft ref null, we must recreate
11.246 - fieldsMap = createFieldsMap();
11.247 - fields = new SoftReference(fieldsMap);
11.248 - }
11.249 - return (FieldElement[])fieldsMap.values().toArray(new FieldElement[0]);
11.250 - }
11.251 -
11.252 - /** Finds a field with given name.
11.253 - * @param name the name of field to look for
11.254 - * @return the element or null if field with such name does not exist
11.255 - */
11.256 - public FieldElement getField (Identifier name) {
11.257 - Map fieldsMap = (fields == null) ? null : (Map)fields.get();
11.258 - if (fieldsMap == null) {
11.259 - // soft ref null, we must recreate
11.260 - fieldsMap = createFieldsMap();
11.261 - fields = new SoftReference(fieldsMap);
11.262 - }
11.263 - return (FieldElement)fieldsMap.get(name);
11.264 - }
11.265 -
11.266 - /** Changes set of elements.
11.267 - * @param elems elements to change
11.268 - * @exception SourceException if the action cannot be handled
11.269 - */
11.270 - public void changeMethods (MethodElement[] elems, int action) throws SourceException {
11.271 - throwReadOnlyException();
11.272 - }
11.273 -
11.274 - public MethodElement[] getMethods () {
11.275 - Map methodsMap = (methods == null) ? null : (Map)methods.get();
11.276 - if (methodsMap == null) {
11.277 - // soft ref null, we must recreate
11.278 - methodsMap = createMethodsMap();
11.279 - methods = new SoftReference(methodsMap);
11.280 - }
11.281 - return (MethodElement[])methodsMap.values().toArray(new MethodElement[0]);
11.282 - }
11.283 -
11.284 - /** Finds a method with given name and argument types.
11.285 - * @param name the name of field to look for
11.286 - * @param arguments for the method
11.287 - * @return the element or null if such method does not exist
11.288 - */
11.289 - public MethodElement getMethod (Identifier name, Type[] arguments) {
11.290 - Map methodsMap = (methods == null) ? null : (Map)methods.get();
11.291 - if (methodsMap == null) {
11.292 - // soft ref null, we must recreate
11.293 - methodsMap = createMethodsMap();
11.294 - methods = new SoftReference(methodsMap);
11.295 - }
11.296 - return (MethodElement)
11.297 - methodsMap.get(new MethodElement.Key(name, arguments));
11.298 - }
11.299 -
11.300 - /** Changes set of elements.
11.301 - * @param elems elements to change
11.302 - * @exception SourceException if the action cannot be handled
11.303 - */
11.304 - public void changeConstructors (ConstructorElement[] elems, int action) throws SourceException {
11.305 - throwReadOnlyException();
11.306 - }
11.307 -
11.308 - public ConstructorElement[] getConstructors () {
11.309 - Map constructorsMap =
11.310 - (constructors == null) ? null :(Map)constructors.get();
11.311 - if (constructorsMap == null) {
11.312 - // soft ref null, we must recreate
11.313 - constructorsMap = createConstructorsMap();
11.314 - constructors = new SoftReference(constructorsMap);
11.315 - }
11.316 - return (ConstructorElement[])constructorsMap.values().
11.317 - toArray(new ConstructorElement[0]);
11.318 - }
11.319 -
11.320 - /** Finds a constructor with argument types.
11.321 - * @param arguments for the method
11.322 - * @return the element or null if such method does not exist
11.323 - */
11.324 - public ConstructorElement getConstructor (Type[] arguments) {
11.325 - Map constructorsMap =
11.326 - (constructors == null) ? null :(Map)constructors.get();
11.327 - if (constructorsMap == null) {
11.328 - // soft ref null, we must recreate
11.329 - constructorsMap = createConstructorsMap();
11.330 - constructors = new SoftReference(constructorsMap);
11.331 - }
11.332 - return (ConstructorElement)
11.333 - constructorsMap.get(new ConstructorElement.Key(arguments));
11.334 - }
11.335 -
11.336 - /** Changes set of elements.
11.337 - * @param elems elements to change
11.338 - * @exception SourceException if the action cannot be handled
11.339 - */
11.340 - public void changeClasses (ClassElement[] elems, int action) throws SourceException {
11.341 - throwReadOnlyException();
11.342 - }
11.343 -
11.344 - public ClassElement[] getClasses () {
11.345 - Map innersMap = (inners == null) ? null : (Map)inners.get();
11.346 - if (innersMap == null) {
11.347 - // soft ref null, we must recreate
11.348 - innersMap = createInnersMap();
11.349 - inners = new SoftReference(innersMap);
11.350 - }
11.351 - return (ClassElement[])innersMap.values().toArray(new ClassElement[0]);
11.352 - }
11.353 -
11.354 - /** Finds an inner class with given name.
11.355 - * @param name the name to look for
11.356 - * @return the element or null if such class does not exist
11.357 - */
11.358 - public ClassElement getClass (Identifier n) {
11.359 - Map innersMap = (inners == null) ? null : (Map)inners.get();
11.360 - if (innersMap == null) {
11.361 - // soft ref null, we must recreate
11.362 - innersMap = createInnersMap();
11.363 - inners = new SoftReference(innersMap);
11.364 - }
11.365 - String key = n.getSourceName();
11.366 - ClassElement el = (ClassElement)innersMap.get(key);
11.367 - if (el != null) {
11.368 - if (!key.equals(n.getFullName()) &&
11.369 - !n.getFullName().equals(el.getName().getFullName()))
11.370 - el = null;
11.371 - }
11.372 - return el;
11.373 - }
11.374 -
11.375 - /** Changes interfaces this class implements (or extends).
11.376 - * @param ids identifiers to change
11.377 - * @exception SourceException if the action cannot be handled
11.378 - */
11.379 - public void changeInterfaces (Identifier[] ids, int action) throws SourceException {
11.380 - throwReadOnlyException();
11.381 - }
11.382 -
11.383 - /** @return all interfaces which the class implements or interface extends.
11.384 - */
11.385 - public Identifier[] getInterfaces () {
11.386 - if (interfaces == null) {
11.387 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
11.388 - repo.beginTrans(false);
11.389 - try {
11.390 - if (!isValid()) {
11.391 - interfaces = new Identifier[0];
11.392 - } else {
11.393 - JavaClass[] reflIntfs = (JavaClass[])getClazz().getInterfaces().toArray(new JavaClass[0]);
11.394 - interfaces = new Identifier[reflIntfs.length];
11.395 - for (int i = 0; i < reflIntfs.length; i++) {
11.396 - interfaces[i] = Identifier.create(Util.createClassName(reflIntfs[i].getName()));
11.397 - }
11.398 - }
11.399 - } finally {
11.400 - repo.endTrans();
11.401 - }
11.402 - }
11.403 - return interfaces;
11.404 - }
11.405 -
11.406 - /** @return class documentation.
11.407 - */
11.408 - public JavaDoc.Class getJavaDoc() {
11.409 - return CLASS_JAVADOC_IMPL;
11.410 - }
11.411 -
11.412 - /******** non public methods ***********/
11.413 -
11.414 - /** Creates map for fields consisting of identifier - field entries */
11.415 - private Map createFieldsMap () {
11.416 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
11.417 - repo.beginTrans(false);
11.418 - try {
11.419 - if (!isValid()) {
11.420 - return Collections.EMPTY_MAP;
11.421 - }
11.422 - Feature[] reflFields = (Feature[])getClazz().getFeatures().toArray(new Feature[0]);
11.423 - Map result = new HashMap(reflFields.length);
11.424 - for (int i = 0; i < reflFields.length; i++) {
11.425 - Feature f=reflFields[i];
11.426 -
11.427 - if (f instanceof Field) {
11.428 - Field field=(Field)f;
11.429 - // filter out methods added by compiler
11.430 - if (!addedByCompiler(field)) {
11.431 - FieldElement curFE = new FieldElement(new FieldElementImpl(field),
11.432 - (ClassElement)element);
11.433 - result.put(curFE.getName(), curFE);
11.434 - }
11.435 - }
11.436 - }
11.437 - return result;
11.438 - } finally {
11.439 - repo.endTrans();
11.440 - }
11.441 - }
11.442 -
11.443 - /** Creates map for inner classes of this class,
11.444 - * consisting of identifier - class element entries */
11.445 - private Map createInnersMap () {
11.446 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
11.447 - repo.beginTrans(false);
11.448 - try {
11.449 - if (!isValid()) {
11.450 - return Collections.EMPTY_MAP;
11.451 - }
11.452 - Feature[] reflInners = (Feature[])getClazz().getFeatures().toArray(new Feature[0]);
11.453 -
11.454 - // create map
11.455 - ClassElement curCE = null;
11.456 - Map result = new HashMap(reflInners.length);
11.457 - for (int i = 0; i < reflInners.length; i++) {
11.458 - Feature f=reflInners[i];
11.459 -
11.460 - if (f instanceof JavaClass) {
11.461 - JavaClass jcls=(JavaClass)f;
11.462 - String iname = jcls.getName();
11.463 - curCE = new ClassElement(new ClassElementImpl(jcls),
11.464 - (ClassElement)element);
11.465 - result.put(iname, curCE);
11.466 - }
11.467 - }
11.468 - return result;
11.469 - } finally {
11.470 - repo.endTrans();
11.471 - }
11.472 - }
11.473 -
11.474 - SourceElementImpl findSourceImpl() {
11.475 - return (SourceElementImpl)((ClassElement)element).getSource().getCookie(SourceElement.Impl.class);
11.476 - }
11.477 -
11.478 - /** Creates map for constructors of this class,
11.479 - * consisting of constructor key - constructor element entries */
11.480 - private Map createConstructorsMap () {
11.481 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
11.482 - repo.beginTrans(false);
11.483 - try {
11.484 - if (!isValid()) {
11.485 - return Collections.EMPTY_MAP;
11.486 - }
11.487 - Feature[] reflCons = (Feature[])getClazz().getFeatures().toArray(new Feature[0]);
11.488 - Map result = new HashMap(reflCons.length);
11.489 -
11.490 - for (int i = 0; i < reflCons.length; i++) {
11.491 - Feature f=reflCons[i];
11.492 -
11.493 - if (f instanceof Constructor) {
11.494 - ConstructorElement curCE = new ConstructorElement(new ConstructorElementImpl((Constructor)f),
11.495 - (ClassElement)element);
11.496 - result.put(new ConstructorElement.Key(curCE), curCE);
11.497 - }
11.498 - }
11.499 - return result;
11.500 - } finally {
11.501 - repo.endTrans();
11.502 - }
11.503 - }
11.504 -
11.505 - /** Creates map for methods of this class,
11.506 - * consisting of method key - method element entries */
11.507 - private Map createMethodsMap () {
11.508 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
11.509 - repo.beginTrans(false);
11.510 - try {
11.511 - if (!isValid()) {
11.512 - return Collections.EMPTY_MAP;
11.513 - }
11.514 - Feature[] reflMethods = (Feature[])getClazz().getFeatures().toArray(new Feature[0]);
11.515 - Map result = new HashMap(reflMethods.length);
11.516 -
11.517 - for (int i = 0; i < reflMethods.length; i++) {
11.518 - Feature f=reflMethods[i];
11.519 -
11.520 - if (f instanceof Method) {
11.521 - // filter out methods added by compiler
11.522 - Method m = (Method)f;
11.523 - if (!addedByCompiler(m)) {
11.524 - MethodElement curME = new MethodElement(new MethodElementImpl(m),
11.525 - (ClassElement)element);
11.526 - result.put(new MethodElement.Key(curME, true), curME);
11.527 - }
11.528 - }
11.529 - }
11.530 - return result;
11.531 - } finally {
11.532 - repo.endTrans();
11.533 - }
11.534 - }
11.535 -
11.536 - public Object readResolve() {
11.537 - return new ClassElement(this, (SourceElement)null);
11.538 - }
11.539 -
11.540 - public void refreshData() {
11.541 - // System.out.println("refreshing class ...");
11.542 - fields = null;
11.543 - inners = null;
11.544 - constructors = null;
11.545 - methods = null;
11.546 - RequestProcessor.getDefault().post(new Runnable() {
11.547 - public void run() {
11.548 - firePropertyChange(PROP_MEMBERS, null, null);
11.549 - firePropertyChange(PROP_METHODS, null, null);
11.550 - firePropertyChange(PROP_FIELDS, null, null);
11.551 - firePropertyChange(PROP_CONSTRUCTORS, null, null);
11.552 - firePropertyChange(PROP_CLASSES, null, null);
11.553 - }
11.554 - });
11.555 - }
11.556 -
11.557 - /** @return true if given member was generated automatically by compiler,
11.558 - * false otherwise. Decision is made by inspecting the name of the member.
11.559 - */
11.560 - private static boolean addedByCompiler(NamedElement field) {
11.561 - String name = field.getName();
11.562 - return name.indexOf('$') >= 0;
11.563 - }
11.564 -}
12.1 --- a/clazz/src/org/netbeans/modules/clazz/ClassElementNodeFactory.java Fri Sep 17 18:36:33 2010 -0400
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,213 +0,0 @@
12.4 -/*
12.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
12.6 - *
12.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
12.8 - *
12.9 - * The contents of this file are subject to the terms of either the GNU
12.10 - * General Public License Version 2 only ("GPL") or the Common
12.11 - * Development and Distribution License("CDDL") (collectively, the
12.12 - * "License"). You may not use this file except in compliance with the
12.13 - * License. You can obtain a copy of the License at
12.14 - * http://www.netbeans.org/cddl-gplv2.html
12.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
12.16 - * specific language governing permissions and limitations under the
12.17 - * License. When distributing the software, include this License Header
12.18 - * Notice in each file and include the License file at
12.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
12.20 - * particular file as subject to the "Classpath" exception as provided
12.21 - * by Sun in the GPL Version 2 section of the License file that
12.22 - * accompanied this code. If applicable, add the following below the
12.23 - * License Header, with the fields enclosed by brackets [] replaced by
12.24 - * your own identifying information:
12.25 - * "Portions Copyrighted [year] [name of copyright owner]"
12.26 - *
12.27 - * Contributor(s):
12.28 - *
12.29 - * The Original Software is NetBeans. The Initial Developer of the Original
12.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
12.31 - * Microsystems, Inc. All Rights Reserved.
12.32 - *
12.33 - * If you wish your version of this file to be governed by only the CDDL
12.34 - * or only the GPL Version 2, indicate your decision by adding
12.35 - * "[Contributor] elects to include this software in this distribution
12.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
12.37 - * single choice of license, a recipient has the option to distribute
12.38 - * your version of this file under either the CDDL, the GPL Version 2 or
12.39 - * to extend the choice of license to its licensees as provided above.
12.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
12.41 - * Version 2 license, then the option applies only if the new code is
12.42 - * made subject to such option by the copyright holder.
12.43 - */
12.44 -
12.45 -package org.netbeans.modules.clazz;
12.46 -
12.47 -import java.beans.*;
12.48 -
12.49 -import org.openide.actions.PropertiesAction;
12.50 -import org.openide.actions.ToolsAction;
12.51 -import org.openide.cookies.FilterCookie;
12.52 -import org.openide.nodes.Node;
12.53 -import org.openide.nodes.AbstractNode;
12.54 -import org.openide.nodes.Children;
12.55 -import org.openide.nodes.CookieSet;
12.56 -import org.openide.src.*;
12.57 -import org.openide.src.nodes.*;
12.58 -import org.openide.util.NbBundle;
12.59 -import org.openide.util.actions.SystemAction;
12.60 -
12.61 -/** The implementation of hierarchy nodes factory for the class loader.
12.62 -*
12.63 -* @author Petr Hamernik, Dafe Simonek
12.64 -*/
12.65 -final class ClassElementNodeFactory extends DefaultFactory {
12.66 -
12.67 - private final FactoryGetterNode FACTORY_GETTER_NODE = new FactoryGetterNode();
12.68 -
12.69 - /** Default instance of this factory. */
12.70 - private static DefaultFactory instance;
12.71 -
12.72 - /** Array of the actions for element nodes */
12.73 - private static SystemAction[] defaultActions;
12.74 -
12.75 - /** Create nodes for tree */
12.76 - private boolean tree = false;
12.77 -
12.78 - /** Creates new factory. */
12.79 - public ClassElementNodeFactory() {
12.80 - super(false);
12.81 - }
12.82 -
12.83 - /** If true generate nodes for tree.
12.84 - */
12.85 - public void setGenerateForTree (boolean tree) {
12.86 - this.tree = tree;
12.87 - }
12.88 -
12.89 - /** Returns true if generate nodes for tree.
12.90 - * @returns true if generate nodes for tree.
12.91 - */
12.92 - public boolean getGenerateForTree () {
12.93 - return tree;
12.94 - }
12.95 -
12.96 - /** Returns the node asociated with specified element.
12.97 - * @return ElementNode
12.98 - */
12.99 - public Node createMethodNode(final MethodElement element) {
12.100 - MethodElementNode n = new MethodElementNode(element, false);
12.101 - n.setDefaultAction(SystemAction.get(PropertiesAction.class));
12.102 - n.setActions(getDefaultActions());
12.103 - return n;
12.104 - }
12.105 -
12.106 - /** Returns the node asociated with specified element.
12.107 - * @return ElementNode
12.108 - */
12.109 - public Node createConstructorNode(ConstructorElement element) {
12.110 - ConstructorElementNode n = new ConstructorElementNode(element, false);
12.111 - n.setDefaultAction(SystemAction.get(PropertiesAction.class));
12.112 - n.setActions(getDefaultActions());
12.113 - return n;
12.114 - }
12.115 -
12.116 - /** Returns the node asociated with specified element.
12.117 - * @return ElementNode
12.118 - */
12.119 - public Node createFieldNode(FieldElement element) {
12.120 - FieldElementNode n = new FieldElementNode(element, false);
12.121 - n.setDefaultAction(SystemAction.get(PropertiesAction.class));
12.122 - n.setActions(getDefaultActions());
12.123 - return n;
12.124 - }
12.125 -
12.126 - /** Returns the node asociated with specified element.
12.127 - * @return ElementNode
12.128 - */
12.129 - public Node createClassNode (final ClassElement element) {
12.130 - if ( element == null ) {
12.131 - return FACTORY_GETTER_NODE;
12.132 - }
12.133 - if (tree) {
12.134 - ClassChildren ch = new ClassChildren(ClassDataObject.getBrowserFactory(), element);
12.135 - ClassElementNode n = new ClassElementNode(element, ch, false) {
12.136 - {
12.137 - getCookieSet().add((FilterCookie)getChildren());
12.138 - }
12.139 - };
12.140 -
12.141 - n.setElementFormat(new ElementFormat (
12.142 - NbBundle.getBundle (ClassElementNodeFactory.class).getString("CTL_Class_name_format")
12.143 - ));
12.144 -
12.145 - // filter out inner classes
12.146 - ClassElementFilter cel = new ClassElementFilter ();
12.147 - cel.setOrder (new int[] {
12.148 - ClassElementFilter.CONSTRUCTOR + ClassElementFilter.METHOD,
12.149 - ClassElementFilter.FIELD,
12.150 - });
12.151 - ch.setFilter (cel);
12.152 - n.setActions(getDefaultActions());
12.153 - n.setIconBase (element.isInterface () ?
12.154 - "org/netbeans/modules/clazz/resources/interfaceBr" : // NOI18N
12.155 - "org/netbeans/modules/clazz/resources/classBr" // NOI18N
12.156 - );
12.157 - return n;
12.158 - }
12.159 - else {
12.160 - Children ch = createClassChildren(element, ClassDataObject.getExplorerFactory() );
12.161 - ClassElementNode n = new ClassElementNode(element, ch, false);
12.162 - n.setActions(getDefaultActions());
12.163 - return n;
12.164 - }
12.165 - }
12.166 -
12.167 - /** Convenience method for obtaining default actions of nodes */
12.168 - SystemAction[] getDefaultActions () {
12.169 - if (defaultActions == null) {
12.170 - defaultActions = new SystemAction[] {
12.171 - SystemAction.get(ToolsAction.class),
12.172 - SystemAction.get(PropertiesAction.class),
12.173 - };
12.174 - }
12.175 - return defaultActions;
12.176 - }
12.177 -
12.178 - /** Returns instance of this element node factory */
12.179 - static DefaultFactory getInstance () {
12.180 - if (instance == null)
12.181 - instance = new ClassElementNodeFactory();
12.182 - return instance;
12.183 - }
12.184 -
12.185 -
12.186 - /** This is an unusuall use of Node and FilterCookie */
12.187 -
12.188 - private class FactoryGetterNode extends AbstractNode implements FilterCookie {
12.189 -
12.190 - FactoryGetterNode( ) {
12.191 - super ( Children.LEAF );
12.192 - }
12.193 -
12.194 - public synchronized Node.Cookie getCookie( Class clazz ) {
12.195 - if ( clazz == FilterFactory.class )
12.196 - return this;
12.197 - else
12.198 - return super.getCookie( clazz );
12.199 - }
12.200 -
12.201 - public Class getFilterClass() {
12.202 - return null;
12.203 - }
12.204 -
12.205 - public void setFilter( Object filter ) {}
12.206 -
12.207 - public Object getFilter( ) {
12.208 - if ( tree )
12.209 - return ClassDataObject.getBrowserFactory();
12.210 - else
12.211 - return ClassDataObject.getExplorerFactory();
12.212 - }
12.213 -
12.214 - }
12.215 -
12.216 -}
13.1 --- a/clazz/src/org/netbeans/modules/clazz/ClassException.java Fri Sep 17 18:36:33 2010 -0400
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,73 +0,0 @@
13.4 -/*
13.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
13.6 - *
13.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
13.8 - *
13.9 - * The contents of this file are subject to the terms of either the GNU
13.10 - * General Public License Version 2 only ("GPL") or the Common
13.11 - * Development and Distribution License("CDDL") (collectively, the
13.12 - * "License"). You may not use this file except in compliance with the
13.13 - * License. You can obtain a copy of the License at
13.14 - * http://www.netbeans.org/cddl-gplv2.html
13.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13.16 - * specific language governing permissions and limitations under the
13.17 - * License. When distributing the software, include this License Header
13.18 - * Notice in each file and include the License file at
13.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
13.20 - * particular file as subject to the "Classpath" exception as provided
13.21 - * by Sun in the GPL Version 2 section of the License file that
13.22 - * accompanied this code. If applicable, add the following below the
13.23 - * License Header, with the fields enclosed by brackets [] replaced by
13.24 - * your own identifying information:
13.25 - * "Portions Copyrighted [year] [name of copyright owner]"
13.26 - *
13.27 - * Contributor(s):
13.28 - *
13.29 - * The Original Software is NetBeans. The Initial Developer of the Original
13.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
13.31 - * Microsystems, Inc. All Rights Reserved.
13.32 - *
13.33 - * If you wish your version of this file to be governed by only the CDDL
13.34 - * or only the GPL Version 2, indicate your decision by adding
13.35 - * "[Contributor] elects to include this software in this distribution
13.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
13.37 - * single choice of license, a recipient has the option to distribute
13.38 - * your version of this file under either the CDDL, the GPL Version 2 or
13.39 - * to extend the choice of license to its licensees as provided above.
13.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
13.41 - * Version 2 license, then the option applies only if the new code is
13.42 - * made subject to such option by the copyright holder.
13.43 - */
13.44 -
13.45 -package org.netbeans.modules.clazz;
13.46 -
13.47 -/**
13.48 -* Exception encapsulating other possible exceptions occurred while working with
13.49 -* .class file.
13.50 -*
13.51 -* @author Jan Jancura
13.52 -* @version 0.10, Apr 15, 1998
13.53 -*/
13.54 -public class ClassException extends java.lang.reflect.InvocationTargetException {
13.55 - /** generated Serialized Version UID */
13.56 - static final long serialVersionUID = 1159065613681402933L;
13.57 -
13.58 - /**
13.59 - * Construct ClassException encapsulating some other.
13.60 - *
13.61 - * @param throwable Exception to be encapsulated.
13.62 - */
13.63 - public ClassException (Throwable throwable) {
13.64 - super (throwable);
13.65 - }
13.66 -
13.67 - /**
13.68 - * Construct ClassException encapsulating some other with special comment.
13.69 - *
13.70 - * @param throwable Exception to be encapsulated.
13.71 - * @param comment Comment.
13.72 - */
13.73 - public ClassException (Throwable throwable, String comment) {
13.74 - super (throwable, comment);
13.75 - }
13.76 -}
14.1 --- a/clazz/src/org/netbeans/modules/clazz/ClassJavaDocImpl.java Fri Sep 17 18:36:33 2010 -0400
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,166 +0,0 @@
14.4 -/*
14.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
14.6 - *
14.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
14.8 - *
14.9 - * The contents of this file are subject to the terms of either the GNU
14.10 - * General Public License Version 2 only ("GPL") or the Common
14.11 - * Development and Distribution License("CDDL") (collectively, the
14.12 - * "License"). You may not use this file except in compliance with the
14.13 - * License. You can obtain a copy of the License at
14.14 - * http://www.netbeans.org/cddl-gplv2.html
14.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
14.16 - * specific language governing permissions and limitations under the
14.17 - * License. When distributing the software, include this License Header
14.18 - * Notice in each file and include the License file at
14.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
14.20 - * particular file as subject to the "Classpath" exception as provided
14.21 - * by Sun in the GPL Version 2 section of the License file that
14.22 - * accompanied this code. If applicable, add the following below the
14.23 - * License Header, with the fields enclosed by brackets [] replaced by
14.24 - * your own identifying information:
14.25 - * "Portions Copyrighted [year] [name of copyright owner]"
14.26 - *
14.27 - * Contributor(s):
14.28 - *
14.29 - * The Original Software is NetBeans. The Initial Developer of the Original
14.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
14.31 - * Microsystems, Inc. All Rights Reserved.
14.32 - *
14.33 - * If you wish your version of this file to be governed by only the CDDL
14.34 - * or only the GPL Version 2, indicate your decision by adding
14.35 - * "[Contributor] elects to include this software in this distribution
14.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
14.37 - * single choice of license, a recipient has the option to distribute
14.38 - * your version of this file under either the CDDL, the GPL Version 2 or
14.39 - * to extend the choice of license to its licensees as provided above.
14.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
14.41 - * Version 2 license, then the option applies only if the new code is
14.42 - * made subject to such option by the copyright holder.
14.43 - */
14.44 -
14.45 -package org.netbeans.modules.clazz;
14.46 -
14.47 -
14.48 -import org.openide.src.*;
14.49 -
14.50 -/** Empty implementation of JavaDoc for sourceless data objects.
14.51 - *
14.52 - * @author Petr Hrebejk
14.53 - */
14.54 -class ClassJavaDocImpl extends Object implements JavaDoc {
14.55 -
14.56 - private static final JavaDocTag[] TAGS_EMPTY = new JavaDocTag[] {};
14.57 - private static final JavaDocTag.See[] SEE_TAGS_EMPTY = new JavaDocTag.See[] {};
14.58 - private static final JavaDocTag.Param[] PARAM_TAGS_EMPTY = new JavaDocTag.Param[] {};
14.59 - private static final JavaDocTag.Throws[] THROWS_TAGS_EMPTY = new JavaDocTag.Throws[] {};
14.60 - private static final JavaDocTag.SerialField[] SERIALFIELD_TAGS_EMPTY = new JavaDocTag.SerialField[] {};
14.61 -
14.62 - /** Creates new ClassJavaDocImpl */
14.63 - public ClassJavaDocImpl() {
14.64 - }
14.65 -
14.66 - /** Get the entire text of the comment.
14.67 - * @return the whole text
14.68 - */
14.69 - public String getRawText() {
14.70 - return ""; // NOI18N
14.71 - }
14.72 -
14.73 - /** Set the raw text of the comment.
14.74 - * @param s the whole text to set
14.75 - * @exception SourceException if the modification cannot be performed
14.76 - */
14.77 - public void setRawText(String s) throws SourceException {
14.78 - throw new SourceException();
14.79 - }
14.80 -
14.81 - /** Get the actual text, cleared of all (non-inline) tags.
14.82 - * @return the plain text
14.83 - */
14.84 - public String getText() {
14.85 - return ""; // NOI18N
14.86 - }
14.87 -
14.88 - /** Set the actual text.
14.89 - * @param s the actual text, without any (non-inline) tags
14.90 - * @exception SourceException if the modification cannot be performed
14.91 - */
14.92 - public void setText(String s) throws SourceException {
14.93 - throw new SourceException();
14.94 - }
14.95 -
14.96 - /** Clears the javadoc from the source.
14.97 - */
14.98 - public void clearJavaDoc() throws SourceException {
14.99 - throw new SourceException();
14.100 - }
14.101 -
14.102 - /** Test if this javadoc is empty.
14.103 - * @return true if it is not generated to the source.
14.104 - */
14.105 - public boolean isEmpty() {
14.106 - return true;
14.107 - }
14.108 -
14.109 - /** Gets all tags from comment.
14.110 - */
14.111 - public JavaDocTag[] getTags() {
14.112 - return TAGS_EMPTY;
14.113 - }
14.114 -
14.115 - /** Gets all tags of given name
14.116 - */
14.117 - public JavaDocTag[] getTags(String name) {
14.118 - return TAGS_EMPTY;
14.119 - }
14.120 -
14.121 - /** Adds removes or sets tags used in this comment
14.122 - * @param elems the new initializers
14.123 - * @param action {@link #ADD}, {@link #REMOVE}, or {@link #SET}
14.124 - * @exception SourceException if impossible
14.125 - */
14.126 - public void changeTags(JavaDocTag[] tags,int action) throws SourceException {
14.127 - throw new SourceException();
14.128 - }
14.129 -
14.130 - /** Gets all @see tags
14.131 - */
14.132 - public JavaDocTag.See[] getSeeTags() {
14.133 - return SEE_TAGS_EMPTY;
14.134 - }
14.135 -
14.136 - /** The JavaDoc of a class.
14.137 - * Class javadoc adds no special tags.
14.138 - */
14.139 - static class Class extends ClassJavaDocImpl implements JavaDoc.Class {
14.140 - }
14.141 -
14.142 - /** The JavaDoc of a field.
14.143 - * <p>Currently adds special @SerialField tag
14.144 - */
14.145 - static class Field extends ClassJavaDocImpl implements JavaDoc.Field {
14.146 - /** Gets SerialField tags.
14.147 - */
14.148 - public JavaDocTag.SerialField[] getSerialFieldTags() {
14.149 - return SERIALFIELD_TAGS_EMPTY;
14.150 - }
14.151 - }
14.152 -
14.153 - /** The JavaDoc of a method. Adds two special tags: @para tag and @throws tag.
14.154 - */
14.155 - static class Method extends ClassJavaDocImpl implements JavaDoc.Method {
14.156 -
14.157 - /** Gets param tags.
14.158 - */
14.159 - public JavaDocTag.Param[] getParamTags() {
14.160 - return PARAM_TAGS_EMPTY;
14.161 - }
14.162 -
14.163 - /** Gets throws tags.
14.164 - */
14.165 - public JavaDocTag.Throws[] getThrowsTags() {
14.166 - return THROWS_TAGS_EMPTY;
14.167 - }
14.168 - }
14.169 -}
15.1 --- a/clazz/src/org/netbeans/modules/clazz/CompiledDataNode.java Fri Sep 17 18:36:33 2010 -0400
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,146 +0,0 @@
15.4 -/*
15.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
15.6 - *
15.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
15.8 - *
15.9 - * The contents of this file are subject to the terms of either the GNU
15.10 - * General Public License Version 2 only ("GPL") or the Common
15.11 - * Development and Distribution License("CDDL") (collectively, the
15.12 - * "License"). You may not use this file except in compliance with the
15.13 - * License. You can obtain a copy of the License at
15.14 - * http://www.netbeans.org/cddl-gplv2.html
15.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15.16 - * specific language governing permissions and limitations under the
15.17 - * License. When distributing the software, include this License Header
15.18 - * Notice in each file and include the License file at
15.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
15.20 - * particular file as subject to the "Classpath" exception as provided
15.21 - * by Sun in the GPL Version 2 section of the License file that
15.22 - * accompanied this code. If applicable, add the following below the
15.23 - * License Header, with the fields enclosed by brackets [] replaced by
15.24 - * your own identifying information:
15.25 - * "Portions Copyrighted [year] [name of copyright owner]"
15.26 - *
15.27 - * Contributor(s):
15.28 - *
15.29 - * The Original Software is NetBeans. The Initial Developer of the Original
15.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
15.31 - * Microsystems, Inc. All Rights Reserved.
15.32 - *
15.33 - * If you wish your version of this file to be governed by only the CDDL
15.34 - * or only the GPL Version 2, indicate your decision by adding
15.35 - * "[Contributor] elects to include this software in this distribution
15.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
15.37 - * single choice of license, a recipient has the option to distribute
15.38 - * your version of this file under either the CDDL, the GPL Version 2 or
15.39 - * to extend the choice of license to its licensees as provided above.
15.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
15.41 - * Version 2 license, then the option applies only if the new code is
15.42 - * made subject to such option by the copyright holder.
15.43 - */
15.44 -package org.netbeans.modules.clazz;
15.45 -
15.46 -import org.openide.util.Task;
15.47 -import org.openide.util.TaskListener;
15.48 -import java.lang.reflect.InvocationTargetException;
15.49 -import java.io.*;
15.50 -import java.util.*;
15.51 -
15.52 -import org.openide.cookies.SourceCookie;
15.53 -import org.openide.nodes.Sheet;
15.54 -import org.openide.nodes.PropertySupport;
15.55 -import org.openide.util.NbBundle;
15.56 -import org.openide.filesystems.FileObject;
15.57 -import org.netbeans.api.java.classpath.ClassPath;
15.58 -
15.59 -/**
15.60 - * This class overrides a few methods from ClassDataNode presenting the contents
15.61 - * as a sourceless class. It also adds .class - specific behaviour such as
15.62 - * execution and parameters property.
15.63 - *
15.64 - * @author sdedic
15.65 - * @version
15.66 - */
15.67 -public class CompiledDataNode extends ClassDataNode {
15.68 - private final static String PROP_IS_EXECUTABLE = "isExecutable"; // NOI18N
15.69 - private final static String PROP_FILE_PARAMS = "fileParams"; // NOI18N
15.70 - private final static String PROP_EXECUTION = "execution"; // NOI18N
15.71 - private final static String EXECUTION_SET_NAME = "Execution"; // NOI18N
15.72 -
15.73 - /** Icon bases for icon manager */
15.74 - protected final static String CLASS_BASE =
15.75 - "org/netbeans/modules/clazz/resources/class"; // NOI18N
15.76 - private final static String CLASS_MAIN_BASE =
15.77 - "org/netbeans/modules/clazz/resources/classMain"; // NOI18N
15.78 - private final static String ERROR_BASE =
15.79 - "org/netbeans/modules/clazz/resources/classError"; // NOI18N
15.80 - private final static String BEAN_BASE =
15.81 - "org/netbeans/modules/clazz/resources/bean"; // NOI18N
15.82 - private final static String BEAN_MAIN_BASE =
15.83 - "org/netbeans/modules/clazz/resources/beanMain"; // NOI18N
15.84 -
15.85 -
15.86 - /** Creates new CompiledDataNode */
15.87 - public CompiledDataNode(final CompiledDataObject obj) {
15.88 - super(obj);
15.89 - }
15.90 -
15.91 - private CompiledDataObject getCompiledDataObject() {
15.92 - return (CompiledDataObject)getDataObject();
15.93 - }
15.94 -
15.95 - boolean isExecutable() {
15.96 - return getCompiledDataObject().isExecutable();
15.97 - }
15.98 -
15.99 - protected Sheet createSheet () {
15.100 - Sheet s = super.createSheet();
15.101 - ResourceBundle bundle = NbBundle.getBundle(ClassDataNode.class);
15.102 - Sheet.Set ps = s.get(Sheet.PROPERTIES);
15.103 -
15.104 - ps.put(new PropertySupport.ReadOnly (
15.105 - PROP_IS_EXECUTABLE,
15.106 - Boolean.TYPE,
15.107 - bundle.getString ("PROP_isExecutable"),
15.108 - bundle.getString ("HINT_isExecutable")
15.109 - ) {
15.110 - public Object getValue () throws InvocationTargetException {
15.111 - return getCompiledDataObject().isExecutable() ? Boolean.TRUE : Boolean.FALSE;
15.112 - }
15.113 - });
15.114 - return s;
15.115 - }
15.116 -
15.117 - protected String initialIconBase() {
15.118 - return CLASS_BASE;
15.119 - }
15.120 -
15.121 - /** Find right icon for this node. */
15.122 - protected void resolveIcons () {
15.123 - iconResolved = true;
15.124 - }
15.125 -
15.126 - /**
15.127 - * Requests construction / retrieval of metadata
15.128 - */
15.129 - protected void requestResolveIcon() {
15.130 - CompiledDataObject dataObj = getCompiledDataObject();
15.131 - FileObject fo=dataObj.getPrimaryFile();
15.132 - ClassPath libs = ClassPath.getClassPath (fo, ClassPath.COMPILE);
15.133 - ClassPath source = ClassPath.getClassPath (fo, ClassPath.SOURCE);
15.134 - ClassPath exec = ClassPath.getClassPath (fo, ClassPath.EXECUTE);
15.135 - if ((libs == null || !libs.contains(fo)) && (source == null || !source.contains(fo))
15.136 - && (exec == null || !exec.contains(fo))) {
15.137 - setIconBase(ERROR_BASE);
15.138 - } else if (dataObj.isJavaBean ()) {
15.139 - if (dataObj.isExecutable ())
15.140 - setIconBase(BEAN_MAIN_BASE);
15.141 - else
15.142 - setIconBase(BEAN_BASE);
15.143 - } else if (dataObj.isExecutable ())
15.144 - setIconBase(CLASS_MAIN_BASE);
15.145 - else
15.146 - setIconBase(CLASS_BASE);
15.147 - iconResolved = true;
15.148 - }
15.149 -}
16.1 --- a/clazz/src/org/netbeans/modules/clazz/CompiledDataObject.java Fri Sep 17 18:36:33 2010 -0400
16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
16.3 @@ -1,189 +0,0 @@
16.4 -/*
16.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
16.6 - *
16.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
16.8 - *
16.9 - * The contents of this file are subject to the terms of either the GNU
16.10 - * General Public License Version 2 only ("GPL") or the Common
16.11 - * Development and Distribution License("CDDL") (collectively, the
16.12 - * "License"). You may not use this file except in compliance with the
16.13 - * License. You can obtain a copy of the License at
16.14 - * http://www.netbeans.org/cddl-gplv2.html
16.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16.16 - * specific language governing permissions and limitations under the
16.17 - * License. When distributing the software, include this License Header
16.18 - * Notice in each file and include the License file at
16.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
16.20 - * particular file as subject to the "Classpath" exception as provided
16.21 - * by Sun in the GPL Version 2 section of the License file that
16.22 - * accompanied this code. If applicable, add the following below the
16.23 - * License Header, with the fields enclosed by brackets [] replaced by
16.24 - * your own identifying information:
16.25 - * "Portions Copyrighted [year] [name of copyright owner]"
16.26 - *
16.27 - * Contributor(s):
16.28 - *
16.29 - * The Original Software is NetBeans. The Initial Developer of the Original
16.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16.31 - * Microsystems, Inc. All Rights Reserved.
16.32 - *
16.33 - * If you wish your version of this file to be governed by only the CDDL
16.34 - * or only the GPL Version 2, indicate your decision by adding
16.35 - * "[Contributor] elects to include this software in this distribution
16.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
16.37 - * single choice of license, a recipient has the option to distribute
16.38 - * your version of this file under either the CDDL, the GPL Version 2 or
16.39 - * to extend the choice of license to its licensees as provided above.
16.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
16.41 - * Version 2 license, then the option applies only if the new code is
16.42 - * made subject to such option by the copyright holder.
16.43 - */
16.44 -
16.45 -package org.netbeans.modules.clazz;
16.46 -
16.47 -import java.applet.Applet;
16.48 -import java.awt.datatransfer.Clipboard;
16.49 -import java.awt.datatransfer.DataFlavor;
16.50 -import java.awt.datatransfer.Transferable;
16.51 -import java.awt.datatransfer.UnsupportedFlavorException;
16.52 -import java.beans.*;
16.53 -import java.io.*;
16.54 -import java.util.StringTokenizer;
16.55 -import java.util.List;
16.56 -import java.util.ArrayList;
16.57 -import java.util.ResourceBundle;
16.58 -import java.text.MessageFormat;
16.59 -import java.util.Iterator;
16.60 -import javax.swing.JApplet;
16.61 -import javax.swing.JButton;
16.62 -
16.63 -import org.openide.*;
16.64 -import org.openide.util.*;
16.65 -import org.openide.cookies.*;
16.66 -import org.openide.filesystems.*;
16.67 -import org.openide.loaders.*;
16.68 -import org.openide.explorer.propertysheet.PropertySheet;
16.69 -import org.openide.nodes.Node;
16.70 -import org.openide.nodes.AbstractNode;
16.71 -import org.openide.nodes.CookieSet;
16.72 -import org.openide.src.SourceElement;
16.73 -import org.openide.src.nodes.SourceChildren;
16.74 -import org.openide.src.nodes.SourceElementFilter;
16.75 -import org.openide.src.nodes.FilterFactory;
16.76 -import org.openide.src.nodes.ElementNodeFactory;
16.77 -import org.netbeans.modules.classfile.ClassFile;
16.78 -
16.79 -/* TODO:
16.80 - - check the showDeclaredOnly flag - it works different for
16.81 - variables/constructors than for methods (i.e. for variables/constructors
16.82 - the declaredOnly are not subset of notDecalredOnly
16.83 -*/
16.84 -
16.85 -/**
16.86 -* DataObject which represents .class files.
16.87 -*
16.88 -* @author Jan Jancura, Ian Formanek, Petr Hamernik, Dafe Simonek
16.89 -*/
16.90 -public class CompiledDataObject extends ClassDataObject {
16.91 - /** generated Serialized Version UID */
16.92 - static final long serialVersionUID = -7355104884002106137L;
16.93 -
16.94 - /** Name of arguments property. */
16.95 - private final static String PROP_ARGV = "Arguments"; // NOI18N
16.96 - /** Name of execution property. */
16.97 - private final static String PROP_EXECUTION = "Execution"; // NOI18N
16.98 -
16.99 - // variables ...................................................................................
16.100 -
16.101 - // constructors ...................................................................................
16.102 -
16.103 - /** Constructs a new ClassDataObject */
16.104 - public CompiledDataObject(final FileObject fo,final ClassDataLoader loader) throws org.openide.loaders.DataObjectExistsException {
16.105 - super (fo, loader);
16.106 - initCookies();
16.107 - }
16.108 -
16.109 - /** Performs cookie initialization. */
16.110 - protected void initCookies () {
16.111 - super.initCookies();
16.112 -
16.113 - CookieSet cs = getCookieSet();
16.114 - // only JavaBeans should offer `Customize Bean' action
16.115 - cs.add(InstanceCookie.class, this);
16.116 - }
16.117 -
16.118 - protected Node.Cookie createBeanInstanceSupport() {
16.119 - if (isJavaBean()) {
16.120 - return createInstanceSupport();
16.121 - } else {
16.122 - return null;
16.123 - }
16.124 - }
16.125 -
16.126 - public Node.Cookie createCookie(Class c) {
16.127 - if (InstanceCookie.class.isAssignableFrom(c)) {
16.128 - return createBeanInstanceSupport();
16.129 - }
16.130 - return super.createCookie(c);
16.131 - }
16.132 -
16.133 -
16.134 - /**
16.135 - * @return class data node
16.136 - */
16.137 - protected Node createNodeDelegate () {
16.138 - return new CompiledDataNode (this);
16.139 - }
16.140 -
16.141 - // Properties implementation .....................................................................
16.142 -
16.143 - boolean isExecutable () {
16.144 - return createInstanceSupport().isExecutable ();
16.145 - }
16.146 -
16.147 - // other methods ..............................................................................
16.148 -
16.149 - /** Check if in specific folder exists .ser fileobject with the same name.
16.150 - * If it exists user is asked for confirmation to rewrite, rename or
16.151 - * cancel operation. Throws UserCancelException if user pressed cancel
16.152 - * button.
16.153 - * @param f destination folder
16.154 - * @return new Name of file in destination
16.155 - */
16.156 - protected String existInFolder(DataFolder f) throws UserCancelException {
16.157 - FileObject fo = getPrimaryFile();
16.158 - String name = fo.getName();
16.159 - String ext = "ser"; // NOI18N
16.160 - String destName = fo.getName();
16.161 - if (f.getPrimaryFile().getFileObject(name, ext) != null) {
16.162 - // file with the same name exists - ask user what to do
16.163 - ResourceBundle bundle = NbBundle.getBundle(ClassDataObject.class);
16.164 - String rewriteStr = bundle.getString("CTL_Rewrite");
16.165 - String renameStr = bundle.getString("CTL_Rename");
16.166 - String cancelStr = bundle.getString("CTL_Cancel");
16.167 - NotifyDescriptor nd = new NotifyDescriptor.Confirmation(
16.168 - new MessageFormat(bundle.getString("MSG_SerExists")).
16.169 - format(new Object[] { name, f.getName() }));
16.170 - nd.setOptions(new Object[] { rewriteStr, renameStr, cancelStr });
16.171 - String retStr = (String)DialogDisplayer.getDefault().notify(nd);
16.172 - if (cancelStr.equals(retStr)) // user cancelled the dialog
16.173 - throw new UserCancelException();
16.174 - if (renameStr.equals(retStr))
16.175 - destName = FileUtil.findFreeFileName (
16.176 - f.getPrimaryFile(), destName, ext);
16.177 - if (rewriteStr.equals(retStr)) {
16.178 - try {
16.179 - FileObject dest = f.getPrimaryFile().getFileObject(name, ext);
16.180 - FileLock lock = dest.lock();
16.181 - dest.delete(lock);
16.182 - lock.releaseLock();
16.183 - }
16.184 - catch (IOException e) {
16.185 - return null;
16.186 - }
16.187 - }
16.188 - }
16.189 - return destName;
16.190 - }
16.191 -}
16.192 -
17.1 --- a/clazz/src/org/netbeans/modules/clazz/ConstructorElementImpl.java Fri Sep 17 18:36:33 2010 -0400
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,181 +0,0 @@
17.4 -/*
17.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
17.6 - *
17.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
17.8 - *
17.9 - * The contents of this file are subject to the terms of either the GNU
17.10 - * General Public License Version 2 only ("GPL") or the Common
17.11 - * Development and Distribution License("CDDL") (collectively, the
17.12 - * "License"). You may not use this file except in compliance with the
17.13 - * License. You can obtain a copy of the License at
17.14 - * http://www.netbeans.org/cddl-gplv2.html
17.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
17.16 - * specific language governing permissions and limitations under the
17.17 - * License. When distributing the software, include this License Header
17.18 - * Notice in each file and include the License file at
17.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17.20 - * particular file as subject to the "Classpath" exception as provided
17.21 - * by Sun in the GPL Version 2 section of the License file that
17.22 - * accompanied this code. If applicable, add the following below the
17.23 - * License Header, with the fields enclosed by brackets [] replaced by
17.24 - * your own identifying information:
17.25 - * "Portions Copyrighted [year] [name of copyright owner]"
17.26 - *
17.27 - * Contributor(s):
17.28 - *
17.29 - * The Original Software is NetBeans. The Initial Developer of the Original
17.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17.31 - * Microsystems, Inc. All Rights Reserved.
17.32 - *
17.33 - * If you wish your version of this file to be governed by only the CDDL
17.34 - * or only the GPL Version 2, indicate your decision by adding
17.35 - * "[Contributor] elects to include this software in this distribution
17.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
17.37 - * single choice of license, a recipient has the option to distribute
17.38 - * your version of this file under either the CDDL, the GPL Version 2 or
17.39 - * to extend the choice of license to its licensees as provided above.
17.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
17.41 - * Version 2 license, then the option applies only if the new code is
17.42 - * made subject to such option by the copyright holder.
17.43 - */
17.44 -
17.45 -package org.netbeans.modules.clazz;
17.46 -
17.47 -import org.netbeans.api.mdr.MDRepository;
17.48 -import org.netbeans.jmi.javamodel.CallableFeature;
17.49 -import org.openide.src.*;
17.50 -import org.netbeans.jmi.javamodel.JavaClass;
17.51 -import org.netbeans.jmi.javamodel.Parameter;
17.52 -import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
17.53 -
17.54 -/** Implementation of the constructor element for class objects.
17.55 -* It's simple bridge to the java reflection Constructor, delegates
17.56 -* all tasks to it.
17.57 -*
17.58 -* @author Dafe Simonek
17.59 -*/
17.60 -class ConstructorElementImpl extends MemberElementImpl
17.61 - implements ConstructorElement.Impl {
17.62 -
17.63 - /** The array of parameters of this constructor (or method)*/
17.64 - private MethodParameter[] parameters;
17.65 - /** The array of exceptions which can be thrown */
17.66 - private Identifier[] exceptions;
17.67 - /** One JavaDoc empty implementation for all objects */
17.68 - private static final ClassJavaDocImpl.Method METHOD_JAVADOC_IMPL = new ClassJavaDocImpl.Method();
17.69 -
17.70 - static final long serialVersionUID =5714347955571851240L;
17.71 -
17.72 - ConstructorElementImpl (final CallableFeature data ) {
17.73 - super(data);
17.74 - }
17.75 -
17.76 - CallableFeature getBehavioral() {
17.77 - return (CallableFeature)data;
17.78 - }
17.79 -
17.80 - public void initializeData() {
17.81 - super.initializeData();
17.82 - getExceptions();
17.83 - getParameters();
17.84 - }
17.85 -
17.86 - /** @return the array specifying the parameters
17.87 - */
17.88 - public MethodParameter[] getParameters () {
17.89 - if (parameters == null) {
17.90 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
17.91 - repo.beginTrans(false);
17.92 - try {
17.93 - if (!isValid()) {
17.94 - parameters = new MethodParameter[0];
17.95 - } else {
17.96 - Parameter[] pars = (Parameter[])getBehavioral().getParameters().toArray(new Parameter[0]);
17.97 - MethodParameter[] mp = new MethodParameter[pars.length];
17.98 - for (int i = 0; i < pars.length; i++) {
17.99 - Parameter p=pars[i];
17.100 - mp[i] = new MethodParameter(p.getName(), Util.createType(p.getType()), p.isFinal());
17.101 - }
17.102 - parameters = mp;
17.103 - }
17.104 - } finally {
17.105 - repo.endTrans();
17.106 - }
17.107 - }
17.108 - return parameters;
17.109 - }
17.110 -
17.111 - protected Identifier createName(Object data) {
17.112 - if (this instanceof MethodElementImpl) {
17.113 - return super.createName(data);
17.114 - }
17.115 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
17.116 - repo.beginTrans(false);
17.117 - try {
17.118 - if (!isValid()) {
17.119 - return Identifier.create(""); // NOI18N
17.120 - }
17.121 - return Identifier.create(((JavaClass)(getBehavioral().getDeclaringClass())).getSimpleName());
17.122 - } finally {
17.123 - repo.endTrans();
17.124 - }
17.125 - }
17.126 -
17.127 - /** Unsupported, throws SourceException
17.128 - */
17.129 - public void setParameters (MethodParameter[] params) throws SourceException {
17.130 - throwReadOnlyException();
17.131 - }
17.132 -
17.133 - /** @return the array of the exceptions throwed by the method.
17.134 - */
17.135 - public Identifier[] getExceptions () {
17.136 - if (exceptions == null) {
17.137 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
17.138 - repo.beginTrans(false);
17.139 - try {
17.140 - if (!isValid()) {
17.141 - return new Identifier[0];
17.142 - }
17.143 - JavaClass[] reflEx = (JavaClass[])getBehavioral().getExceptions().toArray(new JavaClass[0]);
17.144 - exceptions = new Identifier[reflEx.length];
17.145 - // build our exception types
17.146 - for (int i = 0; i < reflEx.length; i++) {
17.147 - exceptions[i] = Identifier.create(Util.createClassName(reflEx[i].getName()));
17.148 - }
17.149 - } finally {
17.150 - repo.endTrans();
17.151 - }
17.152 - }
17.153 - return exceptions;
17.154 - }
17.155 -
17.156 - /** Unsupported, throws SourceException
17.157 - */
17.158 - public void setExceptions (Identifier[] exceptions) throws SourceException {
17.159 - throwReadOnlyException();
17.160 - }
17.161 -
17.162 - /** Unsupported, throws SourceException
17.163 - */
17.164 - public void setBody (String s) throws SourceException {
17.165 - throwReadOnlyException();
17.166 - }
17.167 -
17.168 - /** Unsupported, always return empty string.
17.169 - */
17.170 - public String getBody () {
17.171 - return ""; // NOI18N
17.172 - }
17.173 -
17.174 - /** Empty implementation
17.175 - * @return Empty JavaDoc implementation.
17.176 - */
17.177 - public JavaDoc.Method getJavaDoc () {
17.178 - return METHOD_JAVADOC_IMPL;
17.179 - }
17.180 -
17.181 - public Object readResolve() {
17.182 - return new ConstructorElement(this, null);
17.183 - }
17.184 -}
18.1 --- a/clazz/src/org/netbeans/modules/clazz/ElementImpl.java Fri Sep 17 18:36:33 2010 -0400
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,131 +0,0 @@
18.4 -/*
18.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
18.6 - *
18.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
18.8 - *
18.9 - * The contents of this file are subject to the terms of either the GNU
18.10 - * General Public License Version 2 only ("GPL") or the Common
18.11 - * Development and Distribution License("CDDL") (collectively, the
18.12 - * "License"). You may not use this file except in compliance with the
18.13 - * License. You can obtain a copy of the License at
18.14 - * http://www.netbeans.org/cddl-gplv2.html
18.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18.16 - * specific language governing permissions and limitations under the
18.17 - * License. When distributing the software, include this License Header
18.18 - * Notice in each file and include the License file at
18.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
18.20 - * particular file as subject to the "Classpath" exception as provided
18.21 - * by Sun in the GPL Version 2 section of the License file that
18.22 - * accompanied this code. If applicable, add the following below the
18.23 - * License Header, with the fields enclosed by brackets [] replaced by
18.24 - * your own identifying information:
18.25 - * "Portions Copyrighted [year] [name of copyright owner]"
18.26 - *
18.27 - * Contributor(s):
18.28 - *
18.29 - * The Original Software is NetBeans. The Initial Developer of the Original
18.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
18.31 - * Microsystems, Inc. All Rights Reserved.
18.32 - *
18.33 - * If you wish your version of this file to be governed by only the CDDL
18.34 - * or only the GPL Version 2, indicate your decision by adding
18.35 - * "[Contributor] elects to include this software in this distribution
18.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
18.37 - * single choice of license, a recipient has the option to distribute
18.38 - * your version of this file under either the CDDL, the GPL Version 2 or
18.39 - * to extend the choice of license to its licensees as provided above.
18.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
18.41 - * Version 2 license, then the option applies only if the new code is
18.42 - * made subject to such option by the copyright holder.
18.43 - */
18.44 -
18.45 -package org.netbeans.modules.clazz;
18.46 -
18.47 -import java.io.ObjectInput;
18.48 -import java.io.ObjectOutput;
18.49 -import java.io.IOException;
18.50 -import java.io.Externalizable;
18.51 -import java.beans.PropertyChangeSupport;
18.52 -import java.beans.PropertyChangeListener;
18.53 -
18.54 -import org.openide.ErrorManager;
18.55 -import org.openide.nodes.CookieSet;
18.56 -import org.openide.nodes.Node;
18.57 -import org.openide.src.Element;
18.58 -import org.openide.src.SourceException;
18.59 -import org.openide.util.NbBundle;
18.60 -
18.61 -/** Implementation of Element for classes.
18.62 -*
18.63 -* @author Dafe Simonek
18.64 -*/
18.65 -public abstract class ElementImpl extends Object implements Element.Impl, Externalizable {
18.66 -
18.67 - /** The element we are asociated to. We provide an implementation
18.68 - * to that element */
18.69 - protected Element element;
18.70 -
18.71 - private PropertyChangeSupport support;
18.72 -
18.73 - static final long serialVersionUID =6363778502021582852L;
18.74 -
18.75 - /** Default constructor
18.76 - */
18.77 - public ElementImpl () {
18.78 - }
18.79 -
18.80 - /** Attaches this implementation to the element.
18.81 - *
18.82 - * @param element the element we are attached to
18.83 - */
18.84 - public void attachedToElement (Element element) {
18.85 - this.element = element;
18.86 - }
18.87 -
18.88 - /** We don't support property changes - does nothing */
18.89 - public void addPropertyChangeListener (PropertyChangeListener l) {
18.90 - if (support == null)
18.91 - synchronized (this) {
18.92 - if (support == null)
18.93 - support = new PropertyChangeSupport(this);
18.94 - }
18.95 - support.addPropertyChangeListener(l);
18.96 - }
18.97 -
18.98 - /** We don't support property changes - does nothing */
18.99 - public void removePropertyChangeListener (PropertyChangeListener l) {
18.100 - if (support != null)
18.101 - support.addPropertyChangeListener(l);
18.102 - }
18.103 -
18.104 - protected void firePropertyChange(String propName, Object old, Object n) {
18.105 - if (support != null)
18.106 - support.firePropertyChange(propName, old, n);
18.107 - }
18.108 -
18.109 - /** No cookie supported.
18.110 - * @return null
18.111 - */
18.112 - public Node.Cookie getCookie (Class type) {
18.113 - return null;
18.114 - }
18.115 -
18.116 - /** Mark the current element in the context of this element.
18.117 - * The current element means the position for inserting new elements.
18.118 - * @param beforeAfter <CODE>true</CODE> means that new element is inserted before
18.119 - * the specified element, <CODE>false</CODE> means after.
18.120 - */
18.121 - public void markCurrent(boolean beforeAfter) {
18.122 - // nothing to do - class is not editable
18.123 - }
18.124 -
18.125 -
18.126 - protected final void throwReadOnlyException() throws SourceException {
18.127 - throw (SourceException)ErrorManager.getDefault().annotate(
18.128 - new SourceException("Read-only element"), // NOI18N
18.129 - ErrorManager.USER,
18.130 - null, NbBundle.getMessage(ElementImpl.class, "MSG_CantModify"),
18.131 - null, null
18.132 - );
18.133 - }
18.134 -}
19.1 --- a/clazz/src/org/netbeans/modules/clazz/FieldElementImpl.java Fri Sep 17 18:36:33 2010 -0400
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,131 +0,0 @@
19.4 -/*
19.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
19.6 - *
19.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
19.8 - *
19.9 - * The contents of this file are subject to the terms of either the GNU
19.10 - * General Public License Version 2 only ("GPL") or the Common
19.11 - * Development and Distribution License("CDDL") (collectively, the
19.12 - * "License"). You may not use this file except in compliance with the
19.13 - * License. You can obtain a copy of the License at
19.14 - * http://www.netbeans.org/cddl-gplv2.html
19.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
19.16 - * specific language governing permissions and limitations under the
19.17 - * License. When distributing the software, include this License Header
19.18 - * Notice in each file and include the License file at
19.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
19.20 - * particular file as subject to the "Classpath" exception as provided
19.21 - * by Sun in the GPL Version 2 section of the License file that
19.22 - * accompanied this code. If applicable, add the following below the
19.23 - * License Header, with the fields enclosed by brackets [] replaced by
19.24 - * your own identifying information:
19.25 - * "Portions Copyrighted [year] [name of copyright owner]"
19.26 - *
19.27 - * Contributor(s):
19.28 - *
19.29 - * The Original Software is NetBeans. The Initial Developer of the Original
19.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
19.31 - * Microsystems, Inc. All Rights Reserved.
19.32 - *
19.33 - * If you wish your version of this file to be governed by only the CDDL
19.34 - * or only the GPL Version 2, indicate your decision by adding
19.35 - * "[Contributor] elects to include this software in this distribution
19.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
19.37 - * single choice of license, a recipient has the option to distribute
19.38 - * your version of this file under either the CDDL, the GPL Version 2 or
19.39 - * to extend the choice of license to its licensees as provided above.
19.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
19.41 - * Version 2 license, then the option applies only if the new code is
19.42 - * made subject to such option by the copyright holder.
19.43 - */
19.44 -
19.45 -package org.netbeans.modules.clazz;
19.46 -
19.47 -import org.netbeans.api.mdr.MDRepository;
19.48 -import org.netbeans.jmi.javamodel.Field;
19.49 -import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
19.50 -import org.openide.src.*;
19.51 -
19.52 -/** The implementation of the field element for class objects.
19.53 -*
19.54 -* @author Dafe Simonek
19.55 -*/
19.56 -final class FieldElementImpl extends MemberElementImpl
19.57 - implements FieldElement.Impl {
19.58 - /** Cached type of this field */
19.59 - private Type type;
19.60 -
19.61 - /** One JavaDoc empty implementation for all objects */
19.62 - private static final ClassJavaDocImpl.Field FIELD_JAVADOC_IMPL = new ClassJavaDocImpl.Field();
19.63 -
19.64 - static final long serialVersionUID =-4800326520399939102L;
19.65 - /** Default constructor. Asociates with given
19.66 - * reflection Field data.
19.67 - */
19.68 - public FieldElementImpl (final org.netbeans.modules.classfile.Field data) {
19.69 - super(data);
19.70 - }
19.71 -
19.72 - FieldElementImpl(final Field data) {
19.73 - super(data);
19.74 - }
19.75 -
19.76 - private Field getField() {
19.77 - return (Field)data;
19.78 - }
19.79 -
19.80 - public void initializeData() {
19.81 - super.initializeData();
19.82 - getType();
19.83 - }
19.84 -
19.85 - /** Type of the variable.
19.86 - * @return the type
19.87 - */
19.88 - public Type getType () {
19.89 - if (type == null) {
19.90 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
19.91 - repo.beginTrans(false);
19.92 - try {
19.93 - if (!isValid()) {
19.94 - type = org.openide.src.Type.VOID;
19.95 - } else {
19.96 - type = Util.createType(getField().getType());
19.97 - }
19.98 - //XXX
19.99 - //type = Type.createFromClass(((org.netbeans.modules.classfile.Field)data).getType());
19.100 - } finally {
19.101 - repo.endTrans();
19.102 - }
19.103 - }
19.104 - return type;
19.105 - }
19.106 -
19.107 - /** Not supported. Throws SourceException.
19.108 - */
19.109 - public void setType (Type type) throws SourceException {
19.110 - throwReadOnlyException();
19.111 - }
19.112 -
19.113 - /** PENDING - don't know how to implement...
19.114 - */
19.115 - public String getInitValue () {
19.116 - return ""; // NOI18N
19.117 - }
19.118 -
19.119 - /** Not supported. Throws SourceException.
19.120 - */
19.121 - public void setInitValue (String value) throws SourceException {
19.122 - throwReadOnlyException();
19.123 - }
19.124 -
19.125 - /** @return java doc for the field
19.126 - */
19.127 - public JavaDoc.Field getJavaDoc () {
19.128 - return FIELD_JAVADOC_IMPL;
19.129 - }
19.130 -
19.131 - public Object readResolve() {
19.132 - return new FieldElement(this, null);
19.133 - }
19.134 -}
20.1 --- a/clazz/src/org/netbeans/modules/clazz/LazySourceChildren.java Fri Sep 17 18:36:33 2010 -0400
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,104 +0,0 @@
20.4 -/*
20.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
20.6 - *
20.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
20.8 - *
20.9 - * The contents of this file are subject to the terms of either the GNU
20.10 - * General Public License Version 2 only ("GPL") or the Common
20.11 - * Development and Distribution License("CDDL") (collectively, the
20.12 - * "License"). You may not use this file except in compliance with the
20.13 - * License. You can obtain a copy of the License at
20.14 - * http://www.netbeans.org/cddl-gplv2.html
20.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
20.16 - * specific language governing permissions and limitations under the
20.17 - * License. When distributing the software, include this License Header
20.18 - * Notice in each file and include the License file at
20.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
20.20 - * particular file as subject to the "Classpath" exception as provided
20.21 - * by Sun in the GPL Version 2 section of the License file that
20.22 - * accompanied this code. If applicable, add the following below the
20.23 - * License Header, with the fields enclosed by brackets [] replaced by
20.24 - * your own identifying information:
20.25 - * "Portions Copyrighted [year] [name of copyright owner]"
20.26 - *
20.27 - * Contributor(s):
20.28 - *
20.29 - * The Original Software is NetBeans. The Initial Developer of the Original
20.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
20.31 - * Microsystems, Inc. All Rights Reserved.
20.32 - *
20.33 - * If you wish your version of this file to be governed by only the CDDL
20.34 - * or only the GPL Version 2, indicate your decision by adding
20.35 - * "[Contributor] elects to include this software in this distribution
20.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
20.37 - * single choice of license, a recipient has the option to distribute
20.38 - * your version of this file under either the CDDL, the GPL Version 2 or
20.39 - * to extend the choice of license to its licensees as provided above.
20.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
20.41 - * Version 2 license, then the option applies only if the new code is
20.42 - * made subject to such option by the copyright holder.
20.43 - */
20.44 -
20.45 -package org.netbeans.modules.clazz;
20.46 -
20.47 -import org.openide.cookies.SourceCookie;
20.48 -import org.openide.loaders.DataObject;
20.49 -import org.openide.nodes.Node;
20.50 -import org.openide.src.SourceElement;
20.51 -import org.openide.src.nodes.ElementNodeFactory;
20.52 -import org.openide.src.nodes.SourceChildren;
20.53 -
20.54 -/**
20.55 - * LazySourceChildren is used as a Children of {@link ClassDataNode}
20.56 - * to defer creation of {@link SourceElement} and reading of class file.
20.57 - * @author Tomas Zezula
20.58 - */
20.59 -final class LazySourceChildren extends SourceChildren {
20.60 -
20.61 - private DataObject data;
20.62 -
20.63 - /** Creates a new instance of LazySourceChildren
20.64 - * @param data the source of the {@link SourceCookie} to take the
20.65 - * @param ElementNodeFactory factory
20.66 - * {@link SourceElement} from
20.67 - */
20.68 - public LazySourceChildren (DataObject data, ElementNodeFactory factory) {
20.69 - super (factory);
20.70 - assert data != null;
20.71 - this.data = data;
20.72 - }
20.73 -
20.74 - public SourceElement getElement() {
20.75 - SourceElement retValue = super.getElement();
20.76 - if (retValue == null) {
20.77 - retValue = initElement ();
20.78 - }
20.79 - return retValue;
20.80 - }
20.81 -
20.82 -
20.83 - protected void addNotify() {
20.84 - this.getElement(); //Lazy Initialize the SourceElement
20.85 - super.addNotify();
20.86 - }
20.87 -
20.88 - public Node[] getNodes(boolean initialize) {
20.89 - this.getElement(); //Lazy Initialize the SourceElement
20.90 - return super.getNodes (initialize);
20.91 - }
20.92 -
20.93 - public Node findChild(String name) {
20.94 - this.getElement(); //Lazy Initialize the SourceElement
20.95 - return super.findChild(name);
20.96 - }
20.97 -
20.98 - private SourceElement initElement () {
20.99 - SourceCookie sc = (SourceCookie) this.data.getCookie(SourceCookie.class);
20.100 - SourceElement srcElement = sc.getSource();
20.101 - this.setElement(srcElement);
20.102 - return srcElement;
20.103 - }
20.104 -
20.105 -
20.106 -
20.107 -}
21.1 --- a/clazz/src/org/netbeans/modules/clazz/MemberElementImpl.java Fri Sep 17 18:36:33 2010 -0400
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,224 +0,0 @@
21.4 -/*
21.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
21.6 - *
21.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
21.8 - *
21.9 - * The contents of this file are subject to the terms of either the GNU
21.10 - * General Public License Version 2 only ("GPL") or the Common
21.11 - * Development and Distribution License("CDDL") (collectively, the
21.12 - * "License"). You may not use this file except in compliance with the
21.13 - * License. You can obtain a copy of the License at
21.14 - * http://www.netbeans.org/cddl-gplv2.html
21.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
21.16 - * specific language governing permissions and limitations under the
21.17 - * License. When distributing the software, include this License Header
21.18 - * Notice in each file and include the License file at
21.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
21.20 - * particular file as subject to the "Classpath" exception as provided
21.21 - * by Sun in the GPL Version 2 section of the License file that
21.22 - * accompanied this code. If applicable, add the following below the
21.23 - * License Header, with the fields enclosed by brackets [] replaced by
21.24 - * your own identifying information:
21.25 - * "Portions Copyrighted [year] [name of copyright owner]"
21.26 - *
21.27 - * Contributor(s):
21.28 - *
21.29 - * The Original Software is NetBeans. The Initial Developer of the Original
21.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
21.31 - * Microsystems, Inc. All Rights Reserved.
21.32 - *
21.33 - * If you wish your version of this file to be governed by only the CDDL
21.34 - * or only the GPL Version 2, indicate your decision by adding
21.35 - * "[Contributor] elects to include this software in this distribution
21.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
21.37 - * single choice of license, a recipient has the option to distribute
21.38 - * your version of this file under either the CDDL, the GPL Version 2 or
21.39 - * to extend the choice of license to its licensees as provided above.
21.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
21.41 - * Version 2 license, then the option applies only if the new code is
21.42 - * made subject to such option by the copyright holder.
21.43 - */
21.44 -
21.45 -package org.netbeans.modules.clazz;
21.46 -
21.47 -import java.io.ObjectInput;
21.48 -import java.io.ObjectOutput;
21.49 -import java.io.IOException;
21.50 -
21.51 -import org.openide.src.MemberElement;
21.52 -import org.openide.src.SourceException;
21.53 -import org.openide.src.Identifier;
21.54 -import org.openide.src.ClassElement;
21.55 -import org.openide.src.SourceElement;
21.56 -import org.openide.nodes.Node;
21.57 -import org.openide.util.Task;
21.58 -
21.59 -import javax.jmi.reflect.RefObject;
21.60 -import org.netbeans.api.mdr.MDRepository;
21.61 -import org.netbeans.jmi.javamodel.Feature;
21.62 -import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
21.63 -import org.openide.util.RequestProcessor;
21.64 -
21.65 -/** Implementation of the MemberElement.Impl for the class objects.
21.66 -*
21.67 -* @author Dafe Simonek
21.68 -*/
21.69 -public abstract class MemberElementImpl extends ElementImpl implements MemberElement.Impl, Node.Cookie {
21.70 - /** Asociated java reflection data */
21.71 - protected Object data;
21.72 - /** Cached name identifier */
21.73 - private transient Identifier name;
21.74 -
21.75 - private int modifiers = -1;
21.76 -
21.77 - static final long serialVersionUID =-6841890195552268874L;
21.78 - /** Constructor, asociates this impl with java reflection
21.79 - * Member element, which acts as data source.
21.80 - */
21.81 - public MemberElementImpl (final Object data) {
21.82 - super();
21.83 - this.data = data;
21.84 - }
21.85 -
21.86 - Feature getClassFeature() {
21.87 - return (Feature)data;
21.88 - }
21.89 -
21.90 - public void initializeData() {
21.91 - getName();
21.92 - getModifiers();
21.93 - }
21.94 -
21.95 - /** @return Modifiers for this element.
21.96 - */
21.97 - public int getModifiers () {
21.98 - if (modifiers == -1) {
21.99 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
21.100 - repo.beginTrans(false);
21.101 - try {
21.102 - if (!isValid()) {
21.103 - return 0;
21.104 - }
21.105 - Feature f = getClassFeature();
21.106 - modifiers = f.getModifiers();
21.107 - } finally {
21.108 - repo.endTrans();
21.109 - }
21.110 - }
21.111 - return modifiers;
21.112 - }
21.113 -
21.114 - /** Unsupported. Throws SourceException
21.115 - */
21.116 - public void setModifiers (int mod) throws SourceException {
21.117 - throwReadOnlyException();
21.118 - }
21.119 -
21.120 - /** Getter for name of the field.
21.121 - * @return the name
21.122 - */
21.123 - public Identifier getName () {
21.124 - if (name == null) {
21.125 - name = createName(this.data);
21.126 - }
21.127 - return name;
21.128 - }
21.129 -
21.130 - protected Identifier createName(Object data) {
21.131 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
21.132 - repo.beginTrans(false);
21.133 - try {
21.134 - if (!isValid()) {
21.135 - return Identifier.create(""); // NOI18N
21.136 - }
21.137 - String name = getClassFeature().getName();
21.138 - return Identifier.create(name);
21.139 - } finally {
21.140 - repo.endTrans();
21.141 - }
21.142 - }
21.143 -
21.144 - /** Unsupported. Throws SourceException.
21.145 - */
21.146 - public void setName (Identifier name) throws SourceException {
21.147 - throwReadOnlyException();
21.148 - }
21.149 -
21.150 - /** Delegates to source element implementation class,
21.151 - * if it's possible.
21.152 - */
21.153 - public Node.Cookie getCookie (Class type) {
21.154 - if (type == org.openide.src.Element.Impl.class)
21.155 - return this;
21.156 - ClassElement ce = ((MemberElement)element).getDeclaringClass();
21.157 - if ((ce == null) && (element instanceof ClassElement)) {
21.158 - ce = (ClassElement)element;
21.159 - }
21.160 - if (ce != null) {
21.161 - SourceElement se = ce.getSource();
21.162 - if (se != null) {
21.163 - return se.getCookie(type);
21.164 - }
21.165 - }
21.166 - return null;
21.167 - }
21.168 -
21.169 - org.netbeans.jmi.javamodel.Element getJMIElement() {
21.170 - return data instanceof org.netbeans.jmi.javamodel.Element ?
21.171 - (org.netbeans.jmi.javamodel.Element) data : null;
21.172 - }
21.173 -
21.174 - public void writeExternal (ObjectOutput oi) throws IOException {
21.175 - oi.writeObject(data);
21.176 - }
21.177 -
21.178 - public void readExternal (ObjectInput oi) throws IOException, ClassNotFoundException {
21.179 - data = oi.readObject();
21.180 - }
21.181 -
21.182 -
21.183 - public RefObject getRefObject() {
21.184 - if (data instanceof RefObject)
21.185 - return (RefObject)data;
21.186 - return null;
21.187 - }
21.188 -
21.189 - public boolean isValid() {
21.190 - if (data instanceof org.netbeans.jmi.javamodel.Element) {
21.191 - boolean valid = ((org.netbeans.jmi.javamodel.Element) data).isValid();
21.192 - /*
21.193 - if (!valid) {
21.194 - final SourceElementImpl source = (SourceElementImpl)getCookie(SourceElement.Impl.class);
21.195 - if (source != null) {
21.196 - RequestProcessor.getDefault().post(new Runnable() {
21.197 - public void run() {
21.198 - source.refreshData();
21.199 - }
21.200 - });
21.201 - }
21.202 - }
21.203 - */
21.204 - return valid;
21.205 - }
21.206 - return false;
21.207 - }
21.208 -
21.209 - public ElementImpl getDeclaringElement() {
21.210 - if ((element == null) || !(element instanceof MemberElement))
21.211 - return null;
21.212 - ClassElement declClass = ((MemberElement)element).getDeclaringClass();
21.213 - if (declClass != null)
21.214 - return (ElementImpl) declClass.getCookie(org.openide.src.Element.Impl.class);
21.215 - if (element instanceof ClassElement) {
21.216 - SourceElement source = ((ClassElement) element).getSource();
21.217 - if (source != null)
21.218 - return (ElementImpl) source.getCookie(org.openide.src.Element.Impl.class);
21.219 - }
21.220 - return null;
21.221 - }
21.222 -
21.223 - public Task refresh() {
21.224 - return Task.EMPTY;
21.225 - }
21.226 -
21.227 -}
22.1 --- a/clazz/src/org/netbeans/modules/clazz/MethodElementImpl.java Fri Sep 17 18:36:33 2010 -0400
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,101 +0,0 @@
22.4 -/*
22.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
22.6 - *
22.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
22.8 - *
22.9 - * The contents of this file are subject to the terms of either the GNU
22.10 - * General Public License Version 2 only ("GPL") or the Common
22.11 - * Development and Distribution License("CDDL") (collectively, the
22.12 - * "License"). You may not use this file except in compliance with the
22.13 - * License. You can obtain a copy of the License at
22.14 - * http://www.netbeans.org/cddl-gplv2.html
22.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
22.16 - * specific language governing permissions and limitations under the
22.17 - * License. When distributing the software, include this License Header
22.18 - * Notice in each file and include the License file at
22.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
22.20 - * particular file as subject to the "Classpath" exception as provided
22.21 - * by Sun in the GPL Version 2 section of the License file that
22.22 - * accompanied this code. If applicable, add the following below the
22.23 - * License Header, with the fields enclosed by brackets [] replaced by
22.24 - * your own identifying information:
22.25 - * "Portions Copyrighted [year] [name of copyright owner]"
22.26 - *
22.27 - * Contributor(s):
22.28 - *
22.29 - * The Original Software is NetBeans. The Initial Developer of the Original
22.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
22.31 - * Microsystems, Inc. All Rights Reserved.
22.32 - *
22.33 - * If you wish your version of this file to be governed by only the CDDL
22.34 - * or only the GPL Version 2, indicate your decision by adding
22.35 - * "[Contributor] elects to include this software in this distribution
22.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
22.37 - * single choice of license, a recipient has the option to distribute
22.38 - * your version of this file under either the CDDL, the GPL Version 2 or
22.39 - * to extend the choice of license to its licensees as provided above.
22.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
22.41 - * Version 2 license, then the option applies only if the new code is
22.42 - * made subject to such option by the copyright holder.
22.43 - */
22.44 -
22.45 -package org.netbeans.modules.clazz;
22.46 -
22.47 -import org.netbeans.api.mdr.MDRepository;
22.48 -import org.openide.src.*;
22.49 -import org.netbeans.jmi.javamodel.Method;
22.50 -import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
22.51 -
22.52 -/** Implementation of method element for class objects.
22.53 -*
22.54 -* @author Dafe Simonek
22.55 -*/
22.56 -final class MethodElementImpl extends ConstructorElementImpl
22.57 - implements MethodElement.Impl {
22.58 - /** Return type of the method */
22.59 - private Type returnType;
22.60 -
22.61 - static final long serialVersionUID =7928961724192084484L;
22.62 -
22.63 - MethodElementImpl(final Method data) {
22.64 - super(data);
22.65 - }
22.66 -
22.67 - Method getMethod() {
22.68 - return (Method)data;
22.69 - }
22.70 -
22.71 - public void initializeData() {
22.72 - super.initializeData();
22.73 - getReturn();
22.74 - }
22.75 -
22.76 - /** @return returns teh Type representing return type of this method.
22.77 - */
22.78 - public Type getReturn () {
22.79 - if (returnType == null) {
22.80 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
22.81 - repo.beginTrans(false);
22.82 - try {
22.83 - if (!isValid()) {
22.84 - returnType = org.openide.src.Type.VOID;
22.85 - } else {
22.86 - returnType = Util.createType(getMethod().getType());
22.87 - }
22.88 - } finally {
22.89 - repo.endTrans();
22.90 - }
22.91 - }
22.92 - return returnType;
22.93 - }
22.94 -
22.95 - /** Unsupported. Throws an Source exception. */
22.96 - public void setReturn (Type ret) throws SourceException {
22.97 - throwReadOnlyException();
22.98 - }
22.99 -
22.100 - public Object readResolve() {
22.101 - return new MethodElement(this, null);
22.102 - }
22.103 -
22.104 -}
23.1 --- a/clazz/src/org/netbeans/modules/clazz/NodeFactoryPool.java Fri Sep 17 18:36:33 2010 -0400
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,198 +0,0 @@
23.4 -/*
23.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
23.6 - *
23.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
23.8 - *
23.9 - * The contents of this file are subject to the terms of either the GNU
23.10 - * General Public License Version 2 only ("GPL") or the Common
23.11 - * Development and Distribution License("CDDL") (collectively, the
23.12 - * "License"). You may not use this file except in compliance with the
23.13 - * License. You can obtain a copy of the License at
23.14 - * http://www.netbeans.org/cddl-gplv2.html
23.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
23.16 - * specific language governing permissions and limitations under the
23.17 - * License. When distributing the software, include this License Header
23.18 - * Notice in each file and include the License file at
23.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
23.20 - * particular file as subject to the "Classpath" exception as provided
23.21 - * by Sun in the GPL Version 2 section of the License file that
23.22 - * accompanied this code. If applicable, add the following below the
23.23 - * License Header, with the fields enclosed by brackets [] replaced by
23.24 - * your own identifying information:
23.25 - * "Portions Copyrighted [year] [name of copyright owner]"
23.26 - *
23.27 - * Contributor(s):
23.28 - *
23.29 - * The Original Software is NetBeans. The Initial Developer of the Original
23.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
23.31 - * Microsystems, Inc. All Rights Reserved.
23.32 - *
23.33 - * If you wish your version of this file to be governed by only the CDDL
23.34 - * or only the GPL Version 2, indicate your decision by adding
23.35 - * "[Contributor] elects to include this software in this distribution
23.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
23.37 - * single choice of license, a recipient has the option to distribute
23.38 - * your version of this file under either the CDDL, the GPL Version 2 or
23.39 - * to extend the choice of license to its licensees as provided above.
23.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
23.41 - * Version 2 license, then the option applies only if the new code is
23.42 - * made subject to such option by the copyright holder.
23.43 - */
23.44 -
23.45 -package org.netbeans.modules.clazz;
23.46 -
23.47 -import java.io.IOException;
23.48 -import java.util.*;
23.49 -
23.50 -import org.openide.util.Task;
23.51 -import org.openide.ErrorManager;
23.52 -import org.openide.cookies.InstanceCookie;
23.53 -import org.openide.ErrorManager;
23.54 -import org.openide.loaders.DataFolder;
23.55 -import org.openide.loaders.FolderInstance;
23.56 -import org.openide.src.nodes.FilterFactory;
23.57 -import org.openide.src.nodes.ElementNodeFactory;
23.58 -import org.openide.util.TaskListener;
23.59 -
23.60 -/**
23.61 - * A pool for registering FilterFactories for the object browser and the
23.62 - * explorer.
23.63 - *
23.64 - * @author Svatopluk Dedic
23.65 - */
23.66 -class NodeFactoryPool extends FolderInstance {
23.67 - static final FilterFactory[] EMPTY = new FilterFactory[0];
23.68 -
23.69 - /**
23.70 - * Base factory, which serves as a default and the tail of the chain.
23.71 - */
23.72 - ElementNodeFactory base;
23.73 -
23.74 - /**
23.75 - * Factories, which were explicitly added by calls to {@link #addFactory}
23.76 - */
23.77 - LinkedList explicit;
23.78 -
23.79 - /**
23.80 - * State of the underlying folder. Contains list of factories registered
23.81 - * through the SFS.
23.82 - */
23.83 - FilterFactory[] factories = EMPTY;
23.84 -
23.85 - /**
23.86 - * Computed head of the factory chain.
23.87 - */
23.88 - ElementNodeFactory head;
23.89 -
23.90 - /**
23.91 - * True, if the folder scan was triggered at least once.
23.92 - */
23.93 - boolean initialized;
23.94 -
23.95 - NodeFactoryPool(DataFolder storage, ElementNodeFactory base) {
23.96 - super(storage);
23.97 - this.base = base;
23.98 - head = base;
23.99 - }
23.100 -
23.101 - final Object sync() {
23.102 - return base;
23.103 - }
23.104 -
23.105 - /**
23.106 - * Returns the head of the current factory list. Except for the initialization,
23.107 - * the method does not block.
23.108 - */
23.109 - ElementNodeFactory getHead() {
23.110 - // force folder scan the first time the Pool is queried
23.111 - if (!initialized) {
23.112 - recreate();
23.113 - waitFinished();
23.114 - initialized = true;
23.115 - }
23.116 - return head;
23.117 - }
23.118 -
23.119 - /**
23.120 - * Creates an array of factories from the underlying folder. The "product" of
23.121 - * the method is the head of the factory list.
23.122 - */
23.123 - protected Object createInstance(InstanceCookie[] cookies)
23.124 - throws java.io.IOException, ClassNotFoundException {
23.125 - Collection l = new ArrayList(cookies.length);
23.126 - for (int i = 0; i < cookies.length; i++) {
23.127 - try {
23.128 - Object o = cookies[i].instanceCreate();
23.129 - if (!(o instanceof FilterFactory))
23.130 - continue;
23.131 - l.add(o);
23.132 - } catch (IOException ex) {
23.133 - logError(ex);
23.134 - } catch (ClassNotFoundException ex) {
23.135 - logError(ex);
23.136 - }
23.137 - }
23.138 - synchronized (sync()) {
23.139 - ElementNodeFactory f = relinkFactories(l);
23.140 - this.factories = (FilterFactory[])l.toArray(new FilterFactory[l.size()]);
23.141 - return head = f;
23.142 - }
23.143 - }
23.144 -
23.145 - /**
23.146 - * Reattaches factories in the logicall factory chain to each other.
23.147 - */
23.148 - private ElementNodeFactory relinkFactories(Collection first) {
23.149 - ElementNodeFactory previous = base;
23.150 - FilterFactory f = null;
23.151 - Iterator it;
23.152 - Collection next = explicit;
23.153 -
23.154 - if (first == null)
23.155 - first = Arrays.asList(factories);
23.156 -
23.157 - for (it = first.iterator(); it.hasNext(); ) {
23.158 - f = (FilterFactory)it.next();
23.159 - f.attachTo(previous);
23.160 - previous = f;
23.161 - }
23.162 - if (next != null) {
23.163 - for (it = next.iterator(); it.hasNext(); ) {
23.164 - f = (FilterFactory)it.next();
23.165 - f.attachTo(previous);
23.166 - previous = f;
23.167 - }
23.168 - }
23.169 - return f != null ? f : base;
23.170 - }
23.171 -
23.172 - /**
23.173 - * Adds an explicit factory and the head of the chain. Relinks the entire
23.174 - * chain as well.
23.175 - */
23.176 - void addFactory(FilterFactory f) {
23.177 - synchronized (sync()) {
23.178 - if (explicit == null) {
23.179 - explicit = new LinkedList();
23.180 - }
23.181 - explicit.add(f);
23.182 - head = relinkFactories(null);
23.183 - }
23.184 - }
23.185 -
23.186 - /**
23.187 - * Removes one factory from the explicit list. Relinks the chain, if the
23.188 - * factory was, actually, on the list.
23.189 - */
23.190 - void removeFactory(FilterFactory f) {
23.191 - synchronized (sync()) {
23.192 - if (!explicit.remove(f))
23.193 - return;
23.194 - relinkFactories(null);
23.195 - }
23.196 - }
23.197 -
23.198 - void logError(Exception ex) {
23.199 - ErrorManager.getDefault().notify(ex);
23.200 - }
23.201 -}
24.1 --- a/clazz/src/org/netbeans/modules/clazz/SerDataNode.java Fri Sep 17 18:36:33 2010 -0400
24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
24.3 @@ -1,114 +0,0 @@
24.4 -/*
24.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
24.6 - *
24.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
24.8 - *
24.9 - * The contents of this file are subject to the terms of either the GNU
24.10 - * General Public License Version 2 only ("GPL") or the Common
24.11 - * Development and Distribution License("CDDL") (collectively, the
24.12 - * "License"). You may not use this file except in compliance with the
24.13 - * License. You can obtain a copy of the License at
24.14 - * http://www.netbeans.org/cddl-gplv2.html
24.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
24.16 - * specific language governing permissions and limitations under the
24.17 - * License. When distributing the software, include this License Header
24.18 - * Notice in each file and include the License file at
24.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
24.20 - * particular file as subject to the "Classpath" exception as provided
24.21 - * by Sun in the GPL Version 2 section of the License file that
24.22 - * accompanied this code. If applicable, add the following below the
24.23 - * License Header, with the fields enclosed by brackets [] replaced by
24.24 - * your own identifying information:
24.25 - * "Portions Copyrighted [year] [name of copyright owner]"
24.26 - *
24.27 - * Contributor(s):
24.28 - *
24.29 - * The Original Software is NetBeans. The Initial Developer of the Original
24.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
24.31 - * Microsystems, Inc. All Rights Reserved.
24.32 - *
24.33 - * If you wish your version of this file to be governed by only the CDDL
24.34 - * or only the GPL Version 2, indicate your decision by adding
24.35 - * "[Contributor] elects to include this software in this distribution
24.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
24.37 - * single choice of license, a recipient has the option to distribute
24.38 - * your version of this file under either the CDDL, the GPL Version 2 or
24.39 - * to extend the choice of license to its licensees as provided above.
24.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
24.41 - * Version 2 license, then the option applies only if the new code is
24.42 - * made subject to such option by the copyright holder.
24.43 - */
24.44 -
24.45 -package org.netbeans.modules.clazz;
24.46 -
24.47 -import java.awt.Image;
24.48 -import java.awt.Toolkit;
24.49 -import java.awt.datatransfer.Transferable;
24.50 -import java.beans.BeanInfo;
24.51 -import java.io.IOException;
24.52 -
24.53 -import org.openide.ErrorManager;
24.54 -import org.openide.src.nodes.SourceChildren;
24.55 -
24.56 -/** Exetends ClassDataNode, adds behaviour specific to serialized objects.
24.57 -* This class is final only for performance reasons,
24.58 -* can be happily unfinaled if desired.
24.59 -*
24.60 -* @author Jaroslav Tulach, Dafe Simonek
24.61 -*/
24.62 -final class SerDataNode extends ClassDataNode {
24.63 - /** generated Serialized Version UID */
24.64 - static final long serialVersionUID = -2645179282674800246L;
24.65 -
24.66 - private static final String SER_BASE =
24.67 - "org/netbeans/modules/clazz/resources/ser"; // NOI18N
24.68 - private static final String SER_MAIN_BASE =
24.69 - "org/netbeans/modules/clazz/resources/serMain"; // NOI18N
24.70 - private static final String SER_ERROR_BASE =
24.71 - "org/netbeans/modules/clazz/resources/serError"; // NOI18N
24.72 -
24.73 - /** Constructs bean data node with asociated data object.
24.74 - */
24.75 - public SerDataNode(final SerDataObject obj) {
24.76 - super(obj, new SerTopChildren(obj, new SourceChildren(ClassDataObject.getExplorerFactory())));
24.77 - }
24.78 -
24.79 - protected SourceChildren getSourceChildren() {
24.80 - return ((SerTopChildren)getChildren()).getSourceChildren();
24.81 - }
24.82 -
24.83 - // ----------------------------------------------------------------------------------
24.84 - // methods
24.85 -
24.86 - /** Returns initial icon base string for ser node.
24.87 - */
24.88 - protected String initialIconBase () {
24.89 - return SER_BASE;
24.90 - }
24.91 -
24.92 - protected void resolveIcons () {
24.93 - }
24.94 -
24.95 - protected void requestResolveIcon() {
24.96 - try {
24.97 - ClassDataObject dataObj = (ClassDataObject)getDataObject();
24.98 - dataObj.getBeanClass(); // check exception
24.99 - setIconBase(SER_BASE);
24.100 - } catch (IOException ex) {
24.101 - // log exception only and set error tooltip
24.102 - ErrorManager.getDefault().notify(
24.103 - ErrorManager.INFORMATIONAL, ex
24.104 - );
24.105 - setIconBase(SER_ERROR_BASE);
24.106 - setErrorToolTip(ex);
24.107 - } catch (ClassNotFoundException ex) {
24.108 - // log exception only and set error tooltip
24.109 - ErrorManager.getDefault().notify(
24.110 - ErrorManager.INFORMATIONAL, ex
24.111 - );
24.112 - setIconBase(SER_ERROR_BASE);
24.113 - setErrorToolTip(ex);
24.114 - }
24.115 - iconResolved = true;
24.116 - }
24.117 -}
25.1 --- a/clazz/src/org/netbeans/modules/clazz/SerDataObject.java Fri Sep 17 18:36:33 2010 -0400
25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
25.3 @@ -1,139 +0,0 @@
25.4 -/*
25.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
25.6 - *
25.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
25.8 - *
25.9 - * The contents of this file are subject to the terms of either the GNU
25.10 - * General Public License Version 2 only ("GPL") or the Common
25.11 - * Development and Distribution License("CDDL") (collectively, the
25.12 - * "License"). You may not use this file except in compliance with the
25.13 - * License. You can obtain a copy of the License at
25.14 - * http://www.netbeans.org/cddl-gplv2.html
25.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
25.16 - * specific language governing permissions and limitations under the
25.17 - * License. When distributing the software, include this License Header
25.18 - * Notice in each file and include the License file at
25.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
25.20 - * particular file as subject to the "Classpath" exception as provided
25.21 - * by Sun in the GPL Version 2 section of the License file that
25.22 - * accompanied this code. If applicable, add the following below the
25.23 - * License Header, with the fields enclosed by brackets [] replaced by
25.24 - * your own identifying information:
25.25 - * "Portions Copyrighted [year] [name of copyright owner]"
25.26 - *
25.27 - * Contributor(s):
25.28 - *
25.29 - * The Original Software is NetBeans. The Initial Developer of the Original
25.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
25.31 - * Microsystems, Inc. All Rights Reserved.
25.32 - *
25.33 - * If you wish your version of this file to be governed by only the CDDL
25.34 - * or only the GPL Version 2, indicate your decision by adding
25.35 - * "[Contributor] elects to include this software in this distribution
25.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
25.37 - * single choice of license, a recipient has the option to distribute
25.38 - * your version of this file under either the CDDL, the GPL Version 2 or
25.39 - * to extend the choice of license to its licensees as provided above.
25.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
25.41 - * Version 2 license, then the option applies only if the new code is
25.42 - * made subject to such option by the copyright holder.
25.43 - */
25.44 -
25.45 -package org.netbeans.modules.clazz;
25.46 -
25.47 -import org.openide.util.HelpCtx;
25.48 -import org.netbeans.modules.classfile.ClassFile;
25.49 -import org.openide.loaders.InstanceSupport;
25.50 -import org.openide.loaders.DataObjectExistsException;
25.51 -import org.openide.nodes.Node;
25.52 -import org.openide.nodes.CookieSet;
25.53 -import java.io.InputStream;
25.54 -import org.openide.filesystems.FileObject;
25.55 -import org.openide.ErrorManager;
25.56 -import org.openide.cookies.InstanceCookie;
25.57 -import java.io.IOException;
25.58 -import org.openide.util.NbBundle;
25.59 -
25.60 -
25.61 -/** DataObject which represents JavaBeans (".ser" files).
25.62 -* This class is final only for performance reasons,
25.63 -* can be happily unfinaled if desired.
25.64 -*
25.65 -* @author Jan Jancura, Ian Formanek, Dafe Simonek
25.66 -*/
25.67 -public final class SerDataObject extends ClassDataObject {
25.68 - /** generated Serialized Version UID */
25.69 - static final long serialVersionUID = 8229229209013849842L;
25.70 -
25.71 - /** Constructs a new BeanDataObject */
25.72 - public SerDataObject(FileObject fo, ClassDataLoader loader) throws DataObjectExistsException {
25.73 - super (fo, loader);
25.74 - initCookies();
25.75 - }
25.76 -
25.77 - /** Performs cookie initialization. */
25.78 - protected void initCookies () {
25.79 - super.initCookies();
25.80 -
25.81 - CookieSet cs = getCookieSet();
25.82 - cs.add(InstanceCookie.class, this);
25.83 - }
25.84 -
25.85 - /**
25.86 - * All serialized objects are treated as JavaBeans since the instance of
25.87 - * the object can be obtained (using deserialization).
25.88 - * @returns true
25.89 - */
25.90 - public boolean isJavaBean() {
25.91 - return true;
25.92 - }
25.93 -
25.94 - /**
25.95 - * Creates NodeDelegate for this DataObject
25.96 - * @returns node that represent the obejct
25.97 - */
25.98 - protected Node createNodeDelegate () {
25.99 - return new SerDataNode (this);
25.100 - }
25.101 -
25.102 -
25.103 - protected ClassFile loadClassFile() throws IOException,ClassNotFoundException {
25.104 - Class clazz = createInstanceSupport().instanceClass();
25.105 - String resourceName='/'+clazz.getName().replace('.','/')+".class"; // NOI18N
25.106 - InputStream stream=clazz.getResourceAsStream(resourceName);
25.107 -
25.108 - if (stream==null)
25.109 - return null;
25.110 - try {
25.111 - return new ClassFile(stream,false);
25.112 - } finally {
25.113 - stream.close();
25.114 - }
25.115 - }
25.116 -
25.117 - /**
25.118 - * Provides special processing for the serialized objects:
25.119 - * if the help can be found for the class that is serialized inside
25.120 - * the ser file, returns that help. The default is the help for SerDataObject.
25.121 - * @returns appropriate HelpCtx
25.122 - */
25.123 - public HelpCtx getHelpCtx () {
25.124 - HelpCtx test = InstanceSupport.findHelp (createInstanceSupport());
25.125 - if (test != null)
25.126 - return test;
25.127 - else
25.128 - return super.getHelpCtx();
25.129 - }
25.130 -
25.131 - protected FileObject handleRename (String name) throws IOException {
25.132 - if (name.indexOf(".")!=-1) { // NOI18N
25.133 - throw (IOException)ErrorManager.getDefault().annotate(
25.134 - new IOException("Dot in name"), // NOI18N
25.135 - ErrorManager.USER,
25.136 - null, NbBundle.getMessage(SerDataObject.class, "MSG_INVName"),
25.137 - null, null
25.138 - );
25.139 - }
25.140 - return super.handleRename(name);
25.141 - }
25.142 -}
26.1 --- a/clazz/src/org/netbeans/modules/clazz/SerParser.java Fri Sep 17 18:36:33 2010 -0400
26.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
26.3 @@ -1,605 +0,0 @@
26.4 -/*
26.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
26.6 - *
26.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
26.8 - *
26.9 - * The contents of this file are subject to the terms of either the GNU
26.10 - * General Public License Version 2 only ("GPL") or the Common
26.11 - * Development and Distribution License("CDDL") (collectively, the
26.12 - * "License"). You may not use this file except in compliance with the
26.13 - * License. You can obtain a copy of the License at
26.14 - * http://www.netbeans.org/cddl-gplv2.html
26.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
26.16 - * specific language governing permissions and limitations under the
26.17 - * License. When distributing the software, include this License Header
26.18 - * Notice in each file and include the License file at
26.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
26.20 - * particular file as subject to the "Classpath" exception as provided
26.21 - * by Sun in the GPL Version 2 section of the License file that
26.22 - * accompanied this code. If applicable, add the following below the
26.23 - * License Header, with the fields enclosed by brackets [] replaced by
26.24 - * your own identifying information:
26.25 - * "Portions Copyrighted [year] [name of copyright owner]"
26.26 - *
26.27 - * Contributor(s):
26.28 - *
26.29 - * The Original Software is NetBeans. The Initial Developer of the Original
26.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
26.31 - * Microsystems, Inc. All Rights Reserved.
26.32 - *
26.33 - * If you wish your version of this file to be governed by only the CDDL
26.34 - * or only the GPL Version 2, indicate your decision by adding
26.35 - * "[Contributor] elects to include this software in this distribution
26.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
26.37 - * single choice of license, a recipient has the option to distribute
26.38 - * your version of this file under either the CDDL, the GPL Version 2 or
26.39 - * to extend the choice of license to its licensees as provided above.
26.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
26.41 - * Version 2 license, then the option applies only if the new code is
26.42 - * made subject to such option by the copyright holder.
26.43 - */
26.44 -
26.45 -package org.netbeans.modules.clazz;
26.46 -
26.47 -import java.io.*;
26.48 -import java.util.*;
26.49 -import org.openide.util.NotImplementedException;
26.50 -
26.51 -/* The following may be useful to Emacs users:
26.52 -
26.53 -(defun comma-sep-decimal-encode ()
26.54 - (interactive)
26.55 - (while
26.56 - (let ((p (point)))
26.57 - (and (re-search-forward "\\(-?[0-9][0-9]?[0-9]?\\),?" nil t)
26.58 - (= p (match-beginning 0))))
26.59 - (replace-match (char-to-string
26.60 - (let ((x (string-to-int (match-string 1))))
26.61 - (when (< x 0) (setq x (+ x 256)))
26.62 - x))
26.63 - t t)))
26.64 -
26.65 -After evaluating this, go into an old cpanel.xml or similar
26.66 -(M-x find-file-literally, by the way) and type
26.67 -M-x comma-sep-decimal-encode right after the opening quote
26.68 -of the value. The contents will be converted to raw binary and
26.69 -may be saved as a .ser file parsable by this class.
26.70 -
26.71 -(defun hex-encode ()
26.72 - (interactive)
26.73 - (while
26.74 - (let ((p (point)))
26.75 - (and (re-search-forward "\\s-*\\([a-fA-F0-9][a-fA-F0-9]\\)" nil t)
26.76 - (= p (match-beginning 0))))
26.77 - (replace-match (char-to-string
26.78 - (string-to-int (match-string 1) 16))
26.79 - t t)))
26.80 -
26.81 -Same for hexadecimal serialized data. For .settings files, it is
26.82 -easier to select Customize Bean... in the IDE and save as *.ser.
26.83 -*/
26.84 -
26.85 -/** Parser for Java serialization files.
26.86 - * Does no classloading or per-class semantics, simply parses the
26.87 - * raw serialization structure.
26.88 - * @author Jesse Glick
26.89 - */
26.90 -public final class SerParser implements ObjectStreamConstants {
26.91 -
26.92 - private static final boolean DEBUG = Boolean.getBoolean("org.netbeans.modules.clazz.SerParser.DEBUG"); // NOI18N
26.93 -
26.94 - private final InputStream is;
26.95 - private int seq = 0;
26.96 - private final List refs = new ArrayList(100); // List<Object>
26.97 -
26.98 - public SerParser(InputStream is) {
26.99 - this.is = is;
26.100 - }
26.101 -
26.102 - private int makeRef(Object o) {
26.103 - refs.add(o);
26.104 - int i = seq;
26.105 - seq++;
26.106 - if (DEBUG) System.err.println("makeRef[" + i + "]=" + o); // NOI18N
26.107 - return i;
26.108 - }
26.109 -
26.110 - private Object getRef(int i) throws CorruptException {
26.111 - int idx = i - baseWireHandle;
26.112 - if (idx < 0 || idx >= seq) throw new CorruptException("Invalid reference: " + i); // NOI18N
26.113 - Object o = refs.get(idx);
26.114 - if (o == null) throw new CorruptException("Invalid reference: " + i); // NOI18N
26.115 - return o;
26.116 - }
26.117 -
26.118 - public Stream parse() throws IOException, CorruptException {
26.119 - Stream s = new Stream();
26.120 - s.magic = readShort();
26.121 - s.version = readShort();
26.122 - if (s.magic != STREAM_MAGIC || s.version != STREAM_VERSION) {
26.123 - throw new CorruptException("stream version mismatch: " + hexify(s.magic) + " != " + hexify(STREAM_MAGIC) + " or " + hexify(s.version) + " != " + hexify(STREAM_VERSION)); // NOI18N
26.124 - }
26.125 - s.contents = new ArrayList(10);
26.126 - while (peek() != -1) {
26.127 - s.contents.add(readContent());
26.128 - }
26.129 - if (DEBUG) System.err.println("parsed: " + s); // NOI18N
26.130 - return s;
26.131 - }
26.132 -
26.133 - public static final class CorruptException extends IOException {
26.134 - public CorruptException() {
26.135 - }
26.136 - public CorruptException(String m) {
26.137 - super(m);
26.138 - }
26.139 - }
26.140 -
26.141 - private int pushback = -1;
26.142 - private int rb() throws IOException {
26.143 - if (pushback != -1) {
26.144 - int c = pushback;
26.145 - pushback = -1;
26.146 - return c;
26.147 - }
26.148 - int c = is.read();
26.149 - if (DEBUG) System.err.println("read: " + Integer.toHexString(c)); // NOI18N
26.150 - if (c == -1) {
26.151 - throw new EOFException();
26.152 - } else {
26.153 - return c;
26.154 - }
26.155 - }
26.156 - private int peek() throws IOException {
26.157 - if (pushback != -1) throw new IllegalStateException("can only peek once"); // NOI18N
26.158 - pushback = is.read();
26.159 - if (DEBUG) System.err.println("read: " + Integer.toHexString(pushback)); // NOI18N
26.160 - return pushback;
26.161 - }
26.162 -
26.163 - static String hexify(byte b) {
26.164 - int i = b;
26.165 - if (i < 0) i += 256;
26.166 - String s = Integer.toHexString(i).toUpperCase(Locale.US);
26.167 - return "0x" + pad(s, 2); // NOI18N
26.168 - }
26.169 - static String hexify(short s) {
26.170 - int i = s;
26.171 - if (i < 0) i += 65536;
26.172 - String st = Integer.toHexString(i).toUpperCase(Locale.US);
26.173 - return "0x" + pad(st, 4); // NOI18N
26.174 - }
26.175 - static String hexify(int i) {
26.176 - String s = Integer.toHexString(i).toUpperCase(Locale.US);
26.177 - return "0x" + pad(s, 4); // NOI18N
26.178 - }
26.179 - static String hexify(long l) {
26.180 - String s1 = Integer.toHexString((int)((l & 0xFFFFFFFF00000000L) << 32)).toUpperCase(Locale.US);
26.181 - String s2 = Integer.toHexString((int)(l & 0x00000000FFFFFFFFL)).toUpperCase(Locale.US);
26.182 - return "0x" + pad(s1, 4) + pad(s2, 4); // NOI18N
26.183 - }
26.184 - static String hexify(byte[] b) {
26.185 - StringBuffer buf = new StringBuffer(2 + b.length * 2);
26.186 - buf.append("0x"); // NOI18N
26.187 - for (int i = 0; i < b.length; i++) {
26.188 - int x = b[i];
26.189 - if (x < 0) x += 256;
26.190 - buf.append(pad(Integer.toHexString(x).toUpperCase(Locale.US), 2));
26.191 - }
26.192 - return buf.toString();
26.193 - }
26.194 - private static String pad(String s, int size) {
26.195 - int i = s.length();
26.196 - if (i == size) {
26.197 - return s;
26.198 - } else {
26.199 - StringBuffer b = new StringBuffer(size);
26.200 - for (int k = 0; k < size - i; k++) {
26.201 - b.append('0'); // NOI18N
26.202 - }
26.203 - b.append(s);
26.204 - return b.toString();
26.205 - }
26.206 - }
26.207 -
26.208 - private long readLong() throws IOException {
26.209 - long x1 = rb();
26.210 - long x2 = rb();
26.211 - long x3 = rb();
26.212 - long x4 = rb();
26.213 - long x5 = rb();
26.214 - long x6 = rb();
26.215 - long x7 = rb();
26.216 - long x8 = rb();
26.217 - long l = (x1 << 56) + (x2 << 48) + (x3 << 40) + (x4 << 32) + (x5 << 24) + (x6 << 16) + (x7 << 8) + x8;
26.218 - if (DEBUG) System.err.println("readLong: " + l); // NOI18N
26.219 - return l;
26.220 - }
26.221 -
26.222 - private int readInt() throws IOException {
26.223 - int x1 = rb();
26.224 - int x2 = rb();
26.225 - int x3 = rb();
26.226 - int x4 = rb();
26.227 - int i = (x1 << 24) + (x2 << 16) + (x3 << 8) + x4;
26.228 - if (DEBUG) System.err.println("readInt: " + i); // NOI18N
26.229 - return i;
26.230 - }
26.231 -
26.232 - private short readShort() throws IOException {
26.233 - int x1 = rb();
26.234 - int x2 = rb();
26.235 - short s = (short)((x1 << 8) + x2);
26.236 - //System.err.println("x1=" + hexify(x1) + " x2=" + hexify(x2) + " s=" + hexify(s));
26.237 - //if (DEBUG) System.err.println("x1=" + x1 + " x2=" + x2 + " s=" + s);
26.238 - if (DEBUG) System.err.println("readShort: " + s); // NOI18N
26.239 - return s;
26.240 - }
26.241 -
26.242 - private byte readByte() throws IOException {
26.243 - return (byte)rb();
26.244 - }
26.245 -
26.246 - private String readUTF() throws IOException {
26.247 - short len = readShort();
26.248 - if (len < 0) throw new NotImplementedException();//XXX
26.249 - byte[] buf = new byte[len];
26.250 - for (int i = 0; i < len; i++) {
26.251 - buf[i] = readByte();
26.252 - }
26.253 - String s = new String(buf, "UTF-8"); // NOI18N
26.254 - if (DEBUG) System.err.println("readUTF: " + s); // NOI18N
26.255 - return s;
26.256 - }
26.257 -
26.258 - private String readLongUTF() throws IOException {
26.259 - long len = readLong();
26.260 - if (len < 0) throw new NotImplementedException();//XXX
26.261 - if (len > Integer.MAX_VALUE) throw new NotImplementedException();// XXX
26.262 - int ilen = (int)len;
26.263 - byte[] buf = new byte[ilen];
26.264 - for (int i = 0; i < ilen; i++) {
26.265 - buf[i] = readByte();
26.266 - }
26.267 - String s = new String(buf, "UTF-8"); // NOI18N
26.268 - if (DEBUG) System.err.println("readUTF: " + s); // NOI18N
26.269 - return s;
26.270 - }
26.271 -
26.272 - // See "Rules of the Grammar" in Java Object Serialization Specification
26.273 - // for explanation of all these objects.
26.274 -
26.275 - public static final class Stream /*extends Thing*/ {
26.276 - public short magic;
26.277 - public short version;
26.278 - public List contents; // List<Object>
26.279 - public String toString() {
26.280 - return "Stream[contents=" + contents + "]"; // NOI18N
26.281 - }
26.282 - }
26.283 -
26.284 - public static final Object NULL = "null"; // NOI18N
26.285 -
26.286 - private Object readContent() throws IOException {
26.287 - byte tc = readByte();
26.288 - switch (tc) {
26.289 - case TC_OBJECT:
26.290 - return readNewObject();
26.291 - case TC_CLASS:
26.292 - return readNewClass();
26.293 - case TC_ARRAY:
26.294 - return readNewArray();
26.295 - case TC_CLASSDESC:
26.296 - return readNewClassDesc();
26.297 - case TC_PROXYCLASSDESC:
26.298 - // XXX too complicated:
26.299 - throw new NotImplementedException("TC_PROXYCLASSDESC"); // NOI18N
26.300 - //return readNewProxyClassDesc();
26.301 - case TC_STRING:
26.302 - return readNewString();
26.303 - case TC_LONGSTRING:
26.304 - // XXX later
26.305 - throw new NotImplementedException("TC_LONGSTRING"); // NOI18N
26.306 - //return readNewLongString();
26.307 - case TC_REFERENCE:
26.308 - return readReference();
26.309 - case TC_NULL:
26.310 - return NULL;
26.311 - case TC_EXCEPTION:
26.312 - // XXX what is this??
26.313 - throw new NotImplementedException("TC_EXCEPTION"); // NOI18N
26.314 - case TC_RESET:
26.315 - // XXX what is this??
26.316 - throw new NotImplementedException("TC_RESET"); // NOI18N
26.317 - case TC_BLOCKDATA:
26.318 - return readBlockData();
26.319 - case TC_BLOCKDATALONG:
26.320 - return readBlockDataLong();
26.321 - default:
26.322 - throw new CorruptException("Unknown typecode: " + hexify(tc)); // NOI18N
26.323 - }
26.324 - }
26.325 -
26.326 - public static final class ObjectWrapper {
26.327 - public ClassDesc classdesc;
26.328 - public List data; // List<NameValue|Object>
26.329 - public String toString() {
26.330 - return "Object[class=" + classdesc.name + ",data=" + data + "]"; // NOI18N
26.331 - }
26.332 - }
26.333 -
26.334 - public static final class NameValue {
26.335 - public NameValue(FieldDesc name, Object value) {
26.336 - this.name = name;
26.337 - this.value = value;
26.338 - }
26.339 - public final FieldDesc name;
26.340 - public final Object value;
26.341 - public String toString() {
26.342 - return name.toString() + "=" + value.toString(); // NOI18N
26.343 - }
26.344 - }
26.345 -
26.346 - public static final class ClassDesc {
26.347 - public String name;
26.348 - public long svuid;
26.349 - public boolean writeMethod;
26.350 - public boolean blockData;
26.351 - public boolean serializable;
26.352 - public boolean externalizable;
26.353 - public List fields; // List<FieldDesc>
26.354 - public List annotation; // List<Object>
26.355 - public ClassDesc superclass;
26.356 - public String toString() {
26.357 - return "Class[name=" + name + "]"; // NOI18N
26.358 - }
26.359 - }
26.360 -
26.361 - private ObjectWrapper readNewObject() throws IOException {
26.362 - ObjectWrapper ow = new ObjectWrapper();
26.363 - ow.classdesc = readClassDesc();
26.364 - makeRef(ow);
26.365 - ow.data = new ArrayList (10);
26.366 - LinkedList hier = new LinkedList();
26.367 - for (ClassDesc cd = ow.classdesc; cd != null; cd = cd.superclass) {
26.368 - hier.addFirst(cd);
26.369 - }
26.370 - Iterator it = hier.iterator();
26.371 - while (it.hasNext()) {
26.372 - ClassDesc cd = (ClassDesc)it.next();
26.373 - if (cd.serializable) {
26.374 - ow.data.addAll(readNoWrClass(cd));
26.375 - if (cd.writeMethod) {
26.376 - ow.data.addAll(readContents());
26.377 - }
26.378 - } else {
26.379 - if (cd.blockData) {
26.380 - ow.data.addAll(readContents());
26.381 - } else {
26.382 - // Old externalization. If this is not object content,
26.383 - // the stream could now become corrupted. Oh well.
26.384 - ow.data.add(readContent());
26.385 - }
26.386 - }
26.387 - }
26.388 - if (DEBUG) System.err.println("readNewObject: " + ow); // NOI18N
26.389 - return ow;
26.390 - }
26.391 -
26.392 - private ClassDesc readClassDesc() throws IOException {
26.393 - Object o = readContent();
26.394 - if (o instanceof ClassDesc) {
26.395 - return (ClassDesc)o;
26.396 - } else if (o == NULL) {
26.397 - return null;
26.398 - } else {
26.399 - throw new CorruptException("Expected class desc, got: " + o); // NOI18N
26.400 - }
26.401 - }
26.402 -
26.403 - private ClassDesc readNewClass() throws IOException {
26.404 - ClassDesc cd = readClassDesc();
26.405 - makeRef(cd);
26.406 - return cd;
26.407 - }
26.408 -
26.409 - private ClassDesc readNewClassDesc() throws IOException {
26.410 - ClassDesc cd = new ClassDesc();
26.411 - cd.name = readUTF();
26.412 - if (! cd.name.startsWith("[") && // NOI18N
26.413 - ! (cd.name.length() == 1 && "BSIJFDCZ".indexOf(cd.name) != -1) && // NOI18N
26.414 - ! cd.name.endsWith(";")) { // NOI18N
26.415 - // Canonicalize. It seems class names read normally need this; those
26.416 - // read as part of an array do not. ??
26.417 - cd.name = "L" + cd.name + ";"; // NOI18N
26.418 - }
26.419 - cd.svuid = readLong();
26.420 - makeRef(cd);
26.421 - byte cdf = readByte();
26.422 - cd.writeMethod = (cdf & SC_WRITE_METHOD) != 0;
26.423 - cd.blockData = (cdf & SC_BLOCK_DATA) != 0;
26.424 - cd.serializable = (cdf & SC_SERIALIZABLE) != 0;
26.425 - cd.externalizable = (cdf & SC_EXTERNALIZABLE) != 0;
26.426 - short count = readShort();
26.427 - cd.fields = new ArrayList(count);
26.428 - for (int i = 0; i < count; i++) {
26.429 - cd.fields.add(readFieldDesc());
26.430 - }
26.431 - cd.annotation = readContents();
26.432 - cd.superclass = readClassDesc();
26.433 - if (DEBUG) System.err.println("readNewClassDesc: " + cd); // NOI18N
26.434 - return cd;
26.435 - }
26.436 -
26.437 - public static class FieldDesc {
26.438 - public String name;
26.439 - public String type;
26.440 - public String toString() {
26.441 - return "Field[name=" + name + ",type=" + type + "]"; // NOI18N
26.442 - }
26.443 - }
26.444 - public static final class ObjFieldDesc extends FieldDesc {
26.445 - public boolean array;
26.446 - public String toString() {
26.447 - return "Field[name=" + name + ",type=" + type + (array ? "[]" : "") + "]"; // NOI18N
26.448 - }
26.449 - }
26.450 -
26.451 - private FieldDesc readFieldDesc() throws IOException {
26.452 - char tc = (char)readByte();
26.453 - FieldDesc fd;
26.454 - switch (tc) {
26.455 - case 'B':
26.456 - case 'C':
26.457 - case 'D':
26.458 - case 'F':
26.459 - case 'I':
26.460 - case 'J':
26.461 - case 'S':
26.462 - case 'Z':
26.463 - fd = new FieldDesc();
26.464 - fd.type = new String(new char[] {tc});
26.465 - break;
26.466 - case '[':
26.467 - fd = new ObjFieldDesc();
26.468 - ((ObjFieldDesc)fd).array = true;
26.469 - break;
26.470 - case 'L':
26.471 - fd = new ObjFieldDesc();
26.472 - ((ObjFieldDesc)fd).array = false;
26.473 - break;
26.474 - default:
26.475 - throw new CorruptException("Strange field type: " + tc); // NOI18N
26.476 - }
26.477 - fd.name = readUTF();
26.478 - if (fd instanceof ObjFieldDesc) {
26.479 - String clazz = (String)readContent();
26.480 - /*
26.481 - if (((ObjFieldDesc)fd).array) {
26.482 - if (! clazz.startsWith("[")) throw new CorruptException("Field type: " + clazz); // NOI18N
26.483 - clazz = clazz.substring(1, clazz.length());
26.484 - }
26.485 - if (! (clazz.startsWith("L") && clazz.endsWith(";"))) throw new CorruptException("Field type: " + clazz); // NOI18N
26.486 - fd.type = clazz.substring(1, clazz.length() - 1).replace('/', '.'); // NOI18N
26.487 - */
26.488 - fd.type = clazz;
26.489 - }
26.490 - if (DEBUG) System.err.println("readFieldDesc: " + fd); // NOI18N
26.491 - return fd;
26.492 - }
26.493 -
26.494 - private List readContents() throws IOException {
26.495 - List l = new ArrayList(10);
26.496 - while (peek() != TC_ENDBLOCKDATA) {
26.497 - l.add(readContent());
26.498 - }
26.499 - if (readByte() != TC_ENDBLOCKDATA) throw new IllegalStateException();
26.500 - if (DEBUG) System.err.println("readContents: " + l); // NOI18N
26.501 - return l;
26.502 - }
26.503 -
26.504 - public static final class ArrayWrapper {
26.505 - public ClassDesc classdesc;
26.506 - public List values;
26.507 - public String toString() {
26.508 - return classdesc.name + "{" + values + "}"; // NOI18N
26.509 - }
26.510 - }
26.511 -
26.512 - private ArrayWrapper readNewArray() throws IOException {
26.513 - ArrayWrapper aw = new ArrayWrapper();
26.514 - aw.classdesc = readClassDesc();
26.515 - makeRef(aw);
26.516 - int size = readInt();
26.517 - if (size < 0) throw new NotImplementedException();
26.518 - aw.values = new ArrayList(size);
26.519 - for (int i = 0; i < size; i++) {
26.520 - if (aw.classdesc.name.equals("[B")) { // NOI18N
26.521 - aw.values.add(new Byte(readByte()));
26.522 - } else if (aw.classdesc.name.equals("[S")) { // NOI18N
26.523 - aw.values.add(new Short(readShort()));
26.524 - } else if (aw.classdesc.name.equals("[I")) { // NOI18N
26.525 - aw.values.add(new Integer(readInt()));
26.526 - } else if (aw.classdesc.name.equals("[J")) { // NOI18N
26.527 - aw.values.add(new Long(readLong()));
26.528 - } else if (aw.classdesc.name.equals("[F")) { // NOI18N
26.529 - aw.values.add(new Float(Float.intBitsToFloat(readInt())));
26.530 - } else if (aw.classdesc.name.equals("[D")) { // NOI18N
26.531 - aw.values.add(new Double(Double.longBitsToDouble(readLong())));
26.532 - } else if (aw.classdesc.name.equals("[C")) { // NOI18N
26.533 - aw.values.add(new Character((char)readShort()));
26.534 - } else if (aw.classdesc.name.equals("[Z")) { // NOI18N
26.535 - aw.values.add(readByte() == 1 ? Boolean.TRUE : Boolean.FALSE);
26.536 - } else {
26.537 - aw.values.add(readContent());
26.538 - }
26.539 - }
26.540 - if (DEBUG) System.err.println("readNewArray: " + aw); // NOI18N
26.541 - return aw;
26.542 - }
26.543 -
26.544 - private String readNewString() throws IOException {
26.545 - String s = readUTF();
26.546 - makeRef(s);
26.547 - return s;
26.548 - }
26.549 -
26.550 - private Object readReference() throws IOException {
26.551 - int i = readInt();
26.552 - Object r = getRef(i);
26.553 - if (DEBUG) System.err.println("readReference: " + r); // NOI18N
26.554 - return r;
26.555 - }
26.556 -
26.557 - private byte[] readBlockData() throws IOException {
26.558 - int size = readByte();
26.559 - if (size < 0) size += 256;
26.560 - byte[] b = new byte[size];
26.561 - for (int i = 0; i < size; i++) {
26.562 - b[i] = readByte();
26.563 - }
26.564 - if (DEBUG) System.err.println("readBlockData: " + size + " bytes"); // NOI18N
26.565 - return b;
26.566 - }
26.567 -
26.568 - private byte[] readBlockDataLong() throws IOException {
26.569 - int size = readInt();
26.570 - if (size < 0) throw new NotImplementedException();
26.571 - byte[] b = new byte[size];
26.572 - for (int i = 0; i < size; i++) {
26.573 - b[i] = readByte();
26.574 - }
26.575 - if (DEBUG) System.err.println("readBlockDataLong: " + size + " bytes"); // NOI18N
26.576 - return b;
26.577 - }
26.578 -
26.579 - private List/*<NameValue>*/ readNoWrClass(ClassDesc cd) throws IOException {
26.580 - List fields = cd.fields;
26.581 - List values = new ArrayList(fields.size());
26.582 - for (int i = 0; i < fields.size(); i++) {
26.583 - FieldDesc fd = (FieldDesc)fields.get(i);
26.584 - if (fd.type.equals("B")) { // NOI18N
26.585 - values.add(new NameValue(fd, new Byte(readByte())));
26.586 - } else if (fd.type.equals("S")) { // NOI18N
26.587 - values.add(new NameValue(fd, new Short(readShort())));
26.588 - } else if (fd.type.equals("I")) { // NOI18N
26.589 - values.add(new NameValue(fd, new Integer(readInt())));
26.590 - } else if (fd.type.equals("J")) { // NOI18N
26.591 - values.add(new NameValue(fd, new Long(readLong())));
26.592 - } else if (fd.type.equals("F")) { // NOI18N
26.593 - values.add(new NameValue(fd, new Float(Float.intBitsToFloat(readInt()))));
26.594 - } else if (fd.type.equals("D")) { // NOI18N
26.595 - values.add(new NameValue(fd, new Double(Double.longBitsToDouble(readLong()))));
26.596 - } else if (fd.type.equals("C")) { // NOI18N
26.597 - values.add(new NameValue(fd, new Character((char)readShort())));
26.598 - } else if (fd.type.equals("Z")) { // NOI18N
26.599 - values.add(new NameValue(fd, readByte() == 1 ? Boolean.TRUE : Boolean.FALSE));
26.600 - } else {
26.601 - values.add(new NameValue(fd, readContent()));
26.602 - }
26.603 - }
26.604 - if (DEBUG) System.err.println("readNoWrClass: " + values); // NOI18N
26.605 - return values;
26.606 - }
26.607 -
26.608 -}
27.1 --- a/clazz/src/org/netbeans/modules/clazz/SerStructureNode.java Fri Sep 17 18:36:33 2010 -0400
27.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
27.3 @@ -1,228 +0,0 @@
27.4 -/*
27.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
27.6 - *
27.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
27.8 - *
27.9 - * The contents of this file are subject to the terms of either the GNU
27.10 - * General Public License Version 2 only ("GPL") or the Common
27.11 - * Development and Distribution License("CDDL") (collectively, the
27.12 - * "License"). You may not use this file except in compliance with the
27.13 - * License. You can obtain a copy of the License at
27.14 - * http://www.netbeans.org/cddl-gplv2.html
27.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
27.16 - * specific language governing permissions and limitations under the
27.17 - * License. When distributing the software, include this License Header
27.18 - * Notice in each file and include the License file at
27.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
27.20 - * particular file as subject to the "Classpath" exception as provided
27.21 - * by Sun in the GPL Version 2 section of the License file that
27.22 - * accompanied this code. If applicable, add the following below the
27.23 - * License Header, with the fields enclosed by brackets [] replaced by
27.24 - * your own identifying information:
27.25 - * "Portions Copyrighted [year] [name of copyright owner]"
27.26 - *
27.27 - * Contributor(s):
27.28 - *
27.29 - * The Original Software is NetBeans. The Initial Developer of the Original
27.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
27.31 - * Microsystems, Inc. All Rights Reserved.
27.32 - *
27.33 - * If you wish your version of this file to be governed by only the CDDL
27.34 - * or only the GPL Version 2, indicate your decision by adding
27.35 - * "[Contributor] elects to include this software in this distribution
27.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
27.37 - * single choice of license, a recipient has the option to distribute
27.38 - * your version of this file under either the CDDL, the GPL Version 2 or
27.39 - * to extend the choice of license to its licensees as provided above.
27.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
27.41 - * Version 2 license, then the option applies only if the new code is
27.42 - * made subject to such option by the copyright holder.
27.43 - */
27.44 -
27.45 -package org.netbeans.modules.clazz;
27.46 -
27.47 -import java.io.*;
27.48 -import java.util.*;
27.49 -
27.50 -import org.openide.*;
27.51 -import org.openide.nodes.*;
27.52 -import org.openide.util.NbBundle;
27.53 -
27.54 -/** Nodes representing pieces of a serialized file structurally.
27.55 - * @author Jesse Glick
27.56 - */
27.57 -public abstract class SerStructureNode {
27.58 -
27.59 - private SerStructureNode() {/* do not instantiate me */}
27.60 -
27.61 - public static final class StreamNode extends AbstractNode {
27.62 - public StreamNode(SerParser.Stream s) {
27.63 - super(new GeneralChildren(s.contents));
27.64 - setName(NbBundle.getMessage(SerStructureNode.class, "LBL_ser_stream"));
27.65 - setIconBase("org/netbeans/modules/clazz/resources/serAlone"); // NOI18N
27.66 - }
27.67 - }
27.68 -
27.69 - private static class GeneralChildren extends Children.Keys {
27.70 - private final List things;
27.71 - public GeneralChildren(List things) {
27.72 - this.things = things;
27.73 - }
27.74 - protected void addNotify() {
27.75 - super.addNotify();
27.76 - setKeys(things);
27.77 - }
27.78 - protected void removeNotify() {
27.79 - setKeys(Collections.EMPTY_SET);
27.80 - super.removeNotify();
27.81 - }
27.82 - protected Node[] createNodes(Object key) {
27.83 - return new Node[] {createNode(key)};
27.84 - }
27.85 - protected Node createNode(Object key) {
27.86 - if (key instanceof SerParser.NameValue) {
27.87 - SerParser.NameValue nv = (SerParser.NameValue)key;
27.88 - Node n = createNode(nv.value);
27.89 - n.setName(prettify(nv.name.type) + " " + nv.name.name + " = " + n.getName()); // NOI18N
27.90 - return n;
27.91 - } else if (key instanceof SerParser.ObjectWrapper) {
27.92 - SerParser.ObjectWrapper ow = (SerParser.ObjectWrapper)key;
27.93 - String name = prettify(ow.classdesc.name);
27.94 - Children ch;
27.95 - if (name.equals("org.openide.util.io.NbMarshalledObject")) { // NOI18N
27.96 - // This is special!
27.97 - ch = new NbMarshalledObjectChildren(ow);
27.98 - } else {
27.99 - ch = new GeneralChildren(ow.data);
27.100 - }
27.101 - AbstractNode n = new AbstractNode(ch);
27.102 - n.setName(NbBundle.getMessage(SerStructureNode.class, "LBL_instance_of", name));
27.103 - n.setIconBase("org/netbeans/modules/clazz/resources/serAlone"); // NOI18N
27.104 - return n;
27.105 - } else if (key instanceof SerParser.ArrayWrapper) {
27.106 - SerParser.ArrayWrapper aw = (SerParser.ArrayWrapper)key;
27.107 - AbstractNode n = new AbstractNode(new GeneralChildren(aw.values));
27.108 - if (! aw.classdesc.name.startsWith("[")) throw new IllegalStateException("Strange array name: " + aw.classdesc.name); // NOI18N
27.109 - n.setName(prettify(aw.classdesc.name.substring(1, aw.classdesc.name.length())) + "[" + aw.values.size() + "]"); // NOI18N
27.110 - n.setIconBase("org/netbeans/modules/clazz/resources/serAlone"); // NOI18N
27.111 - return n;
27.112 - } else if (key instanceof byte[]) {
27.113 - // Block data.
27.114 - AbstractNode n = new AbstractNode(Children.LEAF);
27.115 - n.setName(SerParser.hexify((byte[])key));
27.116 - n.setIconBase("org/netbeans/modules/clazz/resources/serAlone"); // NOI18N
27.117 - return n;
27.118 - } else if (key instanceof SerParser.ClassDesc) {
27.119 - AbstractNode n = new AbstractNode(Children.LEAF);
27.120 - n.setName("class " + prettify(((SerParser.ClassDesc)key).name)); // NOI18N
27.121 - n.setIconBase("org/netbeans/modules/clazz/resources/serAlone"); // NOI18N
27.122 - return n;
27.123 - } else if (key == SerParser.NULL) {
27.124 - AbstractNode n = new AbstractNode(Children.LEAF);
27.125 - n.setName("null"); // NOI18N
27.126 - n.setIconBase("org/netbeans/modules/clazz/resources/serAlone"); // NOI18N
27.127 - return n;
27.128 - } else if (key instanceof String) {
27.129 - AbstractNode n = new AbstractNode(Children.LEAF);
27.130 - n.setName("\"" + (String)key + "\""); // NOI18N
27.131 - n.setIconBase("org/netbeans/modules/clazz/resources/serAlone"); // NOI18N
27.132 - return n;
27.133 - } else if ((key instanceof Boolean) || (key instanceof Character) ||
27.134 - (key instanceof Byte) || (key instanceof Short) ||
27.135 - (key instanceof Integer) || (key instanceof Long) ||
27.136 - (key instanceof Float) || (key instanceof Double)) {
27.137 - AbstractNode n = new AbstractNode(Children.LEAF);
27.138 - n.setName(key.toString());
27.139 - n.setIconBase("org/netbeans/modules/clazz/resources/serAlone"); // NOI18N
27.140 - return n;
27.141 - } else {
27.142 - // ????
27.143 - AbstractNode n = new AbstractNode(Children.LEAF);
27.144 - n.setName("What is this? " + key + " [" + key.getClass().getName() + "]"); // NOI18N
27.145 - n.setIconBase("org/netbeans/modules/clazz/resources/serAlone"); // NOI18N
27.146 - return n;
27.147 - }
27.148 - }
27.149 - }
27.150 -
27.151 - private static String prettify(String type) {
27.152 - if (type.equals("B")) { // NOI18N
27.153 - return "byte"; // NOI18N
27.154 - } else if (type.equals("S")) { // NOI18N
27.155 - return "short"; // NOI18N
27.156 - } else if (type.equals("I")) { // NOI18N
27.157 - return "int"; // NOI18N
27.158 - } else if (type.equals("J")) { // NOI18N
27.159 - return "long"; // NOI18N
27.160 - } else if (type.equals("F")) { // NOI18N
27.161 - return "float"; // NOI18N
27.162 - } else if (type.equals("D")) { // NOI18N
27.163 - return "double"; // NOI18N
27.164 - } else if (type.equals("C")) { // NOI18N
27.165 - return "char"; // NOI18N
27.166 - } else if (type.equals("Z")) { // NOI18N
27.167 - return "boolean"; // NOI18N
27.168 - } else if (type.startsWith("L") && type.endsWith(";")) { // NOI18N
27.169 - String fqn = type.substring(1, type.length() - 1).replace('/', '.').replace('$', '.'); // NOI18N
27.170 - if (fqn.startsWith("java.lang.")) { // NOI18N
27.171 - fqn = fqn.substring(10, fqn.length());
27.172 - }
27.173 - return fqn;
27.174 - } else if (type.startsWith("[")) { // NOI18N
27.175 - return prettify(type.substring(1, type.length())) + "[]"; // NOI18N
27.176 - } else {
27.177 - // Should not happen.
27.178 - return "ILLEGAL<" + type + ">"; // NOI18N
27.179 - }
27.180 - }
27.181 -
27.182 - private static final class NbMarshalledObjectChildren extends Children.Keys {
27.183 - private final SerParser.ObjectWrapper ow;
27.184 - public NbMarshalledObjectChildren(SerParser.ObjectWrapper ow) {
27.185 - this.ow = ow;
27.186 - }
27.187 - protected void addNotify() {
27.188 - super.addNotify();
27.189 - setKeys(Collections.singleton(Boolean.TRUE));
27.190 - }
27.191 - protected void removeNotify() {
27.192 - setKeys(Collections.EMPTY_SET);
27.193 - super.removeNotify();
27.194 - }
27.195 - protected Node[] createNodes(Object key) {
27.196 - List pairs = ow.data;
27.197 - Iterator it = pairs.iterator();
27.198 - while (it.hasNext()) {
27.199 - Object pair = (Object)it.next();
27.200 - if (pair instanceof SerParser.NameValue) {
27.201 - SerParser.NameValue nv = (SerParser.NameValue)pair;
27.202 - if (nv.name.name.equals("objBytes") && nv.name.type.equals("[B")) { // NOI18N
27.203 - SerParser.ArrayWrapper aw = (SerParser.ArrayWrapper)nv.value;
27.204 - List vals = aw.values;
27.205 - byte[] b = new byte[vals.size()];
27.206 - for (int i = 0; i < b.length; i++) {
27.207 - b[i] = ((Byte)vals.get(i)).byteValue();
27.208 - }
27.209 - InputStream is = new ByteArrayInputStream(b);
27.210 - try {
27.211 - SerParser.Stream stream = new SerParser(is).parse();
27.212 - return new Node[] {new SerStructureNode.StreamNode(stream)};
27.213 - } catch (SerParser.CorruptException spce) {
27.214 - ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, spce);
27.215 - return new Node[] {};
27.216 - } catch (IOException ioe) {
27.217 - ErrorManager.getDefault().notify(ioe);
27.218 - return new Node[] {};
27.219 - } catch (RuntimeException re) {
27.220 - ErrorManager.getDefault().notify(re);
27.221 - return new Node[] {};
27.222 - }
27.223 - }
27.224 - }
27.225 - }
27.226 - // Improper ser state.
27.227 - return new Node[] {};
27.228 - }
27.229 - }
27.230 -
27.231 -}
28.1 --- a/clazz/src/org/netbeans/modules/clazz/SerTopChildren.java Fri Sep 17 18:36:33 2010 -0400
28.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
28.3 @@ -1,138 +0,0 @@
28.4 -/*
28.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
28.6 - *
28.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
28.8 - *
28.9 - * The contents of this file are subject to the terms of either the GNU
28.10 - * General Public License Version 2 only ("GPL") or the Common
28.11 - * Development and Distribution License("CDDL") (collectively, the
28.12 - * "License"). You may not use this file except in compliance with the
28.13 - * License. You can obtain a copy of the License at
28.14 - * http://www.netbeans.org/cddl-gplv2.html
28.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
28.16 - * specific language governing permissions and limitations under the
28.17 - * License. When distributing the software, include this License Header
28.18 - * Notice in each file and include the License file at
28.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
28.20 - * particular file as subject to the "Classpath" exception as provided
28.21 - * by Sun in the GPL Version 2 section of the License file that
28.22 - * accompanied this code. If applicable, add the following below the
28.23 - * License Header, with the fields enclosed by brackets [] replaced by
28.24 - * your own identifying information:
28.25 - * "Portions Copyrighted [year] [name of copyright owner]"
28.26 - *
28.27 - * Contributor(s):
28.28 - *
28.29 - * The Original Software is NetBeans. The Initial Developer of the Original
28.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28.31 - * Microsystems, Inc. All Rights Reserved.
28.32 - *
28.33 - * If you wish your version of this file to be governed by only the CDDL
28.34 - * or only the GPL Version 2, indicate your decision by adding
28.35 - * "[Contributor] elects to include this software in this distribution
28.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
28.37 - * single choice of license, a recipient has the option to distribute
28.38 - * your version of this file under either the CDDL, the GPL Version 2 or
28.39 - * to extend the choice of license to its licensees as provided above.
28.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
28.41 - * Version 2 license, then the option applies only if the new code is
28.42 - * made subject to such option by the copyright holder.
28.43 - */
28.44 -
28.45 -package org.netbeans.modules.clazz;
28.46 -
28.47 -import java.beans.PropertyChangeEvent;
28.48 -import java.io.*;
28.49 -import java.util.Collections;
28.50 -
28.51 -import org.openide.ErrorManager;
28.52 -import org.openide.loaders.DataObject;
28.53 -import org.openide.nodes.*;
28.54 -import org.openide.src.nodes.*;
28.55 -
28.56 -/** Children for a SerDataNode, including the SourceChildren and
28.57 - * a node for the serialized structure.
28.58 - * @author Jesse Glick
28.59 - */
28.60 -public class SerTopChildren extends Children.Keys implements NodeListener {
28.61 -
28.62 - private final static Object SUPER_KEY = "sourcechildren"; // NOI18N
28.63 - private final static Object ADDED_KEY = "added"; // NOI18N
28.64 -
28.65 - private final DataObject obj;
28.66 - private final SourceChildren src;
28.67 - private Node dummy;
28.68 -
28.69 - public SerTopChildren(DataObject obj, SourceChildren src) {
28.70 - this.obj = obj;
28.71 - this.src = src;
28.72 - }
28.73 -
28.74 - public final SourceChildren getSourceChildren() {
28.75 - return src;
28.76 - }
28.77 -
28.78 - protected void addNotify() {
28.79 - super.addNotify();
28.80 - setKeys(new Object[] {SUPER_KEY, ADDED_KEY});
28.81 - if (dummy == null) {
28.82 - dummy = new AbstractNode(src);
28.83 - }
28.84 - dummy.addNodeListener(this);
28.85 - }
28.86 -
28.87 - protected void removeNotify() {
28.88 - dummy.removeNodeListener(this);
28.89 - setKeys(Collections.EMPTY_SET);
28.90 - super.removeNotify();
28.91 - }
28.92 -
28.93 - protected Node[] createNodes(Object key) {
28.94 - if (key == SUPER_KEY) {
28.95 - Node[] supe = src.getNodes();
28.96 - Node[] mine = new Node[supe.length];
28.97 - for (int i = 0; i < supe.length; i++) {
28.98 - mine[i] = supe[i].cloneNode();
28.99 - }
28.100 - return mine;
28.101 - } else if (key == ADDED_KEY) {
28.102 - try {
28.103 - InputStream is = obj.getPrimaryFile().getInputStream();
28.104 - try {
28.105 - SerParser.Stream stream = new SerParser(is).parse();
28.106 - return new Node[] {new SerStructureNode.StreamNode(stream)};
28.107 - } finally {
28.108 - is.close();
28.109 - }
28.110 - } catch (SerParser.CorruptException spce) {
28.111 - ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, spce);
28.112 - return new Node[] {};
28.113 - } catch (IOException ioe) {
28.114 - ErrorManager.getDefault().notify(ioe);
28.115 - return new Node[] {};
28.116 - } catch (RuntimeException re) {
28.117 - ErrorManager.getDefault().notify(re);
28.118 - return new Node[] {};
28.119 - }
28.120 - } else {
28.121 - throw new IllegalStateException();
28.122 - }
28.123 - }
28.124 -
28.125 - public void childrenAdded(NodeMemberEvent ev) {
28.126 - refreshKey(SUPER_KEY);
28.127 - }
28.128 - public void childrenRemoved(NodeMemberEvent ev) {
28.129 - refreshKey(SUPER_KEY);
28.130 - }
28.131 - public void childrenReordered(NodeReorderEvent ev) {
28.132 - refreshKey(SUPER_KEY);
28.133 - }
28.134 - public void nodeDestroyed(NodeEvent ev) {
28.135 - // ignore
28.136 - }
28.137 - public void propertyChange(PropertyChangeEvent evt) {
28.138 - // ignore
28.139 - }
28.140 -
28.141 -}
29.1 --- a/clazz/src/org/netbeans/modules/clazz/SourceElementImpl.java Fri Sep 17 18:36:33 2010 -0400
29.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
29.3 @@ -1,501 +0,0 @@
29.4 -/*
29.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
29.6 - *
29.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
29.8 - *
29.9 - * The contents of this file are subject to the terms of either the GNU
29.10 - * General Public License Version 2 only ("GPL") or the Common
29.11 - * Development and Distribution License("CDDL") (collectively, the
29.12 - * "License"). You may not use this file except in compliance with the
29.13 - * License. You can obtain a copy of the License at
29.14 - * http://www.netbeans.org/cddl-gplv2.html
29.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
29.16 - * specific language governing permissions and limitations under the
29.17 - * License. When distributing the software, include this License Header
29.18 - * Notice in each file and include the License file at
29.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
29.20 - * particular file as subject to the "Classpath" exception as provided
29.21 - * by Sun in the GPL Version 2 section of the License file that
29.22 - * accompanied this code. If applicable, add the following below the
29.23 - * License Header, with the fields enclosed by brackets [] replaced by
29.24 - * your own identifying information:
29.25 - * "Portions Copyrighted [year] [name of copyright owner]"
29.26 - *
29.27 - * Contributor(s):
29.28 - *
29.29 - * The Original Software is NetBeans. The Initial Developer of the Original
29.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
29.31 - * Microsystems, Inc. All Rights Reserved.
29.32 - *
29.33 - * If you wish your version of this file to be governed by only the CDDL
29.34 - * or only the GPL Version 2, indicate your decision by adding
29.35 - * "[Contributor] elects to include this software in this distribution
29.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
29.37 - * single choice of license, a recipient has the option to distribute
29.38 - * your version of this file under either the CDDL, the GPL Version 2 or
29.39 - * to extend the choice of license to its licensees as provided above.
29.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
29.41 - * Version 2 license, then the option applies only if the new code is
29.42 - * made subject to such option by the copyright holder.
29.43 - */
29.44 -
29.45 -package org.netbeans.modules.clazz;
29.46 -
29.47 -import java.lang.ref.SoftReference;
29.48 -import java.util.Collections;
29.49 -import java.util.HashMap;
29.50 -import java.util.Iterator;
29.51 -import java.util.Map;
29.52 -import javax.swing.SwingUtilities;
29.53 -import org.netbeans.api.java.classpath.ClassPath;
29.54 -import org.netbeans.api.mdr.MDRepository;
29.55 -import org.netbeans.jmi.javamodel.JavaClass;
29.56 -import org.netbeans.jmi.javamodel.JavaPackage;
29.57 -import org.netbeans.jmi.javamodel.NamedElement;
29.58 -import org.netbeans.jmi.javamodel.Resource;
29.59 -import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
29.60 -import org.openide.filesystems.FileObject;
29.61 -import org.openide.loaders.DataObject;
29.62 -import org.openide.loaders.MultiDataObject;
29.63 -import org.openide.nodes.Node;
29.64 -import org.openide.src.*;
29.65 -import org.openide.util.Task;
29.66 -import org.openide.util.TaskListener;
29.67 -
29.68 -/** The implementation of source element for class objects.
29.69 -* This class is final only for performance reasons,
29.70 -* can be happily unfinaled if desired.
29.71 -*
29.72 -* @author Dafe Simonek, Jan Jancura
29.73 -*/
29.74 -final class SourceElementImpl extends MemberElementImpl
29.75 - implements SourceElement.Impl, ElementProperties, TaskListener {
29.76 -
29.77 - private static final Map EMPTY_MAP = Collections.unmodifiableMap(new HashMap(0));
29.78 -
29.79 - /** Empty array of imports - constant to return fro getImports() */
29.80 - static final Import[] EMPTY_IMPORTS = new Import[0];
29.81 - static final ClassElement[] NO_CLASSES = new ClassElement[0];
29.82 -
29.83 - /* Soft reference to the class element */
29.84 - private SoftReference topClass;
29.85 - /** Soft ref to the map holding all inners */
29.86 - private SoftReference allClasses;
29.87 - /** The identifier of the package of the class data */
29.88 - private Identifier packg;
29.89 - /** Association with the class data object (can be null) */
29.90 - private ClassDataObject cdo;
29.91 -
29.92 - private ClassLoader loader;
29.93 -
29.94 - Task loadingTask;
29.95 -
29.96 - int status = -1;
29.97 -
29.98 - private transient boolean attached;
29.99 -
29.100 - private boolean isEmpty = false;
29.101 -
29.102 - private ClassPath classPath = null;
29.103 -
29.104 - static final long serialVersionUID =-4870331896218546842L;
29.105 -
29.106 - SourceElementImpl (ClassDataObject cdo) {
29.107 - this((Resource)null, cdo);
29.108 - }
29.109 -
29.110 - /** Creates object with asociated class and with asociated
29.111 - * class data object which created this source element (can be null).
29.112 - */
29.113 - public SourceElementImpl (Resource res, ClassDataObject cdo) {
29.114 - super(res);
29.115 - this.cdo = cdo;
29.116 - FileObject fo = cdo.getPrimaryFile();
29.117 - classPath = ClassPath.getClassPath(fo, ClassPath.EXECUTE); // hard reference to class path prevents unmounting of related extent
29.118 - }
29.119 -
29.120 - public void attachedToElement (Element element) {
29.121 - super.attachedToElement(element);
29.122 - initializeData();
29.123 -
29.124 - }
29.125 -
29.126 - public void initializeData() {
29.127 - JavaMetamodel model = JavaMetamodel.getManager();
29.128 - FileObject fo = cdo.getPrimaryFile();
29.129 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
29.130 - repo.beginTrans(false);
29.131 - try {
29.132 - Resource resource = model.getResource(fo);
29.133 - if (resource == null || !resource.isValid()) {
29.134 - return;
29.135 - }
29.136 - data = resource;
29.137 - getPackage();
29.138 - ClassElement elem = getClassElement();
29.139 - if (elem!=null) {
29.140 - ClassElementImpl impl = (ClassElementImpl) elem.getCookie(org.openide.src.Element.Impl.class);
29.141 - impl.initializeData();
29.142 - }
29.143 - } finally {
29.144 - repo.endTrans();
29.145 - }
29.146 - }
29.147 -
29.148 - public void refreshData() {
29.149 - boolean fireChange = false;
29.150 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
29.151 - repo.beginTrans(false);
29.152 - try {
29.153 - // System.out.println("refreshing ...");
29.154 - Object oldData = data;
29.155 -
29.156 - FileObject fo = cdo.getPrimaryFile();
29.157 - data = JavaMetamodel.getManager().getResource(fo);
29.158 -
29.159 - // System.out.println(" " + (data != null ? "" + ((Resource)data).isValid() : "null") + " eq: " + (oldData == data));
29.160 -
29.161 - if (data != null && ((Resource) data).isValid()) {
29.162 - // check features validity
29.163 -// for (Iterator iter = ((Resource) data).getClassifiers().iterator(); iter.hasNext();) {
29.164 -// NamedElement cm = (NamedElement) iter.next();
29.165 -// System.out.println(" " + cm.getClass().getName() + " " + cm.isValid());
29.166 -// }
29.167 -
29.168 - topClass = null;
29.169 - allClasses = null;
29.170 - fireChange = true;
29.171 -
29.172 - ClassElement cls = getClassElement();
29.173 - if (cls!=null) {
29.174 - ClassElementImpl impl = (ClassElementImpl) cls.getCookie(org.openide.src.Element.Impl.class);
29.175 - // System.out.println("cls impl: " + (impl != null));
29.176 - if (impl != null) {
29.177 - impl.refreshData();
29.178 - }
29.179 - }
29.180 - }
29.181 - } finally {
29.182 - repo.endTrans();
29.183 - }
29.184 - if (fireChange) {
29.185 - firePropertyChange(PROP_CLASSES, null, null);
29.186 - firePropertyChange(PROP_ALL_CLASSES, null, null);
29.187 - }
29.188 - }
29.189 -
29.190 - public void setResource(Resource data) {
29.191 - int oldStatus;
29.192 - int newStatus;
29.193 -
29.194 - synchronized (this) {
29.195 - oldStatus = getStatus();
29.196 - this.data = data;
29.197 - topClass = null;
29.198 - allClasses = null;
29.199 - newStatus = getStatus();
29.200 - loadingTask = null;
29.201 - }
29.202 - initializeData();
29.203 - if (oldStatus != SourceElement.STATUS_NOT) {
29.204 - firePropertyChange(PROP_CLASSES, null, null);
29.205 - firePropertyChange(PROP_ALL_CLASSES, null, null);
29.206 - }
29.207 - firePropertyChange(PROP_STATUS, new Integer(oldStatus), new Integer(newStatus));
29.208 - }
29.209 -
29.210 - /** Not supported. Throws SourceException.
29.211 - */
29.212 - public void setPackage (Identifier id) throws SourceException {
29.213 - throwReadOnlyException();
29.214 - }
29.215 -
29.216 - Resource getResource() {
29.217 - checkData();
29.218 - return (Resource)data;
29.219 - }
29.220 -
29.221 - /** @return The package of class which we are representing.
29.222 - */
29.223 - public Identifier getPackage () {
29.224 - if (packg != null)
29.225 - return packg;
29.226 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
29.227 - repo.beginTrans(false);
29.228 - try {
29.229 - if ((getResource() == null) || !isValid())
29.230 - return null;
29.231 - JavaPackage p = (JavaPackage) getResource().refImmediateComposite();
29.232 - if (p == null)
29.233 - return null;
29.234 - return packg = Identifier.create(p.getName());
29.235 - } finally {
29.236 - repo.endTrans();
29.237 - }
29.238 - }
29.239 -
29.240 - /** @return always returns empty array
29.241 - */
29.242 - public Import[] getImports () {
29.243 - return EMPTY_IMPORTS;
29.244 - }
29.245 -
29.246 - /** Not supported. Throws SourceException.
29.247 - */
29.248 - public void changeImports (Import[] elems, int action) throws SourceException {
29.249 - throwReadOnlyException();
29.250 - }
29.251 -
29.252 - /** Not supported. Throws SourceException.
29.253 - */
29.254 - public void changeClasses (ClassElement[] elems, int action) throws SourceException {
29.255 - throwReadOnlyException();
29.256 - }
29.257 -
29.258 - /** Always returns only one class element which belongs to the
29.259 - * class data we were given in constructor.
29.260 - */
29.261 - public ClassElement[] getClasses () {
29.262 - checkData();
29.263 - if (data == null)
29.264 - return NO_CLASSES;
29.265 - ClassElement clsElem = getClassElement();
29.266 - if (clsElem == null)
29.267 - return NO_CLASSES;
29.268 - return new ClassElement[] { clsElem };
29.269 - }
29.270 -
29.271 - /** Finds an inner class with given name.
29.272 - * @param name the name to look for
29.273 - * @return the element or null if such class does not exist
29.274 - */
29.275 - public ClassElement getClass (Identifier name) {
29.276 - ClassElement el = getClassElement();
29.277 - if (el != null) {
29.278 - String srcName = name.getSourceName();
29.279 - String fullName = name.getFullName();
29.280 - Identifier idEl = el.getName();
29.281 - String srcEl = idEl.getSourceName();
29.282 - String fullEl = idEl.getFullName();
29.283 -
29.284 - if (srcEl.equals(srcName)) {
29.285 - if (srcName.equals(fullName) || fullEl.equals(fullName))
29.286 - return el;
29.287 - else
29.288 - return null;
29.289 - } else if (fullEl.equals(fullName)) {
29.290 - return el;
29.291 - }
29.292 - }
29.293 - return null;
29.294 - }
29.295 -
29.296 - /** @return Top level class which we are asociated with
29.297 - * and all its innerclasses and innerinterfaces.
29.298 - */
29.299 - public ClassElement[] getAllClasses () {
29.300 - if (isEmpty) {
29.301 - return new ClassElement[0];
29.302 - }
29.303 - return (ClassElement[])getAllClassesMap ().values().toArray (new ClassElement[0]);
29.304 - }
29.305 -
29.306 - /** @return Always returns STATUS_OK, 'cause we always have the class...
29.307 - */
29.308 - public int getStatus () {
29.309 - if (status != -1) {
29.310 - return status;
29.311 - }
29.312 - int s;
29.313 - if (data != null) {
29.314 - s = SourceElement.STATUS_OK;
29.315 - } else {
29.316 - Task t = prepare();
29.317 - if (t.isFinished()) {
29.318 - checkData();
29.319 - s = data == null ? SourceElement.STATUS_ERROR : SourceElement.STATUS_OK;
29.320 - } else {
29.321 - synchronized (this) {
29.322 - if (!attached) {
29.323 - attached = true;
29.324 - t.addTaskListener(this);
29.325 - }
29.326 - }
29.327 - s = SourceElement.STATUS_NOT;
29.328 - }
29.329 - }
29.330 - setStatus(s);
29.331 - return s;
29.332 - }
29.333 -
29.334 - void setStatus(int newStatus) {
29.335 - int old;
29.336 -
29.337 - synchronized (this) {
29.338 - if (status == newStatus)
29.339 - return;
29.340 - old = status;
29.341 - status = newStatus;
29.342 - }
29.343 - if (old != -1)
29.344 - firePropertyChange(ElementProperties.PROP_STATUS, new Integer(old), new Integer(newStatus));
29.345 - }
29.346 -
29.347 - void checkData() {
29.348 - if (data == null) {
29.349 - FileObject fo=cdo.getPrimaryFile();
29.350 - data=JavaMetamodel.getManager().getResource(fo);
29.351 - }
29.352 - }
29.353 -
29.354 - /** Returns empty task, because we don't need any preparation.
29.355 - */
29.356 - public Task prepare() {
29.357 - return Task.EMPTY;
29.358 - }
29.359 -
29.360 - /** .class file are always read only for Java Hierarchy API
29.361 - */
29.362 - public boolean isReadOnly() {
29.363 - return true;
29.364 - }
29.365 -
29.366 - /************* utility methods *********/
29.367 -
29.368 - /** Returns class element for asociated class data.
29.369 - * Care must be taken, 'cause we are playing with soft reference.
29.370 - */
29.371 - private ClassElement getClassElement () {
29.372 - if (isEmpty) {
29.373 - return null;
29.374 - }
29.375 - ClassElement result = (topClass == null) ? null : (ClassElement)topClass.get();
29.376 - if (result == null) {
29.377 - MDRepository repo = JavaMetamodel.getManager().getDefaultRepository();
29.378 - repo.beginTrans(false);
29.379 - try {
29.380 - if (!isValid()) {
29.381 - return null;
29.382 - }
29.383 - if (getResource() == null)
29.384 - return null;
29.385 - JavaClass[] c = (JavaClass[])getResource().getClassifiers().toArray(new JavaClass[0]);
29.386 - if (c.length != 1)
29.387 - return null;
29.388 - result = new ClassElement(new ClassElementImpl(c[0]), (SourceElement)element);
29.389 - topClass = new SoftReference(result);
29.390 - } finally {
29.391 - repo.endTrans();
29.392 - }
29.393 - }
29.394 - return result;
29.395 - }
29.396 -
29.397 - /** Returns map with all innerclasses.
29.398 - * @return map with all innerclasses.
29.399 - */
29.400 - private Map getAllClassesMap () {
29.401 - Map allClassesMap = (allClasses == null) ? null : (Map)allClasses.get();
29.402 - if (allClassesMap == null) {
29.403 - checkData();
29.404 - if (data != null) {
29.405 - // soft ref null, we must recreate
29.406 - allClassesMap = createClassesMap();
29.407 - // remember it, please ...
29.408 - allClasses = new SoftReference(allClassesMap);
29.409 - } else {
29.410 - // can't really do anything - return empty map:
29.411 - return EMPTY_MAP;
29.412 - }
29.413 - }
29.414 - return allClassesMap;
29.415 - }
29.416 -
29.417 - /** Recursively creates the map of all classes.
29.418 - * The entries in the map are built from
29.419 - * identifier - class element pairs.
29.420 - */
29.421 - private Map createClassesMap () {
29.422 - Map result = new HashMap(15);
29.423 - ClassElement clsElem = getClassElement();
29.424 - if (clsElem != null) {
29.425 - addClassElement(result, clsElem);
29.426 - }
29.427 - return result;
29.428 - }
29.429 -
29.430 - /** Adds given class element to the output map and
29.431 - * recurses on its inner classes and interfaces.
29.432 - */
29.433 - private void addClassElement (Map map, final ClassElement outer) {
29.434 - map.put(outer.getName(), outer);
29.435 - // recurse on inners
29.436 - ClassElement[] inners = null;
29.437 - try {
29.438 - inners = outer.getClasses();
29.439 - } catch (Throwable exc) {
29.440 - // rethrow only ThreadDeath, ignore otherwise
29.441 - if (exc instanceof ThreadDeath)
29.442 - throw (ThreadDeath)exc;
29.443 - return;
29.444 - }
29.445 - for (int i = 0; i < inners.length; i++) {
29.446 - addClassElement(map, inners[i]);
29.447 - }
29.448 - }
29.449 -
29.450 - /** Lock the underlaing document to have exclusive access to it and could make changes
29.451 - * on this SourceElement.
29.452 - *
29.453 - * @param run the action to run
29.454 - */
29.455 - public void runAtomic (Runnable run) {
29.456 - run.run();
29.457 - }
29.458 -
29.459 - /** Executes given runnable in "user mode" does not allowing any modifications
29.460 - * to parts of text marked as guarded. The actions should be run as "atomic" so
29.461 - * either happen all at once or none at all (if a guarded block should be modified).
29.462 - *
29.463 - * @param run the action to run
29.464 - */
29.465 - public void runAtomicAsUser (Runnable run) {
29.466 - run.run();
29.467 - }
29.468 -
29.469 - /** DataObject cookie supported.
29.470 - * @return data object cookie or null
29.471 - */
29.472 - public Node.Cookie getCookie (Class type) {
29.473 - if (type.equals(DataObject.class) || type.equals(MultiDataObject.class) ||
29.474 - ClassDataObject.class.isAssignableFrom(type)) {
29.475 - return cdo;
29.476 - } else if (type == SourceElement.Impl.class || type == Element.Impl.class) {
29.477 - return this;
29.478 - }
29.479 - return null;
29.480 - }
29.481 -
29.482 - public Object readResolve() {
29.483 - return new SourceElement(this);
29.484 - }
29.485 -
29.486 - /**
29.487 - * Tries to acquire data file from the owning DataObject, and parse
29.488 - * it using Classfile library.
29.489 - */
29.490 - public void run() {
29.491 - if (cdo == null) {
29.492 - throw new IllegalStateException("Cannot load classfile without " // NOI18N
29.493 - + "the DataObject"); // NOI18N
29.494 - }
29.495 - setResource(null);
29.496 - }
29.497 -
29.498 - public void taskFinished(Task task) {
29.499 - checkData();
29.500 - attached = false;
29.501 - task.removeTaskListener(this);
29.502 - setStatus(data == null ? SourceElement.STATUS_ERROR : SourceElement.STATUS_OK);
29.503 - }
29.504 -}
30.1 --- a/clazz/src/org/netbeans/modules/clazz/Util.java Fri Sep 17 18:36:33 2010 -0400
30.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
30.3 @@ -1,121 +0,0 @@
30.4 -/*
30.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
30.6 - *
30.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
30.8 - *
30.9 - * The contents of this file are subject to the terms of either the GNU
30.10 - * General Public License Version 2 only ("GPL") or the Common
30.11 - * Development and Distribution License("CDDL") (collectively, the
30.12 - * "License"). You may not use this file except in compliance with the
30.13 - * License. You can obtain a copy of the License at
30.14 - * http://www.netbeans.org/cddl-gplv2.html
30.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
30.16 - * specific language governing permissions and limitations under the
30.17 - * License. When distributing the software, include this License Header
30.18 - * Notice in each file and include the License file at
30.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
30.20 - * particular file as subject to the "Classpath" exception as provided
30.21 - * by Sun in the GPL Version 2 section of the License file that
30.22 - * accompanied this code. If applicable, add the following below the
30.23 - * License Header, with the fields enclosed by brackets [] replaced by
30.24 - * your own identifying information:
30.25 - * "Portions Copyrighted [year] [name of copyright owner]"
30.26 - *
30.27 - * Contributor(s):
30.28 - *
30.29 - * The Original Software is NetBeans. The Initial Developer of the Original
30.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30.31 - * Microsystems, Inc. All Rights Reserved.
30.32 - *
30.33 - * If you wish your version of this file to be governed by only the CDDL
30.34 - * or only the GPL Version 2, indicate your decision by adding
30.35 - * "[Contributor] elects to include this software in this distribution
30.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
30.37 - * single choice of license, a recipient has the option to distribute
30.38 - * your version of this file under either the CDDL, the GPL Version 2 or
30.39 - * to extend the choice of license to its licensees as provided above.
30.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
30.41 - * Version 2 license, then the option applies only if the new code is
30.42 - * made subject to such option by the copyright holder.
30.43 - */
30.44 -
30.45 -package org.netbeans.modules.clazz;
30.46 -
30.47 -import java.util.ResourceBundle;
30.48 -import java.util.*;
30.49 -import org.netbeans.jmi.javamodel.Array;
30.50 -import org.netbeans.jmi.javamodel.JavaClass;
30.51 -import org.netbeans.jmi.javamodel.PrimitiveType;
30.52 -import org.netbeans.jmi.javamodel.PrimitiveTypeKind;
30.53 -import org.netbeans.jmi.javamodel.PrimitiveTypeKindEnum;
30.54 -import org.netbeans.jmi.javamodel.Resource;
30.55 -
30.56 -import org.openide.filesystems.Repository;
30.57 -import org.openide.filesystems.FileSystem;
30.58 -import org.openide.filesystems.FileObject;
30.59 -import org.openide.filesystems.FileStateInvalidException;
30.60 -
30.61 -import org.openide.util.Lookup;
30.62 -import org.openide.util.NbBundle;
30.63 -import org.openide.util.RequestProcessor;
30.64 -
30.65 -import org.openide.loaders.DataObject;
30.66 -import org.openide.loaders.DataFolder;
30.67 -import org.openide.loaders.DataObjectNotFoundException;
30.68 -import org.netbeans.modules.classfile.Method;
30.69 -import org.openide.src.Type;
30.70 -import org.openide.src.MethodParameter;
30.71 -import org.openide.src.Identifier;
30.72 -
30.73 -/**
30.74 - *
30.75 - * @author sdedic
30.76 - */
30.77 -final class Util {
30.78 -
30.79 - private static RequestProcessor classProcessor;
30.80 -
30.81 - static String createClassName(String signature) {
30.82 - return signature.replace('/', '.').replace('$', '.');
30.83 - }
30.84 -
30.85 - static Type createType(org.netbeans.jmi.javamodel.Type t) {
30.86 - if (t == null)
30.87 - return null;
30.88 - if (t instanceof Array) {
30.89 - return Type.createArray(createType(((Array)t).getType()));
30.90 - } else if (t instanceof JavaClass) {
30.91 - JavaClass ct=(JavaClass)t;
30.92 - return Type.createClass(
30.93 - Identifier.create(createClassName(ct.getName())));
30.94 - } else if (t instanceof PrimitiveType) {
30.95 - PrimitiveTypeKind tag = ((PrimitiveType)t).getKind();
30.96 - if (tag == PrimitiveTypeKindEnum.BOOLEAN) {
30.97 - return Type.BOOLEAN;
30.98 - } else if (tag == PrimitiveTypeKindEnum.BYTE) {
30.99 - return Type.BYTE;
30.100 - } else if (tag == PrimitiveTypeKindEnum.CHAR) {
30.101 - return Type.CHAR;
30.102 - } else if (tag == PrimitiveTypeKindEnum.DOUBLE) {
30.103 - return Type.DOUBLE;
30.104 - } else if (tag == PrimitiveTypeKindEnum.FLOAT) {
30.105 - return Type.FLOAT;
30.106 - } else if (tag == PrimitiveTypeKindEnum.INT) {
30.107 - return Type.INT;
30.108 - } else if (tag == PrimitiveTypeKindEnum.LONG) {
30.109 - return Type.LONG;
30.110 - } else if (tag == PrimitiveTypeKindEnum.SHORT) {
30.111 - return Type.SHORT;
30.112 - } else if (tag == PrimitiveTypeKindEnum.VOID) {
30.113 - return Type.VOID;
30.114 - }
30.115 - }
30.116 - throw new IllegalArgumentException("Invalid TypeDescriptor: " + t); // NOI18N
30.117 - }
30.118 -
30.119 - static RequestProcessor getClassProcessor() {
30.120 - if (classProcessor==null)
30.121 - classProcessor=new RequestProcessor("Clazz",5); // NOI18N
30.122 - return classProcessor;
30.123 - }
30.124 -}
31.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/bean.gif has changed
32.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/bean32.gif has changed
33.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/beanMain.gif has changed
34.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/beanMain32.gif has changed
35.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/class.gif has changed
36.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/class32.gif has changed
37.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/classBr.gif has changed
38.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/classError.gif has changed
39.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/classError32.gif has changed
40.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/classMain.gif has changed
41.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/classMain32.gif has changed
42.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/interfaceBr.gif has changed
43.1 --- a/clazz/src/org/netbeans/modules/clazz/resources/mf-layer.xml Fri Sep 17 18:36:33 2010 -0400
43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
43.3 @@ -1,119 +0,0 @@
43.4 -<?xml version="1.0" encoding="UTF-8"?>
43.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd">
43.6 -<!--
43.7 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
43.8 -
43.9 -Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
43.10 -
43.11 -
43.12 -The contents of this file are subject to the terms of either the GNU
43.13 -General Public License Version 2 only ("GPL") or the Common
43.14 -Development and Distribution License("CDDL") (collectively, the
43.15 -"License"). You may not use this file except in compliance with the
43.16 -License. You can obtain a copy of the License at
43.17 -http://www.netbeans.org/cddl-gplv2.html
43.18 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
43.19 -specific language governing permissions and limitations under the
43.20 -License. When distributing the software, include this License Header
43.21 -Notice in each file and include the License file at
43.22 -nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
43.23 -particular file as subject to the "Classpath" exception as provided
43.24 -by Sun in the GPL Version 2 section of the License file that
43.25 -accompanied this code. If applicable, add the following below the
43.26 -License Header, with the fields enclosed by brackets [] replaced by
43.27 -your own identifying information:
43.28 -"Portions Copyrighted [year] [name of copyright owner]"
43.29 -
43.30 -Contributor(s):
43.31 -
43.32 -The Original Software is NetBeans. The Initial Developer of the Original
43.33 -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
43.34 -Microsystems, Inc. All Rights Reserved.
43.35 -
43.36 -If you wish your version of this file to be governed by only the CDDL
43.37 -or only the GPL Version 2, indicate your decision by adding
43.38 -"[Contributor] elects to include this software in this distribution
43.39 -under the [CDDL or GPL Version 2] license." If you do not indicate a
43.40 -single choice of license, a recipient has the option to distribute
43.41 -your version of this file under either the CDDL, the GPL Version 2 or
43.42 -to extend the choice of license to its licensees as provided above.
43.43 -However, if you add GPL Version 2 code and therefore, elected the GPL
43.44 -Version 2 license, then the option applies only if the new code is
43.45 -made subject to such option by the copyright holder.
43.46 --->
43.47 -<filesystem>
43.48 - <folder name="NodeFactories">
43.49 - <folder name="clazz">
43.50 - <folder name="explorer"/>
43.51 - <folder name="objectbrowser"/>
43.52 - </folder>
43.53 - </folder>
43.54 - <!--folder name="Services">
43.55 - <file name="ProjectModel.settings" url="../../classmodel/resources/ProjectModel.settings">
43.56 - <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.classmodel.Bundle"/>
43.57 - <attr name="SystemFileSystem.icon" urlvalue="nbres:/org/netbeans/modules/classmodel/resources/projectModelSettings.gif"/>
43.58 -
43.59 - <attr name="instanceOf" stringvalue="org.netbeans.modules.classmodel.ProjectModel"/>
43.60 - <attr name="instanceClass" stringvalue="org.netbeans.modules.classmodel.ProjectModel"/>
43.61 - </file>
43.62 - </folder-->
43.63 - <folder name="Loaders">
43.64 - <folder name="application">
43.65 - <folder name="x-java-class">
43.66 - <folder name="Actions">
43.67 - <attr boolvalue="true" name="OpenAction.instance/FileSystemAction.instance"/>
43.68 - <attr boolvalue="true" name="FileSystemAction.instance/Separator0.instance"/>
43.69 - <file name="CopyAction.shadow">
43.70 - <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CopyAction.instance"/>
43.71 - </file>
43.72 - <file name="CutAction.shadow">
43.73 - <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CutAction.instance"/>
43.74 - </file>
43.75 - <file name="DeleteAction.shadow">
43.76 - <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-DeleteAction.instance"/>
43.77 - </file>
43.78 - <file name="FileSystemAction.shadow">
43.79 - <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-FileSystemAction.instance"/>
43.80 - </file>
43.81 - <file name="OpenAction.shadow">
43.82 - <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-OpenAction.instance"/>
43.83 - </file>
43.84 - <file name="PasteAction.shadow">
43.85 - <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-PasteAction.instance"/>
43.86 - </file>
43.87 - <file name="PropertiesAction.shadow">
43.88 - <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-PropertiesAction.instance"/>
43.89 - </file>
43.90 - <file name="SaveAsTemplateAction.shadow">
43.91 - <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-SaveAsTemplateAction.instance"/>
43.92 - </file>
43.93 - <file name="Separator0.instance">
43.94 - <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
43.95 - </file>
43.96 - <attr boolvalue="true" name="Separator0.instance/CutAction.instance"/>
43.97 - <attr boolvalue="true" name="CutAction.instance/CopyAction.instance"/>
43.98 - <attr boolvalue="true" name="CopyAction.instance/PasteAction.instance"/>
43.99 - <attr boolvalue="true" name="PasteAction.instance/Separator1.instance"/>
43.100 - <file name="Separator1.instance">
43.101 - <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
43.102 - </file>
43.103 - <attr boolvalue="true" name="Separator1.instance/DeleteAction.instance"/>
43.104 - <attr boolvalue="true" name="DeleteAction.instance/Separator2.instance"/>
43.105 - <file name="Separator2.instance">
43.106 - <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
43.107 - </file>
43.108 - <attr boolvalue="true" name="Separator2.instance/SaveAsTemplateAction.instance"/>
43.109 - <attr boolvalue="true" name="SaveAsTemplateAction.instance/Separator3.instance"/>
43.110 - <file name="Separator3.instance">
43.111 - <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
43.112 - </file>
43.113 - <attr boolvalue="true" name="Separator3.instance/ToolsAction.instance"/>
43.114 - <attr boolvalue="true" name="ToolsAction.instance/PropertiesAction.instance"/>
43.115 - <file name="ToolsAction.shadow">
43.116 - <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-ToolsAction.instance"/>
43.117 - </file>
43.118 - </folder> <!-- Actions -->
43.119 - </folder> <!-- application -->
43.120 - </folder> <!-- x-java-class -->
43.121 - </folder> <!-- Loaders -->
43.122 -</filesystem>
44.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/ser.gif has changed
45.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/ser32.gif has changed
46.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/serAlone.gif has changed
47.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/serError.gif has changed
48.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/serError32.gif has changed
49.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/serMain.gif has changed
50.1 Binary file clazz/src/org/netbeans/modules/clazz/resources/serMain32.gif has changed
51.1 --- a/clazz/sub.locale.xml Fri Sep 17 18:36:33 2010 -0400
51.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
51.3 @@ -1,24 +0,0 @@
51.4 -<?xml version="1.0" encoding="UTF-8" ?>
51.5 -
51.6 -<!-- arguments below are taken form the upper ANT task -->
51.7 -
51.8 -<!-- basedir == directory, where the localizable files are -->
51.9 -<!-- destdir == directory, where will be saved final JAR file -->
51.10 -<!-- locale == a locale ... files with these locale will be added to the archive (JAR file) -->
51.11 -
51.12 -<!-- idedir == part in the IDE, where will be stored final file -->
51.13 -
51.14 -
51.15 -<project name="Sub_clazz" default="sub_clazz" basedir="${dir}">
51.16 -
51.17 - <!-- setup the destination directory -->
51.18 - <property name="idedir" value="modules/locale" />
51.19 -
51.20 - <target name="sub_clazz">
51.21 - <!-- create full destination directory -->
51.22 - <mkdir dir="${destdir}/${idedir}" />
51.23 - <!-- create final jar file -->
51.24 - <jar jarfile="${destdir}/${idedir}/clazz_${locale}.jar" basedir="${basedir}/src" includes="**/*_${locale}.*" />
51.25 - </target>
51.26 -
51.27 -</project>
52.1 Binary file clazz/test/qa-functional/src/org/netbeans/test/ClazzTest$InnerClass.class has changed
53.1 Binary file clazz/test/qa-functional/src/org/netbeans/test/ClazzTest$InnerInterface.class has changed
54.1 Binary file clazz/test/qa-functional/src/org/netbeans/test/ClazzTest.class has changed
55.1 --- a/clazz/test/qa-functional/src/org/netbeans/test/clazz/ClazzNodeTest.java Fri Sep 17 18:36:33 2010 -0400
55.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
55.3 @@ -1,195 +0,0 @@
55.4 -/*
55.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55.6 - *
55.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
55.8 - *
55.9 - * The contents of this file are subject to the terms of either the GNU
55.10 - * General Public License Version 2 only ("GPL") or the Common
55.11 - * Development and Distribution License("CDDL") (collectively, the
55.12 - * "License"). You may not use this file except in compliance with the
55.13 - * License. You can obtain a copy of the License at
55.14 - * http://www.netbeans.org/cddl-gplv2.html
55.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
55.16 - * specific language governing permissions and limitations under the
55.17 - * License. When distributing the software, include this License Header
55.18 - * Notice in each file and include the License file at
55.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
55.20 - * particular file as subject to the "Classpath" exception as provided
55.21 - * by Sun in the GPL Version 2 section of the License file that
55.22 - * accompanied this code. If applicable, add the following below the
55.23 - * License Header, with the fields enclosed by brackets [] replaced by
55.24 - * your own identifying information:
55.25 - * "Portions Copyrighted [year] [name of copyright owner]"
55.26 - *
55.27 - * Contributor(s):
55.28 - *
55.29 - * The Original Software is NetBeans. The Initial Developer of the Original
55.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
55.31 - * Microsystems, Inc. All Rights Reserved.
55.32 - *
55.33 - * If you wish your version of this file to be governed by only the CDDL
55.34 - * or only the GPL Version 2, indicate your decision by adding
55.35 - * "[Contributor] elects to include this software in this distribution
55.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
55.37 - * single choice of license, a recipient has the option to distribute
55.38 - * your version of this file under either the CDDL, the GPL Version 2 or
55.39 - * to extend the choice of license to its licensees as provided above.
55.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
55.41 - * Version 2 license, then the option applies only if the new code is
55.42 - * made subject to such option by the copyright holder.
55.43 - */
55.44 -
55.45 -package org.netbeans.test.clazz;
55.46 -
55.47 -import java.io.IOException;
55.48 -import junit.textui.TestRunner;
55.49 -import org.netbeans.jellytools.Bundle;
55.50 -import org.netbeans.jellytools.JellyTestCase;
55.51 -import org.netbeans.jellytools.NbDialogOperator;
55.52 -import org.netbeans.jellytools.RepositoryTabOperator;
55.53 -import org.netbeans.jellytools.nodes.FolderNode;
55.54 -import org.netbeans.jellytools.nodes.JavaNode;
55.55 -import org.netbeans.jemmy.EventTool;
55.56 -import org.netbeans.junit.NbTestSuite;
55.57 -import org.openide.filesystems.FileObject;
55.58 -import org.openide.filesystems.Repository;
55.59 -import org.openide.loaders.DataFolder;
55.60 -import org.openide.loaders.DataObject;
55.61 -
55.62 -
55.63 -public class ClazzNodeTest extends JellyTestCase {
55.64 -
55.65 - private static final String NAME_TEST_FILE = "ClazzTest"; //NOI18N
55.66 - private static final String SRC_PACKAGE = "org.netbeans.test"; //NOI18N
55.67 - private static final String DST_PACKAGE = "org.netbeans.test.clazz"; //NOI18N
55.68 -
55.69 - private DataObject srcFile;
55.70 - private DataFolder srcFolder;
55.71 - private String testFSName;
55.72 -
55.73 - {
55.74 - try {
55.75 - srcFolder = DataFolder.findFolder(Repository.getDefault().findResource(SRC_PACKAGE.replace('.','/')));
55.76 - testFSName = Repository.getDefault().findResource(DST_PACKAGE.replace('.', '/')).getFileSystem().getDisplayName();
55.77 - }
55.78 - catch (Exception e) {
55.79 - e.printStackTrace();
55.80 - }
55.81 -
55.82 - }
55.83 -
55.84 - /** Need to be defined because of JUnit */
55.85 - public ClazzNodeTest(String name) {
55.86 - super(name);
55.87 - }
55.88 -
55.89 - public static NbTestSuite suite() {
55.90 - NbTestSuite suite = new NbTestSuite();
55.91 - suite.addTest(new ClazzNodeTest("testCopyPasteCopy")); //NOI18N
55.92 - suite.addTest(new ClazzNodeTest("testCopyPasteCreateLink")); //NOI18N
55.93 - suite.addTest(new ClazzNodeTest("testCopyPasteSerialize")); //NOI18N
55.94 - suite.addTest(new ClazzNodeTest("testCopyPasteDefaultInstance")); //NOI18N
55.95 - suite.addTest(new ClazzNodeTest("testCutPasteCopy")); //NOI18N
55.96 - return suite;
55.97 - }
55.98 -
55.99 - /** Use for execution inside IDE */
55.100 - public static void main(java.lang.String[] args) {
55.101 - // run whole suite
55.102 - TestRunner.run(suite());
55.103 - // run only selected test case
55.104 - //junit.textui.TestRunner.run(new BeansTemplates("testJavaBean"));
55.105 - }
55.106 -
55.107 - public void setUp() {
55.108 - System.out.println("######## "+getName()+" #######"); //NOI18N
55.109 - RepositoryTabOperator.invoke();
55.110 - }
55.111 -
55.112 - public void testCopyPasteCopy() {
55.113 - JavaNode srcNode = new JavaNode(testFSName + '|' + SRC_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE);
55.114 - srcNode.copy();
55.115 -
55.116 - FolderNode dstNode = new FolderNode(testFSName + '|' + DST_PACKAGE.replace('.', '|'));
55.117 - dstNode.pasteCopy();
55.118 - new EventTool().waitNoEvent(1000);
55.119 - assertNotNull(Repository.getDefault().findResource(DST_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".class")); //NOI18N
55.120 -
55.121 - delete(DST_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".class"); //NOI18N
55.122 - }
55.123 -
55.124 - public void testCopyPasteCreateLink() {
55.125 - JavaNode srcNode = new JavaNode(testFSName + '|' + SRC_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE);
55.126 - srcNode.copy();
55.127 -
55.128 - FolderNode dstNode = new FolderNode(testFSName + "|" + DST_PACKAGE.replace('.', '|'));
55.129 - dstNode.pasteLink();
55.130 - new EventTool().waitNoEvent(1000);
55.131 - assertNotNull(Repository.getDefault().findResource(DST_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".shadow")); //NOI18N
55.132 -
55.133 - delete(DST_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".shadow"); //NOI18N
55.134 - }
55.135 -
55.136 - public void testCopyPasteSerialize() {
55.137 - JavaNode srcNode = new JavaNode(testFSName + '|' + SRC_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE);
55.138 - srcNode.copy();
55.139 -
55.140 - FolderNode dstNode = new FolderNode(testFSName + '|' + DST_PACKAGE.replace('.', '|'));
55.141 - dstNode.performPopupActionNoBlock(Bundle.getStringTrimmed("org.openide.actions.Bundle", "Paste") + '|' + Bundle.getStringTrimmed("org.openide.loaders.Bundle", "CTL_Serialize"));
55.142 - new NbDialogOperator(Bundle.getString("org.openide.loaders.Bundle", "SerializeBean_Title")).ok();
55.143 -
55.144 - new EventTool().waitNoEvent(1000);
55.145 - assertNotNull(Repository.getDefault().findResource(DST_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".ser")); //NOI18N
55.146 -
55.147 - delete(DST_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".ser"); //NOI18N
55.148 - }
55.149 -
55.150 - public void testCopyPasteDefaultInstance() {
55.151 - System.out.println("YYYY ->" + testFSName + '|' + SRC_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE);
55.152 - JavaNode srcNode = new JavaNode(testFSName + '|' + SRC_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE);
55.153 - srcNode.copy();
55.154 -
55.155 - FolderNode dstNode = new FolderNode(testFSName + '|' + DST_PACKAGE.replace('.', '|'));
55.156 - dstNode.performPopupActionNoBlock(Bundle.getStringTrimmed("org.openide.actions.Bundle", "Paste") + '|' + Bundle.getStringTrimmed("org.openide.loaders.Bundle", "PT_instance"));
55.157 -
55.158 - new EventTool().waitNoEvent(1000);
55.159 - System.out.println("XXX ->" + DST_PACKAGE.replace('.', '/') + '/' + SRC_PACKAGE.replace('.', '-') + '-' + NAME_TEST_FILE + ".instance"); //NOI18N
55.160 - assertNotNull(Repository.getDefault().findResource(DST_PACKAGE.replace('.', '/') + '/' + SRC_PACKAGE.replace('.', '-') + '-' + NAME_TEST_FILE + ".instance")); //NOI18N
55.161 -
55.162 - delete(DST_PACKAGE.replace('.', '/') + '/' + SRC_PACKAGE.replace('.', '-') + '-' + NAME_TEST_FILE + ".instance"); //NOI18N
55.163 - }
55.164 -
55.165 - public void testCutPasteCopy() {
55.166 - JavaNode srcNode = new JavaNode(testFSName + '|' + SRC_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE);
55.167 - srcNode.cut();
55.168 - new EventTool().waitNoEvent(1000);
55.169 - FolderNode dstNode = new FolderNode(testFSName + "|" + DST_PACKAGE.replace('.', '|'));
55.170 - System.out.println("AAAAAA");
55.171 - dstNode.performPopupAction(Bundle.getStringTrimmed("org.openide.actions.Bundle", "Paste"));
55.172 - System.out.println("BBBBBB");
55.173 - srcNode.waitNotPresent();
55.174 - new EventTool().waitNoEvent(1000);
55.175 - assertNotNull(Repository.getDefault().findResource(DST_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".class")); //NOI18N
55.176 - assertNull(Repository.getDefault().findResource(SRC_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".class")); //NOI18N
55.177 - new EventTool().waitNoEvent(1000);
55.178 - srcNode = new JavaNode(testFSName + '|' + DST_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE);
55.179 - srcNode.cut();
55.180 - new EventTool().waitNoEvent(1000);
55.181 - dstNode = new FolderNode(testFSName + "|" + SRC_PACKAGE.replace('.', '|'));
55.182 - dstNode.select();
55.183 - new EventTool().waitNoEvent(1000);
55.184 -// dstNode.performPopupActionNoBlock(Bundle.getStringTrimmed("org.openide.actions.Bundle", "Paste"));
55.185 - dstNode.performPopupAction(Bundle.getStringTrimmed("org.openide.actions.Bundle", "Paste"));
55.186 - srcNode.waitNotPresent();
55.187 - new EventTool().waitNoEvent(1000);
55.188 - }
55.189 -
55.190 - public static void delete(String file) {
55.191 - FileObject fileObject = Repository.getDefault().findResource(file);
55.192 - if (fileObject==null) return;
55.193 - try {
55.194 - DataObject.find(fileObject).delete();
55.195 - } catch (IOException e) {
55.196 - }
55.197 - }
55.198 -}
56.1 --- a/clazz/test/qa-functional/src/org/netbeans/test/clazz/ElementRecognitionTest.java Fri Sep 17 18:36:33 2010 -0400
56.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
56.3 @@ -1,233 +0,0 @@
56.4 -/*
56.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
56.6 - *
56.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
56.8 - *
56.9 - * The contents of this file are subject to the terms of either the GNU
56.10 - * General Public License Version 2 only ("GPL") or the Common
56.11 - * Development and Distribution License("CDDL") (collectively, the
56.12 - * "License"). You may not use this file except in compliance with the
56.13 - * License. You can obtain a copy of the License at
56.14 - * http://www.netbeans.org/cddl-gplv2.html
56.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
56.16 - * specific language governing permissions and limitations under the
56.17 - * License. When distributing the software, include this License Header
56.18 - * Notice in each file and include the License file at
56.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
56.20 - * particular file as subject to the "Classpath" exception as provided
56.21 - * by Sun in the GPL Version 2 section of the License file that
56.22 - * accompanied this code. If applicable, add the following below the
56.23 - * License Header, with the fields enclosed by brackets [] replaced by
56.24 - * your own identifying information:
56.25 - * "Portions Copyrighted [year] [name of copyright owner]"
56.26 - *
56.27 - * Contributor(s):
56.28 - *
56.29 - * The Original Software is NetBeans. The Initial Developer of the Original
56.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
56.31 - * Microsystems, Inc. All Rights Reserved.
56.32 - *
56.33 - * If you wish your version of this file to be governed by only the CDDL
56.34 - * or only the GPL Version 2, indicate your decision by adding
56.35 - * "[Contributor] elects to include this software in this distribution
56.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
56.37 - * single choice of license, a recipient has the option to distribute
56.38 - * your version of this file under either the CDDL, the GPL Version 2 or
56.39 - * to extend the choice of license to its licensees as provided above.
56.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
56.41 - * Version 2 license, then the option applies only if the new code is
56.42 - * made subject to such option by the copyright holder.
56.43 - */
56.44 -
56.45 -/*
56.46 - * ElementRecognitionTest.java
56.47 - *
56.48 - * Created on March 26, 2002, 4:22 PM
56.49 - */
56.50 -
56.51 -package org.netbeans.test.clazz;
56.52 -
56.53 -import org.netbeans.junit.NbTestCase;
56.54 -import org.openide.src.*;
56.55 -import org.netbeans.junit.NbTest;
56.56 -import org.netbeans.junit.NbTestSuite;
56.57 -import java.lang.reflect.Modifier;
56.58 -
56.59 -/**
56.60 - *
56.61 - * @author jb105785
56.62 - */
56.63 -public class ElementRecognitionTest extends NbTestCase {
56.64 -
56.65 - ClassElement clazz;
56.66 - public ElementRecognitionTest() {
56.67 - super("");
56.68 - }
56.69 -
56.70 - public ElementRecognitionTest(java.lang.String testName) {
56.71 - super(testName);
56.72 - }
56.73 -
56.74 - public static NbTest suite() {
56.75 - return new NbTestSuite(ElementRecognitionTest.class);
56.76 - }
56.77 -
56.78 - public static void main(java.lang.String[] args) {
56.79 - junit.textui.TestRunner.run(suite());
56.80 - }
56.81 -
56.82 - public void setUp() throws Exception {
56.83 - super.setUp();
56.84 - clazz = ClassElement.forName("org.netbeans.test.ClazzTest");
56.85 - assertNotNull(clazz);
56.86 - }
56.87 -
56.88 - public void testClass() {
56.89 - assertEquals(clazz.getName().getName(), "ClazzTest");
56.90 - assertEquals(clazz.getName().getFullName(), "org.netbeans.test.ClazzTest");
56.91 - assertEquals(clazz.getSuperclass().getFullName(), "javax.swing.JPanel");
56.92 - assertEquals(clazz.getInterfaces().length, 0);
56.93 -
56.94 - assertEquals(clazz.getModifiers(), Modifier.PUBLIC);
56.95 - }
56.96 -
56.97 - public void testInnerClasses() {
56.98 - ClassElement inner = clazz.getClass(Identifier.create("InnerClass"));
56.99 -
56.100 - assertNotNull(inner);
56.101 - assertEquals(inner.getName().getName(), "InnerClass");
56.102 - assertEquals(inner.getName().getFullName(), "org.netbeans.test.ClazzTest.InnerClass");
56.103 - assertEquals("InnerClass should be public static!", inner.getModifiers(), Modifier.PUBLIC | Modifier.STATIC );
56.104 - }
56.105 -
56.106 - public void testInnerInterfaces() {
56.107 - ClassElement inner = clazz.getClass(Identifier.create("InnerInterface"));
56.108 -
56.109 - assertNotNull(inner);
56.110 - assertEquals(inner.getName().getName(), "InnerInterface");
56.111 - assertEquals(inner.getName().getFullName(), "org.netbeans.test.ClazzTest.InnerInterface");
56.112 - assertEquals(inner.getModifiers(), Modifier.PUBLIC | Modifier.ABSTRACT | Modifier.STATIC );
56.113 - }
56.114 -
56.115 - public void testMethods() {
56.116 - assertEquals(clazz.getMethods().length, 4);
56.117 - }
56.118 -
56.119 - public void testMethodInitComponents() {
56.120 - MethodElement method = clazz.getMethod(Identifier.create("initComponents"), new Type[]{});
56.121 -
56.122 - assertNotNull(method);
56.123 - assertEquals(method.getName().getName(), "initComponents");
56.124 - assertEquals(method.getName().getFullName(), "initComponents");
56.125 - assertEquals(method.getModifiers(), Modifier.PRIVATE);
56.126 - assertEquals(method.getReturn(), Type.VOID);
56.127 - assertEquals(method.getParameters().length, 0);
56.128 - assertEquals(method.getExceptions().length, 0);
56.129 - }
56.130 -
56.131 - public void testMethodIsOk() {
56.132 - MethodElement method = clazz.getMethod(Identifier.create("isOk"), new Type[]{});
56.133 -
56.134 - assertNotNull(method);
56.135 - assertEquals(method.getName().getName(), "isOk");
56.136 - assertEquals(method.getName().getFullName(), "isOk");
56.137 - assertEquals(method.getModifiers(), Modifier.PUBLIC);
56.138 - assertEquals(method.getReturn(), Type.BOOLEAN);
56.139 - assertEquals(method.getParameters().length, 0);
56.140 - assertEquals(method.getExceptions().length, 0);
56.141 -
56.142 - }
56.143 -
56.144 - public void testMethodSetOk() {
56.145 - MethodElement method = clazz.getMethod(Identifier.create("setOk"), new Type[]{Type.BOOLEAN});
56.146 -
56.147 - assertNotNull(method);
56.148 - assertEquals(method.getName().getName(), "setOk");
56.149 - assertEquals(method.getName().getFullName(), "setOk");
56.150 - assertEquals(method.getModifiers(), Modifier.PUBLIC);
56.151 - assertEquals(method.getReturn(), Type.VOID);
56.152 - assertEquals(method.getParameters()[0], new MethodParameter(null, Type.BOOLEAN, false));
56.153 - assertEquals(method.getExceptions().length, 0);
56.154 - }
56.155 -
56.156 - public void testMethodTestMethod() throws IllegalArgumentException {
56.157 - MethodElement method = clazz.getMethod(Identifier.create("testMethod"), new Type[]{Type.parse("java.lang.String")});
56.158 -
56.159 - assertNotNull(method);
56.160 - assertEquals(method.getName().getName(), "testMethod");
56.161 - assertEquals(method.getName().getFullName(), "testMethod");
56.162 - assertEquals(method.getModifiers(), Modifier.STATIC | Modifier.PROTECTED);
56.163 - assertEquals(method.getReturn(), Type.VOID);
56.164 - assertEquals(method.getParameters()[0], new MethodParameter(null, Type.parse("java.lang.String"), false));
56.165 - assertEquals(method.getExceptions()[0], Identifier.create("java.io.IOException"));
56.166 - }
56.167 -
56.168 - public void testFields() {
56.169 - assertEquals(clazz.getFields().length, 3);
56.170 - }
56.171 -
56.172 - public void testFieldCONSTANT() {
56.173 - FieldElement field = clazz.getField(Identifier.create("CONSTANT"));
56.174 -
56.175 - assertNotNull(field);
56.176 - assertEquals(field.getName().getName(), "CONSTANT");
56.177 - assertEquals(field.getName().getFullName(), "CONSTANT");
56.178 - assertEquals(field.getModifiers(), Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL);
56.179 - assertEquals(field.getType(), Type.CHAR);
56.180 - assertEquals(field.getInitValue(), "");
56.181 - }
56.182 -
56.183 - public void testFieldTestField() {
56.184 - FieldElement field = clazz.getField(Identifier.create("testField"));
56.185 -
56.186 - assertNotNull(field);
56.187 - assertEquals(field.getName().getName(), "testField");
56.188 - assertEquals(field.getName().getFullName(), "testField");
56.189 - assertEquals(field.getModifiers(), Modifier.PRIVATE);
56.190 - assertEquals(field.getType(), Type.parse("java.lang.Object"));
56.191 - assertEquals(field.getInitValue(),"");
56.192 - }
56.193 -
56.194 - public void testFieldOk() {
56.195 - FieldElement field = clazz.getField(Identifier.create("ok"));
56.196 -
56.197 - assertNotNull(field);
56.198 - assertEquals(field.getName().getName(), "ok");
56.199 - assertEquals(field.getName().getFullName(), "ok");
56.200 - assertEquals(field.getModifiers(), Modifier.PRIVATE);
56.201 - assertEquals(field.getType(), Type.BOOLEAN);
56.202 - assertEquals(field.getInitValue(), "");
56.203 - }
56.204 -
56.205 - public void testConstructors() {
56.206 - assertEquals(clazz.getConstructors().length, 2);
56.207 - }
56.208 -
56.209 - public void testConstructorDefault() {
56.210 - ConstructorElement constr = clazz.getConstructor(new Type[]{});
56.211 -
56.212 - assertNotNull(constr);
56.213 - assertEquals(constr.getName().getName(), "ClazzTest");
56.214 - assertEquals(constr.getName().getFullName(), "ClazzTest");
56.215 - assertEquals(constr.getModifiers(), Modifier.PUBLIC);
56.216 - assertEquals(constr.getParameters().length, 0);
56.217 - assertEquals(constr.getExceptions().length, 0);
56.218 - }
56.219 -
56.220 - public void testConstructorString() {
56.221 - ConstructorElement constr = clazz.getConstructor(new Type[]{Type.parse("java.lang.String")});
56.222 -
56.223 - assertNotNull(constr);
56.224 - assertEquals(constr.getName().getName(), "ClazzTest");
56.225 - assertEquals(constr.getName().getFullName(), "ClazzTest");
56.226 - assertEquals(constr.getModifiers(), Modifier.PUBLIC);
56.227 - assertEquals(constr.getParameters()[0], new MethodParameter(null, Type.parse("java.lang.String"), true));
56.228 - assertEquals(constr.getExceptions()[0], Identifier.create("java.io.IOException"));
56.229 - }
56.230 -
56.231 -
56.232 -
56.233 -
56.234 -
56.235 -
56.236 -}
57.1 --- a/clazz/test/qa-functional/src/org/netbeans/test/clazz/SerNodeTest.java Fri Sep 17 18:36:33 2010 -0400
57.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
57.3 @@ -1,189 +0,0 @@
57.4 -/*
57.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
57.6 - *
57.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
57.8 - *
57.9 - * The contents of this file are subject to the terms of either the GNU
57.10 - * General Public License Version 2 only ("GPL") or the Common
57.11 - * Development and Distribution License("CDDL") (collectively, the
57.12 - * "License"). You may not use this file except in compliance with the
57.13 - * License. You can obtain a copy of the License at
57.14 - * http://www.netbeans.org/cddl-gplv2.html
57.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
57.16 - * specific language governing permissions and limitations under the
57.17 - * License. When distributing the software, include this License Header
57.18 - * Notice in each file and include the License file at
57.19 - * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
57.20 - * particular file as subject to the "Classpath" exception as provided
57.21 - * by Sun in the GPL Version 2 section of the License file that
57.22 - * accompanied this code. If applicable, add the following below the
57.23 - * License Header, with the fields enclosed by brackets [] replaced by
57.24 - * your own identifying information:
57.25 - * "Portions Copyrighted [year] [name of copyright owner]"
57.26 - *
57.27 - * Contributor(s):
57.28 - *
57.29 - * The Original Software is NetBeans. The Initial Developer of the Original
57.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
57.31 - * Microsystems, Inc. All Rights Reserved.
57.32 - *
57.33 - * If you wish your version of this file to be governed by only the CDDL
57.34 - * or only the GPL Version 2, indicate your decision by adding
57.35 - * "[Contributor] elects to include this software in this distribution
57.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
57.37 - * single choice of license, a recipient has the option to distribute
57.38 - * your version of this file under either the CDDL, the GPL Version 2 or
57.39 - * to extend the choice of license to its licensees as provided above.
57.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
57.41 - * Version 2 license, then the option applies only if the new code is
57.42 - * made subject to such option by the copyright holder.
57.43 - */
57.44 -
57.45 -package org.netbeans.test.clazz;
57.46 -
57.47 -import junit.textui.TestRunner;
57.48 -import org.netbeans.jellytools.Bundle;
57.49 -import org.netbeans.jellytools.JellyTestCase;
57.50 -import org.netbeans.jellytools.NbDialogOperator;
57.51 -import org.netbeans.jellytools.RepositoryTabOperator;
57.52 -import org.netbeans.jellytools.nodes.FolderNode;
57.53 -import org.netbeans.jellytools.nodes.JavaNode;
57.54 -import org.netbeans.jellytools.nodes.Node;
57.55 -import org.netbeans.jemmy.EventTool;
57.56 -import org.netbeans.junit.NbTestSuite;
57.57 -import org.openide.filesystems.Repository;
57.58 -import org.openide.loaders.DataFolder;
57.59 -import org.openide.loaders.DataObject;
57.60 -
57.61 -
57.62 -public class SerNodeTest extends JellyTestCase {
57.63 -
57.64 - private static final String NAME_TEST_FILE = "ClazzTest"; //NOI18N
57.65 - private static final String SRC_PACKAGE = "org.netbeans.test"; //NOI18N
57.66 - private static final String DST_PACKAGE = "org.netbeans.test.clazz"; //NOI18N
57.67 -
57.68 - private DataObject srcFile;
57.69 - private DataFolder srcFolder;
57.70 - private String testFSName;
57.71 -
57.72 - {
57.73 - try {
57.74 - srcFolder = DataFolder.findFolder(Repository.getDefault().findResource(SRC_PACKAGE.replace('.','/')));
57.75 - testFSName = Repository.getDefault().findResource(DST_PACKAGE.replace('.', '/')).getFileSystem().getDisplayName();
57.76 - }
57.77 - catch (Exception e) {
57.78 - e.printStackTrace();
57.79 - }
57.80 -
57.81 - }
57.82 -
57.83 - /** Need to be defined because of JUnit */
57.84 - public SerNodeTest(String name) {
57.85 - super(name);
57.86 - }
57.87 -
57.88 - public static NbTestSuite suite() {
57.89 - NbTestSuite suite = new NbTestSuite();
57.90 - suite.addTest(new SerNodeTest("testTree")); //NOI18N
57.91 - return suite;
57.92 - }
57.93 -
57.94 - /** Use for execution inside IDE */
57.95 - public static void main(java.lang.String[] args) {
57.96 - // run whole suite
57.97 - TestRunner.run(suite());
57.98 - // run only selected test case
57.99 - //junit.textui.TestRunner.run(new BeansTemplates("testJavaBean"));
57.100 - }
57.101 -
57.102 - /** setUp method */
57.103 - public void setUp() {
57.104 - System.out.println("######## "+getName()+" #######"); //NOI18N
57.105 - RepositoryTabOperator.invoke();
57.106 - }
57.107 -
57.108 - /** tearDown method */
57.109 - public void tearDown() {
57.110 - deleteSer();
57.111 - }
57.112 -
57.113 - private void createSer() {
57.114 - JavaNode srcNode = new JavaNode(testFSName + '|' + SRC_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE);
57.115 - srcNode.copy();
57.116 -
57.117 - FolderNode dstNode = new FolderNode(testFSName + '|' + DST_PACKAGE.replace('.', '|'));
57.118 - dstNode.performPopupActionNoBlock(Bundle.getStringTrimmed("org.openide.actions.Bundle", "Paste") + '|' + Bundle.getString("org.openide.loaders.Bundle", "CTL_Serialize"));
57.119 - new NbDialogOperator(Bundle.getString("org.openide.loaders.Bundle", "SerializeBean_Title")).ok();
57.120 -
57.121 - new EventTool().waitNoEvent(1000);
57.122 - assertNotNull(Repository.getDefault().findResource(DST_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".ser")); //NOI18N
57.123 -
57.124 - }
57.125 -
57.126 - private void deleteSer() {
57.127 - ClazzNodeTest.delete(DST_PACKAGE.replace('.', '/') + '/' + NAME_TEST_FILE + ".ser"); //NOI18N
57.128 - }
57.129 -
57.130 - public void testTree() {
57.131 - createSer();
57.132 - workaround();
57.133 - dumpNode(new JavaNode(testFSName + '|' + DST_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE), 3);
57.134 - compareReferenceFiles();
57.135 -
57.136 - }
57.137 -
57.138 - private void workaround() {
57.139 - String patterns = Bundle.getString("org.netbeans.modules.beans.Bundle", "Patterns");
57.140 - new JavaNode(testFSName + '|' + DST_PACKAGE.replace('.', '|') + '|' + NAME_TEST_FILE + "|class " + NAME_TEST_FILE + "|" + patterns + "|ok").select();
57.141 - }
57.142 -
57.143 - private int tab = -1;
57.144 -
57.145 - private void writeTabs() {
57.146 - int i=0;
57.147 - while (i++<tab)
57.148 - getRef().print(" ");
57.149 - }
57.150 -
57.151 - private void dumpNode(Node node, int limit) {
57.152 - tab++;
57.153 - writeTabs();
57.154 -
57.155 - String text = node.getText();
57.156 - if (text.startsWith("String country") || text.startsWith("String language")){
57.157 - tab--;
57.158 - return;
57.159 - }
57.160 -
57.161 - if (isLeaf(node) || tab > limit) {
57.162 - getRef().println("<" + text + "/>");
57.163 - tab--;
57.164 - return;
57.165 - }
57.166 -
57.167 - node.expand();
57.168 - node.waitExpanded();
57.169 - String[] names = node.getChildren();
57.170 -
57.171 - getRef().println("<" + text + ">");
57.172 -
57.173 - for (int i=0; i<names.length; i++) {
57.174 - dumpNode(new JavaNode(node.getPath() + "|" + names[i]), limit);
57.175 - }
57.176 -
57.177 - writeTabs();
57.178 -
57.179 - int stop = text.indexOf(' ');
57.180 - if (stop > 0)
57.181 - text = text.substring(0,stop);
57.182 -
57.183 - getRef().println("</" + text + ">");
57.184 -
57.185 - tab--;
57.186 - }
57.187 -
57.188 - private static boolean isLeaf(Node node) {
57.189 - return ((org.openide.nodes.Node) node.getOpenideNode()).isLeaf();
57.190 - }
57.191 -
57.192 -}
58.1 --- a/clazz/test/qa-functional/src/org/netbeans/test/clazz/data/goldenfiles/SerNodeTest/testTree.pass Fri Sep 17 18:36:33 2010 -0400
58.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
58.3 @@ -1,148 +0,0 @@
58.4 -<ClazzTest>
58.5 - <class ClazzTest>
58.6 - <Fields>
58.7 - <CONSTANT/>
58.8 - <ok/>
58.9 - <testField/>
58.10 - </Fields>
58.11 - <Constructors>
58.12 - <ClazzTest(String)/>
58.13 - <ClazzTest()/>
58.14 - </Constructors>
58.15 - <Methods>
58.16 - <initComponents/>
58.17 - <isOk/>
58.18 - <setOk/>
58.19 - <testMethod/>
58.20 - </Methods>
58.21 - <Bean Patterns>
58.22 - <ok/>
58.23 - </Bean>
58.24 - </class>
58.25 - <Serialized stream>
58.26 - <instance of org.netbeans.test.ClazzTest>
58.27 - <int componentSerializedDataVersion = 4/>
58.28 - <boolean enabled = true/>
58.29 - <long eventMask = 4104/>
58.30 - <boolean focusTraversalKeysEnabled = true/>
58.31 - <boolean focusable = true/>
58.32 - <int height = 0/>
58.33 - <boolean ignoreRepaint = false/>
58.34 - <int isFocusTraversableOverridden = 0/>
58.35 - <boolean isPacked = false/>
58.36 - <boolean nameExplicitlySet = false/>
58.37 - <boolean newEventsOnly = true/>
58.38 - <boolean valid = false/>
58.39 - <boolean visible = true/>
58.40 - <int width = 0/>
58.41 - <int x = 0/>
58.42 - <int y = 0/>
58.43 - <javax.accessibility.AccessibleContext accessibleContext = null/>
58.44 - <java.awt.Color background = instance of javax.swing.plaf.ColorUIResource>
58.45 - <float falpha = 0.0/>
58.46 - <int value = -3355444/>
58.47 - <java.awt.color.ColorSpace cs = null/>
58.48 - <float[] frgbvalue = null/>
58.49 - <float[] fvalue = null/>
58.50 - </java.awt.Color>
58.51 - <java.beans.PropertyChangeSupport changeSupport = null/>
58.52 - <java.awt.Cursor cursor = null/>
58.53 - <java.awt.dnd.DropTarget dropTarget = null/>
58.54 - <java.util.Set[] focusTraversalKeys = null/>
58.55 - <java.awt.Font font = instance of javax.swing.plaf.FontUIResource>
58.56 - <int fontSerializedDataVersion = 1/>
58.57 - <float pointSize = 11.0/>
58.58 - <int size = 11/>
58.59 - <int style = 0/>
58.60 - <java.util.Hashtable fRequestedAttributes = instance of java.util.Hashtable/>
58.61 - <String name = "Dialog"/>
58.62 - </java.awt.Font>
58.63 - <java.awt.Color foreground = instance of javax.swing.plaf.ColorUIResource>
58.64 - <float falpha = 0.0/>
58.65 - <int value = -16777216/>
58.66 - <java.awt.color.ColorSpace cs = null/>
58.67 - <float[] frgbvalue = null/>
58.68 - <float[] fvalue = null/>
58.69 - </java.awt.Color>
58.70 - <java.util.Locale locale = instance of java.util.Locale>
58.71 - <int hashcode = -1/>
58.72 - <String variant = ""/>
58.73 - </java.util.Locale>
58.74 - <java.awt.Dimension minSize = null/>
58.75 - <String name = null/>
58.76 - <java.awt.Font peerFont = null/>
58.77 - <java.util.Vector popups = null/>
58.78 - <java.awt.Dimension prefSize = null/>
58.79 - <"focusL"/>
58.80 - <instance of javax.swing.JComponent.EnableSerializationFocusListener>
58.81 - <javax.swing.JComponent this$0 = instance of org.netbeans.test.ClazzTest/>
58.82 - </instance>
58.83 - <javax.accessibility.AccessibleContext accessibleContext = null/>
58.84 - <instance of java.awt.ComponentOrientation>
58.85 - <int orientation = 7/>
58.86 - </instance>
58.87 - <javax.accessibility.AccessibleContext accessibleContext = null/>
58.88 - <javax.accessibility.AccessibleContext accessibleContext = null/>
58.89 - <int containerSerializedDataVersion = 1/>
58.90 - <boolean focusCycleRoot = false/>
58.91 - <int ncomponents = 0/>
58.92 - <java.awt.Component[] component = java.awt.Component[0]>
58.93 - </java.awt.Component[]>
58.94 - <java.awt.LightweightDispatcher dispatcher = null/>
58.95 - <java.awt.LayoutManager layoutMgr = instance of java.awt.BorderLayout>
58.96 - <int hgap = 0/>
58.97 - <int vgap = 0/>
58.98 - <java.awt.Component center = null/>
58.99 - <java.awt.Component east = null/>
58.100 - <java.awt.Component firstItem = null/>
58.101 - <java.awt.Component firstLine = null/>
58.102 - <java.awt.Component lastItem = null/>
58.103 - <java.awt.Component lastLine = null/>
58.104 - <java.awt.Component north = null/>
58.105 - <java.awt.Component south = null/>
58.106 - <java.awt.Component west = null/>
58.107 - </java.awt.LayoutManager>
58.108 - <java.awt.Dimension maxSize = null/>
58.109 - <javax.accessibility.AccessibleContext accessibleContext = null/>
58.110 - <javax.accessibility.AccessibleContext accessibleContext = null/>
58.111 - <int flags = 16393/>
58.112 - <boolean verifyInputWhenFocusTarget = true/>
58.113 - <java.awt.Rectangle _bounds = instance of java.awt.Rectangle>
58.114 - <int height = 0/>
58.115 - <int width = 0/>
58.116 - <int x = 0/>
58.117 - <int y = 0/>
58.118 - </java.awt.Rectangle>
58.119 - <javax.accessibility.AccessibleContext accessibleContext = null/>
58.120 - <javax.swing.ActionMap actionMap = null/>
58.121 - <Float alignmentX = null/>
58.122 - <Float alignmentY = null/>
58.123 - <javax.swing.InputMap ancestorInputMap = null/>
58.124 - <javax.swing.AncestorNotifier ancestorNotifier = null/>
58.125 - <javax.swing.Autoscroller autoscroller = null/>
58.126 - <javax.swing.border.Border border = null/>
58.127 - <javax.swing.event.SwingPropertyChangeSupport changeSupport = null/>
58.128 - <java.util.Hashtable clientProperties = null/>
58.129 - <javax.swing.InputMap focusInputMap = null/>
58.130 - <Object htmlView = null/>
58.131 - <javax.swing.InputVerifier inputVerifier = null/>
58.132 - <javax.swing.event.EventListenerList listenerList = instance of javax.swing.event.EventListenerList>
58.133 - <null/>
58.134 - </javax.swing.event.EventListenerList>
58.135 - <java.awt.Dimension maximumSize = null/>
58.136 - <java.awt.Dimension minimumSize = null/>
58.137 - <java.awt.Rectangle paintImmediatelyClip = instance of java.awt.Rectangle>
58.138 - <int height = 0/>
58.139 - <int width = 0/>
58.140 - <int x = 0/>
58.141 - <int y = 0/>
58.142 - </java.awt.Rectangle>
58.143 - <java.awt.Dimension preferredSize = null/>
58.144 - <javax.swing.TransferHandler transfer = null/>
58.145 - <java.beans.VetoableChangeSupport vetoableChangeSupport = null/>
58.146 - <javax.swing.ComponentInputMap windowInputMap = null/>
58.147 - <boolean ok = false/>
58.148 - <Object testField = null/>
58.149 - </instance>
58.150 - </Serialized>
58.151 -</ClazzTest>