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

(-)projectui/apichanges.xml (+16 lines)
Lines 54-59 Link Here
54
    </apidefs>
54
    </apidefs>
55
55
56
    <changes>
56
    <changes>
57
        <change id="TemplateCategorySorter">
58
            <api name="recent"/>
59
            <summary>Added <code>TemplateCategorySorter</code></summary>
60
            <version major="1" minor="40"/>
61
            <date year="2012" month="12" day="11"/>
62
            <author login="mkleint"/>
63
            <compatibility addition="yes"/>
64
            <description>
65
                <p>
66
                    Added a new SPI interface <code>TemplatesCategorySorter</code> allowing to post process the order of template categories for given project.
67
                    Implementations of this interface are to be put into project's lookup. If not present, standard layer ordering rules apply.
68
                </p>
69
            </description>
70
            <class package="org.netbeans.modules.project.ui.spi" name="TemplatesCategorySorter"/>
71
            <issue number="206126"/>
72
        </change>
57
        <change id="ProjectTemplates">
73
        <change id="ProjectTemplates">
58
            <api name="recent"/>
74
            <api name="recent"/>
59
            <summary>Added <code>ProjectTemplates</code></summary>
75
            <summary>Added <code>ProjectTemplates</code></summary>
(-)projectui/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=1.39.0
45
spec.version.base=1.40.0
46
46
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
(-)projectui/nbproject/project.xml (+1 lines)
Lines 279-284 Link Here
279
                <friend>org.netbeans.modules.team.ui</friend>
279
                <friend>org.netbeans.modules.team.ui</friend>
280
                <friend>org.netbeans.modules.welcome</friend>
280
                <friend>org.netbeans.modules.welcome</friend>
281
                <package>org.netbeans.modules.project.ui.api</package>
281
                <package>org.netbeans.modules.project.ui.api</package>
282
                <package>org.netbeans.modules.project.ui.spi</package>
282
            </friend-packages>
283
            </friend-packages>
283
        </data>
284
        </data>
284
    </configuration>
285
    </configuration>
(-)projectui/src/org/netbeans/modules/project/ui/spi/TemplateCategorySorter.java (+60 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.project.ui.spi;
43
44
import java.util.List;
45
import org.openide.loaders.DataObject;
46
47
/**
48
 * post process the order of template categories for given project. Implementation to be included in project's lookup.
49
 * @author mkleint
50
 * @since 1.40
51
 */
52
public interface TemplateCategorySorter {
53
 
54
    /**
55
     * Sort the template categories
56
     * @param original
57
     * @return new ordering for the list.
58
     */
59
    List<DataObject> sort(List<DataObject> original);
60
}
(-)projectui/src/org/netbeans/modules/project/ui/TemplateChooserPanelGUI.java (-4 / +25 lines)
Lines 49-54 Link Here
49
import java.awt.event.ActionListener;
49
import java.awt.event.ActionListener;
50
import java.beans.PropertyChangeEvent;
50
import java.beans.PropertyChangeEvent;
51
import java.beans.PropertyChangeListener;
51
import java.beans.PropertyChangeListener;
52
import java.util.ArrayList;
52
import java.util.Arrays;
53
import java.util.Arrays;
53
import java.util.List;
54
import java.util.List;
54
import javax.swing.DefaultComboBoxModel;
55
import javax.swing.DefaultComboBoxModel;
Lines 57-62 Link Here
57
import org.netbeans.api.annotations.common.NonNull;
58
import org.netbeans.api.annotations.common.NonNull;
58
import org.netbeans.api.project.Project;
59
import org.netbeans.api.project.Project;
59
import static org.netbeans.modules.project.ui.Bundle.*;
60
import static org.netbeans.modules.project.ui.Bundle.*;
61
import org.netbeans.modules.project.ui.spi.TemplateCategorySorter;
60
import org.openide.filesystems.FileObject;
62
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileUtil;
63
import org.openide.filesystems.FileUtil;
62
import org.openide.loaders.DataFolder;
64
import org.openide.loaders.DataFolder;
Lines 281-289 Link Here
281
    private final class TemplateChildren extends ChildFactory.Detachable<TemplateKey> implements ActionListener {
283
    private final class TemplateChildren extends ChildFactory.Detachable<TemplateKey> implements ActionListener {
282
        
284
        
283
        private final DataFolder folder;
285
        private final DataFolder folder;
286
        private final boolean isRoot;
284
        
287
        
285
        TemplateChildren(DataFolder folder) {
288
        TemplateChildren(DataFolder folder, boolean root) {
286
            this.folder = folder;
289
            this.folder = folder;
290
            isRoot = root;
287
        }
291
        }
288
        
292
        
289
        @Override protected void addNotify() {
293
        @Override protected void addNotify() {
Lines 295-302 Link Here
295
        }
299
        }
296
300
297
        @Override protected boolean createKeys(List<TemplateKey> keys) {
301
        @Override protected boolean createKeys(List<TemplateKey> keys) {
298
            for (DataObject d : folder.getChildren()) {
302
            DataObject[] children = folder.getChildren();
303
            if (isRoot) {
304
                Project p = getProject();
305
                TemplateCategorySorter tcs = p != null ? p.getLookup().lookup(TemplateCategorySorter.class) : null;
306
                if (tcs != null) {
307
                    List<DataObject> dobjs = new ArrayList<DataObject>();                    
308
                    for (DataObject d : children) {
299
                if (isFolderOfTemplates(d)) {
309
                if (isFolderOfTemplates(d)) {
310
                            dobjs.add(d);
311
                        }
312
                    }
313
                    List<DataObject> sorted = tcs.sort(dobjs);
314
                    assert sorted.size() == dobjs.size();
315
                    children = sorted.toArray(new DataObject[children.length]);
316
                }
317
            }
318
            
319
            for (DataObject d : children) {
320
                if (isFolderOfTemplates(d)) {
300
                    boolean leaf = true;
321
                    boolean leaf = true;
301
                    for (DataObject child : ((DataFolder) d).getChildren()) {
322
                    for (DataObject child : ((DataFolder) d).getChildren()) {
302
                        if (isFolderOfTemplates(child)) {
323
                        if (isFolderOfTemplates(child)) {
Lines 311-317 Link Here
311
        }
332
        }
312
        
333
        
313
        @Override protected Node createNodeForKey(TemplateKey k) {
334
        @Override protected Node createNodeForKey(TemplateKey k) {
314
            return new FilterNode(k.d.getNodeDelegate(), k.leaf ? Children.LEAF : Children.create(new TemplateChildren((DataFolder) k.d), true));
335
            return new FilterNode(k.d.getNodeDelegate(), k.leaf ? Children.LEAF : Children.create(new TemplateChildren((DataFolder) k.d, false), true));
315
        }
336
        }
316
        
337
        
317
        @Override public void actionPerformed (ActionEvent event) {
338
        @Override public void actionPerformed (ActionEvent event) {
Lines 369-375 Link Here
369
    final class FileChooserBuilder implements TemplatesPanelGUI.Builder {
390
    final class FileChooserBuilder implements TemplatesPanelGUI.Builder {
370
        
391
        
371
        @Override public Children createCategoriesChildren(DataFolder folder) {
392
        @Override public Children createCategoriesChildren(DataFolder folder) {
372
            return Children.create(new TemplateChildren(folder), true);
393
            return Children.create(new TemplateChildren(folder, true), true);
373
        }
394
        }
374
        
395
        
375
        @Override public Children createTemplatesChildren(DataFolder folder) {
396
        @Override public Children createTemplatesChildren(DataFolder folder) {

Return to bug 206126