Obsoleted by @ServiceProvider.
authorJesse Glick <jglick@netbeans.org>
Fri, 17 Sep 2010 17:10:30 -0400
changeset 1637863fab4918bb9
parent 16376 33c5b4afbbf8
child 16379 dc1e33f80199
Obsoleted by @ServiceProvider.
apisupport.metainfservices/build.xml
apisupport.metainfservices/manifest.mf
apisupport.metainfservices/nbproject/project.properties
apisupport.metainfservices/nbproject/project.xml
apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/Bundle.properties
apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportAction.java
apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportVisualPanel1.form
apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportVisualPanel1.java
apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportWizardIterator.java
apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportWizardPanel1.java
apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/layer.xml
apisupport.metainfservices/test/unit/src/org/netbeans/modules/apisupport/metainfservices/ExportActionTest.java
     1.1 --- a/apisupport.metainfservices/build.xml	Mon Sep 06 10:27:45 2010 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,46 +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 -<project basedir="." default="netbeans" name="contrib/apisupport.metainfservices">
    1.47 -    <description>Builds, tests, and runs the project org.netbeans.modules.apisupport.metainfservices</description>
    1.48 -    <import file="../../nbbuild/templates/projectized.xml"/>
    1.49 -</project>
     2.1 --- a/apisupport.metainfservices/manifest.mf	Mon Sep 06 10:27:45 2010 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,6 +0,0 @@
     2.4 -Manifest-Version: 1.0
     2.5 -OpenIDE-Module: org.netbeans.modules.apisupport.metainfservices
     2.6 -OpenIDE-Module-Layer: org/netbeans/modules/apisupport/metainfservices/layer.xml
     2.7 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/apisupport/metainfservices/Bundle.properties
     2.8 -OpenIDE-Module-Specification-Version: 1.8
     2.9 -
     3.1 --- a/apisupport.metainfservices/nbproject/project.properties	Mon Sep 06 10:27:45 2010 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,41 +0,0 @@
     3.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3.5 -#
     3.6 -# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     3.7 -#
     3.8 -# The contents of this file are subject to the terms of either the GNU
     3.9 -# General Public License Version 2 only ("GPL") or the Common
    3.10 -# Development and Distribution License("CDDL") (collectively, the
    3.11 -# "License"). You may not use this file except in compliance with the
    3.12 -# License. You can obtain a copy of the License at
    3.13 -# http://www.netbeans.org/cddl-gplv2.html
    3.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    3.15 -# specific language governing permissions and limitations under the
    3.16 -# License.  When distributing the software, include this License Header
    3.17 -# Notice in each file and include the License file at
    3.18 -# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    3.19 -# particular file as subject to the "Classpath" exception as provided
    3.20 -# by Sun in the GPL Version 2 section of the License file that
    3.21 -# accompanied this code. If applicable, add the following below the
    3.22 -# License Header, with the fields enclosed by brackets [] replaced by
    3.23 -# your own identifying information:
    3.24 -# "Portions Copyrighted [year] [name of copyright owner]"
    3.25 -#
    3.26 -# Contributor(s):
    3.27 -#
    3.28 -# The Original Software is NetBeans. The Initial Developer of the Original
    3.29 -# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    3.30 -# Microsystems, Inc. All Rights Reserved.
    3.31 -#
    3.32 -# If you wish your version of this file to be governed by only the CDDL
    3.33 -# or only the GPL Version 2, indicate your decision by adding
    3.34 -# "[Contributor] elects to include this software in this distribution
    3.35 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
    3.36 -# single choice of license, a recipient has the option to distribute
    3.37 -# your version of this file under either the CDDL, the GPL Version 2 or
    3.38 -# to extend the choice of license to its licensees as provided above.
    3.39 -# However, if you add GPL Version 2 code and therefore, elected the GPL
    3.40 -# Version 2 license, then the option applies only if the new code is
    3.41 -# made subject to such option by the copyright holder.
    3.42 -
    3.43 -javac.compilerargs=-Xlint:unchecked
    3.44 -javac.source=1.5
     4.1 --- a/apisupport.metainfservices/nbproject/project.xml	Mon Sep 06 10:27:45 2010 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,152 +0,0 @@
     4.4 -<?xml version="1.0" encoding="UTF-8"?>
     4.5 -<!--
     4.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     4.7 -
     4.8 -Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     4.9 -
    4.10 -
    4.11 -The contents of this file are subject to the terms of either the GNU
    4.12 -General Public License Version 2 only ("GPL") or the Common
    4.13 -Development and Distribution License("CDDL") (collectively, the
    4.14 -"License"). You may not use this file except in compliance with the
    4.15 -License. You can obtain a copy of the License at
    4.16 -http://www.netbeans.org/cddl-gplv2.html
    4.17 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    4.18 -specific language governing permissions and limitations under the
    4.19 -License.  When distributing the software, include this License Header
    4.20 -Notice in each file and include the License file at
    4.21 -nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    4.22 -particular file as subject to the "Classpath" exception as provided
    4.23 -by Sun in the GPL Version 2 section of the License file that
    4.24 -accompanied this code. If applicable, add the following below the
    4.25 -License Header, with the fields enclosed by brackets [] replaced by
    4.26 -your own identifying information:
    4.27 -"Portions Copyrighted [year] [name of copyright owner]"
    4.28 -
    4.29 -Contributor(s):
    4.30 -
    4.31 -The Original Software is NetBeans. The Initial Developer of the Original
    4.32 -Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    4.33 -Microsystems, Inc. All Rights Reserved.
    4.34 -
    4.35 -If you wish your version of this file to be governed by only the CDDL
    4.36 -or only the GPL Version 2, indicate your decision by adding
    4.37 -"[Contributor] elects to include this software in this distribution
    4.38 -under the [CDDL or GPL Version 2] license." If you do not indicate a
    4.39 -single choice of license, a recipient has the option to distribute
    4.40 -your version of this file under either the CDDL, the GPL Version 2 or
    4.41 -to extend the choice of license to its licensees as provided above.
    4.42 -However, if you add GPL Version 2 code and therefore, elected the GPL
    4.43 -Version 2 license, then the option applies only if the new code is
    4.44 -made subject to such option by the copyright holder.
    4.45 --->
    4.46 -<project xmlns="http://www.netbeans.org/ns/project/1">
    4.47 -    <type>org.netbeans.modules.apisupport.project</type>
    4.48 -    <configuration>
    4.49 -        <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
    4.50 -            <code-name-base>org.netbeans.modules.apisupport.metainfservices</code-name-base>
    4.51 -            <module-dependencies>
    4.52 -                <dependency>
    4.53 -                    <code-name-base>org.jdesktop.layout</code-name-base>
    4.54 -                    <build-prerequisite/>
    4.55 -                    <compile-dependency/>
    4.56 -                    <run-dependency>
    4.57 -                        <release-version>1</release-version>
    4.58 -                        <specification-version>1.3</specification-version>
    4.59 -                    </run-dependency>
    4.60 -                </dependency>
    4.61 -                <dependency>
    4.62 -                    <code-name-base>org.netbeans.libs.javacapi</code-name-base>
    4.63 -                    <build-prerequisite/>
    4.64 -                    <compile-dependency/>
    4.65 -                    <run-dependency>
    4.66 -                        <specification-version>0.5</specification-version>
    4.67 -                    </run-dependency>
    4.68 -                </dependency>
    4.69 -                <dependency>
    4.70 -                    <code-name-base>org.netbeans.modules.java.project</code-name-base>
    4.71 -                    <build-prerequisite/>
    4.72 -                    <compile-dependency/>
    4.73 -                    <run-dependency>
    4.74 -                        <release-version>1</release-version>
    4.75 -                        <specification-version>1.8</specification-version>
    4.76 -                    </run-dependency>
    4.77 -                </dependency>
    4.78 -                <dependency>
    4.79 -                    <code-name-base>org.netbeans.modules.java.source</code-name-base>
    4.80 -                    <build-prerequisite/>
    4.81 -                    <compile-dependency/>
    4.82 -                    <run-dependency>
    4.83 -                        <specification-version>0.4</specification-version>
    4.84 -                    </run-dependency>
    4.85 -                </dependency>
    4.86 -                <dependency>
    4.87 -                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
    4.88 -                    <build-prerequisite/>
    4.89 -                    <compile-dependency/>
    4.90 -                    <run-dependency>
    4.91 -                        <release-version>1</release-version>
    4.92 -                        <specification-version>1.8</specification-version>
    4.93 -                    </run-dependency>
    4.94 -                </dependency>
    4.95 -                <dependency>
    4.96 -                    <code-name-base>org.openide.awt</code-name-base>
    4.97 -                    <build-prerequisite/>
    4.98 -                    <compile-dependency/>
    4.99 -                    <run-dependency>
   4.100 -                        <specification-version>6.5</specification-version>
   4.101 -                    </run-dependency>
   4.102 -                </dependency>
   4.103 -                <dependency>
   4.104 -                    <code-name-base>org.openide.dialogs</code-name-base>
   4.105 -                    <build-prerequisite/>
   4.106 -                    <compile-dependency/>
   4.107 -                    <run-dependency>
   4.108 -                        <specification-version>6.5</specification-version>
   4.109 -                    </run-dependency>
   4.110 -                </dependency>
   4.111 -                <dependency>
   4.112 -                    <code-name-base>org.openide.filesystems</code-name-base>
   4.113 -                    <build-prerequisite/>
   4.114 -                    <compile-dependency/>
   4.115 -                    <run-dependency>
   4.116 -                        <specification-version>6.4</specification-version>
   4.117 -                    </run-dependency>
   4.118 -                </dependency>
   4.119 -                <dependency>
   4.120 -                    <code-name-base>org.openide.loaders</code-name-base>
   4.121 -                    <build-prerequisite/>
   4.122 -                    <compile-dependency/>
   4.123 -                    <run-dependency>
   4.124 -                        <specification-version>6.0</specification-version>
   4.125 -                    </run-dependency>
   4.126 -                </dependency>
   4.127 -                <dependency>
   4.128 -                    <code-name-base>org.openide.nodes</code-name-base>
   4.129 -                    <build-prerequisite/>
   4.130 -                    <compile-dependency/>
   4.131 -                    <run-dependency>
   4.132 -                        <specification-version>6.6</specification-version>
   4.133 -                    </run-dependency>
   4.134 -                </dependency>
   4.135 -                <dependency>
   4.136 -                    <code-name-base>org.openide.util</code-name-base>
   4.137 -                    <build-prerequisite/>
   4.138 -                    <compile-dependency/>
   4.139 -                    <run-dependency>
   4.140 -                        <specification-version>8.0</specification-version>
   4.141 -                    </run-dependency>
   4.142 -                </dependency>
   4.143 -                <dependency>
   4.144 -                    <code-name-base>org.openide.util.lookup</code-name-base>
   4.145 -                    <build-prerequisite/>
   4.146 -                    <compile-dependency/>
   4.147 -                    <run-dependency>
   4.148 -                        <specification-version>8.0</specification-version>
   4.149 -                    </run-dependency>
   4.150 -                </dependency>
   4.151 -            </module-dependencies>
   4.152 -            <public-packages/>
   4.153 -        </data>
   4.154 -    </configuration>
   4.155 -</project>
     5.1 --- a/apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/Bundle.properties	Mon Sep 06 10:27:45 2010 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,54 +0,0 @@
     5.4 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     5.5 -#
     5.6 -# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     5.7 -#
     5.8 -# The contents of this file are subject to the terms of either the GNU
     5.9 -# General Public License Version 2 only ("GPL") or the Common
    5.10 -# Development and Distribution License("CDDL") (collectively, the
    5.11 -# "License"). You may not use this file except in compliance with the
    5.12 -# License. You can obtain a copy of the License at
    5.13 -# http://www.netbeans.org/cddl-gplv2.html
    5.14 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    5.15 -# specific language governing permissions and limitations under the
    5.16 -# License.  When distributing the software, include this License Header
    5.17 -# Notice in each file and include the License file at
    5.18 -# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    5.19 -# particular file as subject to the "Classpath" exception as provided
    5.20 -# by Sun in the GPL Version 2 section of the License file that
    5.21 -# accompanied this code. If applicable, add the following below the
    5.22 -# License Header, with the fields enclosed by brackets [] replaced by
    5.23 -# your own identifying information:
    5.24 -# "Portions Copyrighted [year] [name of copyright owner]"
    5.25 -#
    5.26 -# Contributor(s):
    5.27 -#
    5.28 -# The Original Software is NetBeans. The Initial Developer of the Original
    5.29 -# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    5.30 -# Microsystems, Inc. All Rights Reserved.
    5.31 -#
    5.32 -# If you wish your version of this file to be governed by only the CDDL
    5.33 -# or only the GPL Version 2, indicate your decision by adding
    5.34 -# "[Contributor] elects to include this software in this distribution
    5.35 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
    5.36 -# single choice of license, a recipient has the option to distribute
    5.37 -# your version of this file under either the CDDL, the GPL Version 2 or
    5.38 -# to extend the choice of license to its licensees as provided above.
    5.39 -# However, if you add GPL Version 2 code and therefore, elected the GPL
    5.40 -# Version 2 license, then the option applies only if the new code is
    5.41 -# made subject to such option by the copyright holder.
    5.42 -
    5.43 -CTL_ExportAction=Export as a Service...
    5.44 -
    5.45 -MSG_CannotFindClass=Cannot find public class in file {0}.
    5.46 -
    5.47 -OpenIDE-Module-Display-Category=Developing NetBeans
    5.48 -OpenIDE-Module-Long-Description=\
    5.49 -    NetBeans extension point system is built around declarative registation of services using META-INF/services files. \
    5.50 -    This module allows you to select a Java class and "export it as a service" - e.g. generate correct META-INF/services files semi-automatically.
    5.51 -OpenIDE-Module-Name=Export as a Service Wizard
    5.52 -
    5.53 -MSG_MetaInfDescription=This wizard is about to generate a registration file that will allow other\n\
    5.54 -   modules to discover your class using Lookup.getDefault().lookup(SomeInterface.class).\n\
    5.55 -   Please select one or more interfaces that you wish to export your class\n\
    5.56 -   as.\n
    5.57 -OpenIDE-Module-Short-Description=Simplifies creation of META-INF/services registrations
     6.1 --- a/apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportAction.java	Mon Sep 06 10:27:45 2010 +0200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,243 +0,0 @@
     6.4 -/*
     6.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     6.6 - *
     6.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     6.8 - *
     6.9 - * The contents of this file are subject to the terms of either the GNU
    6.10 - * General Public License Version 2 only ("GPL") or the Common
    6.11 - * Development and Distribution License("CDDL") (collectively, the
    6.12 - * "License"). You may not use this file except in compliance with the
    6.13 - * License. You can obtain a copy of the License at
    6.14 - * http://www.netbeans.org/cddl-gplv2.html
    6.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    6.16 - * specific language governing permissions and limitations under the
    6.17 - * License.  When distributing the software, include this License Header
    6.18 - * Notice in each file and include the License file at
    6.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    6.20 - * particular file as subject to the "Classpath" exception as provided
    6.21 - * by Sun in the GPL Version 2 section of the License file that
    6.22 - * accompanied this code. If applicable, add the following below the
    6.23 - * License Header, with the fields enclosed by brackets [] replaced by
    6.24 - * your own identifying information:
    6.25 - * "Portions Copyrighted [year] [name of copyright owner]"
    6.26 - *
    6.27 - * Contributor(s):
    6.28 - *
    6.29 - * The Original Software is NetBeans. The Initial Developer of the Original
    6.30 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    6.31 - * Microsystems, Inc. All Rights Reserved.
    6.32 - *
    6.33 - * If you wish your version of this file to be governed by only the CDDL
    6.34 - * or only the GPL Version 2, indicate your decision by adding
    6.35 - * "[Contributor] elects to include this software in this distribution
    6.36 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    6.37 - * single choice of license, a recipient has the option to distribute
    6.38 - * your version of this file under either the CDDL, the GPL Version 2 or
    6.39 - * to extend the choice of license to its licensees as provided above.
    6.40 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    6.41 - * Version 2 license, then the option applies only if the new code is
    6.42 - * made subject to such option by the copyright holder.
    6.43 - */
    6.44 -package org.netbeans.modules.apisupport.metainfservices;
    6.45 -
    6.46 -import com.sun.source.tree.Tree;
    6.47 -import com.sun.source.util.TreePath;
    6.48 -import java.awt.Dialog;
    6.49 -import java.io.FileNotFoundException;
    6.50 -import java.io.IOException;
    6.51 -import java.io.InputStream;
    6.52 -import java.io.OutputStream;
    6.53 -import java.util.Collection;
    6.54 -import java.util.List;
    6.55 -import java.util.TreeSet;
    6.56 -import java.util.logging.Level;
    6.57 -import java.util.logging.Logger;
    6.58 -import javax.lang.model.element.Element;
    6.59 -import javax.lang.model.element.TypeElement;
    6.60 -import javax.lang.model.type.TypeMirror;
    6.61 -import org.netbeans.api.java.project.JavaProjectConstants;
    6.62 -import org.netbeans.api.java.source.CancellableTask;
    6.63 -import org.netbeans.api.java.source.CompilationController;
    6.64 -import org.netbeans.api.java.source.JavaSource;
    6.65 -import org.netbeans.api.project.FileOwnerQuery;
    6.66 -import org.netbeans.api.project.Project;
    6.67 -import org.netbeans.api.project.ProjectUtils;
    6.68 -import org.netbeans.api.project.SourceGroup;
    6.69 -import org.netbeans.api.project.Sources;
    6.70 -import org.openide.DialogDisplayer;
    6.71 -import org.openide.ErrorManager;
    6.72 -import org.openide.NotifyDescriptor;
    6.73 -import org.openide.WizardDescriptor;
    6.74 -import org.openide.filesystems.FileLock;
    6.75 -import org.openide.filesystems.FileObject;
    6.76 -import org.openide.filesystems.FileUtil;
    6.77 -import org.openide.loaders.DataObject;
    6.78 -import org.openide.nodes.Node;
    6.79 -import org.openide.util.HelpCtx;
    6.80 -import org.openide.util.NbBundle;
    6.81 -import org.openide.util.actions.CookieAction;
    6.82 -
    6.83 -public final class ExportAction extends CookieAction {
    6.84 -    private static final Logger LOG = Logger.getLogger(ExportAction.class.getName());
    6.85 -    
    6.86 -    protected void performAction(Node[] activatedNodes) {
    6.87 -        MyTask task = new ExportAction.MyTask();
    6.88 -        FileObject fo = activatedNodes[0].getLookup().lookup(org.openide.filesystems.FileObject.class);
    6.89 -        if (fo == null) {
    6.90 -            return;
    6.91 -        }
    6.92 -        try {
    6.93 -            JavaSource source = JavaSource.forFileObject(fo);
    6.94 -            source.runUserActionTask(task, true);
    6.95 -        } catch (IOException ex) {
    6.96 -            LOG.log(Level.SEVERE, ex.getMessage(), ex);
    6.97 -        }
    6.98 -
    6.99 -        task.postProcess(fo);
   6.100 -    }
   6.101 -
   6.102 -    protected int mode() {
   6.103 -        return CookieAction.MODE_EXACTLY_ONE;
   6.104 -    }
   6.105 -    
   6.106 -    public String getName() {
   6.107 -        return NbBundle.getMessage(ExportAction.class, "CTL_ExportAction");
   6.108 -    }
   6.109 -    
   6.110 -    protected Class[] cookieClasses() {
   6.111 -        return new Class[] {
   6.112 -            DataObject.class
   6.113 -        };
   6.114 -    }
   6.115 -    
   6.116 -    protected void initialize() {
   6.117 -        super.initialize();
   6.118 -        // see org.openide.util.actions.SystemAction.iconResource() javadoc for more details
   6.119 -        putValue("noIconInMenu", Boolean.TRUE);
   6.120 -    }
   6.121 -    
   6.122 -    public HelpCtx getHelpCtx() {
   6.123 -        return HelpCtx.DEFAULT_HELP;
   6.124 -    }
   6.125 -    
   6.126 -    protected boolean asynchronous() {
   6.127 -        return false;
   6.128 -    }
   6.129 -
   6.130 -    private static final class MyTask implements CancellableTask<CompilationController> {
   6.131 -        Collection<String> allInterfaces = new TreeSet<String>();
   6.132 -        String clazzName;
   6.133 -        
   6.134 -        public void cancel() {
   6.135 -        }
   6.136 -
   6.137 -        public void run(CompilationController cont) throws Exception {
   6.138 -            cont.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
   6.139 -            for (Tree t : cont.getCompilationUnit().getTypeDecls()) {
   6.140 -                if (t.getKind() == Tree.Kind.CLASS) {
   6.141 -                    TreePath path = cont.getTrees().getPath(cont.getCompilationUnit(), t);
   6.142 -                    Element e = cont.getTrees().getElement(path);
   6.143 -                    if (e instanceof TypeElement) {
   6.144 -                        TypeElement te = (TypeElement)e;
   6.145 -                        clazzName = te.getQualifiedName().toString();
   6.146 -                    }
   6.147 -                    findInterfaces(cont, e);
   6.148 -                }
   6.149 -            }
   6.150 -        }
   6.151 -        
   6.152 -        private void findInterfaces(CompilationController cont, Element e) {
   6.153 -            if (e == null) {
   6.154 -                return;
   6.155 -            }
   6.156 -            if (!e.getKind().isClass() && !e.getKind().isInterface()) {
   6.157 -                return;
   6.158 -            }
   6.159 -            TypeElement type = (TypeElement)e;
   6.160 -            allInterfaces.add(type.getQualifiedName().toString());
   6.161 -            
   6.162 -            findInterfaces(cont, type.getSuperclass());
   6.163 -            for (TypeMirror m : type.getInterfaces()) {
   6.164 -                findInterfaces(cont, m);
   6.165 -            }
   6.166 -        }
   6.167 -        
   6.168 -        private void findInterfaces(CompilationController cont, TypeMirror m) {
   6.169 -            findInterfaces(cont, cont.getTypes().asElement(m));
   6.170 -        }
   6.171 -
   6.172 -        public void postProcess(FileObject fo) {
   6.173 -            FileObject target = null;
   6.174 -            Project p = FileOwnerQuery.getOwner(fo);
   6.175 -
   6.176 -            if (p != null) {
   6.177 -                Sources s = ProjectUtils.getSources(p);
   6.178 -                SourceGroup[] arr = s.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
   6.179 -                if (arr != null && arr.length > 0) {
   6.180 -                    target = arr[0].getRootFolder();
   6.181 -                }
   6.182 -            }
   6.183 -
   6.184 -
   6.185 -            if (allInterfaces.isEmpty() || clazzName == null) {
   6.186 -                NotifyDescriptor d = new NotifyDescriptor.Message(
   6.187 -                    NbBundle.getMessage(ExportAction.class, "MSG_CannotFindClass", fo),
   6.188 -                    NotifyDescriptor.WARNING_MESSAGE
   6.189 -                );
   6.190 -                DialogDisplayer.getDefault().notify(d);
   6.191 -                return;
   6.192 -            }
   6.193 -
   6.194 -            WizardDescriptor wd = new WizardDescriptor(new ExportWizardIterator());
   6.195 -
   6.196 -            wd.putProperty("implName", clazzName); // NOI18N
   6.197 -            wd.putProperty("interfaceNames", allInterfaces); // NOI18N
   6.198 -            wd.putProperty("target", target);
   6.199 -
   6.200 -            Dialog d = DialogDisplayer.getDefault().createDialog(wd);
   6.201 -            d.setVisible(true);
   6.202 -
   6.203 -            if (wd.FINISH_OPTION == wd.getValue()) {
   6.204 -                try {
   6.205 -                    createFiles(clazzName, wd, target);
   6.206 -                } catch (IOException ex) {
   6.207 -                    ErrorManager.getDefault().notify(ex);
   6.208 -                }
   6.209 -            }
   6.210 -        }
   6.211 -    }
   6.212 -    
   6.213 -    @SuppressWarnings("unchecked")
   6.214 -    private static void createFiles(String implName, WizardDescriptor wd, FileObject target)
   6.215 -    throws IOException, FileNotFoundException {
   6.216 -        List<String> files = (List<String>)wd.getProperty("files"); // NOI18N
   6.217 -        createFiles(implName, files, target);
   6.218 -    }
   6.219 -
   6.220 -    static void createFiles(String implName, List<String> files, FileObject target)
   6.221 -    throws IOException, FileNotFoundException {
   6.222 -        // lets apply the files
   6.223 -        for (String s : files) {
   6.224 -            FileObject f = FileUtil.createData(target, s);
   6.225 -            byte[] exist = new byte[(int)f.getSize()];
   6.226 -            InputStream is = f.getInputStream();
   6.227 -            int len = is.read(exist);
   6.228 -            is.close();
   6.229 -            //assert len == exist.length;
   6.230 -
   6.231 -            String content = new String(exist);
   6.232 -            if (content.length() > 0 && !content.endsWith("\n")) { // NOI18N
   6.233 -                content = content + "\n"; // NOI18N
   6.234 -            }
   6.235 -
   6.236 -            content = content + implName + "\n"; // NOI18N
   6.237 -
   6.238 -            FileLock lock = f.lock();
   6.239 -            OutputStream os = f.getOutputStream(lock);
   6.240 -            os.write(content.getBytes());
   6.241 -            os.close();
   6.242 -            lock.releaseLock();
   6.243 -        }
   6.244 -    }
   6.245 -}
   6.246 -
     7.1 --- a/apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportVisualPanel1.form	Mon Sep 06 10:27:45 2010 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,98 +0,0 @@
     7.4 -<?xml version="1.0" encoding="UTF-8" ?>
     7.5 -
     7.6 -<Form version="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
     7.7 -  <AuxValues>
     7.8 -    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
     7.9 -    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
    7.10 -    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
    7.11 -    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
    7.12 -    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
    7.13 -  </AuxValues>
    7.14 -
    7.15 -  <Layout>
    7.16 -    <DimensionLayout dim="0">
    7.17 -      <Group type="103" groupAlignment="0" attributes="0">
    7.18 -          <Group type="102" alignment="0" attributes="0">
    7.19 -              <EmptySpace max="-2" attributes="0"/>
    7.20 -              <Group type="103" groupAlignment="0" attributes="0">
    7.21 -                  <Component id="jScrollPane2" alignment="1" pref="496" max="32767" attributes="1"/>
    7.22 -                  <Component id="description" alignment="1" max="32767" attributes="1"/>
    7.23 -                  <Component id="jScrollPane1" alignment="1" pref="496" max="32767" attributes="0"/>
    7.24 -                  <Component id="generatedLabel" alignment="0" min="-2" max="-2" attributes="0"/>
    7.25 -              </Group>
    7.26 -              <EmptySpace max="-2" attributes="0"/>
    7.27 -          </Group>
    7.28 -      </Group>
    7.29 -    </DimensionLayout>
    7.30 -    <DimensionLayout dim="1">
    7.31 -      <Group type="103" groupAlignment="0" attributes="0">
    7.32 -          <Group type="102" alignment="0" attributes="0">
    7.33 -              <EmptySpace max="-2" attributes="0"/>
    7.34 -              <Component id="description" min="-2" max="-2" attributes="0"/>
    7.35 -              <EmptySpace max="-2" attributes="0"/>
    7.36 -              <Component id="jScrollPane2" min="-2" pref="202" max="-2" attributes="0"/>
    7.37 -              <EmptySpace max="-2" attributes="0"/>
    7.38 -              <Component id="generatedLabel" min="-2" max="-2" attributes="0"/>
    7.39 -              <EmptySpace max="-2" attributes="0"/>
    7.40 -              <Component id="jScrollPane1" min="-2" pref="103" max="-2" attributes="0"/>
    7.41 -              <EmptySpace max="-2" attributes="0"/>
    7.42 -          </Group>
    7.43 -      </Group>
    7.44 -    </DimensionLayout>
    7.45 -  </Layout>
    7.46 -  <SubComponents>
    7.47 -    <Container class="javax.swing.JScrollPane" name="jScrollPane2">
    7.48 -      <Properties>
    7.49 -        <Property name="focusCycleRoot" type="boolean" value="true"/>
    7.50 -      </Properties>
    7.51 -      <AuxValues>
    7.52 -        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
    7.53 -      </AuxValues>
    7.54 -
    7.55 -      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
    7.56 -      <SubComponents>
    7.57 -        <Component class="javax.swing.JTable" name="table">
    7.58 -          <Properties>
    7.59 -            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
    7.60 -              <Table columnCount="2" rowCount="0">
    7.61 -                <Column editable="true" title="Export this interface?" type="java.lang.Boolean"/>
    7.62 -                <Column editable="false" title="Class Name" type="java.lang.String"/>
    7.63 -              </Table>
    7.64 -            </Property>
    7.65 -          </Properties>
    7.66 -        </Component>
    7.67 -      </SubComponents>
    7.68 -    </Container>
    7.69 -    <Component class="javax.swing.JTextArea" name="description">
    7.70 -      <Properties>
    7.71 -        <Property name="columns" type="int" value="20"/>
    7.72 -        <Property name="editable" type="boolean" value="false"/>
    7.73 -        <Property name="rows" type="int" value="5"/>
    7.74 -        <Property name="text" type="java.lang.String" value="This wizard is about to generate a registration file that will allow other&#xa;modules to discover your class using Lookup.getDefault().lookup(SomeInterface.class).&#xa;Please select one or more interfaces that you which to export your class&#xa;as."/>
    7.75 -        <Property name="enabled" type="boolean" value="false"/>
    7.76 -      </Properties>
    7.77 -    </Component>
    7.78 -    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
    7.79 -      <AuxValues>
    7.80 -        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
    7.81 -      </AuxValues>
    7.82 -
    7.83 -      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
    7.84 -      <SubComponents>
    7.85 -        <Component class="javax.swing.JTextArea" name="generated">
    7.86 -          <Properties>
    7.87 -            <Property name="columns" type="int" value="20"/>
    7.88 -            <Property name="editable" type="boolean" value="false"/>
    7.89 -            <Property name="rows" type="int" value="5"/>
    7.90 -            <Property name="enabled" type="boolean" value="false"/>
    7.91 -          </Properties>
    7.92 -        </Component>
    7.93 -      </SubComponents>
    7.94 -    </Container>
    7.95 -    <Component class="javax.swing.JLabel" name="generatedLabel">
    7.96 -      <Properties>
    7.97 -        <Property name="text" type="java.lang.String" value="Generated Files:"/>
    7.98 -      </Properties>
    7.99 -    </Component>
   7.100 -  </SubComponents>
   7.101 -</Form>
     8.1 --- a/apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportVisualPanel1.java	Mon Sep 06 10:27:45 2010 +0200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,214 +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 -package org.netbeans.modules.apisupport.metainfservices;
    8.45 -
    8.46 -import java.io.File;
    8.47 -import java.util.ArrayList;
    8.48 -import java.util.Collection;
    8.49 -import java.util.List;
    8.50 -import javax.swing.JPanel;
    8.51 -import javax.swing.event.TableModelEvent;
    8.52 -import javax.swing.event.TableModelListener;
    8.53 -import javax.swing.table.DefaultTableModel;
    8.54 -
    8.55 -public final class ExportVisualPanel1 extends JPanel
    8.56 -implements TableModelListener{
    8.57 -    private List<String> files;
    8.58 -
    8.59 -    ExportWizardPanel1 panel;
    8.60 -    /** Creates new form ExportVisualPanel1 */
    8.61 -    public ExportVisualPanel1(ExportWizardPanel1 panel) {
    8.62 -        this.panel = panel;
    8.63 -        initComponents();
    8.64 -
    8.65 -        tableChanged(null);
    8.66 -    }
    8.67 -    
    8.68 -    public String getName() {
    8.69 -        return "Select Inteface to Export";
    8.70 -    }
    8.71 -
    8.72 -    final void fillTable(Collection<String> interfaces) {
    8.73 -        DefaultTableModel t = (DefaultTableModel)table.getModel();
    8.74 -        if (t.getRowCount() > 0) {
    8.75 -            return;
    8.76 -        }
    8.77 -
    8.78 -        for (String s : interfaces) {
    8.79 -            t.addRow(new Object[] { Boolean.FALSE, s });
    8.80 -        }
    8.81 -
    8.82 -        t.addTableModelListener(this);
    8.83 -    }
    8.84 -
    8.85 -    final List<String> generatedFiles() {
    8.86 -        return files;
    8.87 -    }
    8.88 -
    8.89 -
    8.90 -    public void tableChanged(TableModelEvent e) {
    8.91 -        StringBuffer modifiedFiles = new StringBuffer();
    8.92 -        List<String> f = new ArrayList<String>();
    8.93 -
    8.94 -        boolean one = false;
    8.95 -        DefaultTableModel t = (DefaultTableModel)table.getModel();
    8.96 -        for (int i = 0; i < t.getRowCount(); i++) {
    8.97 -            Boolean b = (Boolean)t.getValueAt(i, 0);
    8.98 -            if (Boolean.TRUE.equals(b)) {
    8.99 -                one = true;
   8.100 -                modifiedFiles.append(panel.getTarget().getPath())
   8.101 -                .append(File.separatorChar)
   8.102 -                .append("META-INF")
   8.103 -                .append(File.separatorChar)
   8.104 -                .append("services")
   8.105 -                .append(File.separatorChar)
   8.106 -                .append(t.getValueAt(i, 1).toString())
   8.107 -                .append("\n");
   8.108 -
   8.109 -                f.add("META-INF/services/" + t.getValueAt(i, 1).toString());
   8.110 -            }
   8.111 -        }
   8.112 -        panel.setValid(one);
   8.113 -
   8.114 -        generated.setText(modifiedFiles.toString());
   8.115 -
   8.116 -        files = f;
   8.117 -    }
   8.118 -
   8.119 -    /** This method is called from within the constructor to
   8.120 -     * initialize the form.
   8.121 -     * WARNING: Do NOT modify this code. The content of this method is
   8.122 -     * always regenerated by the Form Editor.
   8.123 -     */
   8.124 -    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
   8.125 -    private void initComponents() {
   8.126 -
   8.127 -        jScrollPane2 = new javax.swing.JScrollPane();
   8.128 -        table = new javax.swing.JTable();
   8.129 -        description = new javax.swing.JTextArea();
   8.130 -        jScrollPane1 = new javax.swing.JScrollPane();
   8.131 -        generated = new javax.swing.JTextArea();
   8.132 -        generatedLabel = new javax.swing.JLabel();
   8.133 -
   8.134 -        jScrollPane2.setFocusCycleRoot(true);
   8.135 -
   8.136 -        table.setModel(new javax.swing.table.DefaultTableModel(
   8.137 -            new Object [][] {
   8.138 -
   8.139 -            },
   8.140 -            new String [] {
   8.141 -                "Export this interface?", "Class Name"
   8.142 -            }
   8.143 -        ) {
   8.144 -            Class[] types = new Class [] {
   8.145 -                java.lang.Boolean.class, java.lang.String.class
   8.146 -            };
   8.147 -            boolean[] canEdit = new boolean [] {
   8.148 -                true, false
   8.149 -            };
   8.150 -
   8.151 -            public Class getColumnClass(int columnIndex) {
   8.152 -                return types [columnIndex];
   8.153 -            }
   8.154 -
   8.155 -            public boolean isCellEditable(int rowIndex, int columnIndex) {
   8.156 -                return canEdit [columnIndex];
   8.157 -            }
   8.158 -        });
   8.159 -        jScrollPane2.setViewportView(table);
   8.160 -
   8.161 -        description.setColumns(20);
   8.162 -        description.setEditable(false);
   8.163 -        description.setRows(5);
   8.164 -        description.setText("This wizard is about to generate a registration file that will allow other\nmodules to discover your class using Lookup.getDefault().lookup(SomeInterface.class).\nPlease select one or more interfaces that you which to export your class\nas.");
   8.165 -        description.setEnabled(false);
   8.166 -
   8.167 -        generated.setColumns(20);
   8.168 -        generated.setEditable(false);
   8.169 -        generated.setRows(5);
   8.170 -        generated.setEnabled(false);
   8.171 -        jScrollPane1.setViewportView(generated);
   8.172 -
   8.173 -        org.openide.awt.Mnemonics.setLocalizedText(generatedLabel, "Generated Files:");
   8.174 -
   8.175 -        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
   8.176 -        this.setLayout(layout);
   8.177 -        layout.setHorizontalGroup(
   8.178 -            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
   8.179 -            .add(layout.createSequentialGroup()
   8.180 -                .addContainerGap()
   8.181 -                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
   8.182 -                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 496, Short.MAX_VALUE)
   8.183 -                    .add(org.jdesktop.layout.GroupLayout.TRAILING, description)
   8.184 -                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 496, Short.MAX_VALUE)
   8.185 -                    .add(generatedLabel))
   8.186 -                .addContainerGap())
   8.187 -        );
   8.188 -        layout.setVerticalGroup(
   8.189 -            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
   8.190 -            .add(layout.createSequentialGroup()
   8.191 -                .addContainerGap()
   8.192 -                .add(description, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
   8.193 -                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
   8.194 -                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 202, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
   8.195 -                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
   8.196 -                .add(generatedLabel)
   8.197 -                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
   8.198 -                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
   8.199 -                .addContainerGap())
   8.200 -        );
   8.201 -    }// </editor-fold>//GEN-END:initComponents
   8.202 -    
   8.203 -    
   8.204 -    // Variables declaration - do not modify//GEN-BEGIN:variables
   8.205 -    private javax.swing.JTextArea description;
   8.206 -    private javax.swing.JTextArea generated;
   8.207 -    private javax.swing.JLabel generatedLabel;
   8.208 -    private javax.swing.JScrollPane jScrollPane1;
   8.209 -    private javax.swing.JScrollPane jScrollPane2;
   8.210 -    private javax.swing.JTable table;
   8.211 -    // End of variables declaration//GEN-END:variables
   8.212 -
   8.213 -
   8.214 -
   8.215 -
   8.216 -}
   8.217 -
     9.1 --- a/apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportWizardIterator.java	Mon Sep 06 10:27:45 2010 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,166 +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 -package org.netbeans.modules.apisupport.metainfservices;
    9.45 -
    9.46 -import java.awt.Component;
    9.47 -import java.util.NoSuchElementException;
    9.48 -import javax.swing.JComponent;
    9.49 -import javax.swing.event.ChangeListener;
    9.50 -import org.openide.WizardDescriptor;
    9.51 -
    9.52 -public final class ExportWizardIterator implements WizardDescriptor.Iterator<WizardDescriptor> {
    9.53 -
    9.54 -    // To invoke this wizard, copy-paste and run the following code, e.g. from
    9.55 -    // SomeAction.performAction():
    9.56 -    /*
    9.57 -    WizardDescriptor.Iterator iterator = new ExportWizardIterator();
    9.58 -    WizardDescriptor wizardDescriptor = new WizardDescriptor(iterator);
    9.59 -    // {0} will be replaced by WizardDescriptor.Panel.getComponent().getName()
    9.60 -    // {1} will be replaced by WizardDescriptor.Iterator.name()
    9.61 -    wizardDescriptor.setTitleFormat(new MessageFormat("{0} ({1})"));
    9.62 -    wizardDescriptor.setTitle("Your wizard dialog title here");
    9.63 -    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    9.64 -    dialog.setVisible(true);
    9.65 -    dialog.toFront();
    9.66 -    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    9.67 -    if (!cancelled) {
    9.68 -        // do something
    9.69 -    }
    9.70 -     */
    9.71 -    
    9.72 -    private int index;
    9.73 -    
    9.74 -    private ExportWizardPanel1[] panels;
    9.75 -    
    9.76 -    /**
    9.77 -     * Initialize panels representing individual wizard's steps and sets
    9.78 -     * various properties for them influencing wizard appearance.
    9.79 -     */
    9.80 -    private ExportWizardPanel1[] getPanels() {
    9.81 -        if (panels == null) {
    9.82 -            panels = new ExportWizardPanel1[] {
    9.83 -                new ExportWizardPanel1(),
    9.84 -            };
    9.85 -            String[] steps = new String[panels.length];
    9.86 -            for (int i = 0; i < panels.length; i++) {
    9.87 -                Component c = panels[i].getComponent();
    9.88 -                // Default step name to component name of panel.
    9.89 -                steps[i] = c.getName();
    9.90 -                if (c instanceof JComponent) { // assume Swing components
    9.91 -                    JComponent jc = (JComponent) c;
    9.92 -                    // Sets step number of a component
    9.93 -                    jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
    9.94 -                    // Sets steps names for a panel
    9.95 -                    jc.putClientProperty("WizardPanel_contentData", steps);
    9.96 -                    // Turn on subtitle creation on each step
    9.97 -                    jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
    9.98 -                    // Show steps on the left side with the image on the background
    9.99 -                    jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
   9.100 -                    // Turn on numbering of all steps
   9.101 -                    jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
   9.102 -                }
   9.103 -            }
   9.104 -        }
   9.105 -        return panels;
   9.106 -    }
   9.107 -    
   9.108 -    public WizardDescriptor.Panel<WizardDescriptor> current() {
   9.109 -        return getPanels()[index];
   9.110 -    }
   9.111 -    
   9.112 -    public String name() {
   9.113 -        return index + 1 + ". from " + getPanels().length;
   9.114 -    }
   9.115 -    
   9.116 -    public boolean hasNext() {
   9.117 -        return index < getPanels().length - 1;
   9.118 -    }
   9.119 -    
   9.120 -    public boolean hasPrevious() {
   9.121 -        return index > 0;
   9.122 -    }
   9.123 -    
   9.124 -    public void nextPanel() {
   9.125 -        if (!hasNext()) {
   9.126 -            throw new NoSuchElementException();
   9.127 -        }
   9.128 -        index++;
   9.129 -    }
   9.130 -    
   9.131 -    public void previousPanel() {
   9.132 -        if (!hasPrevious()) {
   9.133 -            throw new NoSuchElementException();
   9.134 -        }
   9.135 -        index--;
   9.136 -    }
   9.137 -    
   9.138 -    // If nothing unusual changes in the middle of the wizard, simply:
   9.139 -    public void addChangeListener(ChangeListener l) {}
   9.140 -    public void removeChangeListener(ChangeListener l) {}
   9.141 -    
   9.142 -    // If something changes dynamically (besides moving between panels), e.g.
   9.143 -    // the number of panels changes in response to user input, then uncomment
   9.144 -    // the following and call when needed: fireChangeEvent();
   9.145 -    /*
   9.146 -    private Set<ChangeListener> listeners = new HashSet<ChangeListener>(1);
   9.147 -    public final void addChangeListener(ChangeListener l) {
   9.148 -        synchronized (listeners) {
   9.149 -            listeners.add(l);
   9.150 -        }
   9.151 -    }
   9.152 -    public final void removeChangeListener(ChangeListener l) {
   9.153 -        synchronized (listeners) {
   9.154 -            listeners.remove(l);
   9.155 -        }
   9.156 -    }
   9.157 -    protected final void fireChangeEvent() {
   9.158 -        Iterator<ChangeListener> it;
   9.159 -        synchronized (listeners) {
   9.160 -            it = new HashSet<ChangeListener>(listeners).iterator();
   9.161 -        }
   9.162 -        ChangeEvent ev = new ChangeEvent(this);
   9.163 -        while (it.hasNext()) {
   9.164 -            it.next().stateChanged(ev);
   9.165 -        }
   9.166 -    }
   9.167 -     */
   9.168 -    
   9.169 -}
    10.1 --- a/apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/ExportWizardPanel1.java	Mon Sep 06 10:27:45 2010 +0200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,129 +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 -package org.netbeans.modules.apisupport.metainfservices;
   10.45 -
   10.46 -import java.awt.Component;
   10.47 -import java.util.*;
   10.48 -import javax.swing.event.ChangeEvent;
   10.49 -import javax.swing.event.ChangeListener;
   10.50 -import org.openide.WizardDescriptor;
   10.51 -import org.openide.util.HelpCtx;
   10.52 -import org.openide.filesystems.FileObject;
   10.53 -
   10.54 -public class ExportWizardPanel1 implements WizardDescriptor.Panel<WizardDescriptor> {
   10.55 -
   10.56 -    /**
   10.57 -     * The visual component that displays this panel. If you need to access the
   10.58 -     * component from this class, just use getComponent().
   10.59 -     */
   10.60 -    private ExportVisualPanel1 component;
   10.61 -
   10.62 -    private boolean valid;
   10.63 -    private FileObject target;
   10.64 -
   10.65 -    // Get the visual component for the panel. In this template, the component
   10.66 -    // is kept separate. This can be more efficient: if the wizard is created
   10.67 -    // but never displayed, or not all panels are displayed, it is better to
   10.68 -    // create only those which really need to be visible.
   10.69 -    public Component getComponent() {
   10.70 -        if (component == null) {
   10.71 -            component = new ExportVisualPanel1(this);
   10.72 -        }
   10.73 -        return component;
   10.74 -    }
   10.75 -    
   10.76 -    public HelpCtx getHelp() {
   10.77 -        // Show no Help button for this panel:
   10.78 -        return HelpCtx.DEFAULT_HELP;
   10.79 -        // If you have context help:
   10.80 -        // return new HelpCtx(SampleWizardPanel1.class);
   10.81 -    }
   10.82 -
   10.83 -    final FileObject getTarget() {
   10.84 -        return target;
   10.85 -    }
   10.86 -    
   10.87 -    public boolean isValid() {
   10.88 -        return valid;
   10.89 -    }
   10.90 -
   10.91 -    final void setValid(boolean b) {
   10.92 -        this.valid = b;
   10.93 -        fireChangeEvent();
   10.94 -    }
   10.95 -    private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(11);
   10.96 -    public final void addChangeListener(ChangeListener l) {
   10.97 -        synchronized (listeners) {
   10.98 -            listeners.add(l);
   10.99 -        }
  10.100 -    }
  10.101 -    public final void removeChangeListener(ChangeListener l) {
  10.102 -        synchronized (listeners) {
  10.103 -            listeners.remove(l);
  10.104 -        }
  10.105 -    }
  10.106 -    protected final void fireChangeEvent() {
  10.107 -        Iterator<ChangeListener> it;
  10.108 -        synchronized (listeners) {
  10.109 -            it = new HashSet<ChangeListener>(listeners).iterator();
  10.110 -        }
  10.111 -        ChangeEvent ev = new ChangeEvent(this);
  10.112 -        while (it.hasNext()) {
  10.113 -            it.next().stateChanged(ev);
  10.114 -        }
  10.115 -    }
  10.116 -    
  10.117 -    public void readSettings(WizardDescriptor wd) {
  10.118 -        String impl = (String)wd.getProperty("implName"); // NOI18N
  10.119 -        @SuppressWarnings("unchecked")
  10.120 -        Collection<String> interfaces = (Collection<String>)wd.getProperty("interfaceNames"); // NOI18N
  10.121 -        target = (FileObject)wd.getProperty("target"); // NOI18N
  10.122 -
  10.123 -        if (component != null) {
  10.124 -            component.fillTable(interfaces);
  10.125 -        }
  10.126 -    }
  10.127 -    public void storeSettings(WizardDescriptor wd) {
  10.128 -        wd.putProperty("files", component.generatedFiles());
  10.129 -    }
  10.130 -    
  10.131 -}
  10.132 -
    11.1 --- a/apisupport.metainfservices/src/org/netbeans/modules/apisupport/metainfservices/layer.xml	Mon Sep 06 10:27:45 2010 +0200
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,33 +0,0 @@
    11.4 -<?xml version="1.0" encoding="UTF-8"?>
    11.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
    11.6 -<filesystem>
    11.7 -    <folder name="Actions">
    11.8 -        <folder name="Tools">
    11.9 -            <file name="org-netbeans-modules-apisupport-metainfservices-ExportAction.instance"/>
   11.10 -        </folder>
   11.11 -    </folder>
   11.12 -    <folder name="Editors">
   11.13 -        <folder name="text">
   11.14 -            <folder name="x-java">
   11.15 -                <folder name="Popup">
   11.16 -                    <file name="org-netbeans-modules-apisupport-metainfservices-ExportAction.shadow">
   11.17 -                        <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-modules-apisupport-metainfservices-ExportAction.instance"/>
   11.18 -                        <attr name="position" intvalue="9755"/>
   11.19 -                    </file>
   11.20 -                </folder>
   11.21 -            </folder>
   11.22 -        </folder>
   11.23 -    </folder>
   11.24 -    <folder name="Loaders">
   11.25 -        <folder name="text">
   11.26 -            <folder name="x-java">
   11.27 -                <folder name="Actions">
   11.28 -                    <file name="org-netbeans-modules-apisupport-metainfservices-ExportAction.shadow">
   11.29 -                        <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-modules-apisupport-metainfservices-ExportAction.instance"/>
   11.30 -                        <attr name="position" intvalue="2078"/>
   11.31 -                    </file>
   11.32 -                </folder>
   11.33 -            </folder>
   11.34 -        </folder>
   11.35 -    </folder>
   11.36 -</filesystem>
    12.1 --- a/apisupport.metainfservices/test/unit/src/org/netbeans/modules/apisupport/metainfservices/ExportActionTest.java	Mon Sep 06 10:27:45 2010 +0200
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,144 +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 -package org.netbeans.modules.apisupport.metainfservices;
   12.45 -
   12.46 -import java.net.URL;
   12.47 -import java.net.URLClassLoader;
   12.48 -import java.util.ArrayList;
   12.49 -import java.util.Set;
   12.50 -import org.netbeans.junit.NbTestCase;
   12.51 -import org.openide.filesystems.FileObject;
   12.52 -import org.openide.filesystems.FileSystem;
   12.53 -import org.openide.filesystems.FileUtil;
   12.54 -import org.openide.filesystems.LocalFileSystem;
   12.55 -import org.openide.util.Lookup;
   12.56 -import org.openide.util.lookup.Lookups;
   12.57 -
   12.58 -public class ExportActionTest extends NbTestCase {
   12.59 -    
   12.60 -    public ExportActionTest(String testName) {
   12.61 -        super(testName);
   12.62 -    }
   12.63 -
   12.64 -    protected void setUp() throws Exception {
   12.65 -        clearWorkDir();
   12.66 -    }
   12.67 -
   12.68 -    protected void tearDown() throws Exception {
   12.69 -    }
   12.70 -
   12.71 -    public void testGenerateFiles() throws Exception {
   12.72 -        LocalFileSystem lfs = new LocalFileSystem();
   12.73 -        lfs.setRootDirectory(getWorkDir());
   12.74 -
   12.75 -        FileSystem fs = lfs;
   12.76 -        FileObject src = FileUtil.createFolder(fs.getRoot(), "src");
   12.77 -
   12.78 -        ArrayList<String> files = new ArrayList<String>();
   12.79 -        files.add("META-INF/services/java.lang.Object");
   12.80 -        files.add("META-INF/services/java.lang.Runnable");
   12.81 -
   12.82 -        ExportAction.createFiles(R.class.getName(), files, src);
   12.83 -
   12.84 -        URLClassLoader loader = new URLClassLoader(new URL[] { src.getURL() }, getClass().getClassLoader());
   12.85 -        Lookup l = Lookups.metaInfServices(loader);
   12.86 -
   12.87 -        Runnable r = l.lookup(Runnable.class);
   12.88 -
   12.89 -        assertNotNull("Runnable found", r);
   12.90 -        assertEquals("It is my class", R.class, r.getClass());
   12.91 -
   12.92 -
   12.93 -        ExportAction.createFiles(Q.class.getName(), files, src);
   12.94 -
   12.95 -        l = Lookups.metaInfServices(loader);
   12.96 -        Set<Class<? extends Runnable>> all = l.lookupResult(Runnable.class).allClasses();
   12.97 -
   12.98 -        assertEquals(2, all.size());
   12.99 -        assertTrue("Q is there", all.contains(Q.class));
  12.100 -        assertTrue("R is there", all.contains(R.class));
  12.101 -    }
  12.102 -
  12.103 -    /* XXX would need to be rewritten:
  12.104 -    public void testRemovesAnnotations() throws Exception {
  12.105 -        JavaClassImpl impl = new JavaClassImpl();
  12.106 -        impl.setName("org.tst.Test");
  12.107 -        impl.setSimpleName("Test");
  12.108 -
  12.109 -        JavaClassImpl par = new JavaClassImpl();
  12.110 -        par.setName("org.par.Parent <X,Y>");
  12.111 -        par.setSimpleName("Parent <X,Y>");
  12.112 -
  12.113 -        impl.setSuperClass(par);
  12.114 -
  12.115 -        JavaClassImpl obj = new JavaClassImpl();
  12.116 -        obj.setName("java.lang.Object");
  12.117 -        obj.setSimpleName("Object");
  12.118 -
  12.119 -        par.setSuperClass(obj);
  12.120 -
  12.121 -        ArrayList<String> names = new ArrayList<String>();
  12.122 -        ExportAction.findInterfaces(impl, names);
  12.123 -
  12.124 -        assertEquals("Three", 3, names.size());
  12.125 -
  12.126 -        for (String n : names) {
  12.127 -            if (n.indexOf("<") >= 0) {
  12.128 -                fail("Contains wrong char: " + n);
  12.129 -            }
  12.130 -            if (n.endsWith(" ")) {
  12.131 -                fail("Ends with space:[" + n + "]");
  12.132 -            }
  12.133 -        }
  12.134 -    }
  12.135 -     */
  12.136 -
  12.137 -    public static class R extends Object implements Runnable {
  12.138 -        public void run() {
  12.139 -        }
  12.140 -    }
  12.141 -
  12.142 -    public static class Q implements Runnable {
  12.143 -        public void run() {
  12.144 -        }
  12.145 -    }
  12.146 -
  12.147 -}