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

(-)ant/project/apichanges.xml:1.12 (+19 lines)
Lines 82-87 Link Here
82
82
83
    <changes>
83
    <changes>
84
        
84
        
85
        <change id="PropertyUtils.userPropertiesProvider.DelegatingPropertyProvider">
86
            <api name="general"/>
87
            <summary>Added utilities for constructing richer property evaluators</summary>
88
            <version major="1" minor="14"/>
89
            <date day="22" month="6" year="2006"/>
90
            <author login="jglick"/>
91
            <compatibility addition="yes"/>
92
            <description>
93
                <p>
94
                    Added a new method and nested class to <code>PropertyUtils</code> to
95
                    make it easier to write a customizer version of
96
                    <code>AntProjectHelper.getStandardPropertyEvaluator()</code>,
97
                    among other things.
98
                </p>
99
            </description>
100
            <class package="org.netbeans.spi.project.support.ant" name="PropertyUtils"/>
101
            <issue number="49636"/>
102
        </change>
103
        
85
        <change id="ReferenceHelper.addReference-change-of-target-property-file">
104
        <change id="ReferenceHelper.addReference-change-of-target-property-file">
86
            <api name="general"/>
105
            <api name="general"/>
87
            <summary>Semantic changes in the ReferenceHelper behavior</summary>
106
            <summary>Semantic changes in the ReferenceHelper behavior</summary>
(-)ant/project/manifest.mf:1.17 (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.project.ant/1
2
OpenIDE-Module: org.netbeans.modules.project.ant/1
3
OpenIDE-Module-Specification-Version: 1.13
3
OpenIDE-Module-Specification-Version: 1.14
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bundle.properties
5
OpenIDE-Module-Install: org/netbeans/modules/project/ant/AntProjectModule.class
5
OpenIDE-Module-Install: org/netbeans/modules/project/ant/AntProjectModule.class
6
6
(-)ant/project/src/org/netbeans/spi/project/support/ant/ProjectProperties.java:1.16 (-32 / +2 lines)
Lines 19-26 Link Here
19
19
20
package org.netbeans.spi.project.support.ant;
20
package org.netbeans.spi.project.support.ant;
21
21
22
import java.beans.PropertyChangeEvent;
23
import java.beans.PropertyChangeListener;
24
import java.io.ByteArrayOutputStream;
22
import java.io.ByteArrayOutputStream;
25
import java.io.File;
23
import java.io.File;
26
import java.io.IOException;
24
import java.io.IOException;
Lines 400-406 Link Here
400
            PropertyEvaluator findUserPropertiesFile = PropertyUtils.sequentialPropertyEvaluator(
398
            PropertyEvaluator findUserPropertiesFile = PropertyUtils.sequentialPropertyEvaluator(
401
                getStockPropertyPreprovider(),
399
                getStockPropertyPreprovider(),
402
                getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH));
400
                getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH));
403
            PropertyProvider globalProperties = new UserPropertiesProvider(findUserPropertiesFile);
401
            PropertyProvider globalProperties = PropertyUtils.userPropertiesProvider(findUserPropertiesFile,
402
                    "user.properties.file", FileUtil.toFile(helper.getProjectDirectory())); // NOI18N
404
            standardPropertyEvaluator = PropertyUtils.sequentialPropertyEvaluator(
403
            standardPropertyEvaluator = PropertyUtils.sequentialPropertyEvaluator(
405
                getStockPropertyPreprovider(),
404
                getStockPropertyPreprovider(),
406
                getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH),
405
                getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH),
Lines 408-442 Link Here
408
                getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH));
407
                getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH));
409
        }
408
        }
410
        return standardPropertyEvaluator;
409
        return standardPropertyEvaluator;
411
    }
412
    private PropertyProvider computeDelegate(PropertyEvaluator findUserPropertiesFile) {
413
        String userPropertiesFile = findUserPropertiesFile.getProperty("user.properties.file"); // NOI18N
414
        if (userPropertiesFile != null) {
415
            // Have some defined global properties file, so read it and listen to changes in it.
416
            File f = helper.resolveFile(userPropertiesFile);
417
            if (f.equals(PropertyUtils.userBuildProperties())) {
418
                // Just to share the cache.
419
                return PropertyUtils.globalPropertyProvider();
420
            } else {
421
                return PropertyUtils.propertiesFilePropertyProvider(f);
422
            }
423
        } else {
424
            // Use the in-IDE default.
425
            return PropertyUtils.globalPropertyProvider();
426
        }
427
    }
428
    private final class UserPropertiesProvider extends PropertyUtils.DelegatingPropertyProvider implements PropertyChangeListener {
429
        private final PropertyEvaluator findUserPropertiesFile;
430
        public UserPropertiesProvider(PropertyEvaluator findUserPropertiesFile) {
431
            super(computeDelegate(findUserPropertiesFile));
432
            this.findUserPropertiesFile = findUserPropertiesFile;
433
            findUserPropertiesFile.addPropertyChangeListener(this);
434
        }
435
        public void propertyChange(PropertyChangeEvent ev) {
436
            if ("user.properties.file".equals(ev.getPropertyName())) { // NOI18N
437
                setDelegate(computeDelegate(findUserPropertiesFile));
438
            }
439
        }
440
    }
410
    }
441
    
411
    
442
}
412
}
(-)ant/project/src/org/netbeans/spi/project/support/ant/PropertyUtils.java:1.35 (-9 / +68 lines)
Lines 710-715 Link Here
710
    public static PropertyEvaluator sequentialPropertyEvaluator(PropertyProvider preprovider, PropertyProvider... providers) {
710
    public static PropertyEvaluator sequentialPropertyEvaluator(PropertyProvider preprovider, PropertyProvider... providers) {
711
        return new SequentialPropertyEvaluator(preprovider, providers);
711
        return new SequentialPropertyEvaluator(preprovider, providers);
712
    }
712
    }
713
714
    /**
715
     * Creates a property provider similar to {@link #globalPropertyProvider}
716
     * but which can use a different global properties file.
717
     * If a specific file is pointed to, that is loaded; otherwise behaves like {@link #globalPropertyProvider}.
718
     * Permits behavior similar to command-line Ant where not erroneous, but using the IDE's
719
     * default global properties for projects which do not yet have this property registered.
720
     * @param findUserPropertiesFile an evaluator in which to look up <code>propertyName</code>
721
     * @param propertyName a property pointing to the global properties file (typically <code>"user.properties.file"</code>)
722
     * @param basedir a base directory to use when resolving the path to the global properties file, if relative
723
     * @return a provider of global properties
724
     * @since org.netbeans.modules.project.ant/1 1.14
725
     */
726
    public static PropertyProvider userPropertiesProvider(PropertyEvaluator findUserPropertiesFile, String propertyName, File basedir) {
727
        return new UserPropertiesProvider(findUserPropertiesFile, propertyName, basedir);
728
    }
729
    private static final class UserPropertiesProvider extends DelegatingPropertyProvider implements PropertyChangeListener {
730
        private final PropertyEvaluator findUserPropertiesFile;
731
        private final String propertyName;
732
        private final File basedir;
733
        public UserPropertiesProvider(PropertyEvaluator findUserPropertiesFile, String propertyName, File basedir) {
734
            super(computeDelegate(findUserPropertiesFile, propertyName, basedir));
735
            this.findUserPropertiesFile = findUserPropertiesFile;
736
            this.propertyName = propertyName;
737
            this.basedir = basedir;
738
            findUserPropertiesFile.addPropertyChangeListener(this);
739
        }
740
        public void propertyChange(PropertyChangeEvent ev) {
741
            if (propertyName.equals(ev.getPropertyName())) {
742
                setDelegate(computeDelegate(findUserPropertiesFile, propertyName, basedir));
743
            }
744
        }
745
        private static PropertyProvider computeDelegate(PropertyEvaluator findUserPropertiesFile, String propertyName, File basedir) {
746
            String userPropertiesFile = findUserPropertiesFile.getProperty(propertyName);
747
            if (userPropertiesFile != null) {
748
                // Have some defined global properties file, so read it and listen to changes in it.
749
                File f = PropertyUtils.resolveFile(basedir, userPropertiesFile);
750
                if (f.equals(PropertyUtils.userBuildProperties())) {
751
                    // Just to share the cache.
752
                    return PropertyUtils.globalPropertyProvider();
753
                } else {
754
                    return PropertyUtils.propertiesFilePropertyProvider(f);
755
                }
756
            } else {
757
                // Use the in-IDE default.
758
                return PropertyUtils.globalPropertyProvider();
759
            }
760
        }
761
    }
713
    
762
    
714
    private static final class SequentialPropertyEvaluator implements PropertyEvaluator, ChangeListener {
763
    private static final class SequentialPropertyEvaluator implements PropertyEvaluator, ChangeListener {
715
        
764
        
Lines 839-857 Link Here
839
    
888
    
840
    /**
889
    /**
841
     * Property provider that delegates to another source.
890
     * Property provider that delegates to another source.
842
     * Currently attaches a strong listener to it.
891
     * Useful, for example, when conditionally loading from one or another properties file.
892
     * @since org.netbeans.modules.project.ant/1 1.14
843
     */
893
     */
844
    static abstract class DelegatingPropertyProvider implements PropertyProvider, ChangeListener {
894
    public static abstract class DelegatingPropertyProvider implements PropertyProvider {
845
        
895
        
846
        private PropertyProvider delegate;
896
        private PropertyProvider delegate;
847
        private final List<ChangeListener> listeners = new ArrayList<ChangeListener>();
897
        private final List<ChangeListener> listeners = new ArrayList<ChangeListener>();
898
        private final ChangeListener strongListener = new ChangeListener() {
899
            public void stateChanged(ChangeEvent e) {
900
                //System.err.println("DPP: change from current provider " + delegate);
901
                fireChange();
902
            }
903
        };
848
        private ChangeListener weakListener = null; // #50572: must be weak
904
        private ChangeListener weakListener = null; // #50572: must be weak
849
        
905
906
        /**
907
         * Initialize the proxy.
908
         * @param delegate the initial delegate to use
909
         */
850
        protected DelegatingPropertyProvider(PropertyProvider delegate) {
910
        protected DelegatingPropertyProvider(PropertyProvider delegate) {
851
            assert delegate != null;
911
            assert delegate != null;
852
            setDelegate(delegate);
912
            setDelegate(delegate);
853
        }
913
        }
854
        
914
        
915
        /**
916
         * Change the current delegate (firing changes as well).
917
         * @param delegate the initial delegate to use
918
         */
855
        protected final void setDelegate(PropertyProvider delegate) {
919
        protected final void setDelegate(PropertyProvider delegate) {
856
            if (delegate == this.delegate) {
920
            if (delegate == this.delegate) {
857
                return;
921
                return;
Lines 861-867 Link Here
861
                this.delegate.removeChangeListener(weakListener);
925
                this.delegate.removeChangeListener(weakListener);
862
            }
926
            }
863
            this.delegate = delegate;
927
            this.delegate = delegate;
864
            weakListener = WeakListeners.change(this, delegate);
928
            weakListener = WeakListeners.change(strongListener, delegate);
865
            delegate.addChangeListener(weakListener);
929
            delegate.addChangeListener(weakListener);
866
            fireChange();
930
            fireChange();
867
        }
931
        }
Lines 893-903 Link Here
893
            }
957
            }
894
        }
958
        }
895
959
896
        public final void stateChanged(ChangeEvent changeEvent) {
897
            //System.err.println("DPP: change from current provider " + delegate);
898
            fireChange();
899
        }
900
        
901
    }
960
    }
902
    
961
    
903
}
962
}
(-)ant/project/test/unit/src/org/netbeans/spi/project/support/ant/PropertyUtilsTest.java:1.21 (-1 lines)
Lines 563-569 Link Here
563
    }
563
    }
564
    
564
    
565
    public void testDelegatingPropertyProvider() throws Exception {
565
    public void testDelegatingPropertyProvider() throws Exception {
566
        // Used only by ProjectProperties, not publically, but still worth testing.
567
        TestMutablePropertyProvider mpp = new TestMutablePropertyProvider(new HashMap<String,String>());
566
        TestMutablePropertyProvider mpp = new TestMutablePropertyProvider(new HashMap<String,String>());
568
        DPP dpp = new DPP(mpp);
567
        DPP dpp = new DPP(mpp);
569
        AntBasedTestUtil.TestCL l = new AntBasedTestUtil.TestCL();
568
        AntBasedTestUtil.TestCL l = new AntBasedTestUtil.TestCL();
(-)java/j2seproject/nbproject/project.properties:1.29 (+2 lines)
Lines 15-20 Link Here
15
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
15
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16
# Microsystems, Inc. All Rights Reserved.
16
# Microsystems, Inc. All Rights Reserved.
17
17
18
javac.compilerargs=-Xlint
19
javac.source=1.5
18
spec.version.base=1.7.0
20
spec.version.base=1.7.0
19
21
20
javadoc.arch=${basedir}/arch.xml
22
javadoc.arch=${basedir}/arch.xml
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/Bundle.properties:1.28 (+2 lines)
Lines 75-77 Link Here
75
MSG_OldProjectMetadata=The project is not of the current version.
75
MSG_OldProjectMetadata=The project is not of the current version.
76
76
77
CopyLibs=CopyLibs Task
77
CopyLibs=CopyLibs Task
78
79
J2SEConfigurationProvider.default.label=<default>
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java:1.50 (-29 / +59 lines)
Lines 42-47 Link Here
42
import org.netbeans.api.project.ProjectManager;
42
import org.netbeans.api.project.ProjectManager;
43
import org.netbeans.api.project.ProjectUtils;
43
import org.netbeans.api.project.ProjectUtils;
44
import org.netbeans.modules.java.j2seproject.applet.AppletSupport;
44
import org.netbeans.modules.java.j2seproject.applet.AppletSupport;
45
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
45
import org.netbeans.modules.java.j2seproject.ui.customizer.MainClassChooser;
46
import org.netbeans.modules.java.j2seproject.ui.customizer.MainClassChooser;
46
import org.netbeans.modules.java.j2seproject.ui.customizer.MainClassWarning;
47
import org.netbeans.modules.java.j2seproject.ui.customizer.MainClassWarning;
47
import org.netbeans.modules.javacore.JMManager;
48
import org.netbeans.modules.javacore.JMManager;
Lines 277-299 Link Here
277
            p.setProperty("fix.includes", path); // NOI18N
278
            p.setProperty("fix.includes", path); // NOI18N
278
        }
279
        }
279
        else if (command.equals (COMMAND_RUN) || command.equals(COMMAND_DEBUG) || command.equals(COMMAND_DEBUG_STEP_INTO)) {
280
        else if (command.equals (COMMAND_RUN) || command.equals(COMMAND_DEBUG) || command.equals(COMMAND_DEBUG_STEP_INTO)) {
280
            EditableProperties ep = updateHelper.getProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH);
281
            String config = project.evaluator().getProperty(J2SEConfigurationProvider.PROP_CONFIG);
282
            String path;
283
            if (config == null || config.length() == 0) {
284
                path = AntProjectHelper.PROJECT_PROPERTIES_PATH;
285
            } else {
286
                // Set main class for a particular config only.
287
                path = "nbproject/configs/" + config + ".properties"; // NOI18N
288
            }
289
            EditableProperties ep = updateHelper.getProperties(path);
281
290
282
            // check project's main class
291
            // check project's main class
283
            String mainClass = (String)ep.get ("main.class"); // NOI18N
292
            // Check whether main class is defined in this config. Note that we use the evaluator,
284
            int result = isSetMainClass (project.getSourceRoots().getRoots(), mainClass);
293
            // not ep.getProperty(MAIN_CLASS), since it is permissible for the default pseudoconfig
285
            if (result != 0) {                
294
            // to define a main class - in this case an active config need not override it.
295
            String mainClass = project.evaluator().getProperty(J2SEProjectProperties.MAIN_CLASS);
296
            MainClassStatus result = isSetMainClass (project.getSourceRoots().getRoots(), mainClass);
297
            if (context.lookup(J2SEConfigurationProvider.Config.class) != null) {
298
                // If a specific config was selected, just skip this check for now.
299
                // XXX would ideally check that that config in fact had a main class.
300
                // But then evaluator.getProperty(MAIN_CLASS) would be inaccurate.
301
                // Solvable but punt on it for now.
302
                result = MainClassStatus.SET_AND_VALID;
303
            }
304
            if (result != MainClassStatus.SET_AND_VALID) {
286
                do {
305
                do {
287
                    // show warning, if cancel then return
306
                    // show warning, if cancel then return
288
                    if (showMainClassWarning (mainClass, ProjectUtils.getInformation(project).getDisplayName(), ep,result)) {
307
                    if (showMainClassWarning (mainClass, ProjectUtils.getInformation(project).getDisplayName(), ep,result)) {
289
                        return null;
308
                        return null;
290
                    }
309
                    }
291
                    mainClass = (String)ep.get ("main.class"); // NOI18N
310
                    // No longer use the evaluator: have not called putProperties yet so it would not work.
311
                    mainClass = ep.get(J2SEProjectProperties.MAIN_CLASS);
292
                    result=isSetMainClass (project.getSourceRoots().getRoots(), mainClass);
312
                    result=isSetMainClass (project.getSourceRoots().getRoots(), mainClass);
293
                } while (result != 0);
313
                } while (result != MainClassStatus.SET_AND_VALID);
294
                try {
314
                try {
295
                    if (updateHelper.requestSave()) {
315
                    if (updateHelper.requestSave()) {
296
                        updateHelper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
316
                        updateHelper.putProperties(path, ep);
297
                        ProjectManager.getDefault().saveProject(project);
317
                        ProjectManager.getDefault().saveProject(project);
298
                    }
318
                    }
299
                    else {
319
                    else {
Lines 389-394 Link Here
389
                throw new IllegalArgumentException(command);
409
                throw new IllegalArgumentException(command);
390
            }
410
            }
391
        }
411
        }
412
        J2SEConfigurationProvider.Config c = context.lookup(J2SEConfigurationProvider.Config.class);
413
        if (c != null) {
414
            String config;
415
            if (c.name != null) {
416
                config = c.name;
417
            } else {
418
                // Invalid but overrides any valid setting in config.properties.
419
                config = "";
420
            }
421
            p.setProperty(J2SEConfigurationProvider.PROP_CONFIG, config);
422
        }
392
        return targetNames;
423
        return targetNames;
393
    }
424
    }
394
    
425
    
Lines 551-581 Link Here
551
        return srcDir;
582
        return srcDir;
552
    }
583
    }
553
    
584
    
585
    private static enum MainClassStatus {
586
        SET_AND_VALID,
587
        SET_BUT_INVALID,
588
        UNSET
589
    }
554
590
555
    /**
591
    /**
556
     * Tests if the main class is set
592
     * Tests if the main class is set
557
     * @param sourcesRoots source roots
593
     * @param sourcesRoots source roots
558
     * @param mainClass main class name
594
     * @param mainClass main class name
559
     * @return 0 if the main class is set and is valid
595
     * @return status code
560
     *        -1 if the main class is not set
561
     *        -2 if the main class is set but is not valid
562
     */
596
     */
563
    private int isSetMainClass (FileObject[] sourcesRoots, String mainClass) {
597
    private MainClassStatus isSetMainClass(FileObject[] sourcesRoots, String mainClass) {
564
598
565
        // support for unit testing
599
        // support for unit testing
566
        if (MainClassChooser.unitTestingSupport_hasMainMethodResult != null) {
600
        if (MainClassChooser.unitTestingSupport_hasMainMethodResult != null) {
567
            return MainClassChooser.unitTestingSupport_hasMainMethodResult.booleanValue () ? 0 : -2;
601
            return MainClassChooser.unitTestingSupport_hasMainMethodResult ? MainClassStatus.SET_AND_VALID : MainClassStatus.SET_BUT_INVALID;
568
        }
602
        }
569
603
570
        if (mainClass == null || mainClass.length () == 0) {
604
        if (mainClass == null || mainClass.length () == 0) {
571
            return -1;
605
            return MainClassStatus.UNSET;
572
        }
606
        }
573
        
607
        
574
        ClassPath classPath = ClassPath.getClassPath (sourcesRoots[0], ClassPath.EXECUTE);  //Single compilation unit
608
        ClassPath classPath = ClassPath.getClassPath (sourcesRoots[0], ClassPath.EXECUTE);  //Single compilation unit
575
        if (J2SEProjectUtil.isMainClass (mainClass, classPath)) {
609
        if (J2SEProjectUtil.isMainClass (mainClass, classPath)) {
576
            return 0;
610
            return MainClassStatus.SET_AND_VALID;
577
        }
611
        }
578
        return -2;
612
        return MainClassStatus.SET_BUT_INVALID;
579
    }
613
    }
580
    
614
    
581
    /** Checks if given file object contains the main method.
615
    /** Checks if given file object contains the main method.
Lines 590-606 Link Here
590
        }
624
        }
591
        try {
625
        try {
592
            DataObject classDO = DataObject.find (classFO);
626
            DataObject classDO = DataObject.find (classFO);
593
            Object obj = classDO.getCookie (SourceCookie.class);
627
            SourceCookie cookie = classDO.getCookie(SourceCookie.class);
594
            if (obj == null || !(obj instanceof SourceCookie)) {
628
            if (cookie == null) {
595
                return false;
629
                return false;
596
            }
630
            }
597
            SourceCookie cookie = (SourceCookie) obj;
598
            // check the main class
631
            // check the main class
599
            SourceElement source = cookie.getSource ();
632
            for (ClassElement clazz : cookie.getSource().getClasses()) {
600
            ClassElement[] classes = source.getClasses();
633
                if (clazz.hasMainMethod()) {
601
            boolean hasMain = false;
602
            for (int i = 0; i < classes.length; i++) {
603
                if (classes[i].hasMainMethod()) {
604
                    return true;
634
                    return true;
605
                }
635
                }
606
            }
636
            }
Lines 615-625 Link Here
615
     * Asks user for name of main class
645
     * Asks user for name of main class
616
     * @param mainClass current main class
646
     * @param mainClass current main class
617
     * @param projectName the name of project
647
     * @param projectName the name of project
618
     * @param ep EditableProperties
648
     * @param ep project.properties to possibly edit
619
     * @param messgeType type of dialog -1 when the main class is not set, -2 when the main class in not valid
649
     * @param messgeType type of dialog
620
     * @return true if user selected main class
650
     * @return true if user selected main class
621
     */
651
     */
622
    private boolean showMainClassWarning (String mainClass, String projectName, EditableProperties ep, int messageType) {
652
    private boolean showMainClassWarning(String mainClass, String projectName, EditableProperties ep, MainClassStatus messageType) {
623
        boolean canceled;
653
        boolean canceled;
624
        final JButton okButton = new JButton (NbBundle.getMessage (MainClassWarning.class, "LBL_MainClassWarning_ChooseMainClass_OK")); // NOI18N
654
        final JButton okButton = new JButton (NbBundle.getMessage (MainClassWarning.class, "LBL_MainClassWarning_ChooseMainClass_OK")); // NOI18N
625
        okButton.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage (MainClassWarning.class, "AD_MainClassWarning_ChooseMainClass_OK"));
655
        okButton.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage (MainClassWarning.class, "AD_MainClassWarning_ChooseMainClass_OK"));
Lines 627-638 Link Here
627
        // main class goes wrong => warning
657
        // main class goes wrong => warning
628
        String message;
658
        String message;
629
        switch (messageType) {
659
        switch (messageType) {
630
            case -1:
660
            case UNSET:
631
                message = MessageFormat.format (NbBundle.getMessage(MainClassWarning.class,"LBL_MainClassNotFound"), new Object[] {
661
                message = MessageFormat.format (NbBundle.getMessage(MainClassWarning.class,"LBL_MainClassNotFound"), new Object[] {
632
                    projectName
662
                    projectName
633
                });
663
                });
634
                break;
664
                break;
635
            case -2:
665
            case SET_BUT_INVALID:
636
                message = MessageFormat.format (NbBundle.getMessage(MainClassWarning.class,"LBL_MainClassWrong"), new Object[] {
666
                message = MessageFormat.format (NbBundle.getMessage(MainClassWarning.class,"LBL_MainClassWrong"), new Object[] {
637
                    mainClass,
667
                    mainClass,
638
                    projectName
668
                    projectName
Lines 670-676 Link Here
670
        } else {
700
        } else {
671
            mainClass = panel.getSelectedMainClass ();
701
            mainClass = panel.getSelectedMainClass ();
672
            canceled = false;
702
            canceled = false;
673
            ep.put ("main.class", mainClass == null ? "" : mainClass); // NOI18N
703
            ep.put(J2SEProjectProperties.MAIN_CLASS, mainClass == null ? "" : mainClass);
674
        }
704
        }
675
        dlg.dispose();            
705
        dlg.dispose();            
676
706
(-)/dev/null (+233 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.java.j2seproject;
15
16
import java.beans.PropertyChangeEvent;
17
import java.beans.PropertyChangeListener;
18
import java.beans.PropertyChangeSupport;
19
import java.io.IOException;
20
import java.io.InputStream;
21
import java.text.Collator;
22
import java.util.ArrayList;
23
import java.util.Collection;
24
import java.util.Collections;
25
import java.util.Comparator;
26
import java.util.HashMap;
27
import java.util.List;
28
import java.util.Map;
29
import java.util.Properties;
30
import java.util.Set;
31
import java.util.logging.Level;
32
import java.util.logging.Logger;
33
import org.netbeans.api.project.ProjectManager;
34
import org.netbeans.modules.java.j2seproject.ui.customizer.CustomizerProviderImpl;
35
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SECompositePanelProvider;
36
import org.netbeans.spi.project.ActionProvider;
37
import org.netbeans.spi.project.ProjectConfiguration;
38
import org.netbeans.spi.project.ProjectConfigurationProvider;
39
import org.netbeans.spi.project.support.ant.EditableProperties;
40
import org.openide.filesystems.FileChangeAdapter;
41
import org.openide.filesystems.FileChangeListener;
42
import org.openide.filesystems.FileEvent;
43
import org.openide.filesystems.FileObject;
44
import org.openide.filesystems.FileRenameEvent;
45
import org.openide.filesystems.FileUtil;
46
import org.openide.util.NbBundle;
47
import org.openide.util.Utilities;
48
49
/**
50
 * Manages configurations for a Java SE project.
51
 * @author Jesse Glick
52
 */
53
final class J2SEConfigurationProvider implements ProjectConfigurationProvider<J2SEConfigurationProvider.Config> {
54
55
    /**
56
     * Ant property name for active config.
57
     */
58
    public static final String PROP_CONFIG = "config"; // NOI18N
59
    /**
60
     * Ant property file which specified active config.
61
     */
62
    public static final String CONFIG_PROPS_PATH = "nbproject/private/config.properties"; // NOI18N
63
64
    public static final class Config implements ProjectConfiguration {
65
        /** file basename, or null for default config */
66
        public final String name;
67
        private final String displayName;
68
        public Config(String name, String displayName) {
69
            this.name = name;
70
            this.displayName = displayName;
71
        }
72
        public String getDisplayName() {
73
            return displayName;
74
        }
75
        public int hashCode() {
76
            return name != null ? name.hashCode() : 0;
77
        }
78
        public boolean equals(Object o) {
79
            return (o instanceof Config) && Utilities.compareObjects(name, ((Config) o).name);
80
        }
81
        public String toString() {
82
            return "J2SEConfigurationProvider.Config[" + name + "," + displayName + "]"; // NOI18N
83
        }
84
    }
85
86
    private static final Config DEFAULT = new Config(null,
87
            NbBundle.getMessage(J2SEConfigurationProvider.class, "J2SEConfigurationProvider.default.label"));
88
89
    private final J2SEProject p;
90
    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
91
    private final FileChangeListener fcl = new FileChangeAdapter() {
92
        public void fileFolderCreated(FileEvent fe) {
93
            update();
94
        }
95
        public void fileDataCreated(FileEvent fe) {
96
            update();
97
        }
98
        public void fileDeleted(FileEvent fe) {
99
            update();
100
        }
101
        public void fileRenamed(FileRenameEvent fe) {
102
            update();
103
        }
104
        private void update() {
105
            Set<String> oldConfigs = configs != null ? configs.keySet() : Collections.<String>emptySet();
106
            configDir = p.getProjectDirectory().getFileObject("nbproject/configs"); // NOI18N
107
            if (configDir != null) {
108
                configDir.removeFileChangeListener(fclWeak);
109
                configDir.addFileChangeListener(fclWeak);
110
            }
111
            calculateConfigs();
112
            Set<String> newConfigs = configs.keySet();
113
            if (!oldConfigs.equals(newConfigs)) {
114
                pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATIONS, null, null);
115
                // XXX also fire PROP_ACTIVE_CONFIGURATION?
116
            }
117
        }
118
    };
119
    private final FileChangeListener fclWeak;
120
    private FileObject configDir;
121
    private Map<String,Config> configs;
122
123
    public J2SEConfigurationProvider(J2SEProject p) {
124
        this.p = p;
125
        fclWeak = FileUtil.weakFileChangeListener(fcl, null);
126
        FileObject nbp = p.getProjectDirectory().getFileObject("nbproject"); // NOI18N
127
        if (nbp != null) {
128
            nbp.addFileChangeListener(fclWeak);
129
            configDir = nbp.getFileObject("configs"); // NOI18N
130
            if (configDir != null) {
131
                configDir.addFileChangeListener(fclWeak);
132
            }
133
        }
134
        p.evaluator().addPropertyChangeListener(new PropertyChangeListener() {
135
            public void propertyChange(PropertyChangeEvent evt) {
136
                if (PROP_CONFIG.equals(evt.getPropertyName())) {
137
                    pcs.firePropertyChange(PROP_CONFIGURATION_ACTIVE, null, null);
138
                }
139
            }
140
        });
141
    }
142
143
    private void calculateConfigs() {
144
        configs = new HashMap<String,Config>();
145
        if (configDir != null) {
146
            for (FileObject kid : configDir.getChildren()) {
147
                if (!kid.hasExt("properties")) {
148
                    continue;
149
                }
150
                try {
151
                    InputStream is = kid.getInputStream();
152
                    try {
153
                        Properties p = new Properties();
154
                        p.load(is);
155
                        String name = kid.getName();
156
                        String label = p.getProperty("$label"); // NOI18N
157
                        configs.put(name, new Config(name, label != null ? label : name));
158
                    } finally {
159
                        is.close();
160
                    }
161
                } catch (IOException x) {
162
                    Logger.getLogger(J2SEConfigurationProvider.class.getName()).log(Level.INFO, null, x);
163
                }
164
            }
165
        }
166
    }
167
168
    public Collection<Config> getConfigurations() {
169
        calculateConfigs();
170
        List<Config> l = new ArrayList<Config>();
171
        l.addAll(configs.values());
172
        Collections.sort(l, new Comparator<Config>() {
173
            Collator c = Collator.getInstance();
174
            public int compare(Config c1, Config c2) {
175
                return c.compare(c1.getDisplayName(), c2.getDisplayName());
176
            }
177
        });
178
        l.add(0, DEFAULT);
179
        return l;
180
    }
181
182
    public Config getActiveConfiguration() {
183
        calculateConfigs();
184
        String config = p.evaluator().getProperty(PROP_CONFIG);
185
        if (config != null && configs.containsKey(config)) {
186
            return configs.get(config);
187
        } else {
188
            return DEFAULT;
189
        }
190
    }
191
192
    public void setActiveConfiguration(Config c) throws IllegalArgumentException, IOException {
193
        if (c != DEFAULT && !configs.values().contains(c)) {
194
            throw new IllegalArgumentException();
195
        }
196
        final String n = c.name;
197
        EditableProperties ep = p.getUpdateHelper().getProperties(CONFIG_PROPS_PATH);
198
        if (Utilities.compareObjects(n, ep.getProperty(PROP_CONFIG))) {
199
            return;
200
        }
201
        if (n != null) {
202
            ep.setProperty(PROP_CONFIG, n);
203
        } else {
204
            ep.remove(PROP_CONFIG);
205
        }
206
        p.getUpdateHelper().putProperties(CONFIG_PROPS_PATH, ep);
207
        pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE, null, null);
208
        ProjectManager.getDefault().saveProject(p);
209
        assert p.getProjectDirectory().getFileObject(CONFIG_PROPS_PATH) != null;
210
    }
211
212
    public boolean hasCustomizer() {
213
        return true;
214
    }
215
216
    public void customize() {
217
        p.getLookup().lookup(CustomizerProviderImpl.class).showCustomizer(J2SECompositePanelProvider.RUN);
218
    }
219
220
    public boolean configurationsAffectAction(String command) {
221
        return command.equals(ActionProvider.COMMAND_RUN) ||
222
               command.equals(ActionProvider.COMMAND_DEBUG);
223
    }
224
225
    public void addPropertyChangeListener(PropertyChangeListener lst) {
226
        pcs.addPropertyChangeListener(lst);
227
    }
228
229
    public void removePropertyChangeListener(PropertyChangeListener lst) {
230
        pcs.removePropertyChangeListener(lst);
231
    }
232
233
}
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java:1.62 (-6 / +48 lines)
Lines 19-28 Link Here
19
19
20
package org.netbeans.modules.java.j2seproject;
20
package org.netbeans.modules.java.j2seproject;
21
21
22
import java.beans.PropertyChangeEvent;
22
import java.beans.PropertyChangeListener;
23
import java.beans.PropertyChangeListener;
23
import java.beans.PropertyChangeSupport;
24
import java.beans.PropertyChangeSupport;
24
import java.io.File;
25
import java.io.File;
25
import java.io.IOException;
26
import java.io.IOException;
27
import java.util.Collections;
26
import javax.swing.Icon;
28
import javax.swing.Icon;
27
import javax.swing.ImageIcon;
29
import javax.swing.ImageIcon;
28
import org.netbeans.api.java.classpath.ClassPath;
30
import org.netbeans.api.java.classpath.ClassPath;
Lines 31-38 Link Here
31
import org.netbeans.api.project.Project;
33
import org.netbeans.api.project.Project;
32
import org.netbeans.api.project.ProjectInformation;
34
import org.netbeans.api.project.ProjectInformation;
33
import org.netbeans.api.project.ProjectManager;
35
import org.netbeans.api.project.ProjectManager;
34
import org.netbeans.api.project.SourceGroup;
35
import org.netbeans.api.project.Sources;
36
import org.netbeans.api.project.ant.AntArtifact;
36
import org.netbeans.api.project.ant.AntArtifact;
37
import org.netbeans.modules.java.j2seproject.classpath.ClassPathProviderImpl;
37
import org.netbeans.modules.java.j2seproject.classpath.ClassPathProviderImpl;
38
import org.netbeans.modules.java.j2seproject.classpath.J2SEProjectClassPathExtender;
38
import org.netbeans.modules.java.j2seproject.classpath.J2SEProjectClassPathExtender;
Lines 59-64 Link Here
59
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
59
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
60
import org.netbeans.spi.project.support.ant.ProjectXmlSavedHook;
60
import org.netbeans.spi.project.support.ant.ProjectXmlSavedHook;
61
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
61
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
62
import org.netbeans.spi.project.support.ant.PropertyProvider;
62
import org.netbeans.spi.project.support.ant.PropertyUtils;
63
import org.netbeans.spi.project.support.ant.PropertyUtils;
63
import org.netbeans.spi.project.support.ant.ReferenceHelper;
64
import org.netbeans.spi.project.support.ant.ReferenceHelper;
64
import org.netbeans.spi.project.ui.PrivilegedTemplates;
65
import org.netbeans.spi.project.ui.PrivilegedTemplates;
Lines 66-71 Link Here
66
import org.netbeans.spi.project.ui.RecommendedTemplates;
67
import org.netbeans.spi.project.ui.RecommendedTemplates;
67
import org.openide.ErrorManager;
68
import org.openide.ErrorManager;
68
import org.openide.filesystems.FileObject;
69
import org.openide.filesystems.FileObject;
70
import org.openide.filesystems.FileUtil;
69
import org.openide.util.Lookup;
71
import org.openide.util.Lookup;
70
import org.openide.util.Mutex;
72
import org.openide.util.Mutex;
71
import org.openide.util.Utilities;
73
import org.openide.util.Utilities;
Lines 126-137 Link Here
126
    }
128
    }
127
    
129
    
128
    private PropertyEvaluator createEvaluator() {
130
    private PropertyEvaluator createEvaluator() {
129
        // XXX might need to use a custom evaluator to handle active platform substitutions... TBD
130
        // It is currently safe to not use the UpdateHelper for PropertyEvaluator; UH.getProperties() delegates to APH
131
        // It is currently safe to not use the UpdateHelper for PropertyEvaluator; UH.getProperties() delegates to APH
131
        return helper.getStandardPropertyEvaluator();
132
        // Adapted from APH.getStandardPropertyEvaluator (delegates to ProjectProperties):
133
        PropertyEvaluator baseEval1 = PropertyUtils.sequentialPropertyEvaluator(
134
                helper.getStockPropertyPreprovider(),
135
                helper.getPropertyProvider(J2SEConfigurationProvider.CONFIG_PROPS_PATH));
136
        PropertyEvaluator baseEval2 = PropertyUtils.sequentialPropertyEvaluator(
137
                helper.getStockPropertyPreprovider(),
138
                helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH));
139
        return PropertyUtils.sequentialPropertyEvaluator(
140
                helper.getStockPropertyPreprovider(),
141
                helper.getPropertyProvider(J2SEConfigurationProvider.CONFIG_PROPS_PATH),
142
                new ConfigPropertyProvider(baseEval1, "nbproject/private/configs", helper), // NOI18N
143
                helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH),
144
                PropertyUtils.userPropertiesProvider(baseEval2,
145
                    "user.properties.file", FileUtil.toFile(getProjectDirectory())), // NOI18N
146
                new ConfigPropertyProvider(baseEval1, "nbproject/configs", helper), // NOI18N
147
                helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH));
148
    }
149
    private static final class ConfigPropertyProvider extends PropertyUtils.DelegatingPropertyProvider implements PropertyChangeListener {
150
        private final PropertyEvaluator baseEval;
151
        private final String prefix;
152
        private final AntProjectHelper helper;
153
        public ConfigPropertyProvider(PropertyEvaluator baseEval, String prefix, AntProjectHelper helper) {
154
            super(computeDelegate(baseEval, prefix, helper));
155
            this.baseEval = baseEval;
156
            this.prefix = prefix;
157
            this.helper = helper;
158
            baseEval.addPropertyChangeListener(this);
159
        }
160
        public void propertyChange(PropertyChangeEvent ev) {
161
            if (J2SEConfigurationProvider.PROP_CONFIG.equals(ev.getPropertyName())) {
162
                setDelegate(computeDelegate(baseEval, prefix, helper));
163
            }
164
        }
165
        private static PropertyProvider computeDelegate(PropertyEvaluator baseEval, String prefix, AntProjectHelper helper) {
166
            String config = baseEval.getProperty(J2SEConfigurationProvider.PROP_CONFIG);
167
            if (config != null) {
168
                return helper.getPropertyProvider(prefix + "/" + config + ".properties"); // NOI18N
169
            } else {
170
                return PropertyUtils.fixedPropertyProvider(Collections.<String,String>emptyMap());
171
            }
172
        }
132
    }
173
    }
133
    
174
    
134
    PropertyEvaluator evaluator() {
175
    public PropertyEvaluator evaluator() {
135
        return eval;
176
        return eval;
136
    }
177
    }
137
178
Lines 139-145 Link Here
139
        return this.refHelper;
180
        return this.refHelper;
140
    }
181
    }
141
182
142
    UpdateHelper getUpdateHelper() {
183
    public UpdateHelper getUpdateHelper() {
143
        return this.updateHelper;
184
        return this.updateHelper;
144
    }
185
    }
145
    
186
    
Lines 179-184 Link Here
179
            cpMod,
220
            cpMod,
180
            this, // never cast an externally obtained Project to J2SEProject - use lookup instead
221
            this, // never cast an externally obtained Project to J2SEProject - use lookup instead
181
            new J2SEProjectOperations(this),
222
            new J2SEProjectOperations(this),
223
            new J2SEConfigurationProvider(this),
182
            new J2SEProjectWebServicesSupportProvider()
224
            new J2SEProjectWebServicesSupportProvider()
183
        });
225
        });
184
    }
226
    }
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl:1.75 (+3 lines)
Lines 77-82 Link Here
77
77
78
            <target name="-init-private">
78
            <target name="-init-private">
79
                <xsl:attribute name="depends">-pre-init</xsl:attribute>
79
                <xsl:attribute name="depends">-pre-init</xsl:attribute>
80
                <property file="nbproject/private/config.properties"/>
81
                <property file="nbproject/private/configs/${{config}}.properties"/>
80
                <property file="nbproject/private/private.properties"/>
82
                <property file="nbproject/private/private.properties"/>
81
            </target>
83
            </target>
82
84
Lines 91-96 Link Here
91
93
92
            <target name="-init-project">
94
            <target name="-init-project">
93
                <xsl:attribute name="depends">-pre-init,-init-private,-init-user</xsl:attribute>
95
                <xsl:attribute name="depends">-pre-init,-init-private,-init-user</xsl:attribute>
96
                <property file="nbproject/configs/${{config}}.properties"/>
94
                <property file="nbproject/project.properties"/>
97
                <property file="nbproject/project.properties"/>
95
            </target>
98
            </target>
96
99
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/ActionFilterNode.java:1.10 (-10 / +9 lines)
Lines 80-92 Link Here
80
     * @return ActionFilterNode
80
     * @return ActionFilterNode
81
     */
81
     */
82
    static ActionFilterNode create (Node original, UpdateHelper helper, String classPathId, String entryId) {
82
    static ActionFilterNode create (Node original, UpdateHelper helper, String classPathId, String entryId) {
83
        DataObject dobj = (DataObject) original.getLookup().lookup(DataObject.class);
83
        DataObject dobj = original.getLookup().lookup(DataObject.class);
84
        assert dobj != null;
84
        assert dobj != null;
85
        FileObject root =  dobj.getPrimaryFile();
85
        FileObject root =  dobj.getPrimaryFile();
86
        Lookup lkp = new ProxyLookup (new Lookup[] {original.getLookup(), helper == null ?
86
        Lookup lkp = new ProxyLookup (new Lookup[] {original.getLookup(), helper == null ?
87
            Lookups.singleton (new JavadocProvider(root,root)) :
87
            Lookups.singleton (new JavadocProvider(root,root)) :
88
            Lookups.fixed (new Object[] {new Removable (helper, classPathId, entryId),
88
            Lookups.fixed(new Removable(helper, classPathId, entryId),
89
            new JavadocProvider(root,root)})});
89
                          new JavadocProvider(root,root))});
90
        return new ActionFilterNode (original, helper == null ? MODE_PACKAGE : MODE_ROOT, root, lkp);
90
        return new ActionFilterNode (original, helper == null ? MODE_PACKAGE : MODE_ROOT, root, lkp);
91
    }
91
    }
92
92
Lines 152-158 Link Here
152
        return actionCache;
152
        return actionCache;
153
    }
153
    }
154
154
155
    private static class ActionFilterChildren extends Children {
155
    private static class ActionFilterChildren extends FilterNode.Children {
156
156
157
        private final int mode;
157
        private final int mode;
158
        private final FileObject cpRoot;
158
        private final FileObject cpRoot;
Lines 163-187 Link Here
163
            this.cpRoot = cpRooot;
163
            this.cpRoot = cpRooot;
164
        }
164
        }
165
165
166
        protected Node[] createNodes(Object key) {
166
        protected Node[] createNodes(Node n) {
167
            Node n = (Node) key;
168
            switch (mode) {
167
            switch (mode) {
169
                case MODE_ROOT:
168
                case MODE_ROOT:
170
                case MODE_PACKAGE:
169
                case MODE_PACKAGE:
171
                    DataObject dobj = (DataObject) n.getCookie(org.openide.loaders.DataObject.class);
170
                    DataObject dobj = n.getCookie(DataObject.class);
172
                    if (dobj == null) {
171
                    if (dobj == null) {
173
                        assert false : "DataNode without DataObject in Lookup";  //NOI18N
172
                        assert false : "DataNode without DataObject in Lookup";  //NOI18N
174
                        return new Node[0];
173
                        return new Node[0];
175
                    }
174
                    }
176
                    else if (dobj.getPrimaryFile().isFolder()) {
175
                    else if (dobj.getPrimaryFile().isFolder()) {
177
                        return new Node[] {new ActionFilterNode ((Node)key, MODE_PACKAGE,cpRoot,dobj.getPrimaryFile())};
176
                        return new Node[] {new ActionFilterNode(n, MODE_PACKAGE, cpRoot, dobj.getPrimaryFile())};
178
                    }
177
                    }
179
                    else {
178
                    else {
180
                        return new Node[] {new ActionFilterNode ((Node)key, MODE_FILE,cpRoot,dobj.getPrimaryFile())};
179
                        return new Node[] {new ActionFilterNode(n, MODE_FILE, cpRoot, dobj.getPrimaryFile())};
181
                    }
180
                    }
182
                case MODE_FILE:
181
                case MODE_FILE:
183
                case MODE_FILE_CONTENT:
182
                case MODE_FILE_CONTENT:
184
                    return new Node[] {new ActionFilterNode ((Node)key, MODE_FILE_CONTENT)};
183
                    return new Node[] {new ActionFilterNode(n, MODE_FILE_CONTENT)};
185
                default:
184
                default:
186
                    assert false : "Unknown mode";  //NOI18N
185
                    assert false : "Unknown mode";  //NOI18N
187
                    return new Node[0];
186
                    return new Node[0];
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/J2SELogicalViewProvider.java:1.19 (+1 lines)
Lines 514-519 Link Here
514
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_RUN, bundle.getString("LBL_RunAction_Name"), null)); // NOI18N
514
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_RUN, bundle.getString("LBL_RunAction_Name"), null)); // NOI18N
515
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_DEBUG, bundle.getString("LBL_DebugAction_Name"), null)); // NOI18N
515
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_DEBUG, bundle.getString("LBL_DebugAction_Name"), null)); // NOI18N
516
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_TEST, bundle.getString("LBL_TestAction_Name"), null)); // NOI18N
516
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_TEST, bundle.getString("LBL_TestAction_Name"), null)); // NOI18N
517
            actions.add(CommonProjectActions.setProjectConfigurationAction());
517
            actions.add(null);
518
            actions.add(null);
518
            actions.add(CommonProjectActions.setAsMainProjectAction());
519
            actions.add(CommonProjectActions.setAsMainProjectAction());
519
            actions.add(CommonProjectActions.openSubprojectsAction());
520
            actions.add(CommonProjectActions.openSubprojectsAction());
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties:1.81 (+9 lines)
Lines 485-487 Link Here
485
TXT_ModifiedTitle=Edit Project Properties
485
TXT_ModifiedTitle=Edit Project Properties
486
486
487
MSG_CustomizerLibraries_CompileCpMessage=Compile-time libraries are propagated to all library categories.
487
MSG_CustomizerLibraries_CompileCpMessage=Compile-time libraries are propagated to all library categories.
488
489
CustomizerRun.configLabel=&Configuration:
490
CustomizerRun.configNew=&New...
491
CustomizerRun.configDelete=&Delete
492
CustomizerRun.default=<default>
493
CustomizerRun.input.prompt=Profile Name:
494
CustomizerRun.input.title=Create New Profile
495
# {0} - name of configuration
496
CustomizerRun.input.duplicate=Configuration {0} already exists.
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.form:1.12 (-173 / +274 lines)
Lines 3-8 Link Here
3
<Form version="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
4
  <AuxValues>
5
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
5
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
6
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
6
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
7
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
7
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
8
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
8
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
9
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
Lines 11-201 Link Here
11
12
12
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
13
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
13
  <SubComponents>
14
  <SubComponents>
14
    <Component class="javax.swing.JLabel" name="jLabelMainClass">
15
    <Component class="javax.swing.JSeparator" name="configSep">
15
      <Properties>
16
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
17
          <ComponentRef name="jTextFieldMainClass"/>
18
        </Property>
19
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
20
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_MainClass_JLabel" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
21
        </Property>
22
      </Properties>
23
      <AuxValues>
24
        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
25
      </AuxValues>
26
      <Constraints>
16
      <Constraints>
27
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
17
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
28
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
18
          <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
29
        </Constraint>
19
        </Constraint>
30
      </Constraints>
20
      </Constraints>
31
    </Component>
21
    </Component>
32
    <Component class="javax.swing.JTextField" name="jTextFieldMainClass">
22
    <Container class="javax.swing.JPanel" name="configPanel">
33
      <AccessibilityProperties>
34
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
35
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_jTextFieldMainClass" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString(&quot;{key}&quot;)"/>
36
        </Property>
37
      </AccessibilityProperties>
38
      <Constraints>
23
      <Constraints>
39
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
24
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
40
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="5" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
25
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
41
        </Constraint>
26
        </Constraint>
42
      </Constraints>
27
      </Constraints>
43
    </Component>
28
44
    <Component class="javax.swing.JButton" name="jButtonMainClass">
29
      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
45
      <Properties>
30
      <SubComponents>
46
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
31
        <Component class="javax.swing.JLabel" name="configLabel">
47
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_MainClass_JButton" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
32
          <Properties>
48
        </Property>
33
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
49
      </Properties>
34
              <ComponentRef name="configCombo"/>
50
      <AccessibilityProperties>
35
            </Property>
51
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
36
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
52
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_jButtonMainClass" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString(&quot;{key}&quot;)"/>
37
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="CustomizerRun.configLabel" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
53
        </Property>
38
            </Property>
54
      </AccessibilityProperties>
39
          </Properties>
55
      <AuxValues>
40
          <AuxValues>
56
        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
41
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
57
      </AuxValues>
42
          </AuxValues>
58
      <Constraints>
43
          <Constraints>
59
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
44
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
60
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
45
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="0" insetsBottom="2" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
61
        </Constraint>
46
            </Constraint>
62
      </Constraints>
47
          </Constraints>
63
    </Component>
48
        </Component>
64
    <Component class="javax.swing.JLabel" name="jLabelArgs">
49
        <Component class="javax.swing.JComboBox" name="configCombo">
65
      <Properties>
50
          <Properties>
66
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
51
            <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
67
          <ComponentRef name="jTextFieldArgs"/>
52
              <StringArray count="1">
68
        </Property>
53
                <StringItem index="0" value="&lt;default&gt;"/>
69
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
54
              </StringArray>
70
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_Args_JLabel" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
55
            </Property>
71
        </Property>
56
          </Properties>
72
      </Properties>
57
          <Events>
73
      <AuxValues>
58
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="configComboActionPerformed"/>
74
        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
59
          </Events>
75
      </AuxValues>
60
          <Constraints>
76
      <Constraints>
61
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
77
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
62
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="6" insetsBottom="2" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
78
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="12" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
63
            </Constraint>
79
        </Constraint>
64
          </Constraints>
80
      </Constraints>
65
        </Component>
81
    </Component>
66
        <Component class="javax.swing.JButton" name="configNew">
82
    <Component class="javax.swing.JTextField" name="jTextFieldArgs">
67
          <Properties>
83
      <AccessibilityProperties>
68
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
84
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
69
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="CustomizerRun.configNew" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
85
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_jTextFieldArgs" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString(&quot;{key}&quot;)"/>
70
            </Property>
86
        </Property>
71
          </Properties>
87
      </AccessibilityProperties>
72
          <Events>
88
      <Constraints>
73
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="configNewActionPerformed"/>
89
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
74
          </Events>
90
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="12" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
75
          <AuxValues>
91
        </Constraint>
76
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
92
      </Constraints>
77
          </AuxValues>
93
    </Component>
78
          <Constraints>
94
    <Component class="javax.swing.JLabel" name="jLabelWorkingDirectory">
79
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
95
      <Properties>
80
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="6" insetsBottom="2" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
96
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
81
            </Constraint>
97
          <ComponentRef name="jTextWorkingDirectory"/>
82
          </Constraints>
98
        </Property>
83
        </Component>
99
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
84
        <Component class="javax.swing.JButton" name="configDel">
100
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_Working_Directory" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
85
          <Properties>
101
        </Property>
86
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
102
      </Properties>
87
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="CustomizerRun.configDelete" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
103
      <AuxValues>
88
            </Property>
104
        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
89
          </Properties>
105
      </AuxValues>
90
          <Events>
106
      <Constraints>
91
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="configDelActionPerformed"/>
107
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
92
          </Events>
108
          <GridBagConstraints gridX="-1" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
93
          <AuxValues>
109
        </Constraint>
94
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
110
      </Constraints>
95
          </AuxValues>
111
    </Component>
96
          <Constraints>
112
    <Component class="javax.swing.JTextField" name="jTextWorkingDirectory">
97
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
113
      <AccessibilityProperties>
98
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="6" insetsBottom="2" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
114
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
99
            </Constraint>
115
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizeRun_Run_Working_Directory " replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
100
          </Constraints>
116
        </Property>
101
        </Component>
117
      </AccessibilityProperties>
102
      </SubComponents>
118
      <Constraints>
103
    </Container>
119
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
104
    <Container class="javax.swing.JPanel" name="mainPanel">
120
          <GridBagConstraints gridX="-1" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="5" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
121
        </Constraint>
122
      </Constraints>
123
    </Component>
124
    <Component class="javax.swing.JButton" name="jButtonWorkingDirectoryBrowse">
125
      <Properties>
126
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
127
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_Working_Directory_Browse" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
128
        </Property>
129
      </Properties>
130
      <AccessibilityProperties>
131
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
132
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizeRun_Run_Working_Directory_Browse" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
133
        </Property>
134
      </AccessibilityProperties>
135
      <Events>
136
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonWorkingDirectoryBrowseActionPerformed"/>
137
      </Events>
138
      <AuxValues>
139
        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
140
      </AuxValues>
141
      <Constraints>
142
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
143
          <GridBagConstraints gridX="-1" gridY="2" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
144
        </Constraint>
145
      </Constraints>
146
    </Component>
147
    <Component class="javax.swing.JLabel" name="jLabelVMOptions">
148
      <Properties>
149
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
150
          <ComponentRef name="jTextVMOptions"/>
151
        </Property>
152
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
153
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_VM_Options" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
154
        </Property>
155
      </Properties>
156
      <AuxValues>
157
        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
158
      </AuxValues>
159
      <Constraints>
160
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
161
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
162
        </Constraint>
163
      </Constraints>
164
    </Component>
165
    <Component class="javax.swing.JTextField" name="jTextVMOptions">
166
      <AccessibilityProperties>
167
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
168
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizeRun_Run_VM_Options" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
169
        </Property>
170
      </AccessibilityProperties>
171
      <Constraints>
172
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
173
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
174
        </Constraint>
175
      </Constraints>
176
    </Component>
177
    <Component class="javax.swing.JLabel" name="jLabelVMOptionsExample">
178
      <Properties>
179
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
180
          <ComponentRef name="jTextFieldMainClass"/>
181
        </Property>
182
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
183
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_VM_Options_Example" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
184
        </Property>
185
      </Properties>
186
      <AccessibilityProperties>
187
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
188
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_VM_Options_Example" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
189
        </Property>
190
      </AccessibilityProperties>
191
      <AuxValues>
192
        <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
193
      </AuxValues>
194
      <Constraints>
105
      <Constraints>
195
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
106
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
196
          <GridBagConstraints gridX="1" gridY="4" gridWidth="0" gridHeight="0" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="12" insetsRight="0" anchor="18" weightX="0.0" weightY="1.0"/>
107
          <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
197
        </Constraint>
108
        </Constraint>
198
      </Constraints>
109
      </Constraints>
199
    </Component>
110
111
      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
112
      <SubComponents>
113
        <Component class="javax.swing.JLabel" name="jLabelMainClass">
114
          <Properties>
115
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
116
              <ComponentRef name="jTextFieldMainClass"/>
117
            </Property>
118
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
119
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_MainClass_JLabel" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
120
            </Property>
121
          </Properties>
122
          <AuxValues>
123
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
124
          </AuxValues>
125
          <Constraints>
126
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
127
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
128
            </Constraint>
129
          </Constraints>
130
        </Component>
131
        <Component class="javax.swing.JTextField" name="jTextFieldMainClass">
132
          <AccessibilityProperties>
133
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
134
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_jTextFieldMainClass" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString(&quot;{key}&quot;)"/>
135
            </Property>
136
          </AccessibilityProperties>
137
          <Constraints>
138
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
139
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="5" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
140
            </Constraint>
141
          </Constraints>
142
        </Component>
143
        <Component class="javax.swing.JButton" name="jButtonMainClass">
144
          <Properties>
145
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
146
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_MainClass_JButton" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
147
            </Property>
148
          </Properties>
149
          <AccessibilityProperties>
150
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
151
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_jButtonMainClass" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString(&quot;{key}&quot;)"/>
152
            </Property>
153
          </AccessibilityProperties>
154
          <AuxValues>
155
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
156
          </AuxValues>
157
          <Constraints>
158
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
159
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
160
            </Constraint>
161
          </Constraints>
162
        </Component>
163
        <Component class="javax.swing.JLabel" name="jLabelArgs">
164
          <Properties>
165
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
166
              <ComponentRef name="jTextFieldArgs"/>
167
            </Property>
168
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
169
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_Args_JLabel" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
170
            </Property>
171
          </Properties>
172
          <AuxValues>
173
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
174
          </AuxValues>
175
          <Constraints>
176
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
177
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="12" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
178
            </Constraint>
179
          </Constraints>
180
        </Component>
181
        <Component class="javax.swing.JTextField" name="jTextFieldArgs">
182
          <AccessibilityProperties>
183
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
184
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_jTextFieldArgs" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString(&quot;{key}&quot;)"/>
185
            </Property>
186
          </AccessibilityProperties>
187
          <Constraints>
188
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
189
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="12" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
190
            </Constraint>
191
          </Constraints>
192
        </Component>
193
        <Component class="javax.swing.JLabel" name="jLabelWorkingDirectory">
194
          <Properties>
195
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
196
              <ComponentRef name="jTextWorkingDirectory"/>
197
            </Property>
198
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
199
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_Working_Directory" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
200
            </Property>
201
          </Properties>
202
          <AuxValues>
203
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
204
          </AuxValues>
205
          <Constraints>
206
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
207
              <GridBagConstraints gridX="-1" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
208
            </Constraint>
209
          </Constraints>
210
        </Component>
211
        <Component class="javax.swing.JTextField" name="jTextWorkingDirectory">
212
          <AccessibilityProperties>
213
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
214
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizeRun_Run_Working_Directory " replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
215
            </Property>
216
          </AccessibilityProperties>
217
          <Constraints>
218
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
219
              <GridBagConstraints gridX="-1" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="5" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
220
            </Constraint>
221
          </Constraints>
222
        </Component>
223
        <Component class="javax.swing.JButton" name="jButtonWorkingDirectoryBrowse">
224
          <Properties>
225
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
226
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_Working_Directory_Browse" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
227
            </Property>
228
          </Properties>
229
          <AccessibilityProperties>
230
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
231
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizeRun_Run_Working_Directory_Browse" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
232
            </Property>
233
          </AccessibilityProperties>
234
          <Events>
235
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonWorkingDirectoryBrowseActionPerformed"/>
236
          </Events>
237
          <AuxValues>
238
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
239
          </AuxValues>
240
          <Constraints>
241
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
242
              <GridBagConstraints gridX="-1" gridY="2" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
243
            </Constraint>
244
          </Constraints>
245
        </Component>
246
        <Component class="javax.swing.JLabel" name="jLabelVMOptions">
247
          <Properties>
248
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
249
              <ComponentRef name="jTextVMOptions"/>
250
            </Property>
251
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
252
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_VM_Options" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
253
            </Property>
254
          </Properties>
255
          <AuxValues>
256
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
257
          </AuxValues>
258
          <Constraints>
259
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
260
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="5" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
261
            </Constraint>
262
          </Constraints>
263
        </Component>
264
        <Component class="javax.swing.JTextField" name="jTextVMOptions">
265
          <AccessibilityProperties>
266
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
267
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizeRun_Run_VM_Options" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
268
            </Property>
269
          </AccessibilityProperties>
270
          <Constraints>
271
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
272
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
273
            </Constraint>
274
          </Constraints>
275
        </Component>
276
        <Component class="javax.swing.JLabel" name="jLabelVMOptionsExample">
277
          <Properties>
278
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
279
              <ComponentRef name="jTextFieldMainClass"/>
280
            </Property>
281
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
282
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_VM_Options_Example" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
283
            </Property>
284
          </Properties>
285
          <AccessibilityProperties>
286
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
287
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeRun_Run_VM_Options_Example" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
288
            </Property>
289
          </AccessibilityProperties>
290
          <AuxValues>
291
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
292
          </AuxValues>
293
          <Constraints>
294
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
295
              <GridBagConstraints gridX="1" gridY="4" gridWidth="0" gridHeight="0" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="12" insetsRight="0" anchor="18" weightX="0.0" weightY="1.0"/>
296
            </Constraint>
297
          </Constraints>
298
        </Component>
299
      </SubComponents>
300
    </Container>
200
  </SubComponents>
301
  </SubComponents>
201
</Form>
302
</Form>
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.java:1.21 (-39 / +303 lines)
Lines 19-67 Link Here
19
19
20
package org.netbeans.modules.java.j2seproject.ui.customizer;
20
package org.netbeans.modules.java.j2seproject.ui.customizer;
21
21
22
import java.awt.Component;
22
import java.awt.Dialog;
23
import java.awt.Dialog;
24
import java.awt.Font;
23
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionEvent;
24
import java.awt.event.ActionListener;
26
import java.awt.event.ActionListener;
25
import java.awt.event.MouseEvent;
27
import java.awt.event.MouseEvent;
26
import java.io.File;
28
import java.io.File;
29
import java.text.Collator;
30
import java.util.Comparator;
31
import java.util.HashMap;
32
import java.util.Iterator;
33
import java.util.Map;
34
import java.util.SortedSet;
35
import java.util.TreeSet;
36
import javax.swing.DefaultComboBoxModel;
37
import javax.swing.DefaultListCellRenderer;
27
import javax.swing.JButton;
38
import javax.swing.JButton;
28
import javax.swing.JFileChooser;
39
import javax.swing.JFileChooser;
40
import javax.swing.JLabel;
41
import javax.swing.JList;
29
import javax.swing.JPanel;
42
import javax.swing.JPanel;
30
import javax.swing.JTextField;
43
import javax.swing.JTextField;
31
import javax.swing.event.ChangeEvent;
44
import javax.swing.event.ChangeEvent;
32
import javax.swing.event.ChangeListener;
45
import javax.swing.event.ChangeListener;
33
import javax.swing.event.DocumentEvent;
46
import javax.swing.event.DocumentEvent;
34
import javax.swing.event.DocumentListener;
47
import javax.swing.event.DocumentListener;
35
import org.netbeans.api.project.Project;
36
import org.netbeans.modules.java.j2seproject.J2SEProject;
48
import org.netbeans.modules.java.j2seproject.J2SEProject;
37
import org.netbeans.modules.java.j2seproject.SourceRoots;
49
import org.netbeans.modules.java.j2seproject.SourceRoots;
38
import org.openide.DialogDescriptor;
50
import org.openide.DialogDescriptor;
39
import org.openide.DialogDisplayer;
51
import org.openide.DialogDisplayer;
52
import org.openide.NotifyDescriptor;
40
import org.openide.awt.MouseUtils;
53
import org.openide.awt.MouseUtils;
41
import org.openide.filesystems.FileObject;
42
import org.openide.filesystems.FileUtil;
54
import org.openide.filesystems.FileUtil;
43
import org.openide.util.HelpCtx;
55
import org.openide.util.HelpCtx;
44
import org.openide.util.NbBundle;
56
import org.openide.util.NbBundle;
57
import org.openide.util.Utilities;
45
58
46
47
/**
48
 *
49
 * @author  phrebejk
50
 */
51
public class CustomizerRun extends JPanel implements HelpCtx.Provider {
59
public class CustomizerRun extends JPanel implements HelpCtx.Provider {
52
    
60
    
53
    private J2SEProject project;
61
    private J2SEProject project;
54
    
62
    
63
    private JTextField[] data;
64
    private JLabel[] dataLabels;
65
    private String[] keys;
66
    private Map<String/*|null*/,Map<String,String/*|null*/>/*|null*/> configs;
67
    J2SEProjectProperties uiProperties;
68
    
55
    public CustomizerRun( J2SEProjectProperties uiProperties ) {
69
    public CustomizerRun( J2SEProjectProperties uiProperties ) {
70
        this.uiProperties = uiProperties;
56
        initComponents();
71
        initComponents();
57
72
58
        this.project = uiProperties.getProject();
73
        this.project = uiProperties.getProject();
59
        
74
        
60
        jTextFieldMainClass.setDocument( uiProperties.MAIN_CLASS_MODEL );
75
        configs = uiProperties.RUN_CONFIGS;
61
        jTextFieldArgs.setDocument( uiProperties.APPLICATION_ARGS_MODEL );
76
        
62
        jTextVMOptions.setDocument( uiProperties.RUN_JVM_ARGS_MODEL );
77
        data = new JTextField[] {
63
        jTextWorkingDirectory.setDocument( uiProperties.RUN_WORK_DIR_MODEL );
78
            jTextFieldMainClass,
64
           
79
            jTextFieldArgs,
80
            jTextVMOptions,
81
            jTextWorkingDirectory,
82
        };
83
        dataLabels = new JLabel[] {
84
            jLabelMainClass,
85
            jLabelArgs,
86
            jLabelVMOptions,
87
            jLabelWorkingDirectory,
88
        };
89
        keys = new String[] {
90
            J2SEProjectProperties.MAIN_CLASS,
91
            J2SEProjectProperties.APPLICATION_ARGS,
92
            J2SEProjectProperties.RUN_JVM_ARGS,
93
            J2SEProjectProperties.RUN_WORK_DIR,
94
        };
95
        assert data.length == keys.length;
96
        
97
        configChanged(uiProperties.activeConfig);
98
        
99
        configCombo.setRenderer(new DefaultListCellRenderer() {
100
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
101
                String config = (String) value;
102
                String label;
103
                if (config == null) {
104
                    // uninitialized?
105
                    label = null;
106
                } else if (config.length() > 0) {
107
                    Map<String,String> m = configs.get(config);
108
                    label = m != null ? m.get("$label") : /* temporary? */ null;
109
                    if (label == null) {
110
                        label = config;
111
                    }
112
                } else {
113
                    label = NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.default");
114
                }
115
                return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus);
116
            }
117
        });
118
        
119
        for (int i = 0; i < data.length; i++) {
120
            final JTextField field = data[i];
121
            final String prop = keys[i];
122
            final JLabel label = dataLabels[i];
123
            field.getDocument().addDocumentListener(new DocumentListener() {
124
                Font basefont = label.getFont();
125
                Font boldfont = basefont.deriveFont(Font.BOLD);
126
                {
127
                    updateFont();
128
                }
129
                public void insertUpdate(DocumentEvent e) {
130
                    changed();
131
                }
132
                public void removeUpdate(DocumentEvent e) {
133
                    changed();
134
                }
135
                public void changedUpdate(DocumentEvent e) {}
136
                void changed() {
137
                    String config = (String) configCombo.getSelectedItem();
138
                    if (config.length() == 0) {
139
                        config = null;
140
                    }
141
                    String v = field.getText();
142
                    if (v != null && config != null && v.equals(configs.get(null).get(prop))) {
143
                        // default value, do not store as such
144
                        v = null;
145
                    }
146
                    configs.get(config).put(prop, v);
147
                    updateFont();
148
                }
149
                void updateFont() {
150
                    String v = field.getText();
151
                    String config = (String) configCombo.getSelectedItem();
152
                    if (config.length() == 0) {
153
                        config = null;
154
                    }
155
                    String def = configs.get(null).get(prop);
156
                    label.setFont(config != null && !Utilities.compareObjects(v != null ? v : "", def != null ? def : "") ? boldfont : basefont);
157
                }
158
            });
159
        }
160
65
        jButtonMainClass.addActionListener( new MainClassListener( project.getSourceRoots(), jTextFieldMainClass ) );
161
        jButtonMainClass.addActionListener( new MainClassListener( project.getSourceRoots(), jTextFieldMainClass ) );
66
    }
162
    }
67
        
163
        
Lines 78-83 Link Here
78
    private void initComponents() {
174
    private void initComponents() {
79
        java.awt.GridBagConstraints gridBagConstraints;
175
        java.awt.GridBagConstraints gridBagConstraints;
80
176
177
        configSep = new javax.swing.JSeparator();
178
        configPanel = new javax.swing.JPanel();
179
        configLabel = new javax.swing.JLabel();
180
        configCombo = new javax.swing.JComboBox();
181
        configNew = new javax.swing.JButton();
182
        configDel = new javax.swing.JButton();
183
        mainPanel = new javax.swing.JPanel();
81
        jLabelMainClass = new javax.swing.JLabel();
184
        jLabelMainClass = new javax.swing.JLabel();
82
        jTextFieldMainClass = new javax.swing.JTextField();
185
        jTextFieldMainClass = new javax.swing.JTextField();
83
        jButtonMainClass = new javax.swing.JButton();
186
        jButtonMainClass = new javax.swing.JButton();
Lines 92-141 Link Here
92
195
93
        setLayout(new java.awt.GridBagLayout());
196
        setLayout(new java.awt.GridBagLayout());
94
197
198
        gridBagConstraints = new java.awt.GridBagConstraints();
199
        gridBagConstraints.gridx = 0;
200
        gridBagConstraints.gridy = 1;
201
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
202
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
203
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
204
        add(configSep, gridBagConstraints);
205
206
        configPanel.setLayout(new java.awt.GridBagLayout());
207
208
        configLabel.setLabelFor(configCombo);
209
        org.openide.awt.Mnemonics.setLocalizedText(configLabel, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.configLabel")); // NOI18N
210
        gridBagConstraints = new java.awt.GridBagConstraints();
211
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
212
        gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 0);
213
        configPanel.add(configLabel, gridBagConstraints);
214
215
        configCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<default>" }));
216
        configCombo.addActionListener(new java.awt.event.ActionListener() {
217
            public void actionPerformed(java.awt.event.ActionEvent evt) {
218
                configComboActionPerformed(evt);
219
            }
220
        });
221
222
        gridBagConstraints = new java.awt.GridBagConstraints();
223
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
224
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
225
        gridBagConstraints.weightx = 1.0;
226
        gridBagConstraints.insets = new java.awt.Insets(2, 6, 2, 0);
227
        configPanel.add(configCombo, gridBagConstraints);
228
229
        org.openide.awt.Mnemonics.setLocalizedText(configNew, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.configNew")); // NOI18N
230
        configNew.addActionListener(new java.awt.event.ActionListener() {
231
            public void actionPerformed(java.awt.event.ActionEvent evt) {
232
                configNewActionPerformed(evt);
233
            }
234
        });
235
236
        gridBagConstraints = new java.awt.GridBagConstraints();
237
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
238
        gridBagConstraints.insets = new java.awt.Insets(2, 6, 2, 0);
239
        configPanel.add(configNew, gridBagConstraints);
240
241
        org.openide.awt.Mnemonics.setLocalizedText(configDel, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.configDelete")); // NOI18N
242
        configDel.addActionListener(new java.awt.event.ActionListener() {
243
            public void actionPerformed(java.awt.event.ActionEvent evt) {
244
                configDelActionPerformed(evt);
245
            }
246
        });
247
248
        gridBagConstraints = new java.awt.GridBagConstraints();
249
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
250
        gridBagConstraints.insets = new java.awt.Insets(2, 6, 2, 0);
251
        configPanel.add(configDel, gridBagConstraints);
252
253
        gridBagConstraints = new java.awt.GridBagConstraints();
254
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
255
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
256
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
257
        add(configPanel, gridBagConstraints);
258
259
        mainPanel.setLayout(new java.awt.GridBagLayout());
260
95
        jLabelMainClass.setLabelFor(jTextFieldMainClass);
261
        jLabelMainClass.setLabelFor(jTextFieldMainClass);
96
        org.openide.awt.Mnemonics.setLocalizedText(jLabelMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JLabel"));
262
        org.openide.awt.Mnemonics.setLocalizedText(jLabelMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JLabel")); // NOI18N
97
        gridBagConstraints = new java.awt.GridBagConstraints();
263
        gridBagConstraints = new java.awt.GridBagConstraints();
98
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
264
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
99
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
265
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
100
        add(jLabelMainClass, gridBagConstraints);
266
        mainPanel.add(jLabelMainClass, gridBagConstraints);
101
267
102
        gridBagConstraints = new java.awt.GridBagConstraints();
268
        gridBagConstraints = new java.awt.GridBagConstraints();
103
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
269
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
104
        gridBagConstraints.weightx = 1.0;
270
        gridBagConstraints.weightx = 1.0;
105
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 5, 0);
271
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 5, 0);
106
        add(jTextFieldMainClass, gridBagConstraints);
272
        mainPanel.add(jTextFieldMainClass, gridBagConstraints);
107
        jTextFieldMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldMainClass"));
273
        jTextFieldMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldMainClass")); // NOI18N
108
274
109
        org.openide.awt.Mnemonics.setLocalizedText(jButtonMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JButton"));
275
        org.openide.awt.Mnemonics.setLocalizedText(jButtonMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JButton")); // NOI18N
110
        gridBagConstraints = new java.awt.GridBagConstraints();
276
        gridBagConstraints = new java.awt.GridBagConstraints();
111
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
277
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
112
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
278
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
113
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
279
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
114
        add(jButtonMainClass, gridBagConstraints);
280
        mainPanel.add(jButtonMainClass, gridBagConstraints);
115
        jButtonMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jButtonMainClass"));
281
        jButtonMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jButtonMainClass")); // NOI18N
116
282
117
        jLabelArgs.setLabelFor(jTextFieldArgs);
283
        jLabelArgs.setLabelFor(jTextFieldArgs);
118
        org.openide.awt.Mnemonics.setLocalizedText(jLabelArgs, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Args_JLabel"));
284
        org.openide.awt.Mnemonics.setLocalizedText(jLabelArgs, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Args_JLabel")); // NOI18N
119
        gridBagConstraints = new java.awt.GridBagConstraints();
285
        gridBagConstraints = new java.awt.GridBagConstraints();
120
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
286
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
121
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
287
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
122
        add(jLabelArgs, gridBagConstraints);
288
        mainPanel.add(jLabelArgs, gridBagConstraints);
123
289
124
        gridBagConstraints = new java.awt.GridBagConstraints();
290
        gridBagConstraints = new java.awt.GridBagConstraints();
125
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
291
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
126
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
292
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
127
        gridBagConstraints.weightx = 1.0;
293
        gridBagConstraints.weightx = 1.0;
128
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
294
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
129
        add(jTextFieldArgs, gridBagConstraints);
295
        mainPanel.add(jTextFieldArgs, gridBagConstraints);
130
        jTextFieldArgs.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldArgs"));
296
        jTextFieldArgs.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldArgs")); // NOI18N
131
297
132
        jLabelWorkingDirectory.setLabelFor(jTextWorkingDirectory);
298
        jLabelWorkingDirectory.setLabelFor(jTextWorkingDirectory);
133
        org.openide.awt.Mnemonics.setLocalizedText(jLabelWorkingDirectory, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory"));
299
        org.openide.awt.Mnemonics.setLocalizedText(jLabelWorkingDirectory, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory")); // NOI18N
134
        gridBagConstraints = new java.awt.GridBagConstraints();
300
        gridBagConstraints = new java.awt.GridBagConstraints();
135
        gridBagConstraints.gridy = 2;
301
        gridBagConstraints.gridy = 2;
136
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
302
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
137
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
303
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
138
        add(jLabelWorkingDirectory, gridBagConstraints);
304
        mainPanel.add(jLabelWorkingDirectory, gridBagConstraints);
139
305
140
        gridBagConstraints = new java.awt.GridBagConstraints();
306
        gridBagConstraints = new java.awt.GridBagConstraints();
141
        gridBagConstraints.gridy = 2;
307
        gridBagConstraints.gridy = 2;
Lines 143-152 Link Here
143
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
309
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
144
        gridBagConstraints.weightx = 1.0;
310
        gridBagConstraints.weightx = 1.0;
145
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 5, 0);
311
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 5, 0);
146
        add(jTextWorkingDirectory, gridBagConstraints);
312
        mainPanel.add(jTextWorkingDirectory, gridBagConstraints);
147
        jTextWorkingDirectory.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle").getString("AD_CustomizeRun_Run_Working_Directory "));
313
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle"); // NOI18N
314
        jTextWorkingDirectory.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizeRun_Run_Working_Directory ")); // NOI18N
148
315
149
        org.openide.awt.Mnemonics.setLocalizedText(jButtonWorkingDirectoryBrowse, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory_Browse"));
316
        org.openide.awt.Mnemonics.setLocalizedText(jButtonWorkingDirectoryBrowse, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory_Browse")); // NOI18N
150
        jButtonWorkingDirectoryBrowse.addActionListener(new java.awt.event.ActionListener() {
317
        jButtonWorkingDirectoryBrowse.addActionListener(new java.awt.event.ActionListener() {
151
            public void actionPerformed(java.awt.event.ActionEvent evt) {
318
            public void actionPerformed(java.awt.event.ActionEvent evt) {
152
                jButtonWorkingDirectoryBrowseActionPerformed(evt);
319
                jButtonWorkingDirectoryBrowseActionPerformed(evt);
Lines 158-182 Link Here
158
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
325
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
159
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
326
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
160
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
327
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
161
        add(jButtonWorkingDirectoryBrowse, gridBagConstraints);
328
        mainPanel.add(jButtonWorkingDirectoryBrowse, gridBagConstraints);
162
        jButtonWorkingDirectoryBrowse.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle").getString("AD_CustomizeRun_Run_Working_Directory_Browse"));
329
        jButtonWorkingDirectoryBrowse.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizeRun_Run_Working_Directory_Browse")); // NOI18N
163
330
164
        jLabelVMOptions.setLabelFor(jTextVMOptions);
331
        jLabelVMOptions.setLabelFor(jTextVMOptions);
165
        org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptions, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options"));
332
        org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptions, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options")); // NOI18N
166
        gridBagConstraints = new java.awt.GridBagConstraints();
333
        gridBagConstraints = new java.awt.GridBagConstraints();
167
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
334
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
168
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
335
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
169
        add(jLabelVMOptions, gridBagConstraints);
336
        mainPanel.add(jLabelVMOptions, gridBagConstraints);
170
337
171
        gridBagConstraints = new java.awt.GridBagConstraints();
338
        gridBagConstraints = new java.awt.GridBagConstraints();
172
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
339
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
173
        gridBagConstraints.weightx = 1.0;
340
        gridBagConstraints.weightx = 1.0;
174
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
341
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
175
        add(jTextVMOptions, gridBagConstraints);
342
        mainPanel.add(jTextVMOptions, gridBagConstraints);
176
        jTextVMOptions.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle").getString("AD_CustomizeRun_Run_VM_Options"));
343
        jTextVMOptions.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizeRun_Run_VM_Options")); // NOI18N
177
344
178
        jLabelVMOptionsExample.setLabelFor(jTextFieldMainClass);
345
        jLabelVMOptionsExample.setLabelFor(jTextFieldMainClass);
179
        org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptionsExample, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options_Example"));
346
        org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptionsExample, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options_Example")); // NOI18N
180
        gridBagConstraints = new java.awt.GridBagConstraints();
347
        gridBagConstraints = new java.awt.GridBagConstraints();
181
        gridBagConstraints.gridx = 1;
348
        gridBagConstraints.gridx = 1;
182
        gridBagConstraints.gridy = 4;
349
        gridBagConstraints.gridy = 4;
Lines 185-195 Link Here
185
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
352
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
186
        gridBagConstraints.weighty = 1.0;
353
        gridBagConstraints.weighty = 1.0;
187
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
354
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
188
        add(jLabelVMOptionsExample, gridBagConstraints);
355
        mainPanel.add(jLabelVMOptionsExample, gridBagConstraints);
189
        jLabelVMOptionsExample.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle").getString("LBL_CustomizeRun_Run_VM_Options_Example"));
356
        jLabelVMOptionsExample.getAccessibleContext().setAccessibleDescription(bundle.getString("LBL_CustomizeRun_Run_VM_Options_Example")); // NOI18N
190
357
191
    }
358
        gridBagConstraints = new java.awt.GridBagConstraints();
192
    // </editor-fold>//GEN-END:initComponents
359
        gridBagConstraints.gridx = 0;
360
        gridBagConstraints.gridy = 2;
361
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
362
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
363
        gridBagConstraints.weightx = 1.0;
364
        gridBagConstraints.weighty = 1.0;
365
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
366
        add(mainPanel, gridBagConstraints);
367
368
    }// </editor-fold>//GEN-END:initComponents
369
370
    private void configDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configDelActionPerformed
371
        String config = (String) configCombo.getSelectedItem();
372
        assert config != null;
373
        configs.put(config, null);
374
        configChanged(null);
375
        uiProperties.activeConfig = null;
376
    }//GEN-LAST:event_configDelActionPerformed
377
378
    private void configNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configNewActionPerformed
379
        NotifyDescriptor.InputLine d = new NotifyDescriptor.InputLine(
380
                NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.input.prompt"),
381
                NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.input.title"));
382
        if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.OK_OPTION) {
383
            return;
384
        }
385
        String name = d.getInputText();
386
        String config = name.replaceAll("[^a-zA-Z0-9_.-]", "_"); // NOI18N
387
        if (configs.get(config) != null) {
388
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
389
                    NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.input.duplicate", config),
390
                    NotifyDescriptor.WARNING_MESSAGE));
391
            return;
392
        }
393
        Map<String,String> m = new HashMap<String,String>();
394
        if (!name.equals(config)) {
395
            m.put("$label", name); // NOI18N
396
        }
397
        configs.put(config, m);
398
        configChanged(config);
399
        uiProperties.activeConfig = config;
400
    }//GEN-LAST:event_configNewActionPerformed
401
402
    private void configComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configComboActionPerformed
403
        String config = (String) configCombo.getSelectedItem();
404
        if (config.length() == 0) {
405
            config = null;
406
        }
407
        configChanged(config);
408
        uiProperties.activeConfig = config;
409
    }//GEN-LAST:event_configComboActionPerformed
193
410
194
    private void jButtonWorkingDirectoryBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWorkingDirectoryBrowseActionPerformed
411
    private void jButtonWorkingDirectoryBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWorkingDirectoryBrowseActionPerformed
195
        JFileChooser chooser = new JFileChooser();
412
        JFileChooser chooser = new JFileChooser();
Lines 208-216 Link Here
208
            jTextWorkingDirectory.setText(file.getAbsolutePath());
425
            jTextWorkingDirectory.setText(file.getAbsolutePath());
209
        }
426
        }
210
    }//GEN-LAST:event_jButtonWorkingDirectoryBrowseActionPerformed
427
    }//GEN-LAST:event_jButtonWorkingDirectoryBrowseActionPerformed
428
429
    private void configChanged(String activeConfig) {
430
        DefaultComboBoxModel model = new DefaultComboBoxModel();
431
        model.addElement("");
432
        SortedSet<String> alphaConfigs = new TreeSet<String>(new Comparator<String>() {
433
            Collator coll = Collator.getInstance();
434
            public int compare(String s1, String s2) {
435
                return coll.compare(label(s1), label(s2));
436
            }
437
            private String label(String c) {
438
                Map<String,String> m = configs.get(c);
439
                String label = m.get("$label"); // NOI18N
440
                return label != null ? label : c;
441
            }
442
        });
443
        for (Map.Entry<String,Map<String,String>> entry : configs.entrySet()) {
444
            String config = entry.getKey();
445
            if (config != null && entry.getValue() != null) {
446
                alphaConfigs.add(config);
447
            }
448
        }
449
        for (String c : alphaConfigs) {
450
            model.addElement(c);
451
        }
452
        configCombo.setModel(model);
453
        configCombo.setSelectedItem(activeConfig != null ? activeConfig : "");
454
        Map<String,String> m = configs.get(activeConfig);
455
        Map<String,String> def = configs.get(null);
456
        if (m != null) {
457
            for (int i = 0; i < data.length; i++) {
458
                String v = m.get(keys[i]);
459
                if (v == null) {
460
                    // display default value
461
                    v = def.get(keys[i]);
462
                }
463
                data[i].setText(v);
464
            }
465
        } // else ??
466
        configDel.setEnabled(activeConfig != null);
467
    }
211
    
468
    
212
    
469
    
213
    // Variables declaration - do not modify//GEN-BEGIN:variables
470
    // Variables declaration - do not modify//GEN-BEGIN:variables
471
    private javax.swing.JComboBox configCombo;
472
    private javax.swing.JButton configDel;
473
    private javax.swing.JLabel configLabel;
474
    private javax.swing.JButton configNew;
475
    private javax.swing.JPanel configPanel;
476
    private javax.swing.JSeparator configSep;
214
    private javax.swing.JButton jButtonMainClass;
477
    private javax.swing.JButton jButtonMainClass;
215
    private javax.swing.JButton jButtonWorkingDirectoryBrowse;
478
    private javax.swing.JButton jButtonWorkingDirectoryBrowse;
216
    private javax.swing.JLabel jLabelArgs;
479
    private javax.swing.JLabel jLabelArgs;
Lines 222-227 Link Here
222
    private javax.swing.JTextField jTextFieldMainClass;
485
    private javax.swing.JTextField jTextFieldMainClass;
223
    private javax.swing.JTextField jTextVMOptions;
486
    private javax.swing.JTextField jTextVMOptions;
224
    private javax.swing.JTextField jTextWorkingDirectory;
487
    private javax.swing.JTextField jTextWorkingDirectory;
488
    private javax.swing.JPanel mainPanel;
225
    // End of variables declaration//GEN-END:variables
489
    // End of variables declaration//GEN-END:variables
226
    
490
    
227
    
491
    
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SECompositePanelProvider.java:1.2 (-4 / +1 lines)
Lines 36-44 Link Here
36
 * @author mkleint
36
 * @author mkleint
37
 */
37
 */
38
public class J2SECompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider {
38
public class J2SECompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider {
39
    // Names of categories
40
    private static final String BUILD_CATEGORY = "BuildCategory";
41
    private static final String RUN_CATEGORY = "RunCategory";
42
    
39
    
43
    private static final String SOURCES = "Sources";
40
    private static final String SOURCES = "Sources";
44
    static final String LIBRARIES = "Libraries";
41
    static final String LIBRARIES = "Libraries";
Lines 47-53 Link Here
47
//    private static final String BUILD_TESTS = "BuildTests";
44
//    private static final String BUILD_TESTS = "BuildTests";
48
    private static final String JAR = "Jar";
45
    private static final String JAR = "Jar";
49
    private static final String JAVADOC = "Javadoc";
46
    private static final String JAVADOC = "Javadoc";
50
    private static final String RUN = "Run";    
47
    public static final String RUN = "Run";
51
//    private static final String RUN_TESTS = "RunTests";
48
//    private static final String RUN_TESTS = "RunTests";
52
    
49
    
53
    private static final String WEBSERVICECLIENTS = "WebServiceClients";
50
    private static final String WEBSERVICECLIENTS = "WebServiceClients";
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java:1.58 (-20 / +118 lines)
Lines 23-34 Link Here
23
import java.io.IOException;
23
import java.io.IOException;
24
import java.net.MalformedURLException;
24
import java.net.MalformedURLException;
25
import java.net.URL;
25
import java.net.URL;
26
import java.util.Comparator;
26
import java.util.HashMap;
27
import java.util.HashMap;
27
import java.util.HashSet;
28
import java.util.HashSet;
28
import java.util.Iterator;
29
import java.util.Iterator;
29
import java.util.List;
30
import java.util.Map;
31
import java.util.Map.Entry;
30
import java.util.Properties;
32
import java.util.Properties;
31
import java.util.Set;
33
import java.util.Set;
34
import java.util.TreeMap;
32
import java.util.Vector;
35
import java.util.Vector;
33
import javax.swing.ButtonModel;
36
import javax.swing.ButtonModel;
34
import javax.swing.ComboBoxModel;
37
import javax.swing.ComboBoxModel;
Lines 40-46 Link Here
40
import javax.swing.text.BadLocationException;
43
import javax.swing.text.BadLocationException;
41
import javax.swing.text.Document;
44
import javax.swing.text.Document;
42
import org.netbeans.api.project.ProjectManager;
45
import org.netbeans.api.project.ProjectManager;
43
import org.netbeans.api.queries.CollocationQuery;
44
import org.netbeans.modules.java.j2seproject.J2SEProject;
46
import org.netbeans.modules.java.j2seproject.J2SEProject;
45
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil;
47
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil;
46
import org.netbeans.modules.java.j2seproject.SourceRoots;
48
import org.netbeans.modules.java.j2seproject.SourceRoots;
Lines 50-56 Link Here
50
import org.netbeans.spi.project.support.ant.EditableProperties;
52
import org.netbeans.spi.project.support.ant.EditableProperties;
51
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
53
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
52
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
54
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
53
import org.netbeans.spi.project.support.ant.PropertyUtils;
54
import org.netbeans.spi.project.support.ant.ReferenceHelper;
55
import org.netbeans.spi.project.support.ant.ReferenceHelper;
55
import org.netbeans.spi.project.support.ant.ui.StoreGroup;
56
import org.netbeans.spi.project.support.ant.ui.StoreGroup;
56
import org.openide.DialogDisplayer;
57
import org.openide.DialogDisplayer;
Lines 58-67 Link Here
58
import org.openide.NotifyDescriptor;
59
import org.openide.NotifyDescriptor;
59
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileUtil;
61
import org.openide.filesystems.FileUtil;
61
import org.openide.modules.SpecificationVersion;
62
import org.openide.util.Mutex;
62
import org.openide.util.Mutex;
63
import org.openide.util.MutexException;
63
import org.openide.util.MutexException;
64
import org.openide.util.NbBundle;
64
import org.openide.util.NbBundle;
65
import org.openide.util.Utilities;
65
66
66
/**
67
/**
67
 * @author Petr Hrebejk
68
 * @author Petr Hrebejk
Lines 191-201 Link Here
191
    Document JAVADOC_ADDITIONALPARAM_MODEL;
192
    Document JAVADOC_ADDITIONALPARAM_MODEL;
192
193
193
    // CustomizerRun
194
    // CustomizerRun
194
    Document MAIN_CLASS_MODEL;
195
    Map<String/*|null*/,Map<String,String/*|null*/>/*|null*/> RUN_CONFIGS;
195
    Document APPLICATION_ARGS_MODEL;
196
    String activeConfig;
196
    Document RUN_JVM_ARGS_MODEL;
197
    Document RUN_WORK_DIR_MODEL;
198
199
197
200
    // CustomizerRunTest
198
    // CustomizerRunTest
201
199
Lines 289-298 Link Here
289
        
287
        
290
        JAVADOC_ADDITIONALPARAM_MODEL = projectGroup.createStringDocument( evaluator, JAVADOC_ADDITIONALPARAM );
288
        JAVADOC_ADDITIONALPARAM_MODEL = projectGroup.createStringDocument( evaluator, JAVADOC_ADDITIONALPARAM );
291
        // CustomizerRun
289
        // CustomizerRun
292
        MAIN_CLASS_MODEL = projectGroup.createStringDocument( evaluator, MAIN_CLASS ); 
290
        RUN_CONFIGS = readRunConfigs();
293
        APPLICATION_ARGS_MODEL = privateGroup.createStringDocument( evaluator, APPLICATION_ARGS );
291
        activeConfig = evaluator.getProperty("config");
294
        RUN_JVM_ARGS_MODEL = projectGroup.createStringDocument( evaluator, RUN_JVM_ARGS );
295
        RUN_WORK_DIR_MODEL = privateGroup.createStringDocument( evaluator, RUN_WORK_DIR );
296
                
292
                
297
    }
293
    }
298
    
294
    
Lines 363-368 Link Here
363
        projectGroup.store( projectProperties );        
359
        projectGroup.store( projectProperties );        
364
        privateGroup.store( privateProperties );
360
        privateGroup.store( privateProperties );
365
        
361
        
362
        storeRunConfigs(RUN_CONFIGS, projectProperties, privateProperties);
363
        EditableProperties ep = updateHelper.getProperties("nbproject/private/config.properties");
364
        if (activeConfig == null) {
365
            ep.remove("config");
366
        } else {
367
            ep.setProperty("config", activeConfig);
368
        }
369
        updateHelper.putProperties("nbproject/private/config.properties", ep);
370
        
366
        //Hotfix of the issue #70058
371
        //Hotfix of the issue #70058
367
        //Should use the StoreGroup when the StoreGroup SPI will be extended to allow false default value in ToggleButtonModel
372
        //Should use the StoreGroup when the StoreGroup SPI will be extended to allow false default value in ToggleButtonModel
368
        //Save javac.debug
373
        //Save javac.debug
Lines 387-396 Link Here
387
            projectProperties.remove( NO_DEPENDENCIES ); // Remove the property completely if not set
392
            projectProperties.remove( NO_DEPENDENCIES ); // Remove the property completely if not set
388
        }
393
        }
389
394
390
        if ( getDocumentText( RUN_WORK_DIR_MODEL ).trim().equals( "" ) ) { // NOI18N
391
            privateProperties.remove( RUN_WORK_DIR ); // Remove the property completely if not set
392
        }
393
                
394
        storeAdditionalProperties(projectProperties);
395
        storeAdditionalProperties(projectProperties);
395
        
396
        
396
        // Store the property changes into the project
397
        // Store the property changes into the project
Lines 401-408 Link Here
401
  
402
  
402
    private void storeAdditionalProperties(EditableProperties projectProperties) {
403
    private void storeAdditionalProperties(EditableProperties projectProperties) {
403
        for (Iterator i = additionalProperties.keySet().iterator(); i.hasNext();) {
404
        for (Iterator i = additionalProperties.keySet().iterator(); i.hasNext();) {
404
            Object key = i.next();
405
            String key = (String) i.next();
405
            projectProperties.put(key, additionalProperties.get(key));
406
            projectProperties.put(key, (String) additionalProperties.get(key));
406
        }
407
        }
407
    }
408
    }
408
    
409
    
Lines 464-470 Link Here
464
                changed = true;
465
                changed = true;
465
            }
466
            }
466
        }
467
        }
467
        File projDir = FileUtil.toFile(updateHelper.getAntProjectHelper().getProjectDirectory());
468
        for( Iterator it = added.iterator(); it.hasNext(); ) {
468
        for( Iterator it = added.iterator(); it.hasNext(); ) {
469
            ClassPathSupport.Item item = (ClassPathSupport.Item)it.next();
469
            ClassPathSupport.Item item = (ClassPathSupport.Item)it.next();
470
            if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY && !item.isBroken()) {
470
            if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY && !item.isBroken()) {
Lines 553-558 Link Here
553
        JToggleButton.ToggleButtonModel bm = new JToggleButton.ToggleButtonModel();
553
        JToggleButton.ToggleButtonModel bm = new JToggleButton.ToggleButtonModel();
554
        bm.setSelected(isSelected );
554
        bm.setSelected(isSelected );
555
        return bm;
555
        return bm;
556
    }
557
    
558
    /**
559
     * A mess.
560
     */
561
    Map<String/*|null*/,Map<String,String>> readRunConfigs() {
562
        Map<String,Map<String,String>> m = new TreeMap<String,Map<String,String>>(new Comparator<String>() {
563
            public int compare(String s1, String s2) {
564
                return s1 != null ? (s2 != null ? s1.compareTo(s2) : 1) : (s2 != null ? -1 : 0);
565
            }
566
        });
567
        Map<String,String> def = new TreeMap<String,String>();
568
        for (String prop : new String[] {MAIN_CLASS, APPLICATION_ARGS, RUN_JVM_ARGS, RUN_WORK_DIR}) {
569
            String v = updateHelper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH).getProperty(prop);
570
            if (v == null) {
571
                v = updateHelper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH).getProperty(prop);
572
            }
573
            if (v != null) {
574
                def.put(prop, v);
575
            }
576
        }
577
        m.put(null, def);
578
        FileObject configs = project.getProjectDirectory().getFileObject("nbproject/configs");
579
        if (configs != null) {
580
            for (FileObject kid : configs.getChildren()) {
581
                if (!kid.hasExt("properties")) {
582
                    continue;
583
                }
584
                m.put(kid.getName(), new TreeMap<String,String>(updateHelper.getProperties(FileUtil.getRelativePath(project.getProjectDirectory(), kid))));
585
            }
586
        }
587
        configs = project.getProjectDirectory().getFileObject("nbproject/private/configs");
588
        if (configs != null) {
589
            for (FileObject kid : configs.getChildren()) {
590
                if (!kid.hasExt("properties")) {
591
                    continue;
592
                }
593
                Map<String,String> c = m.get(kid.getName());
594
                if (c == null) {
595
                    continue;
596
                }
597
                c.putAll(new HashMap<String,String>(updateHelper.getProperties(FileUtil.getRelativePath(project.getProjectDirectory(), kid))));
598
            }
599
        }
600
        //System.err.println("readRunConfigs: " + m);
601
        return m;
602
    }
603
604
    /**
605
     * A royal mess.
606
     */
607
    void storeRunConfigs(Map<String/*|null*/,Map<String,String/*|null*/>/*|null*/> configs,
608
            EditableProperties projectProperties, EditableProperties privateProperties) throws IOException {
609
        //System.err.println("storeRunConfigs: " + configs);
610
        Map<String,String> def = configs.get(null);
611
        for (String prop : new String[] {MAIN_CLASS, APPLICATION_ARGS, RUN_JVM_ARGS, RUN_WORK_DIR}) {
612
            String v = def.get(prop);
613
            EditableProperties ep = (prop.equals(APPLICATION_ARGS) || prop.equals(RUN_WORK_DIR)) ?
614
                privateProperties : projectProperties;
615
            if (!Utilities.compareObjects(v, ep.getProperty(prop))) {
616
                if (v != null && v.length() > 0) {
617
                    ep.setProperty(prop, v);
618
                } else {
619
                    ep.remove(prop);
620
                }
621
            }
622
        }
623
        for (Map.Entry<String,Map<String,String>> entry : configs.entrySet()) {
624
            String config = entry.getKey();
625
            if (config == null) {
626
                continue;
627
            }
628
            String sharedPath = "nbproject/configs/" + config + ".properties"; // NOI18N
629
            String privatePath = "nbproject/private/configs/" + config + ".properties"; // NOI18N
630
            Map<String,String> c = entry.getValue();
631
            if (c == null) {
632
                updateHelper.putProperties(sharedPath, null);
633
                updateHelper.putProperties(privatePath, null);
634
                continue;
635
            }
636
            for (Map.Entry<String,String> entry2 : c.entrySet()) {
637
                String prop = entry2.getKey();
638
                String v = entry2.getValue();
639
                String path = (prop.equals(APPLICATION_ARGS) || prop.equals(RUN_WORK_DIR)) ?
640
                    privatePath : sharedPath;
641
                EditableProperties ep = updateHelper.getProperties(path);
642
                if (!Utilities.compareObjects(v, ep.getProperty(prop))) {
643
                    if (v != null && (v.length() > 0 || (def.get(prop) != null && def.get(prop).length() > 0))) {
644
                        ep.setProperty(prop, v);
645
                    } else {
646
                        ep.remove(prop);
647
                    }
648
                    updateHelper.putProperties(path, ep);
649
                }
650
            }
651
            // Make sure the definition file is always created, even if it is empty.
652
            updateHelper.putProperties(sharedPath, updateHelper.getProperties(sharedPath));
653
        }
556
    }
654
    }
557
    
655
    
558
}
656
}
(-)/dev/null (+214 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.java.j2seproject;
15
16
import java.beans.PropertyChangeEvent;
17
import java.beans.PropertyChangeListener;
18
import java.io.IOException;
19
import java.io.OutputStream;
20
import java.util.ArrayList;
21
import java.util.Arrays;
22
import java.util.Collection;
23
import java.util.Collections;
24
import java.util.HashSet;
25
import java.util.List;
26
import java.util.Locale;
27
import java.util.Properties;
28
import java.util.Set;
29
import org.netbeans.api.project.ProjectManager;
30
import org.netbeans.junit.NbTestCase;
31
import org.netbeans.spi.project.ProjectConfiguration;
32
import org.netbeans.spi.project.ProjectConfigurationProvider;
33
import org.netbeans.spi.project.support.ant.EditableProperties;
34
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
35
import org.openide.filesystems.FileObject;
36
import org.openide.filesystems.FileUtil;
37
38
/**
39
 * @author Jesse Glick
40
 */
41
public class J2SEConfigurationProviderTest extends NbTestCase {
42
43
    public J2SEConfigurationProviderTest(String name) {
44
        super(name);
45
    }
46
47
    private FileObject d;
48
    private J2SEProject p;
49
    private ProjectConfigurationProvider pcp;
50
51
    protected void setUp() throws Exception {
52
        super.setUp();
53
        clearWorkDir();
54
        d = J2SEProjectGenerator.createProject(getWorkDir(), "test", null, null).getProjectDirectory();
55
        p = (J2SEProject) ProjectManager.getDefault().findProject(d);
56
        pcp = p.getLookup().lookup(ProjectConfigurationProvider.class);
57
        assertNotNull(pcp);
58
        Locale.setDefault(Locale.US);
59
    }
60
61
    public void testInitialState() throws Exception {
62
        assertEquals(1, pcp.getConfigurations().size());
63
        assertNotNull(pcp.getActiveConfiguration());
64
        assertEquals(pcp.getActiveConfiguration(), pcp.getConfigurations().iterator().next());
65
        assertEquals("<default>", pcp.getActiveConfiguration().getDisplayName());
66
        assertTrue(pcp.hasCustomizer());
67
    }
68
69
    public void testConfigurations() throws Exception {
70
        TestListener l = new TestListener();
71
        pcp.addPropertyChangeListener(l);
72
        Properties p = new Properties();
73
        p.setProperty("$label", "Debug");
74
        write(p, d, "nbproject/configs/debug.properties");
75
        p = new Properties();
76
        p.setProperty("$label", "Release");
77
        write(p, d, "nbproject/configs/release.properties");
78
        write(new Properties(), d, "nbproject/configs/misc.properties");
79
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATIONS), l.events());
80
        List<ProjectConfiguration> configs = new ArrayList<ProjectConfiguration>(getConfigurations(pcp));
81
        assertEquals(4, configs.size());
82
        assertEquals("<default>", configs.get(0).getDisplayName());
83
        assertEquals("Debug", configs.get(1).getDisplayName());
84
        assertEquals("misc", configs.get(2).getDisplayName());
85
        assertEquals("Release", configs.get(3).getDisplayName());
86
        assertEquals(Collections.emptySet(), l.events());
87
        d.getFileObject("nbproject/configs/debug.properties").delete();
88
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATIONS), l.events());
89
        configs = new ArrayList<ProjectConfiguration>(getConfigurations(pcp));
90
        assertEquals(3, configs.size());
91
        d.getFileObject("nbproject/configs").delete();
92
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATIONS), l.events());
93
        configs = new ArrayList<ProjectConfiguration>(getConfigurations(pcp));
94
        assertEquals(1, configs.size());
95
        write(new Properties(), d, "nbproject/configs/misc.properties");
96
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATIONS), l.events());
97
        configs = new ArrayList<ProjectConfiguration>(getConfigurations(pcp));
98
        assertEquals(2, configs.size());
99
    }
100
101
    public void testActiveConfiguration() throws Exception {
102
        write(new Properties(), d, "nbproject/configs/debug.properties");
103
        write(new Properties(), d, "nbproject/configs/release.properties");
104
        TestListener l = new TestListener();
105
        pcp.addPropertyChangeListener(l);
106
        ProjectConfiguration def = pcp.getActiveConfiguration();
107
        assertEquals("<default>", def.getDisplayName());
108
        List<ProjectConfiguration> configs = new ArrayList<ProjectConfiguration>(getConfigurations(pcp));
109
        assertEquals(3, configs.size());
110
        ProjectConfiguration c = configs.get(2);
111
        assertEquals("release", c.getDisplayName());
112
        setActiveConfiguration(pcp, c);
113
        assertEquals(c, pcp.getActiveConfiguration());
114
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE), l.events());
115
        setActiveConfiguration(pcp, c);
116
        assertEquals(c, pcp.getActiveConfiguration());
117
        assertEquals(Collections.emptySet(), l.events());
118
        setActiveConfiguration(pcp, def);
119
        assertEquals(def, pcp.getActiveConfiguration());
120
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE), l.events());
121
        try {
122
            setActiveConfiguration(pcp, null);
123
            fail();
124
        } catch (IllegalArgumentException x) {/*OK*/}
125
        assertEquals(Collections.emptySet(), l.events());
126
        try {
127
            setActiveConfiguration(pcp, new ProjectConfiguration() {
128
                public String getDisplayName() {
129
                    return "bogus";
130
                }
131
            });
132
            fail();
133
        } catch (IllegalArgumentException x) {
134
            // OK, not in original set
135
        } catch (ClassCastException x) {
136
            // also OK, not of correct type
137
        }
138
        assertEquals(Collections.emptySet(), l.events());
139
        EditableProperties ep = new EditableProperties();
140
        ep.setProperty("config", "debug");
141
        p.getUpdateHelper().putProperties("nbproject/private/config.properties", ep);
142
        assertEquals("debug", pcp.getActiveConfiguration().getDisplayName());
143
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE), l.events());
144
    }
145
146
    public void testEvaluator() throws Exception {
147
        PropertyEvaluator eval = p.evaluator();
148
        TestListener l = new TestListener();
149
        eval.addPropertyChangeListener(l);
150
        Properties p = new Properties();
151
        p.setProperty("debug", "true");
152
        write(p, d, "nbproject/configs/debug.properties");
153
        p = new Properties();
154
        p.setProperty("debug", "false");
155
        write(p, d, "nbproject/configs/release.properties");
156
        p = new Properties();
157
        p.setProperty("more", "stuff");
158
        write(p, d, "nbproject/private/configs/release.properties");
159
        List<ProjectConfiguration> configs = new ArrayList<ProjectConfiguration>(getConfigurations(pcp));
160
        assertEquals(3, configs.size());
161
        ProjectConfiguration c = configs.get(1);
162
        assertEquals("debug", c.getDisplayName());
163
        setActiveConfiguration(pcp, c);
164
        assertEquals(new HashSet<String>(Arrays.asList(new String[] {"config", "debug"})), l.events());
165
        assertEquals("debug", eval.getProperty("config"));
166
        assertEquals("true", eval.getProperty("debug"));
167
        assertEquals(null, eval.getProperty("more"));
168
        c = configs.get(2);
169
        assertEquals("release", c.getDisplayName());
170
        setActiveConfiguration(pcp, c);
171
        assertEquals(new HashSet<String>(Arrays.asList(new String[] {"config", "debug", "more"})), l.events());
172
        assertEquals("release", eval.getProperty("config"));
173
        assertEquals("false", eval.getProperty("debug"));
174
        assertEquals("stuff", eval.getProperty("more"));
175
        c = configs.get(0);
176
        assertEquals("<default>", c.getDisplayName());
177
        setActiveConfiguration(pcp, c);
178
        assertEquals(new HashSet<String>(Arrays.asList(new String[] {"config", "debug", "more"})), l.events());
179
        assertEquals(null, eval.getProperty("config"));
180
        assertEquals(null, eval.getProperty("debug"));
181
        assertEquals(null, eval.getProperty("more"));
182
        // XXX test nbproject/private/configs/*.properties
183
    }
184
185
    private void write(Properties p, FileObject d, String path) throws IOException {
186
        FileObject f = FileUtil.createData(d, path);
187
        OutputStream os = f.getOutputStream();
188
        p.store(os, null);
189
        os.close();
190
    }
191
192
    private static final class TestListener implements PropertyChangeListener {
193
        private Set<String> events = new HashSet<String>();
194
        public void propertyChange(PropertyChangeEvent evt) {
195
            events.add(evt.getPropertyName());
196
        }
197
        public Set<String> events() {
198
            Set<String> copy = events;
199
            events = new HashSet<String>();
200
            return copy;
201
        }
202
    }
203
204
    private static Collection<? extends ProjectConfiguration> getConfigurations(ProjectConfigurationProvider<?> pcp) {
205
        return pcp.getConfigurations();
206
    }
207
208
    @SuppressWarnings("unchecked")
209
    private static void setActiveConfiguration(ProjectConfigurationProvider<?> pcp, ProjectConfiguration pc) throws IOException {
210
        ProjectConfigurationProvider _pcp = pcp;
211
        _pcp.setActiveConfiguration(pc);
212
    }
213
214
}
(-)/dev/null (+86 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
20
package org.netbeans.modules.java.j2seproject.ui.customizer;
21
22
import java.io.IOException;
23
import java.util.Map;
24
import java.util.TreeMap;
25
import org.netbeans.api.project.ProjectManager;
26
import org.netbeans.junit.NbTestCase;
27
import org.netbeans.modules.java.j2seproject.J2SEProject;
28
import org.netbeans.modules.java.j2seproject.J2SEProjectGenerator;
29
import org.netbeans.spi.project.support.ant.AntProjectHelper;
30
import org.netbeans.spi.project.support.ant.EditableProperties;
31
import org.openide.filesystems.FileUtil;
32
33
public class J2SEProjectPropertiesTest extends NbTestCase {
34
35
    public J2SEProjectPropertiesTest(String name) {
36
        super(name);
37
    }
38
39
    private J2SEProject p;
40
    private J2SEProjectProperties pp;
41
42
    protected void setUp() throws Exception {
43
        super.setUp();
44
        clearWorkDir();
45
        J2SEProjectGenerator.createProject(getWorkDir(), "test", null, null);
46
        p = (J2SEProject) ProjectManager.getDefault().findProject(FileUtil.toFileObject(getWorkDir()));
47
        pp = new J2SEProjectProperties(p, p.getUpdateHelper(), p.evaluator(), /* XXX unneeded probably */null, null);
48
    }
49
50
    public void testRunConfigs() throws Exception {
51
        Map<String,Map<String,String>> m = pp.readRunConfigs();
52
        assertEquals("{null={run.jvmargs=}}", m.toString());
53
        // Define a new config and set some arguments.
54
        Map<String,String> c = new TreeMap<String,String>();
55
        c.put("application.args", "foo");
56
        m.put("foo", c);
57
        storeRunConfigs(m);
58
        m = pp.readRunConfigs();
59
        assertEquals("{null={run.jvmargs=}, foo={application.args=foo}}", m.toString());
60
        // Define args in default config.
61
        m.get(null).put("application.args", "bland");
62
        storeRunConfigs(m);
63
        m = pp.readRunConfigs();
64
        assertEquals("{null={application.args=bland, run.jvmargs=}, foo={application.args=foo}}", m.toString());
65
        // Reset to default in foo config.
66
        m.get("foo").put("application.args", null);
67
        storeRunConfigs(m);
68
        m = pp.readRunConfigs();
69
        assertEquals("{null={application.args=bland, run.jvmargs=}, foo={}}", m.toString());
70
        // Override as blank in foo config.
71
        m.get("foo").put("application.args", "");
72
        storeRunConfigs(m);
73
        m = pp.readRunConfigs();
74
        assertEquals("{null={application.args=bland, run.jvmargs=}, foo={application.args=}}", m.toString());
75
    }
76
77
    private void storeRunConfigs(Map<String,Map<String,String>> m) throws IOException {
78
        EditableProperties prj = p.getUpdateHelper().getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
79
        EditableProperties prv = p.getUpdateHelper().getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
80
        pp.storeRunConfigs(m, prj, prv);
81
        p.getUpdateHelper().putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, prj);
82
        p.getUpdateHelper().putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, prv);
83
        ProjectManager.getDefault().saveProject(p);
84
    }
85
86
}
(-)projects/projectapi/apichanges.xml:1.8 (+19 lines)
Lines 81-86 Link Here
81
    <!-- ACTUAL CHANGES BEGIN HERE: -->
81
    <!-- ACTUAL CHANGES BEGIN HERE: -->
82
82
83
    <changes>
83
    <changes>
84
        
85
        <change id="ProjectConfigurationProvider">
86
            <api name="general"/>
87
            <summary>Added support for project configurations</summary>
88
            <version major="1" minor="11"/>
89
            <date day="22" month="6" year="2006"/>
90
            <author login="jglick"/>
91
            <compatibility addition="yes"/>
92
            <description>
93
                <p>
94
                    Added an interface <code>ProjectConfigurationProvider</code>
95
                    which can be included in a project's lookup to support
96
                    switchable configurations / profiles.
97
                </p>
98
            </description>
99
            <class package="org.netbeans.spi.project" name="ProjectConfiguration"/>
100
            <class package="org.netbeans.spi.project" name="ProjectConfigurationProvider"/>
101
            <issue number="49652"/>
102
        </change>
84
103
85
        <change id="copy-move-support">
104
        <change id="copy-move-support">
86
            <api name="general"/>
105
            <api name="general"/>
(-)projects/projectapi/manifest.mf:1.13 (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.projectapi/1
2
OpenIDE-Module: org.netbeans.modules.projectapi/1
3
OpenIDE-Module-Specification-Version: 1.10
3
OpenIDE-Module-Specification-Version: 1.11
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
5
5
(-)projects/projectapi/src/org/netbeans/api/project/Project.java:1.14 (+1 lines)
Lines 76-81 Link Here
76
     * </ol>
76
     * </ol>
77
     * <p>You might also have e.g.:</p>
77
     * <p>You might also have e.g.:</p>
78
     * <ol>
78
     * <ol>
79
     * <li>{@link org.netbeans.spi.project.ProjectConfigurationProvider}</li>
79
     * <li>{@link org.netbeans.spi.queries.FileBuiltQueryImplementation}</li>
80
     * <li>{@link org.netbeans.spi.queries.FileBuiltQueryImplementation}</li>
80
     * <li>{@link org.netbeans.spi.queries.SharabilityQueryImplementation}</li>
81
     * <li>{@link org.netbeans.spi.queries.SharabilityQueryImplementation}</li>
81
     * <li><a href="@org-netbeans-modules-projectuiapi@/org/netbeans/spi/project/ui/ProjectOpenedHook.html"><code>ProjectOpenedHook</code></a></li>
82
     * <li><a href="@org-netbeans-modules-projectuiapi@/org/netbeans/spi/project/ui/ProjectOpenedHook.html"><code>ProjectOpenedHook</code></a></li>
(-)/dev/null (+33 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.spi.project;
15
16
/**
17
 * Represents one user-selectable configuration of a particular project.
18
 * For example, it might represent a choice of main class and arguments.
19
 * Besides the implementor, only the project UI infrastructure is expected to use this class.
20
 *
21
 * @author Adam Sotona, Jesse Glick
22
 * @since org.netbeans.modules.projectapi/1 1.11
23
 * @see ProjectConfigurationProvider
24
 */
25
public interface ProjectConfiguration {
26
27
    /**
28
     * Provides a display name by which this configuration may be identified in the GUI.
29
     * @return a human-visible display name
30
     */
31
    String getDisplayName();
32
33
}
(-)/dev/null (+123 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.spi.project;
15
16
import java.beans.PropertyChangeListener;
17
import java.io.IOException;
18
import java.util.Collection;
19
20
/**
21
 * Provider of configurations for a project.
22
 * Should be registered in a project's {@link org.netbeans.api.project.Project#getLookup lookup}.
23
 * Besides the implementor, only the project UI infrastructure is expected to use this class.
24
 * @param C the type of configuration created by this provider
25
 *
26
 * @author Adam Sotona, Jesse Glick
27
 * @since org.netbeans.modules.projectapi/1 1.11
28
 * @see <a href="http://projects.netbeans.org/nonav/buildsys/configurations.html">Project Configurations design document</a>
29
 */
30
public interface ProjectConfigurationProvider<C extends ProjectConfiguration> {
31
32
    /**
33
     * Property name for the active configuration.
34
     * Use it when firing a change in the active configuration.
35
     */
36
    String PROP_CONFIGURATION_ACTIVE = "activeConfiguration"; // NOI18N
37
38
    /**
39
     * Property name of the set of configurations.
40
     * Use it when firing a change in the set of configurations.
41
     */
42
    String PROP_CONFIGURATIONS = "configurations"; // NOI18N
43
44
    /**
45
     * Gets a list of configurations.
46
     * Permitted to return different instances from one invocation to the next
47
     * but it is advisable for the "same" instances to compare as equal.
48
     * <p>Should be called within {@link org.netbeans.api.project.ProjectManager#mutex read access}.
49
     * @return all available configurations for this project
50
     */
51
    Collection<C> getConfigurations();
52
53
    /**
54
     * Gets the currently active configuration.
55
     * <p>Should be called within {@link org.netbeans.api.project.ProjectManager#mutex read access}.
56
     * @return the active configuration for this project (should be a member of {@link #getConfigurations}, or null only if that is empty)
57
     */
58
    C getActiveConfiguration();
59
60
    /**
61
     * Sets the active configuration.
62
     * Should fire a change in {@link #PROP_CONFIGURATION_ACTIVE}.
63
     * It should be true afterwards that <code>configuration.equals(getActiveConfiguration())</code>
64
     * though it might not be true that <code>configuration == getActiveConfiguration()</code>.
65
     * <p class="nonnormative">
66
     * If possible, the choice of configuration should be persisted for the next IDE session.
67
     * If applicable, the persisted choice should be kept in per-user settings, not shared or versioned.
68
     * </p>
69
     * <p>Should be called within {@link org.netbeans.api.project.ProjectManager#mutex write access}.
70
     * @param configuration new active configuration
71
     * @throws IllegalArgumentException if the requested configuration is not a member of {@link #getConfigurations}
72
     * @throws IOException if storing the configuration change failed
73
     */
74
    void setActiveConfiguration(C configuration) throws IllegalArgumentException, IOException;
75
76
    /**
77
     * Checks if this project can provide a GUI customizer for its configurations.
78
     * @return true if {@link #customize} may be called
79
     */
80
    boolean hasCustomizer();
81
82
    /**
83
     * Customize this project's configurations.
84
     * Only permitted if {@link #hasCustomizer} is true.
85
     * May, for example, open the project properties dialog.
86
     */
87
    void customize();
88
89
    /**
90
     * Indicates if a project action is affected by the choice of configuration.
91
     * If so, a GUI for this action is permitted to show a list of configurations and
92
     * let the user select a configuration to apply to one action invocation only.
93
     * Such a GUI can avoid the need to first select an active configuration and
94
     * then run the action as two steps.
95
     * This is done by including a {@link ProjectConfiguration} in the context passed
96
     * to {@link ActionProvider#invokeAction}.
97
     * A project is free to return <code>false</code> even if the configuration
98
     * <em>might</em> affect the behavior of the action, if it simply does not
99
     * wish for such a GUI to be shown.
100
     * <p class="nonnormative">
101
     * The likely values of <code>command</code> are those actions
102
     * normally shown in the IDE's tool bar with main project bindings:
103
     * {@link ActionProvider#BUILD}, {@link ActionProvider#REBUILD},
104
     * {@link ActionProvider#RUN}, and {@link ActionProvider#DEBUG}.
105
     * </p>
106
     * @param command one of {@link ActionProvider#getSupportedActions}
107
     * @return true if the named command refers to an action affected by configurations
108
     */
109
    boolean configurationsAffectAction(String command);
110
111
    /**
112
     * Adds a listener to check for changes in {@link #PROP_CONFIGURATION_ACTIVE} or {@link #PROP_CONFIGURATIONS}.
113
     * @param lst a listener to add
114
     */
115
    void addPropertyChangeListener(PropertyChangeListener lst);
116
117
    /**
118
     * Removes a listener.
119
     * @param lst a listener to remove
120
     */
121
    void removePropertyChangeListener(PropertyChangeListener lst);
122
123
}
(-)projects/projectui/arch.xml:1.16 (+7 lines)
Lines 685-690 Link Here
685
      by enhanced UI logger that track what the user is going.
685
      by enhanced UI logger that track what the user is going.
686
      </api>
686
      </api>
687
    </li>
687
    </li>
688
    <li>
689
        <api name="org.netbeans.modules.project.ui.actions.MainProjectAction.SHOW_CONFIG_DROPDOWN" category="devel" group="property" type="export" url="http://www.netbeans.org/nonav/issues/show_bug.cgi?id=49652">
690
            If set to <code>true</code>, main project action toolbar buttons will
691
            under appropriate circumstances display pull-down buttons permitting
692
            the action to be run against a particular nonactive configuration directly.
693
        </api>
694
    </li>
688
  </ul>
695
  </ul>
689
 </answer>
696
 </answer>
690
697
(-)projects/projectui/src/org/netbeans/modules/project/ui/actions/Actions.java:1.30 (+5 lines)
Lines 39-44 Link Here
39
import org.openide.util.Utilities;
39
import org.openide.util.Utilities;
40
import org.openide.util.actions.CallableSystemAction;
40
import org.openide.util.actions.CallableSystemAction;
41
import org.openide.util.actions.NodeAction;
41
import org.openide.util.actions.NodeAction;
42
import org.openide.util.actions.SystemAction;
42
43
43
/** Factory for all kinds of actions used in projectui and
44
/** Factory for all kinds of actions used in projectui and
44
 *projectuiapi.
45
 *projectuiapi.
Lines 353-358 Link Here
353
            new ImageIcon( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/debugProject.gif" ) ) ); //NOI18N
354
            new ImageIcon( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/debugProject.gif" ) ) ); //NOI18N
354
        a.putValue("iconBase","org/netbeans/modules/project/ui/resources/debugProject.gif"); //NOI18N
355
        a.putValue("iconBase","org/netbeans/modules/project/ui/resources/debugProject.gif"); //NOI18N
355
        return a;
356
        return a;
357
    }
358
359
    public Action setProjectConfigurationAction() {
360
        return SystemAction.get(ActiveConfigAction.class);
356
    }
361
    }
357
362
358
}
363
}
(-)/dev/null (+335 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.project.ui.actions;
15
16
import java.awt.Component;
17
import java.awt.Dimension;
18
import java.awt.GridBagConstraints;
19
import java.awt.GridBagLayout;
20
import java.awt.Insets;
21
import java.awt.event.ActionEvent;
22
import java.awt.event.ActionListener;
23
import java.beans.PropertyChangeEvent;
24
import java.beans.PropertyChangeListener;
25
import java.io.IOException;
26
import java.util.Collection;
27
import java.util.logging.Level;
28
import java.util.logging.Logger;
29
import javax.swing.AbstractAction;
30
import javax.swing.Action;
31
import javax.swing.ComboBoxModel;
32
import javax.swing.DefaultComboBoxModel;
33
import javax.swing.DefaultListCellRenderer;
34
import javax.swing.JComboBox;
35
import javax.swing.JComponent;
36
import javax.swing.JList;
37
import javax.swing.JMenu;
38
import javax.swing.JMenuItem;
39
import javax.swing.JPanel;
40
import javax.swing.JRadioButtonMenuItem;
41
import org.netbeans.api.project.Project;
42
import org.netbeans.api.project.ProjectManager;
43
import org.netbeans.modules.project.ui.OpenProjectList;
44
import org.netbeans.spi.project.ProjectConfiguration;
45
import org.netbeans.spi.project.ProjectConfigurationProvider;
46
import org.openide.awt.DynamicMenuContent;
47
import org.openide.awt.Mnemonics;
48
import org.openide.util.ContextAwareAction;
49
import org.openide.util.HelpCtx;
50
import org.openide.util.Lookup;
51
import org.openide.util.Mutex;
52
import org.openide.util.MutexException;
53
import org.openide.util.NbBundle;
54
import org.openide.util.actions.CallableSystemAction;
55
import org.openide.util.actions.Presenter;
56
57
/**
58
 * Action permitting selection of a configuration for the main project.
59
 * @author Greg Crawley, Adam Sotona, Jesse Glick
60
 */
61
public class ActiveConfigAction extends CallableSystemAction implements ContextAwareAction {
62
63
    private static final DefaultComboBoxModel EMPTY_MODEL = new DefaultComboBoxModel();
64
    private static final Object CUSTOMIZE_ENTRY = new Object();
65
66
    private final PropertyChangeListener lst;
67
    private final JComboBox configListCombo;
68
    private boolean listeningToCombo = true;
69
70
    private Project currentProject;
71
    private ProjectConfigurationProvider pcp;
72
73
    public ActiveConfigAction() {
74
        super();
75
        putValue("noIconInMenu", Boolean.TRUE); // NOI18N
76
        configListCombo = new JComboBox();
77
        configListCombo.setRenderer(new ConfigCellRenderer());
78
        configListCombo.setToolTipText(org.openide.awt.Actions.cutAmpersand(getName()));
79
        configurationsListChanged(null);
80
        configListCombo.addActionListener(new ActionListener() {
81
            public void actionPerformed(ActionEvent e) {
82
                if (!listeningToCombo) {
83
                    return;
84
                }
85
                Object o = configListCombo.getSelectedItem();
86
                if (o == CUSTOMIZE_ENTRY) {
87
                    activeConfigurationChanged(pcp != null ? getActiveConfiguration(pcp) : null);
88
                    pcp.customize();
89
                } else if (o != null) {
90
                    activeConfigurationSelected((ProjectConfiguration) o);
91
                }
92
            }
93
        });
94
        lst = new PropertyChangeListener() {
95
            public void propertyChange(PropertyChangeEvent evt) {
96
                if (ProjectConfigurationProvider.PROP_CONFIGURATIONS.equals(evt.getPropertyName())) {
97
                    configurationsListChanged(getConfigurations(pcp));
98
                } else if (ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE.equals(evt.getPropertyName())) {
99
                    activeConfigurationChanged(getActiveConfiguration(pcp));
100
                }
101
            }
102
        };
103
        activeProjectChanged(OpenProjectList.getDefault().getMainProject());
104
        OpenProjectList.getDefault().addPropertyChangeListener(new PropertyChangeListener() {
105
            public void propertyChange(PropertyChangeEvent evt) {
106
                if (OpenProjectList.PROPERTY_MAIN_PROJECT.equals(evt.getPropertyName())) {
107
                    activeProjectChanged(OpenProjectList.getDefault().getMainProject());
108
                }
109
            }
110
        });
111
    }
112
113
114
    private synchronized void configurationsListChanged(Collection<? extends ProjectConfiguration> configs) {
115
        if (configs == null) {
116
            configListCombo.setModel(EMPTY_MODEL);
117
            configListCombo.setEnabled(false);
118
        } else {
119
            DefaultComboBoxModel model = new DefaultComboBoxModel(configs.toArray());
120
            if (pcp.hasCustomizer()) {
121
                model.addElement(CUSTOMIZE_ENTRY);
122
            }
123
            configListCombo.setModel(model);
124
            configListCombo.setEnabled(true);
125
        }
126
        if (pcp != null) {
127
            activeConfigurationChanged(getActiveConfiguration(pcp));
128
        }
129
    }
130
131
    private synchronized void activeConfigurationChanged(ProjectConfiguration config) {
132
        listeningToCombo = false;
133
        try {
134
            configListCombo.setSelectedIndex(-1);
135
            if (config != null) {
136
                ComboBoxModel m = configListCombo.getModel();
137
                for (int i = 0; i < m.getSize(); i++) {
138
                    if (config.equals(m.getElementAt(i))) {
139
                        configListCombo.setSelectedIndex(i);
140
                        break;
141
                    }
142
                }
143
            }
144
        } finally {
145
            listeningToCombo = true;
146
        }
147
    }
148
149
    private synchronized void activeConfigurationSelected(ProjectConfiguration cfg) {
150
        if (pcp != null && cfg != null && !cfg.equals(getActiveConfiguration(pcp))) {
151
            try {
152
                setActiveConfiguration(pcp, cfg);
153
            } catch (IOException x) {
154
                Logger.getLogger(ActiveConfigAction.class.getName()).log(Level.WARNING, null, x);
155
            }
156
        }
157
    }
158
159
    public HelpCtx getHelpCtx() {
160
        return new HelpCtx(ActiveConfigAction.class);
161
    }
162
163
    public String getName() {
164
        return NbBundle.getMessage(ActiveConfigAction.class, "ActiveConfigAction.label");
165
    }
166
167
    public void performAction() {
168
        assert false;
169
    }
170
171
    public Component getToolbarPresenter() {
172
        // Do not return combo box directly; looks bad.
173
        JPanel panel = new JPanel(new GridBagLayout());
174
        panel.setOpaque(false); // don't interrupt JToolBar background
175
        panel.setMaximumSize(new Dimension(150, 80));
176
        panel.setMinimumSize(new Dimension(150, 0));
177
        panel.setPreferredSize(new Dimension(150, 23));
178
        // XXX top inset of 2 looks better w/ small toolbar, but 1 seems to look better for large toolbar (the default):
179
        panel.add(configListCombo, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(1, 6, 1, 5), 0, 0));
180
        return panel;
181
    }
182
183
    class ConfigMenu extends JMenu implements DynamicMenuContent {
184
185
        private final Lookup context;
186
187
        public ConfigMenu(Lookup context) {
188
            this.context = context;
189
            if (context != null) {
190
                Mnemonics.setLocalizedText(this, NbBundle.getMessage(ActiveConfigAction.class, "ActiveConfigAction.context.label"));
191
            } else {
192
                Mnemonics.setLocalizedText(this, ActiveConfigAction.this.getName());
193
            }
194
        }
195
196
        public JComponent[] getMenuPresenters() {
197
            removeAll();
198
            final ProjectConfigurationProvider<?> pcp;
199
            if (context != null) {
200
                Collection<? extends Project> projects = context.lookupAll(Project.class);
201
                if (projects.size() == 1) {
202
                    pcp = projects.iterator().next().getLookup().lookup(ProjectConfigurationProvider.class);
203
                } else {
204
                    // No selection, or multiselection.
205
                    pcp = null;
206
                }
207
            } else {
208
                pcp = ActiveConfigAction.this.pcp; // global menu item; take from main project
209
            }
210
            if (pcp != null) {
211
                boolean something = false;
212
                ProjectConfiguration activeConfig = getActiveConfiguration(pcp);
213
                for (final ProjectConfiguration config : getConfigurations(pcp)) {
214
                    JRadioButtonMenuItem jmi = new JRadioButtonMenuItem(config.getDisplayName(), config.equals(activeConfig));
215
                    jmi.addActionListener(new ActionListener() {
216
                        public void actionPerformed(ActionEvent e) {
217
                            activeConfigurationSelected(config);
218
                        }
219
                    });
220
                    add(jmi);
221
                    something = true;
222
                }
223
                if (pcp.hasCustomizer()) {
224
                    if (something) {
225
                        addSeparator();
226
                    }
227
                    something = true;
228
                    JMenuItem customize = new JMenuItem();
229
                    Mnemonics.setLocalizedText(customize, NbBundle.getMessage(ActiveConfigAction.class, "ActiveConfigAction.customize"));
230
                    customize.addActionListener(new ActionListener() {
231
                        public void actionPerformed(ActionEvent e) {
232
                            pcp.customize();
233
                        }
234
                    });
235
                    add(customize);
236
                }
237
                setEnabled(something);
238
            } else {
239
                // No configurations supported for this project.
240
                setEnabled(false);
241
                // to hide entirely just use: return new JComponent[0];
242
            }
243
            return new JComponent[] {this};
244
        }
245
246
        public JComponent[] synchMenuPresenters(JComponent[] items) {
247
            // Always rebuild submenu.
248
            // For performance, could try to reuse it if context == null and nothing has changed.
249
            return getMenuPresenters();
250
        }
251
252
    }
253
254
    public JMenuItem getMenuPresenter() {
255
        return new ConfigMenu(null);
256
    }
257
258
    private static class ConfigCellRenderer extends DefaultListCellRenderer {
259
260
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
261
            if (value instanceof ProjectConfiguration) {
262
                return super.getListCellRendererComponent(list, ((ProjectConfiguration) value).getDisplayName(), index, isSelected, cellHasFocus);
263
            } else if (value == CUSTOMIZE_ENTRY) {
264
                String label = org.openide.awt.Actions.cutAmpersand(NbBundle.getMessage(ActiveConfigAction.class, "ActiveConfigAction.customize"));
265
                return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus);
266
            } else {
267
                assert value == null;
268
                return super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus);
269
            }
270
        }
271
    }
272
273
    private synchronized void activeProjectChanged(Project p) {
274
        if (currentProject != p) {
275
            if (pcp != null) {
276
                pcp.removePropertyChangeListener(lst);
277
            }
278
            currentProject = p;
279
            if (currentProject != null) {
280
                pcp = currentProject.getLookup().lookup(ProjectConfigurationProvider.class);
281
                if (pcp != null) {
282
                    pcp.addPropertyChangeListener(lst);
283
                }
284
            } else {
285
                pcp = null;
286
            }
287
            configurationsListChanged(pcp == null ? null : getConfigurations(pcp));
288
289
        }
290
    }
291
292
    public Action createContextAwareInstance(final Lookup actionContext) {
293
        class A extends AbstractAction implements Presenter.Popup {
294
            public void actionPerformed(ActionEvent e) {
295
                assert false;
296
            }
297
            public JMenuItem getPopupPresenter() {
298
                return new ConfigMenu(actionContext);
299
            }
300
        }
301
        return new A();
302
    }
303
304
    private static Collection<? extends ProjectConfiguration> getConfigurations(final ProjectConfigurationProvider<?> pcp) {
305
        return ProjectManager.mutex().readAccess(new Mutex.Action<Collection<? extends ProjectConfiguration>>() {
306
            public Collection<? extends ProjectConfiguration> run() {
307
                return pcp.getConfigurations();
308
            }
309
        });
310
    }
311
312
    private static ProjectConfiguration getActiveConfiguration(final ProjectConfigurationProvider<?> pcp) {
313
        return ProjectManager.mutex().readAccess(new Mutex.Action<ProjectConfiguration>() {
314
            public ProjectConfiguration run() {
315
                return pcp.getActiveConfiguration();
316
            }
317
        });
318
    }
319
320
    @SuppressWarnings("unchecked")
321
    private static void setActiveConfiguration(ProjectConfigurationProvider<?> pcp, final ProjectConfiguration pc) throws IOException {
322
        final ProjectConfigurationProvider _pcp = pcp;
323
        try {
324
            ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
325
                public Void run() throws IOException {
326
                    _pcp.setActiveConfiguration(pc);
327
                    return null;
328
                }
329
            });
330
        } catch (MutexException e) {
331
            throw (IOException) e.getException();
332
        }
333
    }
334
335
}
(-)projects/projectui/src/org/netbeans/modules/project/ui/actions/Bundle.properties:1.31 (-5 / +3 lines)
Lines 86-94 Link Here
86
# {0} - project count
86
# {0} - project count
87
OpenProjectFolderAction.LBL_menu_multiple=Open {0} Projects
87
OpenProjectFolderAction.LBL_menu_multiple=Open {0} Projects
88
88
89
ActiveConfigAction.label=Set Main Project Con&figuration
90
ActiveConfigAction.context.label=Set Configuration
91
ActiveConfigAction.customize=&Customize...
89
92
90
91
#
92
# UI Logging
93
# UI Logging
93
#
94
#
94
# UI logging of button press
95
# UI logging of button press
Lines 98-103 Link Here
98
# {3} class of the action
99
# {3} class of the action
99
# {4} display name of the action
100
# {4} display name of the action
100
UI_ACTION_BUTTON_PRESS=Invoking {4} implemented as {3} thru {1}
101
UI_ACTION_BUTTON_PRESS=Invoking {4} implemented as {3} thru {1}
101
102
103
(-)projects/projectui/src/org/netbeans/modules/project/ui/actions/MainProjectAction.java:1.15 (-4 / +132 lines)
Lines 19-54 Link Here
19
19
20
package org.netbeans.modules.project.ui.actions;
20
package org.netbeans.modules.project.ui.actions;
21
21
22
import java.awt.BorderLayout;
23
import java.awt.Color;
24
import java.awt.Component;
22
import java.awt.Dialog;
25
import java.awt.Dialog;
26
import java.awt.Dimension;
27
import java.awt.Graphics;
28
import java.awt.Graphics2D;
29
import java.awt.RenderingHints;
23
import java.awt.Toolkit;
30
import java.awt.Toolkit;
24
import java.awt.event.ActionEvent;
31
import java.awt.event.ActionEvent;
32
import java.awt.event.ActionListener;
25
import java.awt.event.MouseEvent;
33
import java.awt.event.MouseEvent;
26
import java.beans.PropertyChangeEvent;
34
import java.beans.PropertyChangeEvent;
27
import java.beans.PropertyChangeListener;
35
import java.beans.PropertyChangeListener;
28
import java.util.Arrays;
36
import java.util.Arrays;
29
import javax.swing.Icon;
37
import javax.swing.Icon;
30
import javax.swing.JButton;
38
import javax.swing.JButton;
39
import javax.swing.JMenuItem;
40
import javax.swing.JPanel;
41
import javax.swing.JPopupMenu;
42
import javax.swing.border.EmptyBorder;
31
import javax.swing.event.ChangeEvent;
43
import javax.swing.event.ChangeEvent;
32
import javax.swing.event.ChangeListener;
44
import javax.swing.event.ChangeListener;
33
import org.netbeans.api.project.Project;
45
import org.netbeans.api.project.Project;
34
import org.netbeans.modules.project.ui.NoMainProjectWarning;
46
import org.netbeans.modules.project.ui.NoMainProjectWarning;
35
import org.netbeans.modules.project.ui.OpenProjectList;
47
import org.netbeans.modules.project.ui.OpenProjectList;
36
import org.netbeans.spi.project.ActionProvider;
48
import org.netbeans.spi.project.ActionProvider;
49
import org.netbeans.spi.project.ProjectConfiguration;
50
import org.netbeans.spi.project.ProjectConfigurationProvider;
37
import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
51
import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
38
import org.openide.DialogDescriptor;
52
import org.openide.DialogDescriptor;
39
import org.openide.DialogDisplayer;
53
import org.openide.DialogDisplayer;
40
import org.openide.awt.Actions;
54
import org.openide.awt.Actions;
41
import org.openide.awt.MouseUtils;
55
import org.openide.awt.MouseUtils;
56
import org.openide.awt.ToolbarPool;
42
import org.openide.util.Lookup;
57
import org.openide.util.Lookup;
43
import org.openide.util.Mutex;
58
import org.openide.util.Mutex;
44
import org.openide.util.NbBundle;
59
import org.openide.util.NbBundle;
45
import org.openide.util.WeakListeners;
60
import org.openide.util.WeakListeners;
61
import org.openide.util.actions.Presenter;
62
import org.openide.util.lookup.Lookups;
46
63
47
/** Invokes command on the main project.
64
/** Invokes command on the main project.
48
 * 
65
 * 
49
 * @author Pet Hrebejk 
66
 * @author Pet Hrebejk 
50
 */
67
 */
51
public class MainProjectAction extends BasicAction implements PropertyChangeListener {
68
public class MainProjectAction extends BasicAction implements Presenter.Toolbar, PropertyChangeListener {
52
    
69
    
53
    private String command;
70
    private String command;
54
    private ProjectActionPerformer performer;
71
    private ProjectActionPerformer performer;
Lines 144-150 Link Here
144
        }        
161
        }        
145
    }
162
    }
146
    
163
    
147
   private boolean showNoMainProjectWarning (Project[] projects, String action) {
164
    private boolean showNoMainProjectWarning(Project[] projects, String action) {
148
        boolean canceled;
165
        boolean canceled;
149
        final JButton okButton = new JButton (NbBundle.getMessage (NoMainProjectWarning.class, "LBL_NoMainClassWarning_ChooseMainProject_OK")); // NOI18N        
166
        final JButton okButton = new JButton (NbBundle.getMessage (NoMainProjectWarning.class, "LBL_NoMainClassWarning_ChooseMainProject_OK")); // NOI18N        
150
        okButton.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage (NoMainProjectWarning.class, "AD_NoMainClassWarning_ChooseMainProject_OK"));
167
        okButton.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage (NoMainProjectWarning.class, "AD_NoMainClassWarning_ChooseMainProject_OK"));
Lines 191-195 Link Here
191
208
192
        return canceled;
209
        return canceled;
193
    }
210
    }
194
        
211
195
}
212
    private static final boolean SHOW_CONFIG_DROPDOWN = Boolean.getBoolean("org.netbeans.modules.project.ui.actions.MainProjectAction.SHOW_CONFIG_DROPDOWN"); // NOI18N
213
214
    /**
215
     * @see org.openide.awt.Toolbar.Folder#createInstance
216
     * @see org.openide.awt.Actions.ButtonBridge#updateButtonIcon
217
     */
218
    private static final String PREFERRED_ICON_SIZE = "PreferredIconSize"; // NOI18N
219
    public Component getToolbarPresenter() {
220
        final JButton main = new JButton();
221
        Actions.connect(main, this);
222
        if (!SHOW_CONFIG_DROPDOWN) {
223
            return main;
224
        }
225
        final JPanel panel = new JPanel(new BorderLayout());
226
        panel.addPropertyChangeListener(PREFERRED_ICON_SIZE, new PropertyChangeListener() {
227
            public void propertyChange(PropertyChangeEvent evt) {
228
                main.putClientProperty(PREFERRED_ICON_SIZE, panel.getClientProperty(PREFERRED_ICON_SIZE));
229
            }
230
        });
231
        panel.setBorder(new EmptyBorder(0, 0, 0, 0));
232
        panel.add(main, BorderLayout.CENTER);
233
        JButton configs = new ConfigButton(main.getPreferredSize().height);
234
        panel.add(configs, BorderLayout.LINE_END);
235
        return panel;
236
    }
237
238
    private static final class ArrowIcon implements Icon {
239
        private static final int SIZE = 6;
240
        private static final int HEIGHT = ToolbarPool.getDefault().getPreferredIconSize();
241
        private static final int PAD = 3;
242
        public int getIconWidth() {
243
            return SIZE * 2 - 1 + PAD * 2;
244
        }
245
        public int getIconHeight() {
246
            return Math.max(SIZE + PAD * 2, HEIGHT);
247
        }
248
        public void paintIcon(Component c, Graphics g, int x, int y) {
249
            g.setColor(Color.BLACK);
250
            int offx = PAD;
251
            int offy = (g.getClipBounds().height - SIZE) / 2;
252
            ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
253
            g.fillPolygon(new int[] {offx, offx + SIZE * 2 - 2, offx + SIZE - 1}, new int[] {offy, offy, offy + SIZE - 1}, 3);
254
        }
255
    }
256
257
    private final class ConfigButton extends JButton implements PropertyChangeListener, ActionListener {
258
259
        private final PropertyChangeListener pcl = WeakListeners.propertyChange(this, null);
260
        private JPopupMenu menu;
261
262
        public ConfigButton(int height) {
263
            super(new ArrowIcon());
264
            OpenProjectList.getDefault().addPropertyChangeListener(pcl);
265
            propertyChange(null);
266
            addActionListener(this);
267
            setPreferredSize(new Dimension(getIcon().getIconWidth(), height));
268
            setFocusPainted(false);
269
        }
270
271
        public void propertyChange(PropertyChangeEvent evt) {
272
            String prop = evt != null ? evt.getPropertyName() : null;
273
            if (prop == null || prop.equals(OpenProjectList.PROPERTY_MAIN_PROJECT) || prop.equals(ProjectConfigurationProvider.PROP_CONFIGURATIONS)) {
274
                Mutex.EVENT.readAccess(new Runnable() {
275
                    public void run() {
276
                        boolean v = false;
277
                        Project p = OpenProjectList.getDefault().getMainProject();
278
                        if (p != null) {
279
                            ActionProvider ap = p.getLookup().lookup(ActionProvider.class);
280
                            if (ap != null) {
281
                                if (Arrays.asList(ap.getSupportedActions()).contains(command)) {
282
                                    ProjectConfigurationProvider<?> pcp = p.getLookup().lookup(ProjectConfigurationProvider.class);
283
                                    if (pcp != null) {
284
                                        pcp.removePropertyChangeListener(pcl);
285
                                        pcp.addPropertyChangeListener(pcl);
286
                                        v = pcp.configurationsAffectAction(command) &&
287
                                                // Only show it if there are multiple configs to run.
288
                                                pcp.getConfigurations().size() > 1;
289
                                    }
290
                                }
291
                            }
292
                        }
293
                        setVisible(v);
294
                    }
295
                });
296
            }
297
        }
298
299
        public void actionPerformed(ActionEvent e) {
300
            if (menu != null) {
301
                menu.setVisible(false);
302
                menu = null;
303
                return;
304
            }
305
            final Project p = OpenProjectList.getDefault().getMainProject();
306
            ProjectConfigurationProvider<?> pcp = p.getLookup().lookup(ProjectConfigurationProvider.class);
307
            menu = new JPopupMenu();
308
            for (final ProjectConfiguration config : pcp.getConfigurations()) {
309
                JMenuItem item = new JMenuItem(config.getDisplayName());
310
                menu.add(item);
311
                item.addActionListener(new ActionListener() {
312
                    public void actionPerformed(ActionEvent e) {
313
                        menu = null;
314
                        p.getLookup().lookup(ActionProvider.class).invokeAction(command, Lookups.singleton(config));
315
                    }
316
                });
317
            }
318
            menu.show(this, 0, getSize().height);
319
        }
320
321
    }
322
323
}
(-)projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml:1.69 (-2 / +16 lines)
Lines 131-136 Link Here
131
                <attr name="instanceCreate" methodvalue="org.netbeans.modules.project.ui.ProjectTabAction.projectsPhysical"/>
131
                <attr name="instanceCreate" methodvalue="org.netbeans.modules.project.ui.ProjectTabAction.projectsPhysical"/>
132
                <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/project/ui/resources/filesTab.gif"/> 
132
                <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/project/ui/resources/filesTab.gif"/> 
133
            </file>
133
            </file>
134
            
135
            <file name="org-netbeans-modules-project-ui-actions-ActiveConfigAction.instance"/>
134
                                                            
136
                                                            
135
        </folder>
137
        </folder>
136
        
138
        
Lines 349-356 Link Here
349
            </file>
351
            </file>
350
            
352
            
351
353
352
            <attr name="org-netbeans-modules-project-ui-RebuildMainProject.shadow/SeparatorMainProject.instance" boolvalue="true"/>                       
354
            <attr name="org-netbeans-modules-project-ui-RebuildMainProject.shadow/org-netbeans-modules-project-ui-actions-ActiveConfigAction.shadow" boolvalue="true"/>
353
            
355
356
            <file name="org-netbeans-modules-project-ui-actions-ActiveConfigAction.shadow">
357
                <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-actions-ActiveConfigAction.instance"/>
358
            </file>
359
360
            <attr name="org-netbeans-modules-project-ui-actions-ActiveConfigAction.shadow/SeparatorMainProject.instance" boolvalue="true"/>
361
354
            <file name="SeparatorMainProject.instance">
362
            <file name="SeparatorMainProject.instance">
355
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
363
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
356
            </file>
364
            </file>
Lines 489-494 Link Here
489
        <folder name="Build">            
497
        <folder name="Build">            
490
            <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.project.ui.Bundle" />
498
            <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.project.ui.Bundle" />
491
            
499
            
500
            <file name="org-netbeans-modules-project-ui-actions-ActiveConfigAction.shadow">
501
                <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-actions-ActiveConfigAction.instance"/>
502
            </file>
503
504
            <attr name="org-netbeans-modules-project-ui-actions-ActiveConfigAction.shadow/org-netbeans-modules-project-ui-BuildMainProject.shadow" boolvalue="true"/>
505
492
            <file name="org-netbeans-modules-project-ui-BuildMainProject.shadow">
506
            <file name="org-netbeans-modules-project-ui-BuildMainProject.shadow">
493
                <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-BuildMainProject.instance"/>
507
                <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-BuildMainProject.instance"/>
494
            </file>
508
            </file>
(-)projects/projectuiapi/apichanges.xml:1.22 (+18 lines)
Lines 81-86 Link Here
81
    <!-- ACTUAL CHANGES BEGIN HERE: -->
81
    <!-- ACTUAL CHANGES BEGIN HERE: -->
82
82
83
    <changes>
83
    <changes>
84
        
85
        <change id="CommonProjectActions.setProjectConfigurationAction">
86
            <api name="general"/>
87
            <summary>Added <code>CommonProjectActions.setProjectConfigurationAction</code></summary>
88
            <version major="1" minor="16"/>
89
            <date day="22" month="6" year="2006"/>
90
            <author login="jglick"/>
91
            <compatibility addition="yes"/>
92
            <description>
93
                <p>
94
                    Added method <code>CommonProjectActions.setProjectConfigurationAction()</code>
95
                    to permit projects supporting configurations to include a context menu
96
                    item in their logical view to change the active configuration.
97
                </p>
98
            </description>
99
            <class package="org.netbeans.spi.project.ui.support" name="CommonProjectActions"/>
100
            <issue number="49652"/>
101
        </change>
84
102
85
        <change id="CompositeCategoryProvider">
103
        <change id="CompositeCategoryProvider">
86
            <api name="general"/>
104
            <api name="general"/>
(-)projects/projectuiapi/src/org/netbeans/modules/project/uiapi/ActionsFactory.java:1.10 (+2 lines)
Lines 66-70 Link Here
66
    public Action fileCommandAction( String command, String name, Icon icon );
66
    public Action fileCommandAction( String command, String name, Icon icon );
67
67
68
    public Action renameProjectAction();
68
    public Action renameProjectAction();
69
70
    Action setProjectConfigurationAction();
69
    
71
    
70
}
72
}
(-)projects/projectuiapi/src/org/netbeans/spi/project/ui/support/CommonProjectActions.java:1.14 (+16 lines)
Lines 178-181 Link Here
178
        return Utilities.getActionsFactory().newProjectAction();
178
        return Utilities.getActionsFactory().newProjectAction();
179
    }    
179
    }    
180
180
181
    /**
182
     * Creates an action that sets the configuration of the selected project.
183
     * It should be displayed with an action context containing
184
     * exactly one {@link org.netbeans.api.project.Project}.
185
     * The action itself should not be invoked but you may use its popup presenter.
186
     * <p class="nonnormative">
187
     * You might include this in the context menu of a logical view.
188
     * </p>
189
     * @return an action
190
     * @since org.netbeans.modules.projectuiapi/1 1.16
191
     * @see org.netbeans.spi.project.ProjectConfigurationProvider
192
     */
193
    public static Action setProjectConfigurationAction() {
194
        return Utilities.getActionsFactory().setProjectConfigurationAction();
195
    }
196
181
}
197
}

Return to bug 49652