This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 162593
Collapse All | Expand All

(-)a/gsf.testrunner/apichanges.xml (+132 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 2013 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
The contents of this file are subject to the terms of either the GNU
11
General Public License Version 2 only ("GPL") or the Common
12
Development and Distribution License("CDDL") (collectively, the
13
"License"). You may not use this file except in compliance with the
14
License. You can obtain a copy of the License at
15
http://www.netbeans.org/cddl-gplv2.html
16
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
17
specific language governing permissions and limitations under the
18
License.  When distributing the software, include this License Header
19
Notice in each file and include the License file at
20
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
21
particular file as subject to the "Classpath" exception as provided
22
by Oracle in the GPL Version 2 section of the License file that
23
accompanied this code. If applicable, add the following below the
24
License Header, with the fields enclosed by brackets [] replaced by
25
your own identifying information:
26
"Portions Copyrighted [year] [name of copyright owner]"
27
28
If you wish your version of this file to be governed by only the CDDL
29
or only the GPL Version 2, indicate your decision by adding
30
"[Contributor] elects to include this software in this distribution
31
under the [CDDL or GPL Version 2] license." If you do not indicate a
32
single choice of license, a recipient has the option to distribute
33
your version of this file under either the CDDL, the GPL Version 2 or
34
to extend the choice of license to its licensees as provided above.
35
However, if you add GPL Version 2 code and therefore, elected the GPL
36
Version 2 license, then the option applies only if the new code is
37
made subject to such option by the copyright holder.
38
39
Contributor(s):
40
41
Portions Copyrighted 2013 Sun Microsystems, Inc.
42
-->
43
44
45
<?xml-stylesheet href="../nbbuild/javadoctools/apichanges.xsl" type="text/xsl"?>
46
<!DOCTYPE apichanges PUBLIC "-//NetBeans//DTD API changes list 1.0//EN" "../nbbuild/javadoctools/apichanges.dtd">
47
48
<!-- INFO FOR PEOPLE ADDING CHANGES:
49
[most of contents snipped - see openide's apichanges for how-to instructions]
50
<change>
51
    <api name="compiler"/>
52
    <summary>Some brief description here, can use <b>XHTML</b></summary>
53
    <version major="1" minor="99"/>
54
    <date day="13" month="6" year="2001"/>
55
    <author login="jrhacker"/>
56
    <compatibility addition="yes"/>
57
    <description>
58
        The main description of the change here.
59
        Again can use full <b>XHTML</b> as needed.
60
    </description>
61
    <class package="org.openide.compiler" name="DoWhatIWantCompiler"/>
62
    <issue number="14309"/>
63
</change>
64
-->
65
66
<apichanges>
67
68
<!-- First, a list of API names you may use: -->
69
<apidefs>
70
        <apidef name="CommonTestrunnerAPI">Common Test Runner API</apidef>
71
</apidefs>
72
73
<!-- ACTUAL CHANGES BEGIN HERE: -->
74
75
<changes>
76
    <change id="TestCreatorPanelDisplayer">
77
        <api name="CommonTestrunnerAPI"/>
78
        <summary>API to open the configuration dialog when creating tests</summary>
79
        <version major="1" minor="33"/>
80
        <date day="13" month="2" year="2013"/>
81
        <author login="theofanis"/>
82
        <compatibility addition="yes"/>
83
        <description>
84
            Added API to open the configuration dialog when creating tests, so that it
85
	    can be used for example by java.testrunner hints.
86
        </description>
87
        <class package="org.netbeans.modules.gsf.testrunner.api" name="TestCreatorPanelDisplayer"/>
88
        <issue number="162593"/>
89
    </change>
90
</changes>
91
92
  <!-- Now the surrounding HTML text and document structure: -->
93
94
  <htmlcontents>
95
<!--
96
97
                            NO NO NO NO NO!
98
99
         ==============>    DO NOT EDIT ME!  <======================
100
101
          AUTOMATICALLY GENERATED FROM APICHANGES.XML, DO NOT EDIT
102
103
                SEE xml/api/doc/changes/apichanges.xml
104
105
	-->
106
	<head>
107
	    <title>Options Dialog API changes by date</title>
108
	    <link rel="stylesheet" href="prose.css" type="text/css"/>
109
	</head>
110
	<body>
111
112
	    <p class="overviewlink">
113
		<a href="overview-summary.html">Overview</a>
114
	    </p>
115
116
	    <h1>Introduction</h1>
117
118
	    <p>This document lists changes made to the Common Test Runner APIs. Please ask on the
119
		<code>nbdev@netbeans.org</code>
120
		mailing list if you have any questions about the details of a
121
		change, or are wondering how to convert existing code to be compatible.
122
	    </p>
123
124
	    <hr/>
125
	    <standard-changelists module-code-name="org.netbeans.modules.gsf.testrunner.api/1"/>
126
127
	    <hr/>
128
	    <p>@FOOTER@</p>
129
130
	</body>
131
    </htmlcontents>
132
</apichanges>
(-)a/gsf.testrunner/manifest.mf (-1 / +1 lines)
Lines 3-7 Link Here
3
OpenIDE-Module: org.netbeans.modules.gsf.testrunner/1
3
OpenIDE-Module: org.netbeans.modules.gsf.testrunner/1
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gsf/testrunner/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gsf/testrunner/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/gsf/testrunner/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/gsf/testrunner/layer.xml
6
OpenIDE-Module-Specification-Version: 1.32
6
OpenIDE-Module-Specification-Version: 1.33
7
7
(-)a/gsf.testrunner/nbproject/project.properties (+1 lines)
Lines 1-3 Link Here
1
is.autoload=true
1
is.autoload=true
2
javac.source=1.6
2
javac.source=1.6
3
javac.compilerargs=-Xlint -Xlint:-serial
3
javac.compilerargs=-Xlint -Xlint:-serial
4
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/gsf.testrunner/src/org/netbeans/modules/gsf/testrunner/CommonTestsCfgOfCreate.java (+15 lines)
Lines 582-587 Link Here
582
        cboxFramework.setModel(new DefaultComboBoxModel(testingFrameworks.toArray()));
582
        cboxFramework.setModel(new DefaultComboBoxModel(testingFrameworks.toArray()));
583
        fireFrameworkChanged();
583
        fireFrameworkChanged();
584
    }
584
    }
585
586
    public void setPreselectedLocation(Object location) {
587
	if (location != null) {
588
	    cboxLocation.setSelectedItem(location);
589
	    cboxLocation.setEnabled(false);
590
	}
591
    }
592
593
    public void setPreselectedFramework(String testingFramework) {
594
	if (testingFramework != null) {
595
	    cboxFramework.setSelectedItem(testingFramework);
596
	    cboxFramework.setEnabled(false);
597
	    setSelectedTestingFramework();
598
	}
599
    }
585
    
600
    
586
    /**
601
    /**
587
     */
602
     */
(-)a/gsf.testrunner/src/org/netbeans/modules/gsf/testrunner/TestCreatorAction.java (-47 / +2 lines)
Lines 44-63 Link Here
44
44
45
package org.netbeans.modules.gsf.testrunner;
45
package org.netbeans.modules.gsf.testrunner;
46
46
47
import java.io.IOException;
48
import java.util.ArrayList;
47
import java.util.ArrayList;
49
import java.util.Collection;
48
import java.util.Collection;
50
import org.netbeans.modules.gsf.testrunner.CommonTestsCfgOfCreate;
49
import org.netbeans.modules.gsf.testrunner.api.TestCreatorPanelDisplayer;
51
import org.netbeans.modules.gsf.testrunner.api.TestCreatorProvider;
50
import org.netbeans.modules.gsf.testrunner.api.TestCreatorProvider;
52
import org.netbeans.modules.gsf.testrunner.api.TestCreatorProvider.Registration;
53
import org.openide.awt.ActionID;
51
import org.openide.awt.ActionID;
54
import org.openide.awt.ActionReference;
52
import org.openide.awt.ActionReference;
55
import org.openide.awt.ActionReferences;
53
import org.openide.awt.ActionReferences;
56
import org.openide.awt.ActionRegistration;
54
import org.openide.awt.ActionRegistration;
57
import org.openide.cookies.SaveCookie;
58
import org.openide.loaders.DataObject;
59
import org.openide.nodes.Node;
55
import org.openide.nodes.Node;
60
import org.openide.util.Exceptions;
61
import org.openide.util.HelpCtx;
56
import org.openide.util.HelpCtx;
62
import org.openide.util.Lookup;
57
import org.openide.util.Lookup;
63
import org.openide.util.NbBundle;
58
import org.openide.util.NbBundle;
Lines 73-79 Link Here
73
    @ActionReference(path = "UI/ToolActions/Java")})
68
    @ActionReference(path = "UI/ToolActions/Java")})
74
@NbBundle.Messages({"LBL_CreateCommonTestAction=Create Tests"})
69
@NbBundle.Messages({"LBL_CreateCommonTestAction=Create Tests"})
75
public class TestCreatorAction extends NodeAction {
70
public class TestCreatorAction extends NodeAction {
76
    private ArrayList<String> testingFrameworksToAdd = new ArrayList<String>();
77
    
71
    
78
    /** Creates a new instance of TestCreatorAction */
72
    /** Creates a new instance of TestCreatorAction */
79
    public TestCreatorAction() {
73
    public TestCreatorAction() {
Lines 113-158 Link Here
113
107
114
    @Override
108
    @Override
115
    protected void performAction(Node[] activatedNodes) {
109
    protected void performAction(Node[] activatedNodes) {
116
        final DataObject[] modified = DataObject.getRegistry().getModified();
110
	TestCreatorPanelDisplayer.getDefault().displayPanel(activatedNodes, null, null);
117
        CommonTestsCfgOfCreate cfg = new CommonTestsCfgOfCreate(activatedNodes);
118
        cfg.createCfgPanel(modified.length == 0 ? false : true);
119
        
120
        testingFrameworksToAdd.clear();
121
        Collection<? extends Lookup.Item<TestCreatorProvider>> providers = Lookup.getDefault().lookupResult(TestCreatorProvider.class).allItems();
122
        for (Lookup.Item<TestCreatorProvider> provider : providers) {
123
            testingFrameworksToAdd.add(provider.getDisplayName());
124
        }
125
        cfg.addTestingFrameworks(testingFrameworksToAdd);
126
        if (!cfg.configure()) {
127
            return;
128
        }
129
        saveAll(modified); // #149048
130
        String selected = cfg.getSelectedTestingFramework();
131
        
132
        for (Lookup.Item<TestCreatorProvider> provider : providers) {
133
            if (provider.getDisplayName().equals(selected)) {
134
                TestCreatorProvider.Context context = new TestCreatorProvider.Context(activatedNodes);
135
                context.setSingleClass(cfg.isSingleClass());
136
                context.setTargetFolder(cfg.getTargetFolder());
137
                context.setTestClassName(cfg.getTestClassName());
138
                provider.getInstance().createTests(context);
139
                cfg = null;
140
                break;
141
            }
142
        }
143
    }
144
145
    private void saveAll(DataObject[] dataObjects) {
146
        for(DataObject dataObject: dataObjects) {
147
            SaveCookie saveCookie = dataObject.getLookup().lookup(SaveCookie.class);
148
            if(saveCookie != null) {
149
                try {
150
                    saveCookie.save();
151
                } catch (IOException ex) {
152
                    Exceptions.printStackTrace(ex);
153
                }
154
            }
155
        }
156
    }
111
    }
157
    
112
    
158
}
113
}
(-)a/gsf.testrunner/src/org/netbeans/modules/gsf/testrunner/api/TestCreatorPanelDisplayer.java (+111 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.gsf.testrunner.api;
43
44
import java.io.IOException;
45
import java.util.ArrayList;
46
import java.util.Collection;
47
import org.netbeans.modules.gsf.testrunner.CommonTestsCfgOfCreate;
48
import org.openide.cookies.SaveCookie;
49
import org.openide.loaders.DataObject;
50
import org.openide.nodes.Node;
51
import org.openide.util.Exceptions;
52
import org.openide.util.Lookup;
53
54
public final class TestCreatorPanelDisplayer {
55
56
    private static final TestCreatorPanelDisplayer INSTANCE = new TestCreatorPanelDisplayer();
57
58
    private TestCreatorPanelDisplayer() {}
59
    /**
60
     * Get the default <code>TestCreatorPanelDisplayer</code>
61
     * @return the default instance
62
     */
63
    public static TestCreatorPanelDisplayer getDefault() {
64
        return INSTANCE;
65
    }
66
67
    public void displayPanel(Node[] activatedNodes, Object location, String testingFramework) {
68
	final DataObject[] modified = DataObject.getRegistry().getModified();
69
	CommonTestsCfgOfCreate cfg = new CommonTestsCfgOfCreate(activatedNodes);
70
	cfg.createCfgPanel(modified.length == 0 ? false : true);
71
72
	ArrayList<String> testingFrameworks = new ArrayList<String>();
73
	Collection<? extends Lookup.Item<TestCreatorProvider>> providers = Lookup.getDefault().lookupResult(TestCreatorProvider.class).allItems();
74
	for (Lookup.Item<TestCreatorProvider> provider : providers) {
75
	    testingFrameworks.add(provider.getDisplayName());
76
	}
77
	cfg.addTestingFrameworks(testingFrameworks);
78
	cfg.setPreselectedLocation(location);
79
	cfg.setPreselectedFramework(testingFramework);
80
	if (!cfg.configure()) {
81
	    return;
82
	}
83
	saveAll(modified); // #149048
84
	String selected = cfg.getSelectedTestingFramework();
85
86
	for (Lookup.Item<TestCreatorProvider> provider : providers) {
87
	    if (provider.getDisplayName().equals(selected)) {
88
		TestCreatorProvider.Context context = new TestCreatorProvider.Context(activatedNodes);
89
		context.setSingleClass(cfg.isSingleClass());
90
		context.setTargetFolder(cfg.getTargetFolder());
91
		context.setTestClassName(cfg.getTestClassName());
92
		provider.getInstance().createTests(context);
93
		cfg = null;
94
		break;
95
	    }
96
	}
97
    }
98
99
    private void saveAll(DataObject[] dataObjects) {
100
	for (DataObject dataObject : dataObjects) {
101
	    SaveCookie saveCookie = dataObject.getLookup().lookup(SaveCookie.class);
102
	    if (saveCookie != null) {
103
		try {
104
		    saveCookie.save();
105
		} catch (IOException ex) {
106
		    Exceptions.printStackTrace(ex);
107
		}
108
	    }
109
	}
110
    }
111
}
(-)a/java.testrunner/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
AutoUpdate-Show-In-Client: false
2
AutoUpdate-Show-In-Client: false
3
OpenIDE-Module: org.netbeans.modules.java.testrunner
3
OpenIDE-Module: org.netbeans.modules.java.testrunner
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/testrunner/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/testrunner/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.6
5
OpenIDE-Module-Specification-Version: 1.7
6
6
(-)a/java.testrunner/nbproject/project.xml (-1 / +51 lines)
Lines 15-26 Link Here
15
                    </run-dependency>
15
                    </run-dependency>
16
                </dependency>
16
                </dependency>
17
                <dependency>
17
                <dependency>
18
                    <code-name-base>org.netbeans.api.java.classpath</code-name-base>
19
                    <build-prerequisite/>
20
                    <compile-dependency/>
21
                    <run-dependency>
22
                        <release-version>1</release-version>
23
                        <specification-version>1.37</specification-version>
24
                    </run-dependency>
25
                </dependency>
26
                <dependency>
27
                    <code-name-base>org.netbeans.libs.javacapi</code-name-base>
28
                    <build-prerequisite/>
29
                    <compile-dependency/>
30
                    <run-dependency>
31
                        <specification-version>7.14</specification-version>
32
                    </run-dependency>
33
                </dependency>
34
                <dependency>
18
                    <code-name-base>org.netbeans.modules.gsf.testrunner</code-name-base>
35
                    <code-name-base>org.netbeans.modules.gsf.testrunner</code-name-base>
19
                    <build-prerequisite/>
36
                    <build-prerequisite/>
20
                    <compile-dependency/>
37
                    <compile-dependency/>
21
                    <run-dependency>
38
                    <run-dependency>
22
                        <release-version>1</release-version>
39
                        <release-version>1</release-version>
23
                        <specification-version>1.26</specification-version>
40
                        <specification-version>1.33</specification-version>
24
                    </run-dependency>
41
                    </run-dependency>
25
                </dependency>
42
                </dependency>
26
                <dependency>
43
                <dependency>
Lines 33-38 Link Here
33
                    </run-dependency>
50
                    </run-dependency>
34
                </dependency>
51
                </dependency>
35
                <dependency>
52
                <dependency>
53
                    <code-name-base>org.netbeans.modules.java.source</code-name-base>
54
                    <build-prerequisite/>
55
                    <compile-dependency/>
56
                    <run-dependency>
57
                        <specification-version>0.111</specification-version>
58
                    </run-dependency>
59
                </dependency>
60
                <dependency>
36
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
61
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
37
                    <build-prerequisite/>
62
                    <build-prerequisite/>
38
                    <compile-dependency/>
63
                    <compile-dependency/>
Lines 42-47 Link Here
42
                    </run-dependency>
67
                    </run-dependency>
43
                </dependency>
68
                </dependency>
44
                <dependency>
69
                <dependency>
70
                    <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
71
                    <build-prerequisite/>
72
                    <compile-dependency/>
73
                    <run-dependency>
74
                        <release-version>0</release-version>
75
                        <specification-version>1.29</specification-version>
76
                    </run-dependency>
77
                </dependency>
78
                <dependency>
79
                    <code-name-base>org.netbeans.spi.java.hints</code-name-base>
80
                    <build-prerequisite/>
81
                    <compile-dependency/>
82
                    <run-dependency>
83
                        <specification-version>1.11</specification-version>
84
                    </run-dependency>
85
                </dependency>
86
                <dependency>
45
                    <code-name-base>org.openide.awt</code-name-base>
87
                    <code-name-base>org.openide.awt</code-name-base>
46
                    <build-prerequisite/>
88
                    <build-prerequisite/>
47
                    <compile-dependency/>
89
                    <compile-dependency/>
Lines 50-55 Link Here
50
                    </run-dependency>
92
                    </run-dependency>
51
                </dependency>
93
                </dependency>
52
                <dependency>
94
                <dependency>
95
                    <code-name-base>org.openide.dialogs</code-name-base>
96
                    <build-prerequisite/>
97
                    <compile-dependency/>
98
                    <run-dependency>
99
                        <specification-version>7.29</specification-version>
100
                    </run-dependency>
101
                </dependency>
102
                <dependency>
53
                    <code-name-base>org.openide.filesystems</code-name-base>
103
                    <code-name-base>org.openide.filesystems</code-name-base>
54
                    <build-prerequisite/>
104
                    <build-prerequisite/>
55
                    <compile-dependency/>
105
                    <compile-dependency/>
(-)a/java.testrunner/src/org/netbeans/modules/java/testrunner/hints/CreateTestClassHint.java (+183 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.java.testrunner.hints;
43
44
import com.sun.source.tree.ClassTree;
45
import com.sun.source.tree.Tree;
46
import com.sun.source.util.SourcePositions;
47
import com.sun.source.util.TreePath;
48
import java.io.File;
49
import java.util.ArrayList;
50
import java.util.Collection;
51
import java.util.HashMap;
52
import java.util.Map.Entry;
53
import javax.lang.model.element.TypeElement;
54
import org.netbeans.api.java.classpath.ClassPath;
55
import org.netbeans.api.java.source.ClasspathInfo;
56
import org.netbeans.api.java.source.CompilationInfo;
57
import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
58
import org.netbeans.api.project.FileOwnerQuery;
59
import org.netbeans.api.project.Project;
60
import org.netbeans.api.project.SourceGroup;
61
import org.netbeans.api.project.SourceGroupModifier;
62
import org.netbeans.modules.gsf.testrunner.api.TestCreatorPanelDisplayer;
63
import org.netbeans.modules.gsf.testrunner.api.TestCreatorProvider;
64
import org.netbeans.modules.gsf.testrunner.plugin.CommonTestUtilProvider;
65
import org.netbeans.modules.gsf.testrunner.plugin.GuiUtilsProvider;
66
import org.netbeans.modules.gsf.testrunner.plugin.RootsProvider;
67
import org.netbeans.spi.editor.hints.ErrorDescription;
68
import org.netbeans.spi.editor.hints.Fix;
69
import org.netbeans.spi.editor.hints.Severity;
70
import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
71
import org.netbeans.spi.java.hints.Hint;
72
import org.netbeans.spi.java.hints.HintContext;
73
import org.netbeans.spi.java.hints.JavaFix;
74
import org.netbeans.spi.java.hints.TriggerTreeKind;
75
import org.openide.filesystems.FileObject;
76
import org.openide.filesystems.FileUtil;
77
import org.openide.loaders.DataObject;
78
import org.openide.loaders.DataObjectNotFoundException;
79
import org.openide.nodes.Node;
80
import org.openide.util.Exceptions;
81
import org.openide.util.Lookup;
82
import org.openide.util.NbBundle.Messages;
83
84
@Hint(displayName = "#DN_CreateTestClassHint", description = "#DESC_CreateTestClassHint", category = "general"
85
	, hintKind = Hint.Kind.INSPECTION, severity = Severity.HINT)
86
@Messages({
87
    "DN_CreateTestClassHint=Create Test Class",
88
    "DESC_CreateTestClassHint=Create a test class for the selected source class"
89
})
90
public class CreateTestClassHint {
91
92
    private static HashMap<Object, ArrayList<String>> validCombinations;
93
94
    @TriggerTreeKind(Tree.Kind.CLASS)
95
    @Messages("ERR_CreateTestClassHint=Create Test Class")
96
    public static ErrorDescription computeWarning(HintContext context) {
97
	TreePath tp = context.getPath();
98
        ClassTree cls = (ClassTree) tp.getLeaf();
99
        CompilationInfo info = context.getInfo();
100
        SourcePositions sourcePositions = info.getTrees().getSourcePositions();
101
        int startPos = (int) sourcePositions.getStartPosition(tp.getCompilationUnit(), cls);
102
        int caret = CaretAwareJavaSourceTaskFactory.getLastPosition(context.getInfo().getFileObject());
103
        String code = context.getInfo().getText();
104
	if (startPos < 0 || caret < 0 || caret < startPos || caret >= code.length()) {
105
            return null;
106
        }
107
108
        String headerText = code.substring(startPos, caret);
109
        int idx = headerText.indexOf('{'); //NOI18N
110
        if (idx >= 0) {
111
            return null;
112
        }
113
114
        ClassPath cp = info.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
115
        FileObject root = cp.findOwnerRoot(info.getFileObject());
116
        if (root == null) { //File not part of any project
117
            return null;
118
        }
119
120
	Collection<? extends Lookup.Item<TestCreatorProvider>> providers = Lookup.getDefault().lookupResult(TestCreatorProvider.class).allItems();
121
        boolean enable;
122
	DataObject dataObject;
123
	Node activeNode = null;
124
	try {
125
	    dataObject = DataObject.find(info.getFileObject());
126
	    activeNode = dataObject.getNodeDelegate();
127
	} catch (DataObjectNotFoundException ex) {
128
	    Exceptions.printStackTrace(ex);
129
	}
130
	if (activeNode != null) {
131
	    validCombinations = Utils.getValidCombinations(info, null);
132
133
	    for (Lookup.Item<TestCreatorProvider> provider : providers) {
134
		enable = provider.getInstance().enable(new Node[]{activeNode});
135
		if (enable && !validCombinations.isEmpty()) {
136
		    ArrayList<Fix> fixes = new ArrayList<Fix>();
137
		    Fix fix;
138
		    for(Entry<Object, ArrayList<String>> entrySet : validCombinations.entrySet()) {
139
			Object location = entrySet.getKey();
140
			for(String testingFramework : entrySet.getValue()) {
141
			    fix = new CreateTestClassFix(context.getInfo(), context.getPath(), new Node[]{activeNode}, 
142
				    location, testingFramework).toEditorFix();
143
			    fixes.add(fix);
144
			}
145
		    }
146
		    return ErrorDescriptionFactory.forTree(context, context.getPath(), Bundle.ERR_CreateTestClassHint(),
147
			    fixes.toArray(new Fix[fixes.size()]));
148
		}
149
	    }
150
	}
151
	return null;
152
    }
153
154
    private static final class CreateTestClassFix extends JavaFix {
155
156
	CompilationInfo info;
157
	Node[] activatedNodes;
158
	Object location;
159
	String testingFramework;
160
161
	public CreateTestClassFix(CompilationInfo info, TreePath tp, Node[] activatedNodes, Object location, String testingFramework) {
162
	    super(info, tp);
163
	    this.info = info;
164
	    this.activatedNodes = activatedNodes;
165
	    this.location = location;
166
	    this.testingFramework = testingFramework;
167
	}
168
169
	@Override
170
	@Messages({
171
        "# {0} - the testing framework to be used, e.g. JUnit, TestNG,...",
172
        "# {1} - the location where the test class will be created",
173
	"FIX_CreateTestClassHint=Create Test Class [{0} in {1}]"})
174
	protected String getText() {
175
	    return Bundle.FIX_CreateTestClassHint(testingFramework, Utils.getLocationText(location));
176
	}
177
178
	@Override
179
	protected void performRewrite(TransformationContext ctx) {
180
	    TestCreatorPanelDisplayer.getDefault().displayPanel(activatedNodes, location, testingFramework);
181
	}
182
    }
183
}
(-)a/java.testrunner/src/org/netbeans/modules/java/testrunner/hints/CreateTestMethodsHint.java (+191 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.java.testrunner.hints;
43
44
import com.sun.source.tree.ClassTree;
45
import com.sun.source.tree.MethodTree;
46
import com.sun.source.tree.Tree;
47
import com.sun.source.util.SourcePositions;
48
import com.sun.source.util.TreePath;
49
import java.io.File;
50
import java.io.IOException;
51
import java.util.ArrayList;
52
import java.util.Collection;
53
import java.util.HashMap;
54
import java.util.Map.Entry;
55
import javax.lang.model.element.Modifier;
56
import javax.lang.model.element.TypeElement;
57
import org.netbeans.api.java.classpath.ClassPath;
58
import org.netbeans.api.java.source.ClasspathInfo;
59
import org.netbeans.api.java.source.CompilationInfo;
60
import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory;
61
import org.netbeans.api.project.FileOwnerQuery;
62
import org.netbeans.api.project.Project;
63
import org.netbeans.api.project.SourceGroup;
64
import org.netbeans.api.project.SourceGroupModifier;
65
import org.netbeans.modules.gsf.testrunner.api.TestCreatorPanelDisplayer;
66
import org.netbeans.modules.gsf.testrunner.api.TestCreatorProvider;
67
import org.netbeans.modules.gsf.testrunner.plugin.CommonTestUtilProvider;
68
import org.netbeans.modules.gsf.testrunner.plugin.GuiUtilsProvider;
69
import org.netbeans.modules.gsf.testrunner.plugin.RootsProvider;
70
import org.netbeans.spi.editor.hints.ErrorDescription;
71
import org.netbeans.spi.editor.hints.Fix;
72
import org.netbeans.spi.editor.hints.Severity;
73
import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
74
import org.netbeans.spi.java.hints.Hint;
75
import org.netbeans.spi.java.hints.HintContext;
76
import org.netbeans.spi.java.hints.JavaFix;
77
import org.netbeans.spi.java.hints.TriggerTreeKind;
78
import org.openide.filesystems.FileObject;
79
import org.openide.filesystems.FileUtil;
80
import org.openide.loaders.DataObject;
81
import org.openide.loaders.DataObjectNotFoundException;
82
import org.openide.nodes.Node;
83
import org.openide.util.Exceptions;
84
import org.openide.util.Lookup;
85
import org.openide.util.NbBundle.Messages;
86
87
@Hint(displayName = "#DN_CreateTestMethodsHint", description = "#DESC_CreateTestMethodsHint", category = "general"
88
	, hintKind = Hint.Kind.INSPECTION, severity = Severity.HINT)
89
@Messages({
90
    "DN_CreateTestMethodsHint=Generate All Test Methods",
91
    "DESC_CreateTestMethodsHint=Generate all test methods for the selected source class"
92
})
93
public class CreateTestMethodsHint {
94
95
    private static HashMap<Object, ArrayList<String>> validCombinations;
96
97
    @TriggerTreeKind(Tree.Kind.METHOD)
98
    @Messages("ERR_CreateTestMethodsHint=Generate All Test Methods")
99
    public static ErrorDescription computeWarning(HintContext context) {
100
        final TreePath tp = context.getPath();
101
        final MethodTree method = (MethodTree) tp.getLeaf();
102
	if (method.getModifiers().getFlags().contains(Modifier.PRIVATE)) {
103
	    return null;
104
	}
105
	String methodName = method.getName().toString();
106
107
        CompilationInfo info = context.getInfo();
108
        SourcePositions sourcePositions = info.getTrees().getSourcePositions();
109
        int startPos = (int) sourcePositions.getStartPosition(tp.getCompilationUnit(), method);
110
        int caret = CaretAwareJavaSourceTaskFactory.getLastPosition(context.getInfo().getFileObject());
111
        String code = context.getInfo().getText();
112
	if (startPos < 0 || caret < 0 || caret < startPos || caret >= code.length()) {
113
            return null;
114
        }
115
116
        String headerText = code.substring(startPos, caret);
117
        int idx = headerText.indexOf('{'); //NOI18N
118
        if (idx >= 0) {
119
            return null;
120
        }
121
122
        ClassPath cp = info.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
123
        FileObject root = cp.findOwnerRoot(info.getFileObject());
124
        if (root == null) { //File not part of any project
125
            return null;
126
        }
127
128
	Collection<? extends Lookup.Item<TestCreatorProvider>> providers = Lookup.getDefault().lookupResult(TestCreatorProvider.class).allItems();
129
        boolean enable;
130
	DataObject dataObject;
131
	Node activeNode = null;
132
	try {
133
	    dataObject = DataObject.find(info.getFileObject());
134
	    activeNode = dataObject.getNodeDelegate();
135
	} catch (DataObjectNotFoundException ex) {
136
	    Exceptions.printStackTrace(ex);
137
	}
138
	if (activeNode != null) {
139
	    validCombinations = Utils.getValidCombinations(info, methodName);
140
141
	    for (Lookup.Item<TestCreatorProvider> provider : providers) {
142
		enable = provider.getInstance().enable(new Node[]{activeNode});
143
		if (enable && !validCombinations.isEmpty()) {
144
		    ArrayList<Fix> fixes = new ArrayList<Fix>();
145
		    Fix fix;
146
		    for(Entry<Object, ArrayList<String>> entrySet : validCombinations.entrySet()) {
147
			Object location = entrySet.getKey();
148
			for(String testingFramework : entrySet.getValue()) {
149
			    fix = new CreateTestMethodsFix(context.getInfo(), context.getPath(), new Node[]{activeNode},
150
				    location, testingFramework).toEditorFix();
151
			    fixes.add(fix);
152
			}
153
		    }
154
		    return ErrorDescriptionFactory.forTree(context, context.getPath(), Bundle.ERR_CreateTestMethodsHint(),
155
			    fixes.toArray(new Fix[fixes.size()]));
156
		}
157
	    }
158
	}
159
	return null;
160
    }
161
162
    private static final class CreateTestMethodsFix extends JavaFix {
163
164
	CompilationInfo info;
165
	Node[] activatedNodes;
166
	Object location;
167
	String testingFramework;
168
169
	public CreateTestMethodsFix(CompilationInfo info, TreePath tp, Node[] activatedNodes, Object location, String testingFramework) {
170
	    super(info, tp);
171
	    this.info = info;
172
	    this.activatedNodes = activatedNodes;
173
	    this.location = location;
174
	    this.testingFramework = testingFramework;
175
	}
176
177
	@Override
178
	@Messages({
179
        "# {0} - the testing framework to be used, e.g. JUnit, TestNG,...",
180
        "# {1} - the location where the test class is",
181
	"FIX_CreateTestMethodsHint=Generate All Test Methods [{0} in {1}]"})
182
	protected String getText() {
183
	    return Bundle.FIX_CreateTestMethodsHint(testingFramework, Utils.getLocationText(location));
184
	}
185
186
	@Override
187
	protected void performRewrite(TransformationContext ctx) {
188
	    TestCreatorPanelDisplayer.getDefault().displayPanel(activatedNodes, location, testingFramework);
189
	}
190
    }
191
}
(-)a/java.testrunner/src/org/netbeans/modules/java/testrunner/hints/Utils.java (+202 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.java.testrunner.hints;
43
44
import java.io.File;
45
import java.io.IOException;
46
import java.util.ArrayList;
47
import java.util.Collection;
48
import java.util.HashMap;
49
import org.netbeans.api.java.classpath.ClassPath;
50
import org.netbeans.api.java.source.CompilationInfo;
51
import org.netbeans.api.project.FileOwnerQuery;
52
import org.netbeans.api.project.Project;
53
import org.netbeans.api.project.SourceGroup;
54
import org.netbeans.api.project.SourceGroupModifier;
55
import org.netbeans.modules.gsf.testrunner.api.TestCreatorProvider;
56
import org.netbeans.modules.gsf.testrunner.plugin.CommonTestUtilProvider;
57
import org.netbeans.modules.gsf.testrunner.plugin.GuiUtilsProvider;
58
import org.netbeans.modules.gsf.testrunner.plugin.RootsProvider;
59
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileUtil;
61
import org.openide.loaders.DataObject;
62
import org.openide.util.Exceptions;
63
import org.openide.util.Lookup;
64
65
/**
66
 *
67
 * @author theofanis
68
 */
69
public class Utils {
70
71
    private static final String TEST_CLASS_SUFFIX = "Test"; //NOI18N
72
    private static ArrayList<String> testingFrameworks;
73
    private static Object[] locations;
74
75
    public static String getLocationText(Object location) {
76
	String text = location instanceof SourceGroup
77
		? ((SourceGroup) location).getDisplayName()
78
		: location instanceof FileObject
79
		? FileUtil.getFileDisplayName((FileObject) location)
80
		: location.toString();
81
	return text;
82
    }
83
84
    public static HashMap<Object, ArrayList<String>> getValidCombinations(CompilationInfo info, String methodName) {
85
	populateTestingFrameworks();
86
	populateLocations(info.getFileObject());
87
	HashMap<Object, ArrayList<String>> validCombinations = new HashMap<Object, ArrayList<String>>();
88
	for (Object location : locations) {
89
	    FileObject targetFolder = Utils.getTargetFolder(location);
90
	    ArrayList<String> framework2Add = new ArrayList<String>();
91
	    for (String framework : testingFrameworks) {
92
		String preffiledName = Utils.getPreffiledName(info, framework);
93
		preffiledName = preffiledName.replaceAll("\\.", "/").concat(".java"); //NOI18N
94
		String path = targetFolder.getPath().concat("/").concat(preffiledName);
95
		File f = new File(path);
96
		FileObject fo = FileUtil.toFileObject(f);
97
		if(methodName == null) {
98
		    if (fo == null) {
99
			framework2Add.add(framework);
100
		    }
101
		} else {
102
		    try {
103
			String testMethodName = getTestMethodName(methodName);
104
			if (fo != null && !fo.asText().replaceAll("\n", "").trim().contains(testMethodName.concat("("))) { //NOI18N
105
			    framework2Add.add(framework);
106
			}
107
		    } catch (IOException ex) {
108
			Exceptions.printStackTrace(ex);
109
		    }
110
		}
111
	    }
112
	    if (!framework2Add.isEmpty()) {
113
		validCombinations.put(location, framework2Add);
114
	    }
115
	}
116
	return validCombinations;
117
    }
118
119
    private static String getTestMethodName(String methodName) {
120
	return "test" + capitalizeFirstLetter(methodName); //NOI18N
121
    }
122
123
    private static String capitalizeFirstLetter(String str) {
124
        if (str == null || str.length() <= 0) {
125
            return str;
126
        }
127
128
        char chars[] = str.toCharArray();
129
        chars[0] = Character.toUpperCase(chars[0]);
130
        return new String(chars);
131
    }
132
133
    private static void populateTestingFrameworks() {
134
	testingFrameworks = new ArrayList<String>();
135
	Collection<? extends Lookup.Item<TestCreatorProvider>> testCreatorProviders = Lookup.getDefault().lookupResult(TestCreatorProvider.class).allItems();
136
	for (Lookup.Item<TestCreatorProvider> provider : testCreatorProviders) {
137
	    testingFrameworks.add(provider.getDisplayName());
138
	}
139
    }
140
141
    private static void populateLocations(FileObject activeFO) {
142
	Collection<? extends CommonTestUtilProvider> testUtilProviders = Lookup.getDefault().lookupAll(CommonTestUtilProvider.class);
143
	for (CommonTestUtilProvider provider : testUtilProviders) {
144
	    locations = provider.getTestTargets(activeFO);
145
	    break;
146
	}
147
	if (locations != null && locations.length == 0) {
148
	    Project owner = FileOwnerQuery.getOwner(activeFO);
149
	    if (owner != null) {
150
		String type = "";
151
		String hint = "";
152
		Collection<? extends RootsProvider> rootProviders = Lookup.getDefault().lookupAll(RootsProvider.class);
153
		for (RootsProvider rootProvider : rootProviders) {
154
		    type = rootProvider.getSourceRootType();
155
		    hint = rootProvider.getProjectTestsHint();
156
		    break;
157
		}
158
		if (SourceGroupModifier.createSourceGroup(owner, type, hint) != null) {
159
		    testUtilProviders = Lookup.getDefault().lookupAll(CommonTestUtilProvider.class);
160
		    for (CommonTestUtilProvider provider : testUtilProviders) {
161
			locations = provider.getTestTargets(activeFO);
162
			break;
163
		    }
164
		}
165
	    }
166
	}
167
    }
168
169
    private static String getPreffiledName(CompilationInfo info, String selectedFramework) {
170
	DataObject dataObj = info.getFileObject().getLookup().lookup(DataObject.class);
171
	FileObject fileObj = dataObj.getPrimaryFile();
172
	ClassPath cp = ClassPath.getClassPath(fileObj, ClassPath.SOURCE);
173
	String className = cp.getResourceName(fileObj, '.', false);
174
	return className + getTestingFrameworkSuffix(selectedFramework) + TEST_CLASS_SUFFIX;
175
    }
176
177
    private static String getTestingFrameworkSuffix(String selectedFramework) {
178
	if (selectedFramework == null) {
179
	    return "";
180
	}
181
	String testngFramework = "";
182
	Collection<? extends GuiUtilsProvider> providers = Lookup.getDefault().lookupAll(GuiUtilsProvider.class);
183
	for (GuiUtilsProvider provider : providers) {
184
	    testngFramework = provider.getTestngFramework();
185
	    break;
186
	}
187
	return selectedFramework.equals(testngFramework) ? "NG" : ""; //NOI18N
188
    }
189
190
    private static FileObject getTargetFolder(Object selectedLocation) {
191
	if (selectedLocation == null) {
192
	    return null;
193
	}
194
195
	if (selectedLocation instanceof SourceGroup) {
196
	    return ((SourceGroup) selectedLocation).getRootFolder();
197
	}
198
	assert selectedLocation instanceof FileObject;      //root folder
199
	return (FileObject) selectedLocation;
200
    }
201
202
}

Return to bug 162593