move template registration out from a layer
authorLukas Jungmann <jungi@netbeans.org>
Sun, 01 Jan 2012 17:46:36 +0100
changeset 1771958431eb125a1
parent 17718 ad280c1919b9
child 17720 495b4b739dd1
move template registration out from a layer
testng/src/org/netbeans/modules/contrib/testng/NewTestWizardIterator.java
testng/src/org/netbeans/modules/contrib/testng/resources/EmptyTestNGTest.java.template
testng/src/org/netbeans/modules/contrib/testng/resources/layer.xml
testng/src/org/netbeans/modules/contrib/testng/resources/testng.template
     1.1 --- a/testng/src/org/netbeans/modules/contrib/testng/NewTestWizardIterator.java	Sun Jan 01 17:11:55 2012 +0100
     1.2 +++ b/testng/src/org/netbeans/modules/contrib/testng/NewTestWizardIterator.java	Sun Jan 01 17:46:36 2012 +0100
     1.3 @@ -1,7 +1,7 @@
     1.4  /*
     1.5   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.6   *
     1.7 - * Copyright © 2008-2011 Oracle and/or its affiliates. All rights reserved.
     1.8 + * Copyright © 2008-2012 Oracle and/or its affiliates. All rights reserved.
     1.9   *
    1.10   * The contents of this file are subject to the terms of either the GNU
    1.11   * General Public License Version 2 only ("GPL") or the Common
    1.12 @@ -40,21 +40,12 @@
    1.13  
    1.14  import java.awt.Component;
    1.15  import java.io.IOException;
    1.16 -import java.util.ArrayList;
    1.17 -import java.util.Collections;
    1.18 -import java.util.List;
    1.19 -import java.util.NoSuchElementException;
    1.20 -import java.util.Set;
    1.21 -import java.util.logging.Logger;
    1.22 +import java.util.*;
    1.23  import javax.swing.JComponent;
    1.24  import javax.swing.event.ChangeListener;
    1.25  import org.netbeans.api.java.project.JavaProjectConstants;
    1.26 -import org.netbeans.api.project.FileOwnerQuery;
    1.27 -import org.netbeans.api.project.Project;
    1.28 -import org.netbeans.api.project.ProjectUtils;
    1.29 -import org.netbeans.api.project.SourceGroup;
    1.30 -import org.netbeans.api.project.SourceGroupModifier;
    1.31 -import org.netbeans.api.project.Sources;
    1.32 +import org.netbeans.api.project.*;
    1.33 +import org.netbeans.api.templates.TemplateRegistration;
    1.34  import org.netbeans.modules.contrib.testng.api.TestNGSupport;
    1.35  import org.netbeans.spi.java.project.support.ui.templates.JavaTemplates;
    1.36  import org.netbeans.spi.project.ui.templates.support.Templates;
    1.37 @@ -67,17 +58,19 @@
    1.38  /**
    1.39   * Wizard to create a new TestNG file.
    1.40   */
    1.41 +@TemplateRegistration(folder = "TestNG", position = 1000,
    1.42 +        content = "resources/EmptyTestNGTest.java.template",
    1.43 +        scriptEngine = "freemarker",
    1.44 +        displayName = "#Templates/TestNG/TestNGTest.java",
    1.45 +        iconBase = "org/netbeans/modules/contrib/testng/resources/testng.gif",
    1.46 +        description = "/org/netbeans/modules/contrib/testng/resources/newTest.html")
    1.47  public final class NewTestWizardIterator implements WizardDescriptor.InstantiatingIterator {
    1.48  
    1.49      private transient int index;
    1.50      private transient WizardDescriptor.Panel[] panels;
    1.51      private transient WizardDescriptor wiz;
    1.52  
    1.53 -    public static NewTestWizardIterator create() {
    1.54 -        return new NewTestWizardIterator();
    1.55 -    }
    1.56 -
    1.57 -    private NewTestWizardIterator() {
    1.58 +    public NewTestWizardIterator() {
    1.59      }
    1.60  
    1.61      private WizardDescriptor.Panel[] createPanels(final WizardDescriptor wizardDescriptor) {
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/testng/src/org/netbeans/modules/contrib/testng/resources/EmptyTestNGTest.java.template	Sun Jan 01 17:46:36 2012 +0100
     2.3 @@ -0,0 +1,34 @@
     2.4 +<#assign licenseFirst = "/*">
     2.5 +<#assign licensePrefix = " * ">
     2.6 +<#assign licenseLast = " */">
     2.7 +<#include "../Licenses/license-${project.license}.txt">
     2.8 +
     2.9 +<#if package?? && package != "">
    2.10 +package ${package};
    2.11 +
    2.12 +</#if>
    2.13 +import org.testng.annotations.AfterClass;
    2.14 +import org.testng.annotations.BeforeClass;
    2.15 +import org.testng.annotations.Test;
    2.16 +
    2.17 +/**
    2.18 + *
    2.19 + * @author ${user}
    2.20 + */
    2.21 +public class ${name} {
    2.22 +
    2.23 +    @BeforeClass
    2.24 +    public void setUp() {
    2.25 +        // code that will be invoked before this test starts
    2.26 +    }
    2.27 +
    2.28 +    @Test
    2.29 +    public void aTest() {
    2.30 +        System.out.println("Test");
    2.31 +    }
    2.32 +
    2.33 +    @AfterClass
    2.34 +    public void cleanUp() {
    2.35 +        // code that will be invoked after this test ends
    2.36 +    }
    2.37 +}
     3.1 --- a/testng/src/org/netbeans/modules/contrib/testng/resources/layer.xml	Sun Jan 01 17:11:55 2012 +0100
     3.2 +++ b/testng/src/org/netbeans/modules/contrib/testng/resources/layer.xml	Sun Jan 01 17:46:36 2012 +0100
     3.3 @@ -2,7 +2,7 @@
     3.4  <!--
     3.5  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3.6  
     3.7 -Copyright © 1997-2011 Oracle and/or its affiliates. All rights reserved.
     3.8 +Copyright © 1997-2012 Oracle and/or its affiliates. All rights reserved.
     3.9  
    3.10  
    3.11  The contents of this file are subject to the terms of either the GNU
    3.12 @@ -138,15 +138,6 @@
    3.13          <folder name="TestNG">
    3.14              <attr name="displayName" bundlevalue="org.netbeans.modules.contrib.testng.Bundle#Templates/TestNG"/>
    3.15              <attr name="position" intvalue="1250"/>
    3.16 -            <file name="TestNGTest.java" url="testng.template">
    3.17 -                <attr name="displayName" bundlevalue="org.netbeans.modules.contrib.testng.Bundle#Templates/TestNG/TestNGTest.java"/>
    3.18 -                <attr name="iconBase" stringvalue="org/netbeans/modules/contrib/testng/resources/testng.gif"/>
    3.19 -                <attr name="position" intvalue="1000"/>
    3.20 -                <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
    3.21 -                <attr name="instantiatingIterator" methodvalue="org.netbeans.modules.contrib.testng.NewTestWizardIterator.create"/>
    3.22 -                <attr name="template" boolvalue="true"/>
    3.23 -                <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/contrib/testng/resources/newTest.html"/>
    3.24 -            </file>
    3.25          </folder>
    3.26      </folder>
    3.27      <folder name="org-netbeans-api-project-libraries">
     4.1 --- a/testng/src/org/netbeans/modules/contrib/testng/resources/testng.template	Sun Jan 01 17:11:55 2012 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,34 +0,0 @@
     4.4 -<#assign licenseFirst = "/*">
     4.5 -<#assign licensePrefix = " * ">
     4.6 -<#assign licenseLast = " */">
     4.7 -<#include "../Licenses/license-${project.license}.txt">
     4.8 -
     4.9 -<#if package?? && package != "">
    4.10 -package ${package};
    4.11 -
    4.12 -</#if>
    4.13 -import org.testng.annotations.AfterClass;
    4.14 -import org.testng.annotations.BeforeClass;
    4.15 -import org.testng.annotations.Test;
    4.16 -
    4.17 -/**
    4.18 - *
    4.19 - * @author ${user}
    4.20 - */
    4.21 -public class ${name} {
    4.22 -
    4.23 -    @BeforeClass
    4.24 -    public void setUp() {
    4.25 -        // code that will be invoked before this test starts
    4.26 -    }
    4.27 -
    4.28 -    @Test
    4.29 -    public void aTest() {
    4.30 -        System.out.println("Test");
    4.31 -    }
    4.32 -
    4.33 -    @AfterClass
    4.34 -    public void cleanUp() {
    4.35 -        // code that will be invoked after this test ends
    4.36 -    }
    4.37 -}