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 268677
Collapse All | Expand All

(-)a/api.maven/nbproject/project.properties (-1 / +1 lines)
Lines 39-45 Link Here
39
# Portions Copyrighted 2008 Sun Microsystems, Inc.
39
# Portions Copyrighted 2008 Sun Microsystems, Inc.
40
40
41
is.autoload=true
41
is.autoload=true
42
javac.source=1.6
42
javac.source=1.8
43
javac.compilerargs=-Xlint -Xlint:-serial
43
javac.compilerargs=-Xlint -Xlint:-serial
44
javadoc.apichanges=${basedir}/apichanges.xml
44
javadoc.apichanges=${basedir}/apichanges.xml
45
javadoc.arch=${basedir}/arch.xml
45
javadoc.arch=${basedir}/arch.xml
(-)a/api.maven/nbproject/project.xml (-2 / +51 lines)
Lines 59-64 Link Here
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
62
                    <code-name-base>org.netbeans.api.templates</code-name-base>
63
                    <build-prerequisite/>
64
                    <compile-dependency/>
65
                    <run-dependency>
66
                        <specification-version>1.0</specification-version>
67
                    </run-dependency>
68
                </dependency>
69
                <dependency>
70
                    <code-name-base>org.netbeans.core.multiview</code-name-base>
71
                    <build-prerequisite/>
72
                    <compile-dependency/>
73
                    <run-dependency>
74
                        <release-version>1</release-version>
75
                        <specification-version>1.44</specification-version>
76
                    </run-dependency>
77
                </dependency>
78
                <dependency>
62
                    <code-name-base>org.netbeans.modules.maven</code-name-base>
79
                    <code-name-base>org.netbeans.modules.maven</code-name-base>
63
                    <build-prerequisite/>
80
                    <build-prerequisite/>
64
                    <compile-dependency/>
81
                    <compile-dependency/>
Lines 68-73 Link Here
68
                    </run-dependency>
85
                    </run-dependency>
69
                </dependency>
86
                </dependency>
70
                <dependency>
87
                <dependency>
88
                    <code-name-base>org.openide.awt</code-name-base>
89
                    <build-prerequisite/>
90
                    <compile-dependency/>
91
                    <run-dependency>
92
                        <specification-version>7.67</specification-version>
93
                    </run-dependency>
94
                </dependency>
95
                <dependency>
71
                    <code-name-base>org.openide.dialogs</code-name-base>
96
                    <code-name-base>org.openide.dialogs</code-name-base>
72
                    <build-prerequisite/>
97
                    <build-prerequisite/>
73
                    <compile-dependency/>
98
                    <compile-dependency/>
Lines 92-102 Link Here
92
                    </run-dependency>
117
                    </run-dependency>
93
                </dependency>
118
                </dependency>
94
                <dependency>
119
                <dependency>
95
                    <code-name-base>org.netbeans.api.templates</code-name-base>
120
                    <code-name-base>org.openide.nodes</code-name-base>
96
                    <build-prerequisite/>
121
                    <build-prerequisite/>
97
                    <compile-dependency/>
122
                    <compile-dependency/>
98
                    <run-dependency>
123
                    <run-dependency>
99
                        <specification-version>1.0</specification-version>
124
                        <specification-version>7.45</specification-version>
125
                    </run-dependency>
126
                </dependency>
127
                <dependency>
128
                    <code-name-base>org.openide.util</code-name-base>
129
                    <build-prerequisite/>
130
                    <compile-dependency/>
131
                    <run-dependency>
132
                        <specification-version>9.7</specification-version>
100
                    </run-dependency>
133
                    </run-dependency>
101
                </dependency>
134
                </dependency>
102
                <dependency>
135
                <dependency>
Lines 107-112 Link Here
107
                        <specification-version>8.0</specification-version>
140
                        <specification-version>8.0</specification-version>
108
                    </run-dependency>
141
                    </run-dependency>
109
                </dependency>
142
                </dependency>
143
                <dependency>
144
                    <code-name-base>org.openide.util.ui</code-name-base>
145
                    <build-prerequisite/>
146
                    <compile-dependency/>
147
                    <run-dependency>
148
                        <specification-version>9.6</specification-version>
149
                    </run-dependency>
150
                </dependency>
151
                <dependency>
152
                    <code-name-base>org.openide.windows</code-name-base>
153
                    <build-prerequisite/>
154
                    <compile-dependency/>
155
                    <run-dependency>
156
                        <specification-version>6.75</specification-version>
157
                    </run-dependency>
158
                </dependency>
110
            </module-dependencies>
159
            </module-dependencies>
111
            <test-dependencies>
160
            <test-dependencies>
112
                <test-type>
161
                <test-type>
(-)a/maven/nbproject/project.xml (-2 / +8 lines)
Lines 572-577 Link Here
572
                        <compile-dependency/>
572
                        <compile-dependency/>
573
                    </test-dependency>
573
                    </test-dependency>
574
                    <test-dependency>
574
                    <test-dependency>
575
                        <code-name-base>org.netbeans.modules.templatesui</code-name-base>
576
                        <recursive/>
577
                        <compile-dependency/>
578
                    </test-dependency>
579
                    <test-dependency>
575
                        <code-name-base>org.netbeans.modules.xml.xdm</code-name-base>
580
                        <code-name-base>org.netbeans.modules.xml.xdm</code-name-base>
576
                        <recursive/>
581
                        <recursive/>
577
                    </test-dependency>
582
                    </test-dependency>
Lines 581-592 Link Here
581
                        <test/>
586
                        <test/>
582
                    </test-dependency>
587
                    </test-dependency>
583
                    <test-dependency>
588
                    <test-dependency>
584
                        <code-name-base>org.openide.util.ui</code-name-base>
589
                        <code-name-base>org.openide.util.lookup</code-name-base>
585
                        <compile-dependency/>
590
                        <compile-dependency/>
586
                        <test/>
591
                        <test/>
587
                    </test-dependency>
592
                    </test-dependency>
588
                    <test-dependency>
593
                    <test-dependency>
589
                        <code-name-base>org.openide.util.lookup</code-name-base>
594
                        <code-name-base>org.openide.util.ui</code-name-base>
595
                        <recursive/>
590
                        <compile-dependency/>
596
                        <compile-dependency/>
591
                        <test/>
597
                        <test/>
592
                    </test-dependency>
598
                    </test-dependency>
(-)a/maven/src/org/netbeans/modules/maven/api/archetype/ArchetypeWizards.java (+6 lines)
Lines 47-52 Link Here
47
import java.util.Map;
47
import java.util.Map;
48
import java.util.Set;
48
import java.util.Set;
49
import org.netbeans.api.annotations.common.NullAllowed;
49
import org.netbeans.api.annotations.common.NullAllowed;
50
import org.netbeans.api.project.Project;
50
import org.netbeans.api.templates.TemplateRegistration;
51
import org.netbeans.api.templates.TemplateRegistration;
51
import org.netbeans.modules.maven.model.ModelOperation;
52
import org.netbeans.modules.maven.model.ModelOperation;
52
import org.netbeans.modules.maven.model.pom.POMModel;
53
import org.netbeans.modules.maven.model.pom.POMModel;
Lines 54-59 Link Here
54
import org.netbeans.modules.maven.newproject.BasicWizardPanel;
55
import org.netbeans.modules.maven.newproject.BasicWizardPanel;
55
import org.netbeans.modules.maven.newproject.MavenWizardIterator;
56
import org.netbeans.modules.maven.newproject.MavenWizardIterator;
56
import org.netbeans.validation.api.ui.ValidationGroup;
57
import org.netbeans.validation.api.ui.ValidationGroup;
58
import org.netbeans.validation.api.ui.ValidationGroupProvider;
57
import org.openide.WizardDescriptor;
59
import org.openide.WizardDescriptor;
58
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileObject;
59
61
Lines 107-112 Link Here
107
        return new BasicWizardPanel(vg, archetype, isFinish, false);
109
        return new BasicWizardPanel(vg, archetype, isFinish, false);
108
    }
110
    }
109
111
112
    static WizardDescriptor.Panel<WizardDescriptor> basicWizardPanel(Object p, String type) {
113
        return basicWizardPanel(ValidationGroup.create(), false, null);
114
    }
115
110
    /**
116
    /**
111
     * Wizard iterator using a predetermined archetype.
117
     * Wizard iterator using a predetermined archetype.
112
     * @since 2.28
118
     * @since 2.28
(-)a/maven/src/org/netbeans/modules/maven/execute/MavenCommandLineExecutor.java (-7 / +9 lines)
Lines 67-73 Link Here
67
import java.util.zip.ZipInputStream;
67
import java.util.zip.ZipInputStream;
68
import javax.swing.AbstractAction;
68
import javax.swing.AbstractAction;
69
import org.apache.maven.artifact.Artifact;
69
import org.apache.maven.artifact.Artifact;
70
import org.apache.maven.artifact.versioning.ArtifactVersion;
71
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
70
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
72
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
71
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
73
import org.apache.maven.artifact.versioning.VersionRange;
72
import org.apache.maven.artifact.versioning.VersionRange;
Lines 78-84 Link Here
78
import org.codehaus.plexus.util.IOUtil;
77
import org.codehaus.plexus.util.IOUtil;
79
import org.codehaus.plexus.util.cli.CommandLineUtils;
78
import org.codehaus.plexus.util.cli.CommandLineUtils;
80
import org.codehaus.plexus.util.xml.Xpp3Dom;
79
import org.codehaus.plexus.util.xml.Xpp3Dom;
81
import org.netbeans.api.extexecution.ExternalProcessSupport;
82
import org.netbeans.api.extexecution.base.Processes;
80
import org.netbeans.api.extexecution.base.Processes;
83
import org.netbeans.api.progress.ProgressHandle;
81
import org.netbeans.api.progress.ProgressHandle;
84
import org.netbeans.api.progress.ProgressHandleFactory;
82
import org.netbeans.api.progress.ProgressHandleFactory;
Lines 604-613 Link Here
604
        }
602
        }
605
       
603
       
606
        //#195039
604
        //#195039
607
        builder.environment().put("M2_HOME", mavenHome.getAbsolutePath());
605
        if (mavenHome != null) {
608
        if (!mavenHome.equals(EmbedderFactory.getDefaultMavenHome())) {
606
            builder.environment().put("M2_HOME", mavenHome.getAbsolutePath());
609
            //only relevant display when using the non-default maven installation.
607
            if (!mavenHome.equals(EmbedderFactory.getDefaultMavenHome())) {
610
            display.append(Utilities.escapeParameters(new String[] {"M2_HOME=" + mavenHome.getAbsolutePath()})).append(' '); // NOI18N
608
                //only relevant display when using the non-default maven installation.
609
                display.append(Utilities.escapeParameters(new String[] {"M2_HOME=" + mavenHome.getAbsolutePath()})).append(' '); // NOI18N
610
            }
611
        }
611
        }
612
612
613
        //very hacky here.. have a way to remove
613
        //very hacky here.. have a way to remove
Lines 709-715 Link Here
709
            mavenPath = delimiter + mavenPath;
709
            mavenPath = delimiter + mavenPath;
710
        }
710
        }
711
        //netbeans-eventspy.jar comes first on classpath
711
        //netbeans-eventspy.jar comes first on classpath
712
        mavenPath = jar.getAbsolutePath() + mavenPath;
712
        if (jar != null) {
713
            mavenPath = jar.getAbsolutePath() + mavenPath;
714
        }
713
        clonedConfig.setProperty(CosChecker.MAVENEXTCLASSPATH, mavenPath);
715
        clonedConfig.setProperty(CosChecker.MAVENEXTCLASSPATH, mavenPath);
714
    }
716
    }
715
717
(-)e66070a74aa4 (+174 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright (c) 2016 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
package org.netbeans.modules.maven.newproject;
41
42
import java.io.File;
43
import java.io.IOException;
44
import java.io.InputStream;
45
import java.util.ArrayList;
46
import java.util.Collection;
47
import java.util.Collections;
48
import java.util.Enumeration;
49
import java.util.List;
50
import java.util.Map;
51
import java.util.Properties;
52
import java.util.regex.Pattern;
53
import org.netbeans.api.project.Project;
54
import org.netbeans.api.project.ProjectManager;
55
import org.netbeans.api.templates.CreateDescriptor;
56
import org.netbeans.api.templates.CreateFromTemplateHandler;
57
import org.netbeans.modules.maven.api.archetype.Archetype;
58
import org.netbeans.modules.maven.api.archetype.ArchetypeWizards;
59
import org.netbeans.modules.maven.api.archetype.ProjectInfo;
60
import org.netbeans.spi.project.ActionProvider;
61
import org.netbeans.spi.project.ui.support.CommonProjectActions;
62
import org.openide.filesystems.FileObject;
63
import org.openide.filesystems.FileUtil;
64
import org.openide.util.NbBundle;
65
import org.openide.util.NbCollections;
66
import org.openide.util.lookup.ServiceProvider;
67
68
@ServiceProvider(service = CreateFromTemplateHandler.class, position = 5000)
69
public final class ArchetypeTemplateHandler extends CreateFromTemplateHandler {
70
    public ArchetypeTemplateHandler() {
71
    }
72
73
    @Override
74
    protected boolean accept(CreateDescriptor desc) {
75
        return desc.getTemplate().hasExt("archetype"); // NOI18N
76
    }
77
78
    @NbBundle.Messages({
79
        "MSG_NoVersion=No version attribute specified for the Maven project",
80
        "MSG_NoArtifactId=No artifactId attribute specified for the Maven project",
81
        "MSG_NoGroupId=No groupId attribute specified for the Maven project",
82
    })
83
    @Override
84
    protected List<FileObject> createFromTemplate(CreateDescriptor desc) throws IOException {
85
        Properties p = new Properties();
86
        try (InputStream is = desc.getTemplate().getInputStream()) {
87
            p.load(is);
88
        }
89
        String version = (String)desc.getValue("version"); // NOI18N
90
        if (version == null) {
91
            throw new IOException(Bundle.MSG_NoVersion());
92
        }
93
        String artifactId = (String)desc.getValue("artifactId"); // NOI18N
94
        if (version == null) {
95
            throw new IOException(Bundle.MSG_NoArtifactId());
96
        }
97
        String groupId = (String)desc.getValue("groupId"); // NOI18N
98
        if (version == null) {
99
            throw new IOException(Bundle.MSG_NoGroupId());
100
        }
101
        String packageName = (String)desc.getValue("package"); // NOI18N
102
        ProjectInfo pi = new ProjectInfo(groupId, artifactId, version, packageName);
103
        Map<?,?> additionalProperties = desc.getValue("wizard"); // NOI18N
104
        Archetype arch = new Archetype();
105
        arch.setArtifactId(p.getProperty("artifactId")); // NOI18N
106
        arch.setGroupId(p.getProperty("groupId")); // NOI18N
107
        arch.setVersion(p.getProperty("version")); // NOI18N
108
        File projDir = desc.getValue(CommonProjectActions.PROJECT_PARENT_FOLDER);
109
        if (projDir == null && desc.getTarget() != null) {
110
            projDir = FileUtil.toFile(desc.getTarget());
111
        }
112
        if (projDir == null) {
113
            throw new IOException(CommonProjectActions.PROJECT_PARENT_FOLDER + " not specified");
114
        }
115
        
116
        Map<String, String> filteredProperties = 
117
                additionalProperties == null ?
118
                Collections.emptyMap()
119
                :
120
                NbCollections.checkedMapByFilter(additionalProperties, String.class, String.class, false);
121
        ArchetypeWizards.createFromArchetype(projDir, pi, arch, filteredProperties, true);
122
        FileObject fo = FileUtil.toFileObject(projDir);
123
124
        List<FileObject> fos = new ArrayList<>();
125
        collectPomDirs(fo, fos);
126
        final String toOpen = p.getProperty("open"); // NOI18N
127
        if (toOpen != null) {
128
            collectFiles(fo, fos, toOpen.split(",")); // NOI18N
129
        }
130
        
131
        Project prj = ProjectManager.getDefault().findProject(fo);
132
        ActionProvider ap = prj == null ? null : prj.getLookup().lookup(ActionProvider.class);
133
        if (ap != null) {
134
            ap.invokeAction(ActionProvider.COMMAND_BUILD, prj.getLookup());
135
        }
136
        return fos;
137
    }
138
    
139
    private static void collectPomDirs(FileObject dir, Collection<? super FileObject> found) {
140
        if (dir == null || !dir.isFolder()) {
141
            return;
142
        }
143
        if (dir.getFileObject("pom.xml") == null) {
144
            return;
145
        }
146
        found.add(dir);
147
        for (FileObject f : dir.getChildren()) {
148
            collectPomDirs(f, found);
149
        }
150
    }
151
152
    static void collectFiles(FileObject root, Collection<? super FileObject> found, String... includes) {
153
        Pattern[] check = new Pattern[includes.length];
154
        for (int i = 0; i < check.length; i++) {
155
            check[i] = Pattern.compile(includes[i]);
156
        }
157
158
        Enumeration<? extends FileObject> en = root.getChildren(true);
159
        while (en.hasMoreElements()) {
160
            FileObject fo = en.nextElement();
161
            String relPath = FileUtil.getRelativePath(root, fo);
162
            if (relPath == null) {
163
                continue;
164
            }
165
            for (Pattern p : check) {
166
                if (p.matcher(relPath).matches()) {
167
                    found.add(fo);
168
                    break;
169
                }
170
            }
171
        }
172
    }
173
    
174
}
(-)a/maven/src/org/netbeans/modules/maven/newproject/ArchetypeWizardUtils.java (-1 lines)
Lines 46-52 Link Here
46
import java.io.IOException;
46
import java.io.IOException;
47
import java.util.ArrayList;
47
import java.util.ArrayList;
48
import java.util.Collections;
48
import java.util.Collections;
49
import java.util.Enumeration;
50
import java.util.HashMap;
49
import java.util.HashMap;
51
import java.util.LinkedHashSet;
50
import java.util.LinkedHashSet;
52
import java.util.List;
51
import java.util.List;
(-)a/maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java (-1 / +11 lines)
Lines 91-96 Link Here
91
import org.openide.WizardDescriptor;
91
import org.openide.WizardDescriptor;
92
import org.openide.awt.Mnemonics;
92
import org.openide.awt.Mnemonics;
93
import org.openide.filesystems.FileUtil;
93
import org.openide.filesystems.FileUtil;
94
import org.openide.loaders.DataFolder;
95
import org.openide.loaders.TemplateWizard;
94
import org.openide.util.NbBundle.Messages;
96
import org.openide.util.NbBundle.Messages;
95
import org.openide.util.RequestProcessor;
97
import org.openide.util.RequestProcessor;
96
import org.openide.util.Utilities;
98
import org.openide.util.Utilities;
Lines 530-538 Link Here
530
        }
532
        }
531
        String name = projectNameTextField.getText().trim();
533
        String name = projectNameTextField.getText().trim();
532
        String folder = createdFolderTextField.getText().trim();
534
        String folder = createdFolderTextField.getText().trim();
535
        final File parentFolder = new File(folder);
533
        
536
        
534
        d.putProperty(CommonProjectActions.PROJECT_PARENT_FOLDER, new File(folder)); //NOI18N
537
        d.putProperty(CommonProjectActions.PROJECT_PARENT_FOLDER, parentFolder);
538
        if (d instanceof TemplateWizard) {
539
            parentFolder.mkdirs();
540
            ((TemplateWizard) d).setTargetFolder(DataFolder.findFolder(FileUtil.toFileObject(parentFolder)));
541
        }
535
        d.putProperty("name", name); //NOI18N
542
        d.putProperty("name", name); //NOI18N
543
        if (d instanceof TemplateWizard) {
544
            ((TemplateWizard) d).setTargetName(name);
545
        }
536
        d.putProperty("artifactId", txtArtifactId.getText().trim()); //NOI18N
546
        d.putProperty("artifactId", txtArtifactId.getText().trim()); //NOI18N
537
        d.putProperty("groupId", txtGroupId.getText().trim()); //NOI18N
547
        d.putProperty("groupId", txtGroupId.getText().trim()); //NOI18N
538
        MavenSettings.getDefault().setLastArchetypeGroupId(txtGroupId.getText().trim());
548
        MavenSettings.getDefault().setLastArchetypeGroupId(txtGroupId.getText().trim());
(-)e66070a74aa4 (+3 lines)
Added Link Here
1
groupId=org.codehaus.mojo.archetypes
2
artifactId=javafx
3
version=0.6
(-)e66070a74aa4 (+18 lines)
Added Link Here
1
<!--
2
To change this license header, choose License Headers in Project Properties.
3
To change this template file, choose Tools | Templates
4
and open the template in the editor.
5
-->
6
<html>
7
    <head>
8
        <title>SimpleWizard</title>
9
        <meta charset="UTF-8">
10
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
11
    </head>
12
    <body>
13
        <div>
14
            <section data-bind="step: 'targetChooser:archetype'">
15
            </section>
16
        </div>
17
    </body>
18
</html>
(-)e66070a74aa4 (+118 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright (c) 2016 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
package org.netbeans.modules.maven.newproject.simplewizard;
41
42
import java.io.File;
43
import java.util.Set;
44
import net.java.html.json.Model;
45
import org.netbeans.api.templates.TemplateRegistration;
46
import org.netbeans.junit.MockServices;
47
import org.netbeans.junit.NbTestCase;
48
import org.netbeans.modules.project.indexingbridge.IndexingBridge;
49
import org.openide.WizardDescriptor;
50
import org.openide.filesystems.FileObject;
51
import org.openide.filesystems.FileUtil;
52
import org.openide.loaders.DataFolder;
53
import org.openide.loaders.DataObject;
54
import org.openide.loaders.TemplateWizard;
55
import org.openide.util.NbBundle;
56
57
@Model(className = "EmptyModel", properties = {})
58
public class SimpleWizardHandlerTest extends NbTestCase {
59
    
60
    public SimpleWizardHandlerTest(String name) {
61
        super(name);
62
    }
63
    
64
    
65
    @TemplateRegistration(
66
            page = "SimpleWizard.html",
67
            folder = "Project/Test",
68
            displayName = "#Wizard_displayName",
69
            content = "SimpleWizard.archetype"
70
    )
71
    @NbBundle.Messages({
72
        "Wizard_displayName=SimpleWizard"
73
    })
74
    private static EmptyModel simpleWizard() {
75
        return new EmptyModel();
76
    }
77
    
78
    public void testSimpleWizard() throws Exception {
79
        clearWorkDir();
80
        File whereTo = new File(getWorkDir(), "whereTo");
81
        whereTo.mkdirs();
82
        FileObject whereToObj = FileUtil.toFileObject(whereTo);
83
        assertNotNull("Where obj found", whereToObj);
84
        MockServices.setServices(MockIndexingBridge.class);
85
        
86
        FileObject archetype = FileUtil.getConfigFile("Templates/Project/Test/SimpleWizard.archetype");
87
        assertNotNull(archetype);
88
        Object iterator = archetype.getAttribute("instantiatingIterator");
89
        assertNotNull("Iterator found", iterator);
90
        assertTrue("It is iterator", iterator instanceof WizardDescriptor.InstantiatingIterator);
91
        WizardDescriptor.InstantiatingIterator instIter = (WizardDescriptor.InstantiatingIterator) iterator;
92
    
93
        TemplateWizard tw = new TemplateWizard();
94
        tw.setTemplate(DataObject.find(archetype));
95
        tw.setTargetFolder(DataFolder.findFolder(whereToObj));
96
        tw.putProperty("version", "6.5");
97
        tw.putProperty("artifactId", "simplewizardtest");
98
        tw.putProperty("groupId", "org.netbeans.test");
99
        
100
        instIter.initialize(tw);
101
        Set<?> results = instIter.instantiate();
102
        fail("results: " + results);
103
    }
104
105
    public static final class MockIndexingBridge extends IndexingBridge {
106
        public MockIndexingBridge() {
107
        }
108
109
        @Override
110
        protected void enterProtectedMode() {
111
        }
112
113
        @Override
114
        protected void exitProtectedMode() {
115
        }
116
    }
117
    
118
}
(-)a/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java (-2 lines)
Lines 48-54 Link Here
48
import java.lang.ref.Reference;
48
import java.lang.ref.Reference;
49
import java.lang.ref.WeakReference;
49
import java.lang.ref.WeakReference;
50
import java.net.MalformedURLException;
50
import java.net.MalformedURLException;
51
import java.net.URI;
52
import java.net.URISyntaxException;
51
import java.net.URISyntaxException;
53
import java.net.URL;
52
import java.net.URL;
54
import java.security.InvalidParameterException;
53
import java.security.InvalidParameterException;
Lines 67-73 Link Here
67
import java.util.logging.Logger;
66
import java.util.logging.Logger;
68
import java.util.prefs.Preferences;
67
import java.util.prefs.Preferences;
69
import java.util.stream.Collectors;
68
import java.util.stream.Collectors;
70
import java.util.stream.Stream;
71
import java.util.zip.ZipEntry;
69
import java.util.zip.ZipEntry;
72
import java.util.zip.ZipFile;
70
import java.util.zip.ZipFile;
73
import javax.swing.event.DocumentEvent;
71
import javax.swing.event.DocumentEvent;
(-)a/templatesui/src/org/netbeans/modules/templatesui/AbstractWizard.java (-9 / +33 lines)
Lines 51-56 Link Here
51
import java.util.ArrayList;
51
import java.util.ArrayList;
52
import java.util.Collections;
52
import java.util.Collections;
53
import java.util.HashMap;
53
import java.util.HashMap;
54
import java.util.LinkedHashSet;
54
import java.util.List;
55
import java.util.List;
55
import java.util.Map;
56
import java.util.Map;
56
import java.util.NoSuchElementException;
57
import java.util.NoSuchElementException;
Lines 74-81 Link Here
74
import net.java.html.js.JavaScriptBody;
75
import net.java.html.js.JavaScriptBody;
75
import net.java.html.json.Model;
76
import net.java.html.json.Model;
76
import net.java.html.json.Models;
77
import net.java.html.json.Models;
78
import org.netbeans.api.templates.FileBuilder;
77
import org.openide.WizardDescriptor;
79
import org.openide.WizardDescriptor;
78
import org.openide.WizardValidationException;
80
import org.openide.WizardValidationException;
81
import org.openide.filesystems.FileObject;
79
import org.openide.loaders.DataObject;
82
import org.openide.loaders.DataObject;
80
import org.openide.loaders.TemplateWizard;
83
import org.openide.loaders.TemplateWizard;
81
import org.openide.util.Lookup;
84
import org.openide.util.Lookup;
Lines 109-114 Link Here
109
    @Override
112
    @Override
110
    public Set<? extends Object> instantiate() throws IOException {
113
    public Set<? extends Object> instantiate() throws IOException {
111
        try {
114
        try {
115
            final TemplateWizard tw = (TemplateWizard) wizard;
112
            FutureTask<?> t = new FutureTask<>(new Callable<Map<String,Object>>() {
116
            FutureTask<?> t = new FutureTask<>(new Callable<Map<String,Object>>() {
113
                @Override
117
                @Override
114
                public Map<String,Object> call() throws Exception {
118
                public Map<String,Object> call() throws Exception {
Lines 122-135 Link Here
122
                    return map;
126
                    return map;
123
                }
127
                }
124
            });
128
            });
125
            FXBrowsers.runInBrowser(v, t);
129
            if (v != null) {
130
                FXBrowsers.runInBrowser(v, t);
131
            }
132
            Map<String, Object> params = new HashMap<>();
126
            
133
            
127
            TemplateWizard tw = (TemplateWizard) wizard;
134
            for (Map.Entry<String, Object> entry : tw.getProperties().entrySet()) {
128
            Map<String, ? extends Object> params = Collections.singletonMap(
135
                String key = entry.getKey();
129
                "wizard", t.get()
136
                Object value = entry.getValue();
130
            );
137
                params.put(key, value);
131
            DataObject obj = tw.getTemplate().createFromTemplate(tw.getTargetFolder(), tw.getTargetName(), params);
138
            }
132
            return Collections.singleton(obj);
139
            if (v != null) {
140
                params.put("wizard", t.get());
141
            }
142
            
143
            List<FileObject> result = new FileBuilder(
144
                tw.getTemplate().getPrimaryFile(),
145
                tw.getTargetFolder().getPrimaryFile()
146
            ).
147
            name(tw.getTargetName()).
148
            withParameters(params).build();
149
                    
150
            return new LinkedHashSet<>(result);
133
        } catch (Exception ex) {
151
        } catch (Exception ex) {
134
            throw (IOException)new InterruptedIOException().initCause(ex);
152
            throw (IOException)new InterruptedIOException().initCause(ex);
135
        }
153
        }
Lines 588-595 Link Here
588
                if (l == null) {
606
                if (l == null) {
589
                    l = AbstractWizard.class.getClassLoader();
607
                    l = AbstractWizard.class.getClassLoader();
590
                }
608
                }
591
                Class<?> clazz = Class.forName("org.netbeans.spi.java.project.support.ui.templates.JavaTemplates", true, l); // NOI18N
609
                Method create;
592
                Method create = clazz.getDeclaredMethod("createPackageChooser", Object.class, String.class); // NOI18N
610
                if ("archetype".equals(type)) {
611
                    Class<?> clazz = Class.forName("org.netbeans.modules.maven.api.archetype.ArchetypeWizards", true, l); // NOI18N
612
                    create = clazz.getDeclaredMethod("basicWizardPanel", Object.class, String.class);
613
                } else {
614
                    Class<?> clazz = Class.forName("org.netbeans.spi.java.project.support.ui.templates.JavaTemplates", true, l); // NOI18N
615
                    create = clazz.getDeclaredMethod("createPackageChooser", Object.class, String.class); // NOI18N
616
                }
593
                create.setAccessible(true);
617
                create.setAccessible(true);
594
                panel = (WizardDescriptor.Panel<WizardDescriptor>) create.invoke(
618
                panel = (WizardDescriptor.Panel<WizardDescriptor>) create.invoke(
595
                    null, wizard.getProperty("project"), type // NOI18N
619
                    null, wizard.getProperty("project"), type // NOI18N

Return to bug 268677