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

(-)a/groovy.grailsproject/nbproject/project.properties (-1 / +1 lines)
Lines 36-42 Link Here
36
#
36
#
37
# Contributor(s):
37
# Contributor(s):
38
javac.compilerargs=-Xlint -Xlint:-serial
38
javac.compilerargs=-Xlint -Xlint:-serial
39
javac.source=1.7
39
javac.source=1.8
40
javadoc.arch=${basedir}/arch.xml
40
javadoc.arch=${basedir}/arch.xml
41
nbm.homepage=http://wiki.netbeans.org/groovy
41
nbm.homepage=http://wiki.netbeans.org/groovy
42
nbm.module.author=Martin Adamek, Matthias Schmidt
42
nbm.module.author=Martin Adamek, Matthias Schmidt
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/GrailsProject.java (+10 lines)
Lines 93-98 Link Here
93
    private final ClassPathProviderImpl cpProvider;
93
    private final ClassPathProviderImpl cpProvider;
94
    private final GrailsCommandSupport commandSupport;
94
    private final GrailsCommandSupport commandSupport;
95
    private final BuildConfig buildConfig;
95
    private final BuildConfig buildConfig;
96
    private final SourceCategoriesFactory sourceCategoriesFactory;
96
    private SourceRoots sourceRoots;
97
    private SourceRoots sourceRoots;
97
    private SourceRoots testRoots;
98
    private SourceRoots testRoots;
98
    private Lookup lookup;
99
    private Lookup lookup;
Lines 105-110 Link Here
105
        this.cpProvider = new ClassPathProviderImpl(getSourceRoots(), getTestSourceRoots(), this);
106
        this.cpProvider = new ClassPathProviderImpl(getSourceRoots(), getTestSourceRoots(), this);
106
        this.commandSupport = new GrailsCommandSupport(this);
107
        this.commandSupport = new GrailsCommandSupport(this);
107
        this.buildConfig = new BuildConfig(this);
108
        this.buildConfig = new BuildConfig(this);
109
110
        /* TODO: when projects have their own grails version we need to pass it
111
                 to the source categories factory.
112
         */
113
        this.sourceCategoriesFactory = new SourceCategoriesFactory();
108
    }
114
    }
109
115
110
    @Override
116
    @Override
Lines 123-128 Link Here
123
    public BuildConfig getBuildConfig() {
129
    public BuildConfig getBuildConfig() {
124
        return buildConfig;
130
        return buildConfig;
125
    }
131
    }
132
    
133
    public SourceCategoriesFactory getSourceCategoriesFactory() {
134
        return sourceCategoriesFactory;
135
    }
126
136
127
    @Override
137
    @Override
128
    public Lookup getLookup() {
138
    public Lookup getLookup() {
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/GrailsSources.java (-19 / +21 lines)
Lines 143-166 Link Here
143
        if (Sources.TYPE_GENERIC.equals(type)) {
143
        if (Sources.TYPE_GENERIC.equals(type)) {
144
            addGroup(projectDir, projectDir.getName(), result);
144
            addGroup(projectDir, projectDir.getName(), result);
145
        } else if (JavaProjectConstants.SOURCES_TYPE_JAVA.equals(type)) {
145
        } else if (JavaProjectConstants.SOURCES_TYPE_JAVA.equals(type)) {
146
            addGroup(SourceCategory.SRC_JAVA, "LBL_SrcJava", result);
146
            addGroup(SourceCategoryType.SRC_JAVA, "LBL_SrcJava", result);
147
        } else if (GroovySources.SOURCES_TYPE_GROOVY.equals(type)) {
147
        } else if (GroovySources.SOURCES_TYPE_GROOVY.equals(type)) {
148
            addGroup(SourceCategory.GRAILSAPP_CONF, "LBL_grails-app_conf", result);
148
            addGroup(SourceCategoryType.GRAILSAPP_CONF, "LBL_grails-app_conf", result);
149
            addGroup(SourceCategory.GRAILSAPP_CONTROLLERS, "LBL_grails-app_controllers", result);
149
            addGroup(SourceCategoryType.GRAILSAPP_CONTROLLERS, "LBL_grails-app_controllers", result);
150
            addGroup(SourceCategory.GRAILSAPP_DOMAIN, "LBL_grails-app_domain", result);
150
            addGroup(SourceCategoryType.GRAILSAPP_DOMAIN, "LBL_grails-app_domain", result);
151
            addGroup(SourceCategory.GRAILSAPP_SERVICES, "LBL_grails-app_services", result);
151
            addGroup(SourceCategoryType.GRAILSAPP_SERVICES, "LBL_grails-app_services", result);
152
            addGroup(SourceCategory.GRAILSAPP_TAGLIB, "LBL_grails-app_taglib", result);
152
            addGroup(SourceCategoryType.GRAILSAPP_TAGLIB, "LBL_grails-app_taglib", result);
153
            addGroup(SourceCategory.GRAILSAPP_UTILS, "LBL_grails-app_utils", result);
153
            addGroup(SourceCategoryType.GRAILSAPP_UTILS, "LBL_grails-app_utils", result);
154
            addGroup(SourceCategory.SCRIPTS, "LBL_scripts", result);
154
            addGroup(SourceCategoryType.SCRIPTS, "LBL_scripts", result);
155
            addGroup(SourceCategory.SRC_GROOVY, "LBL_SrcGroovy", result);
155
            addGroup(SourceCategoryType.SRC_GROOVY, "LBL_SrcGroovy", result);
156
            addGroup(SourceCategory.TEST_INTEGRATION, "LBL_IntegrationTests", result);
156
            addGroup(SourceCategoryType.TEST_INTEGRATION, "LBL_IntegrationTests", result);
157
            addGroup(SourceCategory.TEST_UNIT, "LBL_UnitTests", result);
157
            addGroup(SourceCategoryType.TEST_UNIT, "LBL_UnitTests", result);
158
        } else if (GroovySources.SOURCES_TYPE_GRAILS.equals(type)) {
158
        } else if (GroovySources.SOURCES_TYPE_GRAILS.equals(type)) {
159
            addGroup(SourceCategory.LIB, "LBL_lib", result);
159
            addGroup(SourceCategoryType.LIB, "LBL_lib", result);
160
            addGroup(SourceCategory.GRAILSAPP_I18N, "LBL_grails-app_i18n", result);
160
            addGroup(SourceCategoryType.GRAILSAPP_I18N, "LBL_grails-app_i18n", result);
161
            addGroup(SourceCategory.WEBAPP, "LBL_web-app", result);
161
            addGroup(SourceCategoryType.WEBAPP, "LBL_web-app", result);
162
            addGroup(SourceCategory.GRAILSAPP_VIEWS, "LBL_grails-app_views", result);
162
            addGroup(SourceCategoryType.GRAILSAPP_VIEWS, "LBL_grails-app_views", result);
163
            addGroup(SourceCategory.TEMPLATES, "LBL_grails-templates", result);
163
            addGroup(SourceCategoryType.TEMPLATES, "LBL_grails-templates", result);
164
        } else if (GroovySources.SOURCES_TYPE_GRAILS_UNKNOWN.equals(type)) {
164
        } else if (GroovySources.SOURCES_TYPE_GRAILS_UNKNOWN.equals(type)) {
165
            // plugins may reside in project dir
165
            // plugins may reside in project dir
166
            File pluginsDirFile = project.getBuildConfig().getProjectPluginsDir();
166
            File pluginsDirFile = project.getBuildConfig().getProjectPluginsDir();
Lines 182-188 Link Here
182
                }
182
                }
183
            }
183
            }
184
184
185
            addGroup(SourceCategory.SRC_GWT, "LBL_SrcGwt", result);
185
            addGroup(SourceCategoryType.SRC_GWT, "LBL_SrcGwt", result);
186
            addUnknownGroups(KNOWN_FOLDERS_IN_GRAILS_APP, result, "grails-app", null);
186
            addUnknownGroups(KNOWN_FOLDERS_IN_GRAILS_APP, result, "grails-app", null);
187
            addUnknownGroups(KNOWN_OR_IGNORED_FOLDERS_IN_TEST, result, "test", "LBL_SomeTests");
187
            addUnknownGroups(KNOWN_OR_IGNORED_FOLDERS_IN_TEST, result, "test", "LBL_SomeTests");
188
        }
188
        }
Lines 238-245 Link Here
238
        }
238
        }
239
    }
239
    }
240
240
241
    private void addGroup(SourceCategory sourceCategory, String bundleLabel, List<Group> list) {
241
    private void addGroup(SourceCategoryType sourceCategory, String bundleLabel, List<Group> list) {
242
        FileObject fileObject = projectDir.getFileObject(sourceCategory.getRelativePath());
242
        FileObject fileObject = projectDir.getFileObject(
243
                project.getSourceCategoriesFactory().getSourceCategory(sourceCategory).getRelativePath()
244
        );
243
        if (fileObject != null) {
245
        if (fileObject != null) {
244
            list.add(new Group(fileObject, NbBundle.getMessage(GrailsSources.class, bundleLabel)));
246
            list.add(new Group(fileObject, NbBundle.getMessage(GrailsSources.class, bundleLabel)));
245
        }
247
        }
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/SourceCategory.java (-51 / +65 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
4
 * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
7
 * Other names may be trademarks of their respective owners.
Lines 23-83 Link Here
23
 * License Header, with the fields enclosed by brackets [] replaced by
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 * 
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
 *
27
 * Contributor(s):
38
 * Contributor(s):
28
 * 
39
 *
29
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
30
 */
41
 */
31
package org.netbeans.modules.groovy.grailsproject;
42
package org.netbeans.modules.groovy.grailsproject;
32
43
33
/**
44
import java.util.Collections;
34
 *
45
import java.util.Map;
35
 * @author schmidtm
46
import java.util.TreeMap;
36
 * @author Martin Adamek
47
import org.netbeans.modules.groovy.grails.api.GrailsPlatform;
37
 */
48
import org.netbeans.modules.groovy.grails.api.GrailsPlatform.Version;
38
public enum SourceCategory {
39
49
40
    GRAILSAPP_CONF("grails-app/conf", null, null),
50
/**
41
    GRAILSAPP_CONTROLLERS("grails-app/controllers", "create-controller", "Controller.groovy"),
51
 * This factory provides source categories for a given version of grails.
42
    GRAILSAPP_DOMAIN("grails-app/domain", "create-domain-class", null),
52
 * @author Bruno Flavio
43
    GRAILSAPP_I18N("grails-app/i18n", null, null),
53
 */
44
    GRAILSAPP_SERVICES("grails-app/services", "create-service", "Service.groovy"),
54
public class SourceCategoriesFactory {
45
    GRAILSAPP_TAGLIB("grails-app/taglib", "create-tag-lib", "TagLib.groovy"),
46
    GRAILSAPP_UTILS("grails-app/utils", null, null),
47
    GRAILSAPP_VIEWS("grails-app/views", null, null),
48
    PLUGINS("plugins", null, null),
49
    TEST_INTEGRATION("test/integration", "create-integration-test", "Tests.groovy"),
50
    TEST_UNIT("test/unit", "create-unit-test", "Tests.groovy"),
51
    SCRIPTS("scripts", "create-script", null),
52
    SRC_JAVA("src/java", null, null),
53
    SRC_GWT("src/gwt", null, null),
54
    SRC_GROOVY("src/groovy", null, null),
55
    TEMPLATES("src/templates", "install-templates", null),
56
    WEBAPP("web-app", null, null),
57
    LIB("lib", null, null);
58
59
    private final String relativePath;
60
    
55
    
61
    private final String command;
56
    private static final Map<Version, SourceCategoriesInterface> versions = 
62
57
            new TreeMap<>(Collections.reverseOrder());
63
    private final String suffix;
58
    
64
59
    static {
65
    SourceCategory(String relativePath, String command, String suffix) {
60
        /*
66
        this.relativePath = relativePath;
61
        Registers the available Source Categories handlers and their minimum version.
67
        this.command = command;
62
        */
68
        this.suffix = suffix;
63
        versions.put(SourceCategoriesGrails11.MIN_VERSION, new SourceCategoriesGrails11());
64
        versions.put(SourceCategoriesGrails301.MIN_VERSION, new SourceCategoriesGrails301());
65
    }
66
    
67
    private SourceCategoriesInterface categories;
68
    
69
    /**
70
     * Creates a source categories factory using the current Grails Platform default version.
71
     */
72
    public SourceCategoriesFactory() {
73
        this(GrailsPlatform.getDefault().getVersion());
74
    }
75
    
76
    /**
77
     * Creates a source categories factory using the specified Grails version.
78
     * @param version - Grails version to use.
79
     */
80
    public SourceCategoriesFactory(GrailsPlatform.Version version) {
81
        this.categories =  SourceCategoriesFactory.versions.entrySet().stream()
82
                .filter(map -> version.compareTo(map.getKey()) >= 0)
83
                .map( map -> map.getValue() )
84
                .findFirst()
85
                .orElse(new SourceCategoriesGrails11());
86
    }
87
    
88
    /**
89
     * Returns the source category for a given source category type.
90
     * @param type Source category type to retrieve
91
     * @return The source category found for this type and factory version.
92
     */
93
    public SourceCategory getSourceCategory(SourceCategoryType type) {
94
        return categories.getSourceCategory(type);
69
    }
95
    }
70
96
71
    public String getRelativePath() {
97
}
72
        return relativePath;
73
    }
74
75
    public String getCommand() {
76
        return command;
77
    }
78
79
    public String getSuffix() {
80
        return suffix;
81
    }
82
83
}
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/SourceCategoriesGrails11.java (+82 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 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
 * Contributor(s):
28
 * 
29
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
30
 */
31
package org.netbeans.modules.groovy.grailsproject;
32
33
import java.util.HashMap;
34
import java.util.Map;
35
import org.netbeans.modules.groovy.grails.api.GrailsPlatform;
36
37
/**
38
 * This class registers the Source Categories for Grails versions 1 and 2
39
 * @author schmidtm
40
 * @author Martin Adamek
41
 */
42
public class SourceCategoriesGrails11 implements SourceCategoriesInterface {
43
44
    static public final GrailsPlatform.Version MIN_VERSION = GrailsPlatform.Version.VERSION_DEFAULT;
45
    static private final Map<SourceCategoryType, SourceCategory> SOURCE_CATEGORIES
46
            = new HashMap<>();
47
48
    static {
49
        /*
50
        Registers the Source Categories for each type supported by this version.
51
        */
52
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_CONF, new SourceCategory("grails-app/conf", null, null));
53
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_CONTROLLERS, new SourceCategory("grails-app/controllers", "create-controller", "Controller.groovy"));
54
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_DOMAIN, new SourceCategory("grails-app/domain", "create-domain-class", null));
55
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_I18N, new SourceCategory("grails-app/i18n", null, null));
56
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_SERVICES, new SourceCategory("grails-app/services", "create-service", "Service.groovy"));
57
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_TAGLIB, new SourceCategory("grails-app/taglib", "create-tag-lib", "TagLib.groovy"));
58
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_UTILS, new SourceCategory("grails-app/utils", null, null));
59
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_VIEWS, new SourceCategory("grails-app/views", null, null));
60
        SOURCE_CATEGORIES.put(SourceCategoryType.PLUGINS, new SourceCategory("plugins", null, null));
61
        SOURCE_CATEGORIES.put(SourceCategoryType.TEST_INTEGRATION, new SourceCategory("test/integration", "create-integration-test", "Tests.groovy"));
62
        SOURCE_CATEGORIES.put(SourceCategoryType.TEST_UNIT, new SourceCategory("test/unit", "create-unit-test", "Tests.groovy"));
63
        SOURCE_CATEGORIES.put(SourceCategoryType.SCRIPTS, new SourceCategory("scripts", "create-script", null));
64
        SOURCE_CATEGORIES.put(SourceCategoryType.SRC_JAVA, new SourceCategory("src/java", null, null));
65
        SOURCE_CATEGORIES.put(SourceCategoryType.SRC_GWT, new SourceCategory("src/gwt", null, null));
66
        SOURCE_CATEGORIES.put(SourceCategoryType.SRC_GROOVY, new SourceCategory("src/groovy", null, null));
67
        SOURCE_CATEGORIES.put(SourceCategoryType.TEMPLATES, new SourceCategory("src/templates", "install-templates", null));
68
        SOURCE_CATEGORIES.put(SourceCategoryType.WEBAPP, new SourceCategory("web-app", null, null));
69
        SOURCE_CATEGORIES.put(SourceCategoryType.LIB, new SourceCategory("lib", null, null));
70
    }
71
72
    /**
73
     * Returns the source category for the given type.
74
     * @param type Source category type to lookup
75
     * @return the source category, null if not present.
76
     */
77
    @Override
78
    public SourceCategory getSourceCategory(SourceCategoryType type) {
79
        return SourceCategoriesGrails11.SOURCE_CATEGORIES.get(type);
80
    }
81
82
}
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/SourceCategoriesGrails301.java (+83 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 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
 * Contributor(s):
28
 * 
29
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
30
 */
31
package org.netbeans.modules.groovy.grailsproject;
32
33
import java.util.HashMap;
34
import java.util.Map;
35
import org.netbeans.modules.groovy.grails.api.GrailsPlatform;
36
37
/**
38
 * This class registers the Source Categories for Grails version 3
39
 * @author schmidtm
40
 * @author Martin Adamek
41
 */
42
public class SourceCategoriesGrails301 implements SourceCategoriesInterface {
43
44
    static public final GrailsPlatform.Version MIN_VERSION = GrailsPlatform.Version.valueOf("3.0.1");    
45
    
46
    static private final Map<SourceCategoryType, SourceCategory> SOURCE_CATEGORIES
47
            = new HashMap<>();
48
49
    static {
50
        /*
51
        Registers the Source Categories for each type supported by this version.
52
        */
53
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_CONF, new SourceCategory("grails-app/conf", null, null));
54
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_CONTROLLERS, new SourceCategory("grails-app/controllers", "create-controller", "Controller.groovy"));
55
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_DOMAIN, new SourceCategory("grails-app/domain", "create-domain-class", null));
56
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_I18N, new SourceCategory("grails-app/i18n", null, null));
57
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_SERVICES, new SourceCategory("grails-app/services", "create-service", "Service.groovy"));
58
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_TAGLIB, new SourceCategory("grails-app/taglib", "create-taglib", "TagLib.groovy"));
59
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_UTILS, new SourceCategory("grails-app/utils", null, null));
60
        SOURCE_CATEGORIES.put(SourceCategoryType.GRAILSAPP_VIEWS, new SourceCategory("grails-app/views", null, null));
61
        SOURCE_CATEGORIES.put(SourceCategoryType.PLUGINS, new SourceCategory("plugins", null, null));
62
        SOURCE_CATEGORIES.put(SourceCategoryType.TEST_INTEGRATION, new SourceCategory("test/integration", "create-integration-test", "Tests.groovy"));
63
        SOURCE_CATEGORIES.put(SourceCategoryType.TEST_UNIT, new SourceCategory("test/unit", "create-unit-test", "Tests.groovy"));
64
        SOURCE_CATEGORIES.put(SourceCategoryType.SCRIPTS, new SourceCategory("scripts", "create-script", null));
65
        SOURCE_CATEGORIES.put(SourceCategoryType.SRC_JAVA, new SourceCategory("src/java", null, null));
66
        SOURCE_CATEGORIES.put(SourceCategoryType.SRC_GWT, new SourceCategory("src/gwt", null, null));
67
        SOURCE_CATEGORIES.put(SourceCategoryType.SRC_GROOVY, new SourceCategory("src/groovy", null, null));
68
        SOURCE_CATEGORIES.put(SourceCategoryType.TEMPLATES, new SourceCategory("src/templates", "install-templates", null));
69
        SOURCE_CATEGORIES.put(SourceCategoryType.WEBAPP, new SourceCategory("web-app", null, null));
70
        SOURCE_CATEGORIES.put(SourceCategoryType.LIB, new SourceCategory("lib", null, null));
71
    }
72
73
    /**
74
     * Returns the source category for the given type.
75
     * @param type Source category type to lookup
76
     * @return the source category, null if not present.
77
     */
78
    @Override
79
    public SourceCategory getSourceCategory(SourceCategoryType type) {
80
        return SourceCategoriesGrails301.SOURCE_CATEGORIES.get(type);
81
    }
82
83
}
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/SourceCategoriesInterface.java (+52 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 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
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.groovy.grailsproject;
43
44
/**
45
 *
46
 * @author Bruno Flavio
47
 */
48
public interface SourceCategoriesInterface {
49
50
    SourceCategory getSourceCategory(SourceCategoryType type);
51
52
}
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/SourceCategory.java (-29 / +40 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
4
 * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
7
 * Other names may be trademarks of their respective owners.
Lines 23-83 Link Here
23
 * License Header, with the fields enclosed by brackets [] replaced by
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 * 
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
 *
27
 * Contributor(s):
38
 * Contributor(s):
28
 * 
39
 *
29
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
30
 */
41
 */
31
package org.netbeans.modules.groovy.grailsproject;
42
package org.netbeans.modules.groovy.grailsproject;
32
43
33
/**
44
/**
34
 *
45
 * Represents a grails source category.
35
 * @author schmidtm
46
 * @author Bruno Flavio
36
 * @author Martin Adamek
37
 */
47
 */
38
public enum SourceCategory {
48
public class SourceCategory {
39
40
    GRAILSAPP_CONF("grails-app/conf", null, null),
41
    GRAILSAPP_CONTROLLERS("grails-app/controllers", "create-controller", "Controller.groovy"),
42
    GRAILSAPP_DOMAIN("grails-app/domain", "create-domain-class", null),
43
    GRAILSAPP_I18N("grails-app/i18n", null, null),
44
    GRAILSAPP_SERVICES("grails-app/services", "create-service", "Service.groovy"),
45
    GRAILSAPP_TAGLIB("grails-app/taglib", "create-tag-lib", "TagLib.groovy"),
46
    GRAILSAPP_UTILS("grails-app/utils", null, null),
47
    GRAILSAPP_VIEWS("grails-app/views", null, null),
48
    PLUGINS("plugins", null, null),
49
    TEST_INTEGRATION("test/integration", "create-integration-test", "Tests.groovy"),
50
    TEST_UNIT("test/unit", "create-unit-test", "Tests.groovy"),
51
    SCRIPTS("scripts", "create-script", null),
52
    SRC_JAVA("src/java", null, null),
53
    SRC_GWT("src/gwt", null, null),
54
    SRC_GROOVY("src/groovy", null, null),
55
    TEMPLATES("src/templates", "install-templates", null),
56
    WEBAPP("web-app", null, null),
57
    LIB("lib", null, null);
58
49
59
    private final String relativePath;
50
    private final String relativePath;
60
    
51
61
    private final String command;
52
    private final String command;
62
53
63
    private final String suffix;
54
    private final String suffix;
64
55
56
    /**
57
     * Creates a grails source category.
58
     * @param relativePath place where files of this category should be stored
59
     * @param command grails command that should be invoked to create a file of this category
60
     * @param suffix suffix present in every file name of this category
61
     */
65
    SourceCategory(String relativePath, String command, String suffix) {
62
    SourceCategory(String relativePath, String command, String suffix) {
66
        this.relativePath = relativePath;
63
        this.relativePath = relativePath;
67
        this.command = command;
64
        this.command = command;
68
        this.suffix = suffix;
65
        this.suffix = suffix;
69
    }
66
    }
70
67
68
    /**
69
     * Returns this category relative path, i.e the folder where source files
70
     * of this category should be placed.
71
     * 
72
     * @return the relative path.
73
     */
71
    public String getRelativePath() {
74
    public String getRelativePath() {
72
        return relativePath;
75
        return relativePath;
73
    }
76
    }
74
77
78
    /**
79
     * Returns the grails command that creates files of this category.
80
     * @return the grails command.
81
     */
75
    public String getCommand() {
82
    public String getCommand() {
76
        return command;
83
        return command;
77
    }
84
    }
78
85
86
    /**
87
     * Returns the filename suffix that should be applied by convention to this
88
     * source category.
89
     * @return  filename suffix.
90
     */
79
    public String getSuffix() {
91
    public String getSuffix() {
80
        return suffix;
92
        return suffix;
81
    }
93
    }
82
83
}
94
}
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/SourceCategory.java (-45 / +19 lines)
Lines 35-83 Link Here
35
 * @author schmidtm
35
 * @author schmidtm
36
 * @author Martin Adamek
36
 * @author Martin Adamek
37
 */
37
 */
38
public enum SourceCategory {
38
public enum SourceCategoryType {
39
39
    GRAILSAPP_CONF,
40
    GRAILSAPP_CONF("grails-app/conf", null, null),
40
    GRAILSAPP_CONTROLLERS,
41
    GRAILSAPP_CONTROLLERS("grails-app/controllers", "create-controller", "Controller.groovy"),
41
    GRAILSAPP_DOMAIN,
42
    GRAILSAPP_DOMAIN("grails-app/domain", "create-domain-class", null),
42
    GRAILSAPP_I18N,
43
    GRAILSAPP_I18N("grails-app/i18n", null, null),
43
    GRAILSAPP_SERVICES,
44
    GRAILSAPP_SERVICES("grails-app/services", "create-service", "Service.groovy"),
44
    GRAILSAPP_TAGLIB,
45
    GRAILSAPP_TAGLIB("grails-app/taglib", "create-tag-lib", "TagLib.groovy"),
45
    GRAILSAPP_UTILS,
46
    GRAILSAPP_UTILS("grails-app/utils", null, null),
46
    GRAILSAPP_VIEWS,
47
    GRAILSAPP_VIEWS("grails-app/views", null, null),
47
    PLUGINS,
48
    PLUGINS("plugins", null, null),
48
    TEST_INTEGRATION,
49
    TEST_INTEGRATION("test/integration", "create-integration-test", "Tests.groovy"),
49
    TEST_UNIT,
50
    TEST_UNIT("test/unit", "create-unit-test", "Tests.groovy"),
50
    SCRIPTS,
51
    SCRIPTS("scripts", "create-script", null),
51
    SRC_JAVA,
52
    SRC_JAVA("src/java", null, null),
52
    SRC_GWT,
53
    SRC_GWT("src/gwt", null, null),
53
    SRC_GROOVY,
54
    SRC_GROOVY("src/groovy", null, null),
54
    TEMPLATES,
55
    TEMPLATES("src/templates", "install-templates", null),
55
    WEBAPP,
56
    WEBAPP("web-app", null, null),
56
    LIB;    
57
    LIB("lib", null, null);
58
59
    private final String relativePath;
60
    
61
    private final String command;
62
63
    private final String suffix;
64
65
    SourceCategory(String relativePath, String command, String suffix) {
66
        this.relativePath = relativePath;
67
        this.command = command;
68
        this.suffix = suffix;
69
    }
70
71
    public String getRelativePath() {
72
        return relativePath;
73
    }
74
75
    public String getCommand() {
76
        return command;
77
    }
78
79
    public String getSuffix() {
80
        return suffix;
81
    }
82
83
}
57
}
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/classpath/ProjectClassPathImplementation.java (-3 / +8 lines)
Lines 59-65 Link Here
59
import org.netbeans.modules.groovy.grails.api.GrailsPlatform;
59
import org.netbeans.modules.groovy.grails.api.GrailsPlatform;
60
import org.netbeans.modules.groovy.grails.api.GrailsProjectConfig;
60
import org.netbeans.modules.groovy.grails.api.GrailsProjectConfig;
61
import org.netbeans.modules.groovy.grailsproject.GrailsProject;
61
import org.netbeans.modules.groovy.grailsproject.GrailsProject;
62
import org.netbeans.modules.groovy.grailsproject.SourceCategory;
62
import org.netbeans.modules.groovy.grailsproject.SourceCategoriesFactory;
63
import org.netbeans.modules.groovy.grailsproject.SourceCategoryType;
63
import org.netbeans.modules.groovy.grailsproject.config.BuildConfig;
64
import org.netbeans.modules.groovy.grailsproject.config.BuildConfig;
64
import org.netbeans.modules.groovy.grailsproject.plugins.GrailsPlugin;
65
import org.netbeans.modules.groovy.grailsproject.plugins.GrailsPlugin;
65
import org.netbeans.modules.groovy.grailsproject.plugins.GrailsPluginSupport;
66
import org.netbeans.modules.groovy.grailsproject.plugins.GrailsPluginSupport;
Lines 83-88 Link Here
83
    private final BuildConfigListener buildConfigListener = new BuildConfigListener();
84
    private final BuildConfigListener buildConfigListener = new BuildConfigListener();
84
    private final GrailsProjectConfig projectConfig;
85
    private final GrailsProjectConfig projectConfig;
85
    private final File projectRoot;
86
    private final File projectRoot;
87
    private final SourceCategoriesFactory sourceCategoriesFactory;
86
88
87
    private List<PathResourceImplementation> resources;
89
    private List<PathResourceImplementation> resources;
88
    private GrailsPlatform.Version version;
90
    private GrailsPlatform.Version version;
Lines 95-100 Link Here
95
        this.projectConfig = projectConfig;
97
        this.projectConfig = projectConfig;
96
        this.projectRoot = FileUtil.toFile(projectConfig.getProject().getProjectDirectory());
98
        this.projectRoot = FileUtil.toFile(projectConfig.getProject().getProjectDirectory());
97
        this.version = projectConfig.getGrailsPlatform().getVersion();
99
        this.version = projectConfig.getGrailsPlatform().getVersion();
100
101
        //TODO: would be nice to reuse the project source categories factory here:
102
        this.sourceCategoriesFactory = new SourceCategoriesFactory();
98
    }
103
    }
99
104
100
    public static ProjectClassPathImplementation forProject(Project project) {
105
    public static ProjectClassPathImplementation forProject(Project project) {
Lines 134-140 Link Here
134
        // http://grails.org/GWT+Plugin
139
        // http://grails.org/GWT+Plugin
135
        GrailsPluginSupport pluginSupport = GrailsPluginSupport.forProject(projectConfig.getProject());
140
        GrailsPluginSupport pluginSupport = GrailsPluginSupport.forProject(projectConfig.getProject());
136
        if (pluginSupport != null && pluginSupport.usesPlugin("gwt")) { // NOI18N
141
        if (pluginSupport != null && pluginSupport.usesPlugin("gwt")) { // NOI18N
137
            File gwtDir = new File(new File(projectRoot, SourceCategory.LIB.getRelativePath()), "gwt"); // NOI18N
142
            File gwtDir = new File(new File(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.LIB).getRelativePath()), "gwt"); // NOI18N
138
            if (gwtDir.exists() && gwtDir.isDirectory()) {
143
            if (gwtDir.exists() && gwtDir.isDirectory()) {
139
                addJars(gwtDir, result, false);
144
                addJars(gwtDir, result, false);
140
            }
145
            }
Lines 242-248 Link Here
242
            return;
247
            return;
243
        }
248
        }
244
249
245
        File libDir = new File(root, SourceCategory.LIB.getRelativePath());
250
        File libDir = new File(root, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.LIB).getRelativePath());
246
        if (!libDir.exists() || !libDir.isDirectory()) {
251
        if (!libDir.exists() || !libDir.isDirectory()) {
247
            return;
252
            return;
248
        }
253
        }
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/classpath/SourceRoots.java (-12 / +15 lines)
Lines 54-59 Link Here
54
import org.netbeans.modules.groovy.grailsproject.GrailsProject;
54
import org.netbeans.modules.groovy.grailsproject.GrailsProject;
55
import org.netbeans.modules.groovy.grailsproject.GrailsSources;
55
import org.netbeans.modules.groovy.grailsproject.GrailsSources;
56
import org.netbeans.modules.groovy.grailsproject.SourceCategory;
56
import org.netbeans.modules.groovy.grailsproject.SourceCategory;
57
import org.netbeans.modules.groovy.grailsproject.SourceCategoriesFactory;
58
import org.netbeans.modules.groovy.grailsproject.SourceCategoryType;
57
import org.netbeans.modules.groovy.grailsproject.plugins.GrailsPlugin;
59
import org.netbeans.modules.groovy.grailsproject.plugins.GrailsPlugin;
58
import org.netbeans.modules.groovy.grailsproject.plugins.GrailsPluginSupport;
60
import org.netbeans.modules.groovy.grailsproject.plugins.GrailsPluginSupport;
59
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileObject;
Lines 136-153 Link Here
136
    }
138
    }
137
139
138
    private void addGrailsSourceRoots(FileObject projectRoot, List<FileObject> result) {
140
    private void addGrailsSourceRoots(FileObject projectRoot, List<FileObject> result) {
139
        addRoot(projectRoot, SourceCategory.GRAILSAPP_CONF, result);
141
        SourceCategoriesFactory sourceCategoriesFactory = project.getSourceCategoriesFactory();
140
        addRoot(projectRoot, SourceCategory.GRAILSAPP_CONTROLLERS, result);
142
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.GRAILSAPP_CONF), result);
141
        addRoot(projectRoot, SourceCategory.GRAILSAPP_DOMAIN, result);
143
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.GRAILSAPP_CONTROLLERS), result);
142
        addRoot(projectRoot, SourceCategory.GRAILSAPP_SERVICES, result);
144
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.GRAILSAPP_DOMAIN), result);
143
        addRoot(projectRoot, SourceCategory.GRAILSAPP_TAGLIB, result);
145
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.GRAILSAPP_SERVICES), result);
144
        addRoot(projectRoot, SourceCategory.GRAILSAPP_UTILS, result);
146
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.GRAILSAPP_TAGLIB), result);
145
        addRoot(projectRoot, SourceCategory.SCRIPTS, result);
147
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.GRAILSAPP_UTILS), result);
146
        addRoot(projectRoot, SourceCategory.SRC_GROOVY, result);
148
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.SCRIPTS), result);
147
        addRoot(projectRoot, SourceCategory.SRC_JAVA, result);
149
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.SRC_GROOVY), result);
148
        addRoot(projectRoot, SourceCategory.SRC_GWT, result);
150
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.SRC_JAVA), result);
149
        addRoot(projectRoot, SourceCategory.TEST_INTEGRATION, result);
151
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.SRC_GWT), result);
150
        addRoot(projectRoot, SourceCategory.TEST_UNIT, result);
152
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.TEST_INTEGRATION), result);
153
        addRoot(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.TEST_UNIT), result);
151
154
152
        File pluginsDirFile = project == null ? null : project.getBuildConfig().getProjectPluginsDir();
155
        File pluginsDirFile = project == null ? null : project.getBuildConfig().getProjectPluginsDir();
153
        FileObject pluginsDir = pluginsDirFile == null ? null : FileUtil.toFileObject(
156
        FileObject pluginsDir = pluginsDirFile == null ? null : FileUtil.toFileObject(
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/TemplatesImpl.java (-3 / +3 lines)
Lines 44-50 Link Here
44
44
45
import org.netbeans.api.project.SourceGroup;
45
import org.netbeans.api.project.SourceGroup;
46
import org.netbeans.modules.groovy.grailsproject.GrailsProject;
46
import org.netbeans.modules.groovy.grailsproject.GrailsProject;
47
import org.netbeans.modules.groovy.grailsproject.SourceCategory;
47
import org.netbeans.modules.groovy.grailsproject.SourceCategoryType;
48
import org.netbeans.modules.groovy.grailsproject.ui.wizards.impl.GrailsArtifacts;
48
import org.netbeans.modules.groovy.grailsproject.ui.wizards.impl.GrailsArtifacts;
49
import org.netbeans.spi.project.ui.PrivilegedTemplates;
49
import org.netbeans.spi.project.ui.PrivilegedTemplates;
50
import org.netbeans.spi.project.ui.RecommendedTemplates;
50
import org.netbeans.spi.project.ui.RecommendedTemplates;
Lines 147-160 Link Here
147
    };
147
    };
148
148
149
149
150
    private final SourceCategory sourceCategory;
150
    private final SourceCategoryType sourceCategory;
151
151
152
152
153
    public TemplatesImpl(GrailsProject project, SourceGroup sourceGroup) {
153
    public TemplatesImpl(GrailsProject project, SourceGroup sourceGroup) {
154
        FileObject projectDir = project.getProjectDirectory();
154
        FileObject projectDir = project.getProjectDirectory();
155
        FileObject rootFolder = sourceGroup.getRootFolder();
155
        FileObject rootFolder = sourceGroup.getRootFolder();
156
156
157
        sourceCategory = GrailsArtifacts.getCategoryForFolder(projectDir, rootFolder);
157
        sourceCategory = GrailsArtifacts.getCategoryTypeForFolder(projectDir, rootFolder, project.getSourceCategoriesFactory());
158
    }
158
    }
159
159
160
    @Override
160
    @Override
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/GrailsArtifactWizardIterator.java (-4 / +6 lines)
Lines 79-84 Link Here
79
import org.netbeans.modules.groovy.grails.api.GrailsProjectConfig;
79
import org.netbeans.modules.groovy.grails.api.GrailsProjectConfig;
80
import org.netbeans.modules.groovy.grailsproject.GrailsProject;
80
import org.netbeans.modules.groovy.grailsproject.GrailsProject;
81
import org.netbeans.modules.groovy.grailsproject.SourceCategory;
81
import org.netbeans.modules.groovy.grailsproject.SourceCategory;
82
import org.netbeans.modules.groovy.grailsproject.SourceCategoriesFactory;
82
import org.netbeans.modules.groovy.grailsproject.actions.RefreshProjectRunnable;
83
import org.netbeans.modules.groovy.grailsproject.actions.RefreshProjectRunnable;
83
import org.netbeans.modules.groovy.grailsproject.ui.wizards.impl.GrailsArtifacts;
84
import org.netbeans.modules.groovy.grailsproject.ui.wizards.impl.GrailsArtifacts;
84
import org.netbeans.modules.groovy.grailsproject.ui.wizards.impl.GrailsTargetChooserPanel;
85
import org.netbeans.modules.groovy.grailsproject.ui.wizards.impl.GrailsTargetChooserPanel;
Lines 262-273 Link Here
262
        this.wiz = wiz;
263
        this.wiz = wiz;
263
264
264
        FileObject template = Templates.getTemplate(wiz);
265
        FileObject template = Templates.getTemplate(wiz);
265
266
        
266
        sourceCategory = GrailsArtifacts.getCategoryForTemplate(template);
267
        project = Templates.getProject(wiz).getLookup().lookup(GrailsProject.class);
268
        
269
        SourceCategoriesFactory sourceCategoriesFactory = project.getSourceCategoriesFactory();
270
        sourceCategory = sourceCategoriesFactory.getSourceCategory(GrailsArtifacts.getCategoryTypeForTemplate(template));
267
        assert sourceCategory != null;
271
        assert sourceCategory != null;
268
272
269
        project = Templates.getProject(wiz).getLookup().lookup(GrailsProject.class);
270
271
        index = 0;
273
        index = 0;
272
        panels = createPanels(wiz);
274
        panels = createPanels(wiz);
273
        // Make sure list of steps is accurate.
275
        // Make sure list of steps is accurate.
(-)a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/impl/GrailsArtifacts.java (-44 / +47 lines)
Lines 46-51 Link Here
46
import org.netbeans.api.project.Project;
46
import org.netbeans.api.project.Project;
47
import org.netbeans.api.project.SourceGroup;
47
import org.netbeans.api.project.SourceGroup;
48
import org.netbeans.modules.groovy.grailsproject.SourceCategory;
48
import org.netbeans.modules.groovy.grailsproject.SourceCategory;
49
import org.netbeans.modules.groovy.grailsproject.SourceCategoriesFactory;
50
import org.netbeans.modules.groovy.grailsproject.SourceCategoryType;
49
import org.netbeans.modules.groovy.grailsproject.ui.TemplatesImpl;
51
import org.netbeans.modules.groovy.grailsproject.ui.TemplatesImpl;
50
import org.openide.filesystems.FileObject;
52
import org.openide.filesystems.FileObject;
51
import org.openide.filesystems.FileUtil;
53
import org.openide.filesystems.FileUtil;
Lines 56-62 Link Here
56
 */
58
 */
57
public class GrailsArtifacts {
59
public class GrailsArtifacts {
58
60
59
    public static SourceCategory getCategoryForFolder(FileObject projectRoot, FileObject fileObject) {
61
    public static SourceCategoryType getCategoryTypeForFolder(FileObject projectRoot, FileObject fileObject, SourceCategoriesFactory sourceCategoriesFactory) {
60
        String dirName = null;
62
        String dirName = null;
61
        if (projectRoot != null && fileObject.isFolder()) {
63
        if (projectRoot != null && fileObject.isFolder()) {
62
            dirName = FileUtil.getRelativePath(projectRoot, fileObject);
64
            dirName = FileUtil.getRelativePath(projectRoot, fileObject);
Lines 64-127 Link Here
64
        if (dirName == null) {
66
        if (dirName == null) {
65
            return null;
67
            return null;
66
        }
68
        }
67
        if (SourceCategory.GRAILSAPP_CONF.getRelativePath().equals(dirName)) {
69
68
            return SourceCategory.GRAILSAPP_CONF;
70
        if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.GRAILSAPP_CONF).getRelativePath().equals(dirName)) {
69
        } else if (SourceCategory.GRAILSAPP_CONTROLLERS.getRelativePath().equals(dirName)) {
71
            return SourceCategoryType.GRAILSAPP_CONF;
70
            return SourceCategory.GRAILSAPP_CONTROLLERS;
72
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.GRAILSAPP_CONTROLLERS).getRelativePath().equals(dirName)) {
71
        } else if (SourceCategory.GRAILSAPP_DOMAIN.getRelativePath().equals(dirName)) {
73
            return SourceCategoryType.GRAILSAPP_CONTROLLERS;
72
            return SourceCategory.GRAILSAPP_DOMAIN;
74
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.GRAILSAPP_DOMAIN).getRelativePath().equals(dirName)) {
73
        } else if (SourceCategory.TEST_INTEGRATION.getRelativePath().equals(dirName)) {
75
            return SourceCategoryType.GRAILSAPP_DOMAIN;
74
            return SourceCategory.TEST_INTEGRATION;
76
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.TEST_INTEGRATION).getRelativePath().equals(dirName)) {
75
        } else if (SourceCategory.LIB.getRelativePath().equals(dirName)) {
77
            return SourceCategoryType.TEST_INTEGRATION;
76
            return SourceCategory.LIB;
78
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.LIB).getRelativePath().equals(dirName)) {
77
        } else if (SourceCategory.GRAILSAPP_I18N.getRelativePath().equals(dirName)) {
79
            return SourceCategoryType.LIB;
78
            return SourceCategory.GRAILSAPP_I18N;
80
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.GRAILSAPP_I18N).getRelativePath().equals(dirName)) {
79
        } else if (SourceCategory.SCRIPTS.getRelativePath().equals(dirName)) {
81
            return SourceCategoryType.GRAILSAPP_I18N;
80
            return SourceCategory.SCRIPTS;
82
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.SCRIPTS).getRelativePath().equals(dirName)) {
81
        } else if (SourceCategory.GRAILSAPP_SERVICES.getRelativePath().equals(dirName)) {
83
            return SourceCategoryType.SCRIPTS;
82
            return SourceCategory.GRAILSAPP_SERVICES;
84
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.GRAILSAPP_SERVICES).getRelativePath().equals(dirName)) {
83
        } else if (SourceCategory.SRC_GROOVY.getRelativePath().equals(dirName)) {
85
            return SourceCategoryType.GRAILSAPP_SERVICES;
84
            return SourceCategory.SRC_GROOVY;
86
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.SRC_GROOVY).getRelativePath().equals(dirName)) {
85
        } else if (SourceCategory.SRC_JAVA.getRelativePath().equals(dirName)) {
87
            return SourceCategoryType.SRC_GROOVY;
86
            return SourceCategory.SRC_JAVA;
88
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.SRC_JAVA).getRelativePath().equals(dirName)) {
87
        } else if (SourceCategory.SRC_GWT.getRelativePath().equals(dirName)) {
89
            return SourceCategoryType.SRC_JAVA;
88
            return SourceCategory.SRC_GWT;
90
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.SRC_GWT).getRelativePath().equals(dirName)) {
89
        } else if (SourceCategory.GRAILSAPP_TAGLIB.getRelativePath().equals(dirName)) {
91
            return SourceCategoryType.SRC_GWT;
90
            return SourceCategory.GRAILSAPP_TAGLIB;
92
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.GRAILSAPP_TAGLIB).getRelativePath().equals(dirName)) {
91
        } else if (SourceCategory.TEST_UNIT.getRelativePath().equals(dirName)) {
93
            return SourceCategoryType.GRAILSAPP_TAGLIB;
92
            return SourceCategory.TEST_UNIT;
94
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.TEST_UNIT).getRelativePath().equals(dirName)) {
93
        } else if (SourceCategory.GRAILSAPP_UTILS.getRelativePath().equals(dirName)) {
95
            return SourceCategoryType.TEST_UNIT;
94
            return SourceCategory.GRAILSAPP_UTILS;
96
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.GRAILSAPP_UTILS).getRelativePath().equals(dirName)) {
95
        } else if (SourceCategory.GRAILSAPP_VIEWS.getRelativePath().equals(dirName)) {
97
            return SourceCategoryType.GRAILSAPP_UTILS;
96
            return SourceCategory.GRAILSAPP_VIEWS;
98
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.GRAILSAPP_VIEWS).getRelativePath().equals(dirName)) {
97
        } else if (SourceCategory.WEBAPP.getRelativePath().equals(dirName)) {
99
            return SourceCategoryType.GRAILSAPP_VIEWS;
98
            return SourceCategory.WEBAPP;
100
        } else if (sourceCategoriesFactory.getSourceCategory( SourceCategoryType.WEBAPP).getRelativePath().equals(dirName)) {
101
            return SourceCategoryType.WEBAPP;
99
        }
102
        }
100
        return null;
103
        return null;
101
    }
104
    }
102
105
103
    public static SourceCategory getCategoryForTemplate(FileObject template) {
106
    public static SourceCategoryType getCategoryTypeForTemplate(FileObject template) {
104
        String templatePath = template.getPath();
107
        String templatePath = template.getPath();
105
        if (TemplatesImpl.CONTROLLER.equals(templatePath)) { // NOI18N
108
        if (TemplatesImpl.CONTROLLER.equals(templatePath)) { // NOI18N
106
            return SourceCategory.GRAILSAPP_CONTROLLERS;
109
            return SourceCategoryType.GRAILSAPP_CONTROLLERS;
107
        } else if (TemplatesImpl.DOMAIN_CLASS.equals(templatePath)) {
110
        } else if (TemplatesImpl.DOMAIN_CLASS.equals(templatePath)) {
108
            return SourceCategory.GRAILSAPP_DOMAIN;
111
            return SourceCategoryType.GRAILSAPP_DOMAIN;
109
        } else if (TemplatesImpl.GANT_SCRIPT.equals(templatePath)) {
112
        } else if (TemplatesImpl.GANT_SCRIPT.equals(templatePath)) {
110
            return SourceCategory.SCRIPTS;
113
            return SourceCategoryType.SCRIPTS;
111
        } else if (TemplatesImpl.GROOVY_CLASS.equals(templatePath)) {
114
        } else if (TemplatesImpl.GROOVY_CLASS.equals(templatePath)) {
112
            return SourceCategory.SRC_GROOVY;
115
            return SourceCategoryType.SRC_GROOVY;
113
        } else if (TemplatesImpl.GROOVY_SCRIPT.equals(templatePath)) {
116
        } else if (TemplatesImpl.GROOVY_SCRIPT.equals(templatePath)) {
114
            return SourceCategory.SCRIPTS;
117
            return SourceCategoryType.SCRIPTS;
115
        } else if (TemplatesImpl.GSP.equals(templatePath)) {
118
        } else if (TemplatesImpl.GSP.equals(templatePath)) {
116
            return SourceCategory.GRAILSAPP_VIEWS;
119
            return SourceCategoryType.GRAILSAPP_VIEWS;
117
        } else if (TemplatesImpl.INTEGRATION_TEST.equals(templatePath)) {
120
        } else if (TemplatesImpl.INTEGRATION_TEST.equals(templatePath)) {
118
            return SourceCategory.TEST_INTEGRATION;
121
            return SourceCategoryType.TEST_INTEGRATION;
119
        } else if (TemplatesImpl.SERVICE.equals(templatePath)) {
122
        } else if (TemplatesImpl.SERVICE.equals(templatePath)) {
120
            return SourceCategory.GRAILSAPP_SERVICES;
123
            return SourceCategoryType.GRAILSAPP_SERVICES;
121
        } else if (TemplatesImpl.TAG_LIB.equals(templatePath)) {
124
        } else if (TemplatesImpl.TAG_LIB.equals(templatePath)) {
122
            return SourceCategory.GRAILSAPP_TAGLIB;
125
            return SourceCategoryType.GRAILSAPP_TAGLIB;
123
        } else if (TemplatesImpl.UNIT_TEST.equals(templatePath)) {
126
        } else if (TemplatesImpl.UNIT_TEST.equals(templatePath)) {
124
            return SourceCategory.TEST_UNIT;
127
            return SourceCategoryType.TEST_UNIT;
125
        }
128
        }
126
        return null;
129
        return null;
127
    }
130
    }

Return to bug 257835