[nb-antprojectsample~subversion:2] Initial revision of Ant Project Factory Sample

  • From: GWiel@kenai.com
  • To: commits@nb-antprojectsample.kenai.com
  • Subject: [nb-antprojectsample~subversion:2] Initial revision of Ant Project Factory Sample
  • Date: Sat, 11 Jul 2009 20:30:33 +0000

Project:    nb-antprojectsample
Repository: subversion
Revision:   2
Author:     GWiel
Date:       2009-07-11 20:30:31 UTC
Link:       
http://kenai.com/projects/nb-antprojectsample/sources/subversion/revision/2

Log Message:
------------
Initial revision of Ant Project Factory Sample


Modified Paths:
---------------
AntProjectFactorySample


Added Paths:
------------
AntProjectFactorySample/src/org/demo/ant/project/sample/demo/DemoWizardIterator.java
AntProjectFactorySample/src/org
AntProjectFactorySample/src/org/demo/ant/project/sample/demo/DemoWizardPanel.java
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleWizardPanel.java
AntProjectFactorySample/test
AntProjectFactorySample/nbproject/project.properties
AntProjectFactorySample/src/org/demo/ant/project
AntProjectFactorySample/src/org/demo/ant/project/sample/demo/Bundle.properties
AntProjectFactorySample/src/org/demo/ant/project/sample/demo/DemoPanelVisual.java
AntProjectFactorySample/src/org/demo/ant/project/sample/DemoProject.zip
AntProjectFactorySample/test/unit
AntProjectFactorySample/src/org/demo/ant/project/sample/Bundle.properties
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSamplePanelVisual.form
AntProjectFactorySample/test/unit/src
AntProjectFactorySample/src/org/demo/ant/project/sample
AntProjectFactorySample/src/org/demo/ant/project/sample/AntBasedProjectSampleProject.zip
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleWizardIterator.java
AntProjectFactorySample/src/org/demo/ant/project/sample/layer.xml
AntProjectFactorySample/src/org/demo/ant/project/sample/demo
AntProjectFactorySample/nbproject/project.xml
AntProjectFactorySample/src/org/demo/ant/project/sample/type
AntProjectFactorySample/src/org/demo/ant/project/sample/type/Bundle.properties
AntProjectFactorySample/build.xml
AntProjectFactorySample/nbproject
AntProjectFactorySample/src/org/demo/ant/project/sample/demo/DemoDescription.html
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSamplePanelVisual.java
AntProjectFactorySample/src/org/demo/ant/project/sample/demo/DemoPanelVisual.form
AntProjectFactorySample/nbproject/platform.properties
AntProjectFactorySample/nbproject/build-impl.xml
AntProjectFactorySample/manifest.mf
AntProjectFactorySample/nbproject/genfiles.properties
AntProjectFactorySample/src/org/demo/ant/project/sample/icon1.png
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleDescription.html
AntProjectFactorySample/src/org/demo
AntProjectFactorySample/src/org/demo/ant
AntProjectFactorySample/src


Diffs:
------
Index: AntProjectFactorySample/nbproject/platform.properties
===================================================================
--- AntProjectFactorySample/nbproject/platform.properties       (revision 0)
+++ AntProjectFactorySample/nbproject/platform.properties       (revision 2)
@@ -0,0 +1,16 @@
+cluster.path=\
+    ${nbplatform.active.dir}/nb:\
+    ${nbplatform.active.dir}/ergonomics:\
+    ${nbplatform.active.dir}/websvccommon:\
+    ${nbplatform.active.dir}/mobility:\
+    ${nbplatform.active.dir}/enterprise:\
+    ${nbplatform.active.dir}/profiler:\
+    ${nbplatform.active.dir}/identity:\
+    ${nbplatform.active.dir}/java:\
+    ${nbplatform.active.dir}/platform:\
+    ${nbplatform.active.dir}/apisupport:\
+    ${nbplatform.active.dir}/ide:\
+    ${nbplatform.active.dir}/groovy:\
+    ${nbplatform.active.dir}/webcommon:\
+    ${nbplatform.active.dir}/harness
+nbplatform.active=default
Index: AntProjectFactorySample/nbproject/project.properties
===================================================================
--- AntProjectFactorySample/nbproject/project.properties        (revision 0)
+++ AntProjectFactorySample/nbproject/project.properties        (revision 2)
@@ -0,0 +1,2 @@
+javac.source=1.5
+javac.compilerargs=-Xlint -Xlint:-serial
Index: AntProjectFactorySample/nbproject/project.xml
===================================================================
--- AntProjectFactorySample/nbproject/project.xml       (revision 0)
+++ AntProjectFactorySample/nbproject/project.xml       (revision 2)
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1";>
+    <type>org.netbeans.modules.apisupport.project</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3";>
+            <code-name-base>org.demo.ant.project.sample</code-name-base>
+            <standalone/>
+            <module-dependencies>
+                <dependency>
+                    <code-name-base>org.jdesktop.layout</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        
<specification-version>1.7.1.103</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    
<code-name-base>org.netbeans.modules.projectapi</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.24.1</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    
<code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        
<specification-version>1.35.1.6</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.awt</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        
<specification-version>7.8.1.1</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.dialogs</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>7.10.1</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.filesystems</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        
<specification-version>7.21.1.1.1</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.loaders</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>7.5.1</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.util</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        
<specification-version>7.22.1.1</specification-version>
+                    </run-dependency>
+                </dependency>
+            </module-dependencies>
+            <public-packages/>
+        </data>
+    </configuration>
+</project>
Index: AntProjectFactorySample/nbproject/genfiles.properties
===================================================================
--- AntProjectFactorySample/nbproject/genfiles.properties       (revision 0)
+++ AntProjectFactorySample/nbproject/genfiles.properties       (revision 2)
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=c9d73477
+build.xml.script.CRC32=0e4de925
+build.xml.stylesheet.CRC32=79c3b980@1.28.1.7
+# This file is used by a NetBeans-based IDE to track changes in generated 
files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never 
regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=c9d73477
+nbproject/build-impl.xml.script.CRC32=1798aa86
+nbproject/build-impl.xml.stylesheet.CRC32=261c4bef@1.28.1.7
Index: AntProjectFactorySample/nbproject/build-impl.xml
===================================================================
--- AntProjectFactorySample/nbproject/build-impl.xml    (revision 0)
+++ AntProjectFactorySample/nbproject/build-impl.xml    (revision 2)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT  ***
+***         EDIT ../build.xml INSTEAD         ***
+-->
+<project name="org.demo.ant.project.sample-impl" basedir="..">
+    <fail message="Please build using Ant 1.7.1 or higher.">
+        <condition>
+            <not>
+                <antversion atleast="1.7.1"/>
+            </not>
+        </condition>
+    </fail>
+    <property file="nbproject/private/platform-private.properties"/>
+    <property file="nbproject/platform.properties"/>
+    <macrodef name="property" 
uri="http://www.netbeans.org/ns/nb-module-project/2";>
+        <attribute name="name"/>
+        <attribute name="value"/>
+        <sequential>
+            <property name="@{name}" value="${@{value}}"/>
+        </sequential>
+    </macrodef>
+    <macrodef name="evalprops" 
uri="http://www.netbeans.org/ns/nb-module-project/2";>
+        <attribute name="property"/>
+        <attribute name="value"/>
+        <sequential>
+            <property name="@{property}" value="@{value}"/>
+        </sequential>
+    </macrodef>
+    <property file="${user.properties.file}"/>
+    <nbmproject2:property name="harness.dir" 
value="nbplatform.${nbplatform.active}.harness.dir" 
xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+    <nbmproject2:property name="nbplatform.active.dir" 
value="nbplatform.${nbplatform.active}.netbeans.dest.dir" 
xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+    <nbmproject2:evalprops property="cluster.path.evaluated" 
value="${cluster.path}" 
xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+    <fail message="Path to 'platform' cluster missing in $${cluster.path} 
property or using corrupt Netbeans Platform (missing harness).">
+        <condition>
+            <not>
+                <contains string="${cluster.path.evaluated}" 
substring="platform"/>
+            </not>
+        </condition>
+    </fail>
+    <import file="${harness.dir}/build.xml"/>
+</project>

Property changes on: AntProjectFactorySample/nbproject
___________________________________________________________________
Added: svn:ignore
   + private


Index: AntProjectFactorySample/manifest.mf
===================================================================
--- AntProjectFactorySample/manifest.mf (revision 0)
+++ AntProjectFactorySample/manifest.mf (revision 2)
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: org.demo.ant.project.sample
+OpenIDE-Module-Layer: org/demo/ant/project/sample/layer.xml
+OpenIDE-Module-Localizing-Bundle: 
org/demo/ant/project/sample/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
Index: 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSamplePanelVisual.form
===================================================================
--- 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSamplePanelVisual.form
  (revision 0)
+++ 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSamplePanelVisual.form
  (revision 2)
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" 
type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" 
value="1"/>
+    <AuxValue name="FormSettings_autoSetComponentName" 
type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" 
value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" 
type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" 
value="true"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" 
value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" 
type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" 
value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" 
value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="projectNameLabel" alignment="0" min="-2" 
max="-2" attributes="0"/>
+                  <Component id="projectLocationLabel" alignment="0" 
min="-2" max="-2" attributes="0"/>
+                  <Component id="createdFolderLabel" alignment="0" min="-2" 
max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="projectNameTextField" alignment="1" 
pref="191" max="32767" attributes="0"/>
+                  <Component id="projectLocationTextField" alignment="1" 
pref="191" max="32767" attributes="0"/>
+                  <Component id="createdFolderTextField" alignment="1" 
pref="191" max="32767" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+              <Component id="browseButton" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="projectNameLabel" alignment="3" min="-2" 
max="-2" attributes="0"/>
+                  <Component id="projectNameTextField" alignment="3" 
min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="projectLocationLabel" alignment="3" 
min="-2" max="-2" attributes="0"/>
+                  <Component id="projectLocationTextField" alignment="3" 
min="-2" max="-2" attributes="0"/>
+                  <Component id="browseButton" alignment="3" min="-2" 
max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="createdFolderLabel" alignment="3" min="-2" 
max="-2" attributes="0"/>
+                  <Component id="createdFolderTextField" alignment="3" 
min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace pref="213" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="projectNameLabel">
+      <Properties>
+        <Property name="labelFor" type="java.awt.Component" 
editor="org.netbeans.modules.form.ComponentChooserEditor">
+          <ComponentRef name="projectNameTextField"/>
+        </Property>
+        <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="org/demo/ant/project/sample/type/Bundle.properties" 
key="AntBasedProjectSamplePanelVisual.projectNameLabel.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+        </Property>
+      </Properties>
+      <AuxValues>
+        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" 
value="true"/>
+      </AuxValues>
+    </Component>
+    <Component class="javax.swing.JTextField" name="projectNameTextField">
+    </Component>
+    <Component class="javax.swing.JLabel" name="projectLocationLabel">
+      <Properties>
+        <Property name="labelFor" type="java.awt.Component" 
editor="org.netbeans.modules.form.ComponentChooserEditor">
+          <ComponentRef name="projectLocationTextField"/>
+        </Property>
+        <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="org/demo/ant/project/sample/type/Bundle.properties" 
key="AntBasedProjectSamplePanelVisual.projectLocationLabel.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+        </Property>
+      </Properties>
+      <AuxValues>
+        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" 
value="true"/>
+      </AuxValues>
+    </Component>
+    <Component class="javax.swing.JTextField" 
name="projectLocationTextField">
+    </Component>
+    <Component class="javax.swing.JButton" name="browseButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="org/demo/ant/project/sample/type/Bundle.properties" 
key="AntBasedProjectSamplePanelVisual.browseButton.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+        </Property>
+        <Property name="actionCommand" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="org/demo/ant/project/sample/type/Bundle.properties" 
key="AntBasedProjectSamplePanelVisual.browseButton.actionCommand" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" 
handler="browseButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="createdFolderLabel">
+      <Properties>
+        <Property name="labelFor" type="java.awt.Component" 
editor="org.netbeans.modules.form.ComponentChooserEditor">
+          <ComponentRef name="createdFolderTextField"/>
+        </Property>
+        <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString 
bundle="org/demo/ant/project/sample/type/Bundle.properties" 
key="AntBasedProjectSamplePanelVisual.createdFolderLabel.text" 
replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, 
&quot;{key}&quot;)"/>
+        </Property>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JTextField" name="createdFolderTextField">
+      <Properties>
+        <Property name="editable" type="boolean" value="false"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
Index: 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleDescription.html
===================================================================
--- 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleDescription.html
  (revision 0)
+++ 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleDescription.html
  (revision 2)
@@ -0,0 +1,12 @@
+<!--
+To change this template, choose Tools | Templates
+and open the template in the editor.
+-->
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    </head>
+    <body>
+        Demo Ant-based project type.
+    </body>
+</html>
Index: 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/Bundle.properties
===================================================================
--- 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/Bundle.properties
      (revision 0)
+++ 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/Bundle.properties
      (revision 2)
@@ -0,0 +1,6 @@
+LBL_CreateProjectStep=Name and Location
+AntBasedProjectSamplePanelVisual.projectNameLabel.text=Project &Name:
+AntBasedProjectSamplePanelVisual.projectLocationLabel.text=Project &Location:
+AntBasedProjectSamplePanelVisual.browseButton.actionCommand=BROWSE
+AntBasedProjectSamplePanelVisual.browseButton.text=Br&owse...
+AntBasedProjectSamplePanelVisual.createdFolderLabel.text=Project &Folder:
Index: 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleWizardIterator.java
===================================================================
--- 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleWizardIterator.java
       (revision 0)
+++ 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleWizardIterator.java
       (revision 2)
@@ -0,0 +1,220 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.demo.ant.project.sample.type;
+
+import java.awt.Component;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.MessageFormat;
+import java.util.Enumeration;
+import java.util.LinkedHashSet;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import javax.swing.JComponent;
+import javax.swing.event.ChangeListener;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.spi.project.ui.support.ProjectChooser;
+import org.netbeans.spi.project.ui.templates.support.Templates;
+import org.openide.WizardDescriptor;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+import org.openide.util.NbBundle;
+import org.openide.xml.XMLUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+public class AntBasedProjectSampleWizardIterator implements 
WizardDescriptor./*Progress*/InstantiatingIterator {
+
+    private int index;
+    private WizardDescriptor.Panel[] panels;
+    private WizardDescriptor wiz;
+
+    public AntBasedProjectSampleWizardIterator() {
+    }
+
+    public static AntBasedProjectSampleWizardIterator createIterator() {
+        return new AntBasedProjectSampleWizardIterator();
+    }
+
+    private WizardDescriptor.Panel[] createPanels() {
+        return new WizardDescriptor.Panel[]{
+                    new AntBasedProjectSampleWizardPanel(),};
+    }
+
+    private String[] createSteps() {
+        return new String[]{
+                    
NbBundle.getMessage(AntBasedProjectSampleWizardIterator.class, 
"LBL_CreateProjectStep")
+                };
+    }
+
+    public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws 
IOException {
+        Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
+        File dirF = FileUtil.normalizeFile((File) 
wiz.getProperty("projdir"));
+        dirF.mkdirs();
+
+        FileObject template = Templates.getTemplate(wiz);
+        FileObject dir = FileUtil.toFileObject(dirF);
+        unZipFile(template.getInputStream(), dir);
+
+        // Always open top dir as a project:
+        resultSet.add(dir);
+        // Look for nested projects to open as well:
+        Enumeration<? extends FileObject> e = dir.getFolders(true);
+        while (e.hasMoreElements()) {
+            FileObject subfolder = e.nextElement();
+            if (ProjectManager.getDefault().isProject(subfolder)) {
+                resultSet.add(subfolder);
+            }
+        }
+
+        File parent = dirF.getParentFile();
+        if (parent != null && parent.exists()) {
+            ProjectChooser.setProjectsFolder(parent);
+        }
+
+        return resultSet;
+    }
+
+    public void initialize(WizardDescriptor wiz) {
+        this.wiz = wiz;
+        index = 0;
+        panels = createPanels();
+        // Make sure list of steps is accurate.
+        String[] steps = createSteps();
+        for (int i = 0; i < panels.length; i++) {
+            Component c = panels[i].getComponent();
+            if (steps[i] == null) {
+                // Default step name to component name of panel.
+                // Mainly useful for getting the name of the target
+                // chooser to appear in the list of steps.
+                steps[i] = c.getName();
+            }
+            if (c instanceof JComponent) { // assume Swing components
+                JComponent jc = (JComponent) c;
+                // Step #.
+                // TODO if using org.openide.dialogs >= 7.8, can use 
WizardDescriptor.PROP_*:
+                jc.putClientProperty("WizardPanel_contentSelectedIndex", new 
Integer(i));
+                // Step name (actually the whole list for reference).
+                jc.putClientProperty("WizardPanel_contentData", steps);
+            }
+        }
+    }
+
+    public void uninitialize(WizardDescriptor wiz) {
+        this.wiz.putProperty("projdir", null);
+        this.wiz.putProperty("name", null);
+        this.wiz = null;
+        panels = null;
+    }
+
+    public String name() {
+        return MessageFormat.format("{0} of {1}",
+                new Object[]{new Integer(index + 1), new 
Integer(panels.length)});
+    }
+
+    public boolean hasNext() {
+        return index < panels.length - 1;
+    }
+
+    public boolean hasPrevious() {
+        return index > 0;
+    }
+
+    public void nextPanel() {
+        if (!hasNext()) {
+            throw new NoSuchElementException();
+        }
+        index++;
+    }
+
+    public void previousPanel() {
+        if (!hasPrevious()) {
+            throw new NoSuchElementException();
+        }
+        index--;
+    }
+
+    public WizardDescriptor.Panel current() {
+        return panels[index];
+    }
+
+    // If nothing unusual changes in the middle of the wizard, simply:
+    public final void addChangeListener(ChangeListener l) {
+    }
+
+    public final void removeChangeListener(ChangeListener l) {
+    }
+
+    private static void unZipFile(InputStream source, FileObject 
projectRoot) throws IOException {
+        try {
+            ZipInputStream str = new ZipInputStream(source);
+            ZipEntry entry;
+            while ((entry = str.getNextEntry()) != null) {
+                if (entry.isDirectory()) {
+                    FileUtil.createFolder(projectRoot, entry.getName());
+                } else {
+                    FileObject fo = FileUtil.createData(projectRoot, 
entry.getName());
+                    if ("nbproject/project.xml".equals(entry.getName())) {
+                        // Special handling for setting name of Ant-based 
projects; customize as needed:
+                        filterProjectXML(fo, str, projectRoot.getName());
+                    } else {
+                        writeFile(str, fo);
+                    }
+                }
+            }
+        } finally {
+            source.close();
+        }
+    }
+
+    private static void writeFile(ZipInputStream str, FileObject fo) throws 
IOException {
+        OutputStream out = fo.getOutputStream();
+        try {
+            FileUtil.copy(str, out);
+        } finally {
+            out.close();
+        }
+    }
+
+    private static void filterProjectXML(FileObject fo, ZipInputStream str, 
String name) throws IOException {
+        try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            FileUtil.copy(str, baos);
+            Document doc = XMLUtil.parse(new InputSource(new 
ByteArrayInputStream(baos.toByteArray())), false, false, null, null);
+            NodeList nl = 
doc.getDocumentElement().getElementsByTagName("name");
+            if (nl != null) {
+                for (int i = 0; i < nl.getLength(); i++) {
+                    Element el = (Element) nl.item(i);
+                    if (el.getParentNode() != null && 
"data".equals(el.getParentNode().getNodeName())) {
+                        NodeList nl2 = el.getChildNodes();
+                        if (nl2.getLength() > 0) {
+                            nl2.item(0).setNodeValue(name);
+                        }
+                        break;
+                    }
+                }
+            }
+            OutputStream out = fo.getOutputStream();
+            try {
+                XMLUtil.write(doc, out, "UTF-8");
+            } finally {
+                out.close();
+            }
+        } catch (Exception ex) {
+            Exceptions.printStackTrace(ex);
+            writeFile(str, fo);
+        }
+
+    }
+}
Index: 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleWizardPanel.java
===================================================================
--- 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleWizardPanel.java
  (revision 0)
+++ 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSampleWizardPanel.java
  (revision 2)
@@ -0,0 +1,88 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.demo.ant.project.sample.type;
+
+import java.awt.Component;
+import java.util.HashSet;
+import java.util.Set;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import org.openide.WizardDescriptor;
+import org.openide.WizardValidationException;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+
+/**
+ * Panel just asking for basic info.
+ */
+public class AntBasedProjectSampleWizardPanel implements 
WizardDescriptor.Panel,
+        WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel {
+
+    private WizardDescriptor wizardDescriptor;
+    private AntBasedProjectSamplePanelVisual component;
+
+    public AntBasedProjectSampleWizardPanel() {
+    }
+
+    public Component getComponent() {
+        if (component == null) {
+            component = new AntBasedProjectSamplePanelVisual(this);
+            
component.setName(NbBundle.getMessage(AntBasedProjectSampleWizardPanel.class, 
"LBL_CreateProjectStep"));
+        }
+        return component;
+    }
+
+    public HelpCtx getHelp() {
+        return new HelpCtx(AntBasedProjectSampleWizardPanel.class);
+    }
+
+    public boolean isValid() {
+        getComponent();
+        return component.valid(wizardDescriptor);
+    }
+    private final Set<ChangeListener> listeners = new 
HashSet<ChangeListener>(1); // or can use ChangeSupport in NB 6.0
+
+    public final void addChangeListener(ChangeListener l) {
+        synchronized (listeners) {
+            listeners.add(l);
+        }
+    }
+
+    public final void removeChangeListener(ChangeListener l) {
+        synchronized (listeners) {
+            listeners.remove(l);
+        }
+    }
+
+    protected final void fireChangeEvent() {
+        Set<ChangeListener> ls;
+        synchronized (listeners) {
+            ls = new HashSet<ChangeListener>(listeners);
+        }
+        ChangeEvent ev = new ChangeEvent(this);
+        for (ChangeListener l : ls) {
+            l.stateChanged(ev);
+        }
+    }
+
+    public void readSettings(Object settings) {
+        wizardDescriptor = (WizardDescriptor) settings;
+        component.read(wizardDescriptor);
+    }
+
+    public void storeSettings(Object settings) {
+        WizardDescriptor d = (WizardDescriptor) settings;
+        component.store(d);
+    }
+
+    public boolean isFinishPanel() {
+        return true;
+    }
+
+    public void validate() throws WizardValidationException {
+        getComponent();
+        component.validate(wizardDescriptor);
+    }
+}
Index: 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSamplePanelVisual.java
===================================================================
--- 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSamplePanelVisual.java
  (revision 0)
+++ 
AntProjectFactorySample/src/org/demo/ant/project/sample/type/AntBasedProjectSamplePanelVisual.java
  (revision 2)
@@ -0,0 +1,262 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.demo.ant.project.sample.type;
+
+import java.io.File;
+import javax.swing.JFileChooser;
+import javax.swing.JPanel;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.Document;
+import org.netbeans.spi.project.ui.support.ProjectChooser;
+import org.openide.WizardDescriptor;
+import org.openide.WizardValidationException;
+import org.openide.filesystems.FileUtil;
+
+public class AntBasedProjectSamplePanelVisual extends JPanel implements 
DocumentListener {
+
+    public static final String PROP_PROJECT_NAME = "projectName";
+
+    private AntBasedProjectSampleWizardPanel panel;
+
+    public AntBasedProjectSamplePanelVisual(AntBasedProjectSampleWizardPanel 
panel) {
+        initComponents();
+        this.panel = panel;
+        // Register listener on the textFields to make the automatic updates
+        projectNameTextField.getDocument().addDocumentListener(this);
+        projectLocationTextField.getDocument().addDocumentListener(this);
+    }
+
+    public String getProjectName() {
+        return this.projectNameTextField.getText();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated 
Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        projectNameLabel = new javax.swing.JLabel();
+        projectNameTextField = new javax.swing.JTextField();
+        projectLocationLabel = new javax.swing.JLabel();
+        projectLocationTextField = new javax.swing.JTextField();
+        browseButton = new javax.swing.JButton();
+        createdFolderLabel = new javax.swing.JLabel();
+        createdFolderTextField = new javax.swing.JTextField();
+
+        projectNameLabel.setLabelFor(projectNameTextField);
+        org.openide.awt.Mnemonics.setLocalizedText(projectNameLabel, 
org.openide.util.NbBundle.getMessage(AntBasedProjectSamplePanelVisual.class, 
"AntBasedProjectSamplePanelVisual.projectNameLabel.text")); // NOI18N
+
+        projectLocationLabel.setLabelFor(projectLocationTextField);
+        org.openide.awt.Mnemonics.setLocalizedText(projectLocationLabel, 
org.openide.util.NbBundle.getMessage(AntBasedProjectSamplePanelVisual.class, 
"AntBasedProjectSamplePanelVisual.projectLocationLabel.text")); // NOI18N
+
+        org.openide.awt.Mnemonics.setLocalizedText(browseButton, 
org.openide.util.NbBundle.getMessage(AntBasedProjectSamplePanelVisual.class, 
"AntBasedProjectSamplePanelVisual.browseButton.text")); // NOI18N
+        
browseButton.setActionCommand(org.openide.util.NbBundle.getMessage(AntBasedProjectSamplePanelVisual.class,
 "AntBasedProjectSamplePanelVisual.browseButton.actionCommand")); // NOI18N
+        browseButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                browseButtonActionPerformed(evt);
+            }
+        });
+
+        createdFolderLabel.setLabelFor(createdFolderTextField);
+        org.openide.awt.Mnemonics.setLocalizedText(createdFolderLabel, 
org.openide.util.NbBundle.getMessage(AntBasedProjectSamplePanelVisual.class, 
"AntBasedProjectSamplePanelVisual.createdFolderLabel.text")); // NOI18N
+
+        createdFolderTextField.setEditable(false);
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(projectNameLabel)
+                    .addComponent(projectLocationLabel)
+                    .addComponent(createdFolderLabel))
+                
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(projectNameTextField, 
javax.swing.GroupLayout.Alignment.TRAILING, 
javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
+                    .addComponent(projectLocationTextField, 
javax.swing.GroupLayout.Alignment.TRAILING, 
javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
+                    .addComponent(createdFolderTextField, 
javax.swing.GroupLayout.Alignment.TRAILING, 
javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))
+                
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(browseButton)
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(projectNameLabel)
+                    .addComponent(projectNameTextField, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE))
+                
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(projectLocationLabel)
+                    .addComponent(projectLocationTextField, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addComponent(browseButton))
+                
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(createdFolderLabel)
+                    .addComponent(createdFolderTextField, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 
javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addContainerGap(213, Short.MAX_VALUE))
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) 
{//GEN-FIRST:event_browseButtonActionPerformed
+        String command = evt.getActionCommand();
+        if ("BROWSE".equals(command)) {
+            JFileChooser chooser = new JFileChooser();
+            FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
+            chooser.setDialogTitle("Select Project Location");
+            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+            String path = this.projectLocationTextField.getText();
+            if (path.length() > 0) {
+                File f = new File(path);
+                if (f.exists()) {
+                    chooser.setSelectedFile(f);
+                }
+            }
+            if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) 
{
+                File projectDir = chooser.getSelectedFile();
+                
projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
+            }
+            panel.fireChangeEvent();
+        }
+
+    }//GEN-LAST:event_browseButtonActionPerformed
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton browseButton;
+    private javax.swing.JLabel createdFolderLabel;
+    private javax.swing.JTextField createdFolderTextField;
+    private javax.swing.JLabel projectLocationLabel;
+    private javax.swing.JTextField projectLocationTextField;
+    private javax.swing.JLabel projectNameLabel;
+    private javax.swing.JTextField projectNameTextField;
+    // End of variables declaration//GEN-END:variables
+
+    @Override
+    public void addNotify() {
+        super.addNotify();
+        //same problem as in 31086, initial focus on Cancel button
+        projectNameTextField.requestFocus();
+    }
+
+    boolean valid(WizardDescriptor wizardDescriptor) {
+
+        if (projectNameTextField.getText().length() == 0) {
+            // TODO if using org.openide.dialogs >= 7.8, can use 
WizardDescriptor.PROP_ERROR_MESSAGE:
+            wizardDescriptor.putProperty("WizardPanel_errorMessage",
+                    "Project Name is not a valid folder name.");
+            return false; // Display name not specified
+        }
+        File f = FileUtil.normalizeFile(new 
File(projectLocationTextField.getText()).getAbsoluteFile());
+        if (!f.isDirectory()) {
+            String message = "Project Folder is not a valid path.";
+            wizardDescriptor.putProperty("WizardPanel_errorMessage", 
message);
+            return false;
+        }
+        final File destFolder = FileUtil.normalizeFile(new 
File(createdFolderTextField.getText()).getAbsoluteFile());
+
+        File projLoc = destFolder;
+        while (projLoc != null && !projLoc.exists()) {
+            projLoc = projLoc.getParentFile();
+        }
+        if (projLoc == null || !projLoc.canWrite()) {
+            wizardDescriptor.putProperty("WizardPanel_errorMessage",
+                    "Project Folder cannot be created.");
+            return false;
+        }
+
+        if (FileUtil.toFileObject(projLoc) == null) {
+            String message = "Project Folder is not a valid path.";
+            wizardDescriptor.putProperty("WizardPanel_errorMessage", 
message);
+            return false;
+        }
+
+        File[] kids = destFolder.listFiles();
+        if (destFolder.exists() && kids != null && kids.length > 0) {
+            // Folder exists and is not empty
+            wizardDescriptor.putProperty("WizardPanel_errorMessage",
+                    "Project Folder already exists and is not empty.");
+            return false;
+        }
+        wizardDescriptor.putProperty("WizardPanel_errorMessage", "");
+        return true;
+    }
+
+    void store(WizardDescriptor d) {
+        String name = projectNameTextField.getText().trim();
+        String folder = createdFolderTextField.getText().trim();
+
+        d.putProperty("projdir", new File(folder));
+        d.putProperty("name", name);
+    }
+
+    void read(WizardDescriptor settings) {
+        File projectLocation = (File) settings.getProperty("projdir");
+        if (projectLocation == null || projectLocation.getParentFile() == 
null || !projectLocation.getParentFile().isDirectory()) {
+            projectLocation = ProjectChooser.getProjectsFolder();
+        } else {
+            projectLocation = projectLocation.getParentFile();
+        }
+        
this.projectLocationTextField.setText(projectLocation.getAbsolutePath());
+
+        String projectName = (String) settings.getProperty("name");
+        if (projectName == null) {
+            projectName = "AntBasedProjectSample";
+        }
+        this.projectNameTextField.setText(projectName);
+        this.projectNameTextField.selectAll();
+    }
+
+    void validate(WizardDescriptor d) throws WizardValidationException {
+        // nothing to validate
+    }
+
+    // Implementation of DocumentListener 
--------------------------------------
+    public void changedUpdate(DocumentEvent e) {
+        updateTexts(e);
+        if (this.projectNameTextField.getDocument() == e.getDocument()) {
+            firePropertyChange(PROP_PROJECT_NAME, null, 
this.projectNameTextField.getText());
+        }
+    }
+
+    public void insertUpdate(DocumentEvent e) {
+        updateTexts(e);
+        if (this.projectNameTextField.getDocument() == e.getDocument()) {
+            firePropertyChange(PROP_PROJECT_NAME, null, 
this.projectNameTextField.getText());
+        }
+    }
+
+    public void removeUpdate(DocumentEvent e) {
+        updateTexts(e);
+        if (this.projectNameTextField.getDocument() == e.getDocument()) {
+            firePropertyChange(PROP_PROJECT_NAME, null, 
this.projectNameTextField.getText());
+        }
+    }
+
+    /** Handles changes in the Project name and project directory, */
+    private void updateTexts(DocumentEvent e) {
+
+        Document doc = e.getDocument();
+
+        if (doc == projectNameTextField.getDocument() || doc == 
projectLocationTextField.getDocument()) {
+            // Change in the project name
+
+            String projectName = projectNameTextField.getText();
+            String projectFolder = projectLocationTextField.getText();
+
+            //if (projectFolder.trim().length() == 0 || 
projectFolder.equals(oldName)) {
+            createdFolderTextField.setText(projectFolder + 
File.separatorChar + projectName);
+            //}
+
+        }
+        panel.fireChangeEvent(); // Notify that the panel changed
+    }
+}
Index: 
AntProjectFactorySample/src/org/demo/ant/project/sample/AntBasedProjectSampleProject.zip
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: 
AntProjectFactorySample/src/org/demo/ant/project/sample/AntBasedProjectSampleProject.zip
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: 
AntProjectFactorySample/src/org/demo/ant/project/sample/Bundle.properties
===================================================================
--- AntProjectFactorySample/src/org/demo/ant/project/sample/Bundle.properties 
  (revision 0)
+++ AntProjectFactorySample/src/org/demo/ant/project/sample/Bundle.properties 
  (revision 2)
@@ -0,0 +1,3 @@
+OpenIDE-Module-Name=AntProjectFactorySample
+Templates/Project/Samples/ApiSupport/AntBasedProjectSampleProject.zip=Ant 
Based Project Sample
+Templates/Project/Samples/DemoProject.zip=Demo
Index: 
AntProjectFactorySample/src/org/demo/ant/project/sample/demo/DemoWizardIterator.java
===================================================================
--- 
AntProjectFactorySample/src/org/demo/ant/project/sample/demo/DemoWizardIterator.java
        (revision 0)
+++ 
AntProjectFactorySample/src/org/demo/ant/project/sample/demo/DemoWizardIterator.java
        (revision 2)
@@ -0,0 +1,220 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.demo.ant.project.sample.demo;
+
+import java.awt.Component;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.MessageFormat;
+import java.util.Enumeration;
+import java.util.LinkedHashSet;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import javax.swing.JComponent;
+import javax.swing.event.ChangeListener;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.spi.project.ui.support.ProjectChooser;
+import org.netbeans.spi.project.ui.templates.support.Templates;
+import org.openide.WizardDescriptor;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+import org.openide.util.NbBundle;
+import org.openide.xml.XMLUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+public class DemoWizardIterator implements 
WizardDescriptor./*Progress*/InstantiatingIterator {
+
+    private int index;
+    private WizardDescriptor.Panel[] panels;
+    private WizardDescriptor wiz;
+
+    public DemoWizardIterator() {
+    }
+
+    public static DemoWizardIterator createIterator() {
+        return new DemoWizardIterator();
+    }
+
+    private WizardDescriptor.Panel[] createPanels() {
+        return new WizardDescriptor.Panel[]{
+                    new DemoWizardPanel(),};
+    }
+
+    private String[] createSteps() {
+        return new String[]{
+                    NbBundle.getMessage(DemoWizardIterator.class, 
"LBL_CreateProjectStep")
+                };
+    }
+
+    public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws 
IOException {
+        Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
+        File dirF = FileUtil.normalizeFile((File) 
wiz.getProperty("projdir"));
+        dirF.mkdirs();
+
+        FileObject template = Templates.getTemplate(wiz);
+        FileObject dir = FileUtil.toFileObject(dirF);
+        unZipFile(template.getInputStream(), dir);
+
+        // Always open top dir as a project:
+        resultSet.add(dir);
+        // Look for nested projects to open as well:
+        Enumeration<? extends FileObject> e = dir.getFolders(true);
+        while (e.hasMoreElements()) {
+            FileObject subfolder = e.nextElement();
+            if (ProjectManager.getDefault().isProject(subfolder)) {
+                resultSet.add(subfolder);
+            }
+        }
+
+        File parent = dirF.getParentFile();
+        if (parent != null && parent.exists()) {
+            ProjectChooser.setProjectsFolder(parent);
+        }
+
+        return resultSet;
+    }
+
+    public void initialize(WizardDescriptor wiz) {
+        this.wiz = wiz;
+        index = 0;
+        panels = createPanels();
+        // Make sure list of steps is accurate.
+        String[] steps = createSteps();
+        for (int i = 0; i < panels.length; i++) {
+            Component c = panels[i].getComponent();
+            if (steps[i] == null) {
+                // Default step name to component name of panel.
+                // Mainly useful for getting the name of the target
+                // chooser to appear in the list of steps.
+                steps[i] = c.getName();
+            }
+            if (c instanceof JComponent) { // assume Swing components
+                JComponent jc = (JComponent) c;
+                // Step #.
+                // TODO if using org.openide.dialogs >= 7.8, can use 
WizardDescriptor.PROP_*:
+                jc.putClientProperty("WizardPanel_contentSelectedIndex", new 
Integer(i));
+                // Step name (actually the whole list for reference).
+                jc.putClientProperty("WizardPanel_contentData", steps);
+            }
+        }
+    }
+
+    public void uninitialize(WizardDescriptor wiz) {
+        this.wiz.putProperty("projdir", null);
+        this.wiz.putProperty("name", null);
+        this.wiz = null;
+        panels = null;
+    }
+
+    public String name() {
+        return MessageFormat.format("{0} of {1}",
+                new Object[]{new Integer(index + 1), new 
Integer(panels.length)});
+    }
+
+    public boolean hasNext() {
+        return index < panels.length - 1;
+    }
+
+    public boolean hasPrevious() {
+        return index > 0;
+    }
+
+    public void nextPanel() {
+        if (!hasNext()) {
+            throw new NoSuchElementException();
+        }
+        index++;
+    }
+
+    public void previousPanel() {
+        if (!hasPrevious()) {
+            throw new NoSuchElementException();
+        }
+        index--;
+    }
+
+    public WizardDescriptor.Panel current() {
+        return panels[index];
+    }
+
+    // If nothing unusual changes in the middle of the wizard, simply:
+    public final void addChangeListener(ChangeListener l) {
+    }
+
+    public final void removeChangeListener(ChangeListener l) {
+    }
+
+    private static void unZipFile(InputStream source, FileObject 
projectRoot) throws IOException {
+        try {
+            ZipInputStream str = new ZipInputStream(source);
+            ZipEntry entry;
+            while ((entry = str.getNextEntry()) != null) {
+                if (entry.isDirectory()) {
+                    FileUtil.createFolder(projectRoot, entry.getName());
+                } else {
+                    FileObject fo = FileUtil.createData(projectRoot, 
entry.getName());
+                    if ("nbproject/project.xml".equals(entry.getName())) {
+                        // Special handling for setting name of Ant-based 
projects; customize as needed:
+                        filterProjectXML(fo, str, projectRoot.getName());
+                    } else {
+                        writeFile(str, fo);
+                    }
+                }
+            }
+        } finally {
+            source.close();
+        }
+    }
+
+    private static void writeFile(ZipInputStream str, FileObject fo) throws 
IOException {
+        OutputStream out = fo.getOutputStream();
+        try {
+            FileUtil.copy(
[truncated due to length]



[nb-antprojectsample~subversion:2] Initial revision of Ant Project Factory Sample

GWiel 07/11/2009
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close