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

(-)ant/project/apichanges.xml (+19 lines)
Lines 76-81 Link Here
76
76
77
    <changes>
77
    <changes>
78
        
78
        
79
        <change id="PropertyUtils.userPropertiesProvider.DelegatingPropertyProvider">
80
            <api name="general"/>
81
            <summary>Added utilities for constructing richer property evaluators</summary>
82
            <version major="1" minor="14"/>
83
            <date day="22" month="6" year="2006"/>
84
            <author login="jglick"/>
85
            <compatibility addition="yes"/>
86
            <description>
87
                <p>
88
                    Added a new method and nested class to <code>PropertyUtils</code> to
89
                    make it easier to write a customizer version of
90
                    <code>AntProjectHelper.getStandardPropertyEvaluator()</code>,
91
                    among other things.
92
                </p>
93
            </description>
94
            <class package="org.netbeans.spi.project.support.ant" name="PropertyUtils"/>
95
            <issue number="49636"/>
96
        </change>
97
        
79
        <change id="ReferenceHelper.addReference-change-of-target-property-file">
98
        <change id="ReferenceHelper.addReference-change-of-target-property-file">
80
            <api name="general"/>
99
            <api name="general"/>
81
            <summary>Semantic changes in the ReferenceHelper behavior</summary>
100
            <summary>Semantic changes in the ReferenceHelper behavior</summary>
(-)ant/project/manifest.mf (-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 (-32 / +2 lines)
Lines 13-20 Link Here
13
13
14
package org.netbeans.spi.project.support.ant;
14
package org.netbeans.spi.project.support.ant;
15
15
16
import java.beans.PropertyChangeEvent;
17
import java.beans.PropertyChangeListener;
18
import java.io.ByteArrayOutputStream;
16
import java.io.ByteArrayOutputStream;
19
import java.io.File;
17
import java.io.File;
20
import java.io.IOException;
18
import java.io.IOException;
Lines 397-403 Link Here
397
                    getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH),
395
                    getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH),
398
                }
396
                }
399
            );
397
            );
400
            PropertyProvider globalProperties = new UserPropertiesProvider(findUserPropertiesFile);
398
            PropertyProvider globalProperties = PropertyUtils.userPropertiesProvider(findUserPropertiesFile,
399
                    "user.properties.file", FileUtil.toFile(helper.getProjectDirectory())); // NOI18N
401
            standardPropertyEvaluator = PropertyUtils.sequentialPropertyEvaluator(
400
            standardPropertyEvaluator = PropertyUtils.sequentialPropertyEvaluator(
402
                getStockPropertyPreprovider(),
401
                getStockPropertyPreprovider(),
403
                new PropertyProvider[] {
402
                new PropertyProvider[] {
Lines 408-442 Link Here
408
            );
407
            );
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 (-9 / +68 lines)
Lines 706-711 Link Here
706
    public static PropertyEvaluator sequentialPropertyEvaluator(PropertyProvider preprovider, PropertyProvider[] providers) {
706
    public static PropertyEvaluator sequentialPropertyEvaluator(PropertyProvider preprovider, PropertyProvider[] providers) {
707
        return new SequentialPropertyEvaluator(preprovider, providers);
707
        return new SequentialPropertyEvaluator(preprovider, providers);
708
    }
708
    }
709
710
    /**
711
     * Creates a property provider similar to {@link #globalPropertyProvider}
712
     * but which can use a different global properties file.
713
     * If a specific file is pointed to, that is loaded; otherwise behaves like {@link #globalPropertyProvider}.
714
     * Permits behavior similar to command-line Ant where not erroneous, but using the IDE's
715
     * default global properties for projects which do not yet have this property registered.
716
     * @param findUserPropertiesFile an evaluator in which to look up <code>propertyName</code>
717
     * @param propertyName a property pointing to the global properties file (typically <code>"user.properties.file"</code>)
718
     * @param basedir a base directory to use when resolving the path to the global properties file, if relative
719
     * @return a provider of global properties
720
     * @since org.netbeans.modules.project.ant/1 1.14
721
     */
722
    public static PropertyProvider userPropertiesProvider(PropertyEvaluator findUserPropertiesFile, String propertyName, File basedir) {
723
        return new UserPropertiesProvider(findUserPropertiesFile, propertyName, basedir);
724
    }
725
    private static final class UserPropertiesProvider extends DelegatingPropertyProvider implements PropertyChangeListener {
726
        private final PropertyEvaluator findUserPropertiesFile;
727
        private final String propertyName;
728
        private final File basedir;
729
        public UserPropertiesProvider(PropertyEvaluator findUserPropertiesFile, String propertyName, File basedir) {
730
            super(computeDelegate(findUserPropertiesFile, propertyName, basedir));
731
            this.findUserPropertiesFile = findUserPropertiesFile;
732
            this.propertyName = propertyName;
733
            this.basedir = basedir;
734
            findUserPropertiesFile.addPropertyChangeListener(this);
735
        }
736
        public void propertyChange(PropertyChangeEvent ev) {
737
            if (propertyName.equals(ev.getPropertyName())) {
738
                setDelegate(computeDelegate(findUserPropertiesFile, propertyName, basedir));
739
            }
740
        }
741
        private static PropertyProvider computeDelegate(PropertyEvaluator findUserPropertiesFile, String propertyName, File basedir) {
742
            String userPropertiesFile = findUserPropertiesFile.getProperty(propertyName);
743
            if (userPropertiesFile != null) {
744
                // Have some defined global properties file, so read it and listen to changes in it.
745
                File f = PropertyUtils.resolveFile(basedir, userPropertiesFile);
746
                if (f.equals(PropertyUtils.userBuildProperties())) {
747
                    // Just to share the cache.
748
                    return PropertyUtils.globalPropertyProvider();
749
                } else {
750
                    return PropertyUtils.propertiesFilePropertyProvider(f);
751
                }
752
            } else {
753
                // Use the in-IDE default.
754
                return PropertyUtils.globalPropertyProvider();
755
            }
756
        }
757
    }
709
    
758
    
710
    private static final class SequentialPropertyEvaluator implements PropertyEvaluator, ChangeListener {
759
    private static final class SequentialPropertyEvaluator implements PropertyEvaluator, ChangeListener {
711
        
760
        
Lines 858-876 Link Here
858
    
907
    
859
    /**
908
    /**
860
     * Property provider that delegates to another source.
909
     * Property provider that delegates to another source.
861
     * Currently attaches a strong listener to it.
910
     * Useful, for example, when conditionally loading from one or another properties file.
911
     * @since org.netbeans.modules.project.ant/1 1.14
862
     */
912
     */
863
    static abstract class DelegatingPropertyProvider implements PropertyProvider, ChangeListener {
913
    public static abstract class DelegatingPropertyProvider implements PropertyProvider {
864
        
914
        
865
        private PropertyProvider delegate;
915
        private PropertyProvider delegate;
866
        private final List/*<ChangeListener>*/ listeners = new ArrayList();
916
        private final List/*<ChangeListener>*/ listeners = new ArrayList();
917
        private final ChangeListener strongListener = new ChangeListener() {
918
            public void stateChanged(ChangeEvent e) {
919
                //System.err.println("DPP: change from current provider " + delegate);
920
                fireChange();
921
            }
922
        };
867
        private ChangeListener weakListener = null; // #50572: must be weak
923
        private ChangeListener weakListener = null; // #50572: must be weak
868
        
924
925
        /**
926
         * Initialize the proxy.
927
         * @param delegate the initial delegate to use
928
         */
869
        protected DelegatingPropertyProvider(PropertyProvider delegate) {
929
        protected DelegatingPropertyProvider(PropertyProvider delegate) {
870
            assert delegate != null;
930
            assert delegate != null;
871
            setDelegate(delegate);
931
            setDelegate(delegate);
872
        }
932
        }
873
        
933
        
934
        /**
935
         * Change the current delegate (firing changes as well).
936
         * @param delegate the initial delegate to use
937
         */
874
        protected final void setDelegate(PropertyProvider delegate) {
938
        protected final void setDelegate(PropertyProvider delegate) {
875
            if (delegate == this.delegate) {
939
            if (delegate == this.delegate) {
876
                return;
940
                return;
Lines 880-886 Link Here
880
                this.delegate.removeChangeListener(weakListener);
944
                this.delegate.removeChangeListener(weakListener);
881
            }
945
            }
882
            this.delegate = delegate;
946
            this.delegate = delegate;
883
            weakListener = WeakListeners.change(this, delegate);
947
            weakListener = WeakListeners.change(strongListener, delegate);
884
            delegate.addChangeListener(weakListener);
948
            delegate.addChangeListener(weakListener);
885
            fireChange();
949
            fireChange();
886
        }
950
        }
Lines 912-922 Link Here
912
            }
976
            }
913
        }
977
        }
914
978
915
        public final void stateChanged(ChangeEvent changeEvent) {
916
            //System.err.println("DPP: change from current provider " + delegate);
917
            fireChange();
918
        }
919
        
920
    }
979
    }
921
    
980
    
922
}
981
}
(-)ant/project/test/unit/src/org/netbeans/spi/project/support/ant/PropertyUtilsTest.java (-1 lines)
Lines 557-563 Link Here
557
    }
557
    }
558
    
558
    
559
    public void testDelegatingPropertyProvider() throws Exception {
559
    public void testDelegatingPropertyProvider() throws Exception {
560
        // Used only by ProjectProperties, not publically, but still worth testing.
561
        TestMutablePropertyProvider mpp = new TestMutablePropertyProvider(new HashMap());
560
        TestMutablePropertyProvider mpp = new TestMutablePropertyProvider(new HashMap());
562
        DPP dpp = new DPP(mpp);
561
        DPP dpp = new DPP(mpp);
563
        AntBasedTestUtil.TestCL l = new AntBasedTestUtil.TestCL();
562
        AntBasedTestUtil.TestCL l = new AntBasedTestUtil.TestCL();
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/Bundle.properties (+2 lines)
Lines 69-71 Link Here
69
MSG_OldProjectMetadata=The project is not of the current version.
69
MSG_OldProjectMetadata=The project is not of the current version.
70
70
71
CopyLibs=CopyLibs Task
71
CopyLibs=CopyLibs Task
72
73
J2SEConfigurationProvider.default.label=<default>
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEConfigurationProvider.java (+244 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.ProjectConfiguration;
37
import org.netbeans.spi.project.ProjectConfigurationProvider;
38
import org.netbeans.spi.project.support.ant.EditableProperties;
39
import org.openide.filesystems.FileChangeAdapter;
40
import org.openide.filesystems.FileChangeListener;
41
import org.openide.filesystems.FileEvent;
42
import org.openide.filesystems.FileObject;
43
import org.openide.filesystems.FileRenameEvent;
44
import org.openide.filesystems.FileUtil;
45
import org.openide.util.Mutex;
46
import org.openide.util.MutexException;
47
import org.openide.util.NbBundle;
48
import org.openide.util.Utilities;
49
50
/**
51
 * Manages configurations for a Java SE project.
52
 * @author Jesse Glick
53
 */
54
final class J2SEConfigurationProvider implements ProjectConfigurationProvider {
55
56
    /**
57
     * Ant property name for active config.
58
     */
59
    public static final String PROP_CONFIG = "config"; // NOI18N
60
    /**
61
     * Ant property file which specified active config.
62
     */
63
    public static final String CONFIG_PROPS_PATH = "nbproject/private/config.properties"; // NOI18N
64
65
    private static final class Config implements ProjectConfiguration {
66
        /** file basename, or null for default config */
67
        public final String name;
68
        private final String displayName;
69
        public Config(String name, String displayName) {
70
            this.name = name;
71
            this.displayName = displayName;
72
        }
73
        public String getDisplayName() {
74
            return displayName;
75
        }
76
        public int hashCode() {
77
            return name != null ? name.hashCode() : 0;
78
        }
79
        public boolean equals(Object o) {
80
            return (o instanceof Config) && Utilities.compareObjects(name, ((Config) o).name);
81
        }
82
        public String toString() {
83
            return "J2SEConfigurationProvider.Config[" + name + "," + displayName + "]"; // NOI18N
84
        }
85
    }
86
87
    private static final ProjectConfiguration DEFAULT = new Config(null,
88
            NbBundle.getMessage(J2SEConfigurationProvider.class, "J2SEConfigurationProvider.default.label"));
89
90
    private final J2SEProject p;
91
    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
92
    private final FileChangeListener fcl = new FileChangeAdapter() {
93
        public void fileFolderCreated(FileEvent fe) {
94
            update();
95
        }
96
        public void fileDataCreated(FileEvent fe) {
97
            update();
98
        }
99
        public void fileDeleted(FileEvent fe) {
100
            update();
101
        }
102
        public void fileRenamed(FileRenameEvent fe) {
103
            update();
104
        }
105
        private void update() {
106
            Set/*<String>*/ oldConfigs = configs != null ? configs.keySet() : Collections.emptySet();
107
            configDir = p.getProjectDirectory().getFileObject("nbproject/configs"); // NOI18N
108
            if (configDir != null) {
109
                configDir.removeFileChangeListener(fclWeak);
110
                configDir.addFileChangeListener(fclWeak);
111
            }
112
            calculateConfigs();
113
            Set/*<String>*/ newConfigs = configs.keySet();
114
            if (!oldConfigs.equals(newConfigs)) {
115
                pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATIONS, null, null);
116
                // XXX also fire PROP_ACTIVE_CONFIGURATION?
117
            }
118
        }
119
    };
120
    private final FileChangeListener fclWeak;
121
    private FileObject configDir;
122
    private Map/*<String,ProjectConfiguration>*/ configs;
123
124
    public J2SEConfigurationProvider(J2SEProject p) {
125
        this.p = p;
126
        fclWeak = FileUtil.weakFileChangeListener(fcl, null);
127
        FileObject nbp = p.getProjectDirectory().getFileObject("nbproject"); // NOI18N
128
        if (nbp != null) {
129
            nbp.addFileChangeListener(fclWeak);
130
            configDir = nbp.getFileObject("configs"); // NOI18N
131
            if (configDir != null) {
132
                configDir.addFileChangeListener(fclWeak);
133
            }
134
        }
135
        p.evaluator().addPropertyChangeListener(new PropertyChangeListener() {
136
            public void propertyChange(PropertyChangeEvent evt) {
137
                if (PROP_CONFIG.equals(evt.getPropertyName())) {
138
                    pcs.firePropertyChange(PROP_CONFIGURATION_ACTIVE, null, null);
139
                }
140
            }
141
        });
142
    }
143
144
    private void calculateConfigs() {
145
        configs = new HashMap();
146
        if (configDir != null) {
147
            FileObject[] kids = configDir.getChildren();
148
            for (int i = 0; i < kids.length; i++) {
149
                if (!kids[i].hasExt("properties")) {
150
                    continue;
151
                }
152
                try {
153
                    InputStream is = kids[i].getInputStream();
154
                    try {
155
                        Properties p = new Properties();
156
                        p.load(is);
157
                        String name = kids[i].getName();
158
                        String label = p.getProperty("$label"); // NOI18N
159
                        configs.put(name, new Config(name, label != null ? label : name));
160
                    } finally {
161
                        is.close();
162
                    }
163
                } catch (IOException x) {
164
                    Logger.getLogger(J2SEConfigurationProvider.class.getName()).log(Level.INFO, null, x);
165
                }
166
            }
167
        }
168
    }
169
170
    public Collection/*<? extends ProjectConfiguration>*/ getConfigurations() {
171
        calculateConfigs();
172
        List/*<ProjectConfiguration>*/ l = new ArrayList();
173
        l.addAll(configs.values());
174
        Collections.sort(l, new Comparator() {
175
            Collator c = Collator.getInstance();
176
            public int compare(Object o1, Object o2) {
177
                return c.compare(((ProjectConfiguration) o1).getDisplayName(), ((ProjectConfiguration) o2).getDisplayName());
178
            }
179
        });
180
        l.add(0, DEFAULT);
181
        return l;
182
    }
183
184
    public ProjectConfiguration getActiveConfiguration() {
185
        calculateConfigs();
186
        String config = p.evaluator().getProperty(PROP_CONFIG);
187
        if (config != null && configs.containsKey(config)) {
188
            return (ProjectConfiguration) configs.get(config);
189
        } else {
190
            return DEFAULT;
191
        }
192
    }
193
194
    public void setActiveConfiguration(ProjectConfiguration configuration) throws IllegalArgumentException, IOException {
195
        if (!(configuration instanceof Config)) {
196
            throw new IllegalArgumentException();
197
        }
198
        Config c = (Config) configuration;
199
        if (c != DEFAULT && !configs.values().contains(c)) {
200
            throw new IllegalArgumentException();
201
        }
202
        final String n = c.name;
203
        try {
204
            ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction() {
205
                public Object run() throws IOException {
206
                    EditableProperties ep = p.getAntProjectHelper().getProperties(CONFIG_PROPS_PATH);
207
                    if (Utilities.compareObjects(n, ep.getProperty(PROP_CONFIG))) {
208
                        return null;
209
                    }
210
                    if (n != null) {
211
                        ep.setProperty(PROP_CONFIG, n);
212
                    } else {
213
                        ep.remove(PROP_CONFIG);
214
                    }
215
                    p.getAntProjectHelper().putProperties(CONFIG_PROPS_PATH, ep);
216
                    pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE, null, null);
217
                    ProjectManager.getDefault().saveProject(p);
218
                    assert p.getProjectDirectory().getFileObject(CONFIG_PROPS_PATH) != null;
219
                    return null;
220
                }
221
            });
222
        } catch (MutexException x) {
223
            throw (IOException) x.getException();
224
        }
225
    }
226
227
    public boolean hasCustomizer() {
228
        return true;
229
    }
230
231
    public void customize() {
232
        CustomizerProviderImpl cust = (CustomizerProviderImpl) p.getLookup().lookup(CustomizerProviderImpl.class);
233
        cust.showCustomizer(J2SECompositePanelProvider.RUN);
234
    }
235
236
    public void addPropertyChangeListener(PropertyChangeListener lst) {
237
        pcs.addPropertyChangeListener(lst);
238
    }
239
240
    public void removePropertyChangeListener(PropertyChangeListener lst) {
241
        pcs.removePropertyChangeListener(lst);
242
    }
243
244
}
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java (-4 / +52 lines)
Lines 13-22 Link Here
13
13
14
package org.netbeans.modules.java.j2seproject;
14
package org.netbeans.modules.java.j2seproject;
15
15
16
import java.beans.PropertyChangeEvent;
16
import java.beans.PropertyChangeListener;
17
import java.beans.PropertyChangeListener;
17
import java.beans.PropertyChangeSupport;
18
import java.beans.PropertyChangeSupport;
18
import java.io.File;
19
import java.io.File;
19
import java.io.IOException;
20
import java.io.IOException;
21
import java.util.Collections;
20
import javax.swing.Icon;
22
import javax.swing.Icon;
21
import javax.swing.ImageIcon;
23
import javax.swing.ImageIcon;
22
import org.netbeans.api.java.classpath.ClassPath;
24
import org.netbeans.api.java.classpath.ClassPath;
Lines 25-32 Link Here
25
import org.netbeans.api.project.Project;
27
import org.netbeans.api.project.Project;
26
import org.netbeans.api.project.ProjectInformation;
28
import org.netbeans.api.project.ProjectInformation;
27
import org.netbeans.api.project.ProjectManager;
29
import org.netbeans.api.project.ProjectManager;
28
import org.netbeans.api.project.SourceGroup;
29
import org.netbeans.api.project.Sources;
30
import org.netbeans.api.project.ant.AntArtifact;
30
import org.netbeans.api.project.ant.AntArtifact;
31
import org.netbeans.modules.java.j2seproject.classpath.ClassPathProviderImpl;
31
import org.netbeans.modules.java.j2seproject.classpath.ClassPathProviderImpl;
32
import org.netbeans.modules.java.j2seproject.classpath.J2SEProjectClassPathExtender;
32
import org.netbeans.modules.java.j2seproject.classpath.J2SEProjectClassPathExtender;
Lines 53-58 Link Here
53
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
53
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
54
import org.netbeans.spi.project.support.ant.ProjectXmlSavedHook;
54
import org.netbeans.spi.project.support.ant.ProjectXmlSavedHook;
55
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
55
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
56
import org.netbeans.spi.project.support.ant.PropertyProvider;
56
import org.netbeans.spi.project.support.ant.PropertyUtils;
57
import org.netbeans.spi.project.support.ant.PropertyUtils;
57
import org.netbeans.spi.project.support.ant.ReferenceHelper;
58
import org.netbeans.spi.project.support.ant.ReferenceHelper;
58
import org.netbeans.spi.project.ui.PrivilegedTemplates;
59
import org.netbeans.spi.project.ui.PrivilegedTemplates;
Lines 60-65 Link Here
60
import org.netbeans.spi.project.ui.RecommendedTemplates;
61
import org.netbeans.spi.project.ui.RecommendedTemplates;
61
import org.openide.ErrorManager;
62
import org.openide.ErrorManager;
62
import org.openide.filesystems.FileObject;
63
import org.openide.filesystems.FileObject;
64
import org.openide.filesystems.FileUtil;
63
import org.openide.util.Lookup;
65
import org.openide.util.Lookup;
64
import org.openide.util.Mutex;
66
import org.openide.util.Mutex;
65
import org.openide.util.Utilities;
67
import org.openide.util.Utilities;
Lines 120-128 Link Here
120
    }
122
    }
121
    
123
    
122
    private PropertyEvaluator createEvaluator() {
124
    private PropertyEvaluator createEvaluator() {
123
        // XXX might need to use a custom evaluator to handle active platform substitutions... TBD
124
        // It is currently safe to not use the UpdateHelper for PropertyEvaluator; UH.getProperties() delegates to APH
125
        // It is currently safe to not use the UpdateHelper for PropertyEvaluator; UH.getProperties() delegates to APH
125
        return helper.getStandardPropertyEvaluator();
126
        // Adapted from APH.getStandardPropertyEvaluator (delegates to ProjectProperties):
127
        PropertyEvaluator baseEval1 = PropertyUtils.sequentialPropertyEvaluator(
128
                helper.getStockPropertyPreprovider(),
129
                new PropertyProvider[] {
130
                    helper.getPropertyProvider(J2SEConfigurationProvider.CONFIG_PROPS_PATH),
131
                });
132
        PropertyEvaluator baseEval2 = PropertyUtils.sequentialPropertyEvaluator(
133
                helper.getStockPropertyPreprovider(),
134
                new PropertyProvider[] {
135
                    helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH),
136
                });
137
        return PropertyUtils.sequentialPropertyEvaluator(
138
                helper.getStockPropertyPreprovider(),
139
                new PropertyProvider[] {
140
                    helper.getPropertyProvider(J2SEConfigurationProvider.CONFIG_PROPS_PATH),
141
                    new ConfigPropertyProvider(baseEval1, "nbproject/private/configs", helper), // NOI18N
142
                    helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH),
143
                    PropertyUtils.userPropertiesProvider(baseEval2,
144
                            "user.properties.file", FileUtil.toFile(getProjectDirectory())), // NOI18N
145
                    new ConfigPropertyProvider(baseEval1, "nbproject/configs", helper), // NOI18N
146
                    helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH),
147
                });
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.emptyMap());
171
            }
172
        }
126
    }
173
    }
127
    
174
    
128
    PropertyEvaluator evaluator() {
175
    PropertyEvaluator evaluator() {
Lines 173-178 Link Here
173
            cpMod,
220
            cpMod,
174
            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
175
            new J2SEProjectOperations(this),
222
            new J2SEProjectOperations(this),
223
            new J2SEConfigurationProvider(this),
176
            new J2SEProjectWebServicesSupportProvider()
224
            new J2SEProjectWebServicesSupportProvider()
177
        });
225
        });
178
    }
226
    }
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl (+3 lines)
Lines 71-76 Link Here
71
71
72
            <target name="-init-private">
72
            <target name="-init-private">
73
                <xsl:attribute name="depends">-pre-init</xsl:attribute>
73
                <xsl:attribute name="depends">-pre-init</xsl:attribute>
74
                <property file="nbproject/private/config.properties"/>
75
                <property file="nbproject/private/configs/${{config}}.properties"/>
74
                <property file="nbproject/private/private.properties"/>
76
                <property file="nbproject/private/private.properties"/>
75
            </target>
77
            </target>
76
78
Lines 85-90 Link Here
85
87
86
            <target name="-init-project">
88
            <target name="-init-project">
87
                <xsl:attribute name="depends">-pre-init,-init-private,-init-user</xsl:attribute>
89
                <xsl:attribute name="depends">-pre-init,-init-private,-init-user</xsl:attribute>
90
                <property file="nbproject/configs/${{config}}.properties"/>
88
                <property file="nbproject/project.properties"/>
91
                <property file="nbproject/project.properties"/>
89
            </target>
92
            </target>
90
93
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/J2SELogicalViewProvider.java (+1 lines)
Lines 503-508 Link Here
503
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_RUN, bundle.getString("LBL_RunAction_Name"), null)); // NOI18N
503
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_RUN, bundle.getString("LBL_RunAction_Name"), null)); // NOI18N
504
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_DEBUG, bundle.getString("LBL_DebugAction_Name"), null)); // NOI18N
504
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_DEBUG, bundle.getString("LBL_DebugAction_Name"), null)); // NOI18N
505
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_TEST, bundle.getString("LBL_TestAction_Name"), null)); // NOI18N
505
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_TEST, bundle.getString("LBL_TestAction_Name"), null)); // NOI18N
506
            actions.add(CommonProjectActions.setProjectConfigurationAction());
506
            actions.add(null);
507
            actions.add(null);
507
            actions.add(CommonProjectActions.setAsMainProjectAction());
508
            actions.add(CommonProjectActions.setAsMainProjectAction());
508
            actions.add(CommonProjectActions.openSubprojectsAction());
509
            actions.add(CommonProjectActions.openSubprojectsAction());
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties (+7 lines)
Lines 479-481 Link Here
479
TXT_ModifiedTitle=Edit Project Properties
479
TXT_ModifiedTitle=Edit Project Properties
480
480
481
MSG_CustomizerLibraries_CompileCpMessage=Compile-time libraries are propagated to all library categories.
481
MSG_CustomizerLibraries_CompileCpMessage=Compile-time libraries are propagated to all library categories.
482
483
CustomizerRun.configLabel=&Profile\:
484
CustomizerRun.configNew=&New...
485
CustomizerRun.configDelete=&Delete
486
CustomizerRun.default=<default>
487
CustomizerRun.input.prompt=Profile Name:
488
CustomizerRun.input.title=Create New Profile
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.form (-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 (-39 / +293 lines)
Lines 13-61 Link Here
13
13
14
package org.netbeans.modules.java.j2seproject.ui.customizer;
14
package org.netbeans.modules.java.j2seproject.ui.customizer;
15
15
16
import java.awt.Component;
16
import java.awt.Dialog;
17
import java.awt.Dialog;
18
import java.awt.Font;
17
import java.awt.event.ActionEvent;
19
import java.awt.event.ActionEvent;
18
import java.awt.event.ActionListener;
20
import java.awt.event.ActionListener;
19
import java.awt.event.MouseEvent;
21
import java.awt.event.MouseEvent;
20
import java.io.File;
22
import java.io.File;
23
import java.text.Collator;
24
import java.util.Comparator;
25
import java.util.HashMap;
26
import java.util.Iterator;
27
import java.util.Map;
28
import java.util.SortedSet;
29
import java.util.TreeSet;
30
import javax.swing.DefaultComboBoxModel;
31
import javax.swing.DefaultListCellRenderer;
21
import javax.swing.JButton;
32
import javax.swing.JButton;
22
import javax.swing.JFileChooser;
33
import javax.swing.JFileChooser;
34
import javax.swing.JList;
23
import javax.swing.JPanel;
35
import javax.swing.JPanel;
24
import javax.swing.JTextField;
36
import javax.swing.JTextField;
25
import javax.swing.event.ChangeEvent;
37
import javax.swing.event.ChangeEvent;
26
import javax.swing.event.ChangeListener;
38
import javax.swing.event.ChangeListener;
27
import javax.swing.event.DocumentEvent;
39
import javax.swing.event.DocumentEvent;
28
import javax.swing.event.DocumentListener;
40
import javax.swing.event.DocumentListener;
29
import org.netbeans.api.project.Project;
30
import org.netbeans.modules.java.j2seproject.J2SEProject;
41
import org.netbeans.modules.java.j2seproject.J2SEProject;
31
import org.netbeans.modules.java.j2seproject.SourceRoots;
42
import org.netbeans.modules.java.j2seproject.SourceRoots;
32
import org.openide.DialogDescriptor;
43
import org.openide.DialogDescriptor;
33
import org.openide.DialogDisplayer;
44
import org.openide.DialogDisplayer;
45
import org.openide.NotifyDescriptor;
34
import org.openide.awt.MouseUtils;
46
import org.openide.awt.MouseUtils;
35
import org.openide.filesystems.FileObject;
36
import org.openide.filesystems.FileUtil;
47
import org.openide.filesystems.FileUtil;
37
import org.openide.util.HelpCtx;
48
import org.openide.util.HelpCtx;
38
import org.openide.util.NbBundle;
49
import org.openide.util.NbBundle;
39
50
40
41
/**
42
 *
43
 * @author  phrebejk
44
 */
45
public class CustomizerRun extends JPanel implements HelpCtx.Provider {
51
public class CustomizerRun extends JPanel implements HelpCtx.Provider {
46
    
52
    
47
    private J2SEProject project;
53
    private J2SEProject project;
48
    
54
    
55
    private JTextField[] data;
56
    private String[] keys;
57
    private Map/*<String|null,Map<String,String|null>|null>*/ configs;
58
    J2SEProjectProperties uiProperties;
59
    
49
    public CustomizerRun( J2SEProjectProperties uiProperties ) {
60
    public CustomizerRun( J2SEProjectProperties uiProperties ) {
61
        this.uiProperties = uiProperties;
50
        initComponents();
62
        initComponents();
51
63
52
        this.project = uiProperties.getProject();
64
        this.project = uiProperties.getProject();
53
        
65
        
54
        jTextFieldMainClass.setDocument( uiProperties.MAIN_CLASS_MODEL );
66
        configs = uiProperties.RUN_CONFIGS;
55
        jTextFieldArgs.setDocument( uiProperties.APPLICATION_ARGS_MODEL );
67
        
56
        jTextVMOptions.setDocument( uiProperties.RUN_JVM_ARGS_MODEL );
68
        data = new JTextField[] {
57
        jTextWorkingDirectory.setDocument( uiProperties.RUN_WORK_DIR_MODEL );
69
            jTextFieldMainClass,
58
           
70
            jTextFieldArgs,
71
            jTextVMOptions,
72
            jTextWorkingDirectory,
73
        };
74
        keys = new String[] {
75
            J2SEProjectProperties.MAIN_CLASS,
76
            J2SEProjectProperties.APPLICATION_ARGS,
77
            J2SEProjectProperties.RUN_JVM_ARGS,
78
            J2SEProjectProperties.RUN_WORK_DIR,
79
        };
80
        assert data.length == keys.length;
81
        
82
        configChanged(uiProperties.activeConfig);
83
        
84
        configCombo.setRenderer(new DefaultListCellRenderer() {
85
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
86
                String config = (String) value;
87
                String label;
88
                if (config == null) {
89
                    // uninitialized?
90
                    label = null;
91
                } else if (config.length() > 0) {
92
                    Map m = (Map) configs.get(config);
93
                    label = m != null ? (String) m.get("$label") : /* temporary? */ null;
94
                    if (label == null) {
95
                        label = config;
96
                    }
97
                } else {
98
                    label = NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.default");
99
                }
100
                return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus);
101
            }
102
        });
103
        
104
        for (int i = 0; i < data.length; i++) {
105
            final JTextField field = data[i];
106
            final String prop = keys[i];
107
            field.getDocument().addDocumentListener(new DocumentListener() {
108
                Font basefont = field.getFont();
109
                Font boldfont = basefont.deriveFont(Font.BOLD);
110
                {
111
                    updateFont();
112
                }
113
                public void insertUpdate(DocumentEvent e) {
114
                    changed();
115
                }
116
                public void removeUpdate(DocumentEvent e) {
117
                    changed();
118
                }
119
                public void changedUpdate(DocumentEvent e) {}
120
                void changed() {
121
                    String config = (String) configCombo.getSelectedItem();
122
                    if (config.length() == 0) {
123
                        config = null;
124
                    }
125
                    String v = field.getText();
126
                    if (v != null && config != null && v.equals(((Map) configs.get(null)).get(prop))) {
127
                        // default value, do not store as such
128
                        v = null;
129
                    }
130
                    ((Map) configs.get(config)).put(prop, v);
131
                    updateFont();
132
                }
133
                void updateFont() {
134
                    String v = field.getText();
135
                    String config = (String) configCombo.getSelectedItem();
136
                    if (config.length() == 0) {
137
                        config = null;
138
                    }
139
                    field.setFont(config != null && v != null && !v.equals(((Map) configs.get(null)).get(prop)) ? boldfont : basefont);
140
                }
141
            });
142
        }
143
59
        jButtonMainClass.addActionListener( new MainClassListener( project.getSourceRoots(), jTextFieldMainClass ) );
144
        jButtonMainClass.addActionListener( new MainClassListener( project.getSourceRoots(), jTextFieldMainClass ) );
60
    }
145
    }
61
        
146
        
Lines 72-77 Link Here
72
    private void initComponents() {
157
    private void initComponents() {
73
        java.awt.GridBagConstraints gridBagConstraints;
158
        java.awt.GridBagConstraints gridBagConstraints;
74
159
160
        configSep = new javax.swing.JSeparator();
161
        configPanel = new javax.swing.JPanel();
162
        configLabel = new javax.swing.JLabel();
163
        configCombo = new javax.swing.JComboBox();
164
        configNew = new javax.swing.JButton();
165
        configDel = new javax.swing.JButton();
166
        mainPanel = new javax.swing.JPanel();
75
        jLabelMainClass = new javax.swing.JLabel();
167
        jLabelMainClass = new javax.swing.JLabel();
76
        jTextFieldMainClass = new javax.swing.JTextField();
168
        jTextFieldMainClass = new javax.swing.JTextField();
77
        jButtonMainClass = new javax.swing.JButton();
169
        jButtonMainClass = new javax.swing.JButton();
Lines 86-135 Link Here
86
178
87
        setLayout(new java.awt.GridBagLayout());
179
        setLayout(new java.awt.GridBagLayout());
88
180
181
        gridBagConstraints = new java.awt.GridBagConstraints();
182
        gridBagConstraints.gridx = 0;
183
        gridBagConstraints.gridy = 1;
184
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
185
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
186
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
187
        add(configSep, gridBagConstraints);
188
189
        configPanel.setLayout(new java.awt.GridBagLayout());
190
191
        configLabel.setLabelFor(configCombo);
192
        org.openide.awt.Mnemonics.setLocalizedText(configLabel, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.configLabel")); // NOI18N
193
        gridBagConstraints = new java.awt.GridBagConstraints();
194
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
195
        gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 0);
196
        configPanel.add(configLabel, gridBagConstraints);
197
198
        configCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<default>" }));
199
        configCombo.addActionListener(new java.awt.event.ActionListener() {
200
            public void actionPerformed(java.awt.event.ActionEvent evt) {
201
                configComboActionPerformed(evt);
202
            }
203
        });
204
205
        gridBagConstraints = new java.awt.GridBagConstraints();
206
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
207
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
208
        gridBagConstraints.weightx = 1.0;
209
        gridBagConstraints.insets = new java.awt.Insets(2, 6, 2, 0);
210
        configPanel.add(configCombo, gridBagConstraints);
211
212
        org.openide.awt.Mnemonics.setLocalizedText(configNew, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.configNew")); // NOI18N
213
        configNew.addActionListener(new java.awt.event.ActionListener() {
214
            public void actionPerformed(java.awt.event.ActionEvent evt) {
215
                configNewActionPerformed(evt);
216
            }
217
        });
218
219
        gridBagConstraints = new java.awt.GridBagConstraints();
220
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
221
        gridBagConstraints.insets = new java.awt.Insets(2, 6, 2, 0);
222
        configPanel.add(configNew, gridBagConstraints);
223
224
        org.openide.awt.Mnemonics.setLocalizedText(configDel, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.configDelete")); // NOI18N
225
        configDel.addActionListener(new java.awt.event.ActionListener() {
226
            public void actionPerformed(java.awt.event.ActionEvent evt) {
227
                configDelActionPerformed(evt);
228
            }
229
        });
230
231
        gridBagConstraints = new java.awt.GridBagConstraints();
232
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
233
        gridBagConstraints.insets = new java.awt.Insets(2, 6, 2, 0);
234
        configPanel.add(configDel, gridBagConstraints);
235
236
        gridBagConstraints = new java.awt.GridBagConstraints();
237
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
238
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
239
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
240
        add(configPanel, gridBagConstraints);
241
242
        mainPanel.setLayout(new java.awt.GridBagLayout());
243
89
        jLabelMainClass.setLabelFor(jTextFieldMainClass);
244
        jLabelMainClass.setLabelFor(jTextFieldMainClass);
90
        org.openide.awt.Mnemonics.setLocalizedText(jLabelMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JLabel"));
245
        org.openide.awt.Mnemonics.setLocalizedText(jLabelMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JLabel")); // NOI18N
91
        gridBagConstraints = new java.awt.GridBagConstraints();
246
        gridBagConstraints = new java.awt.GridBagConstraints();
92
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
247
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
93
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
248
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
94
        add(jLabelMainClass, gridBagConstraints);
249
        mainPanel.add(jLabelMainClass, gridBagConstraints);
95
250
96
        gridBagConstraints = new java.awt.GridBagConstraints();
251
        gridBagConstraints = new java.awt.GridBagConstraints();
97
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
252
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
98
        gridBagConstraints.weightx = 1.0;
253
        gridBagConstraints.weightx = 1.0;
99
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 5, 0);
254
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 5, 0);
100
        add(jTextFieldMainClass, gridBagConstraints);
255
        mainPanel.add(jTextFieldMainClass, gridBagConstraints);
101
        jTextFieldMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldMainClass"));
256
        jTextFieldMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldMainClass")); // NOI18N
102
257
103
        org.openide.awt.Mnemonics.setLocalizedText(jButtonMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JButton"));
258
        org.openide.awt.Mnemonics.setLocalizedText(jButtonMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JButton")); // NOI18N
104
        gridBagConstraints = new java.awt.GridBagConstraints();
259
        gridBagConstraints = new java.awt.GridBagConstraints();
105
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
260
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
106
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
261
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
107
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
262
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
108
        add(jButtonMainClass, gridBagConstraints);
263
        mainPanel.add(jButtonMainClass, gridBagConstraints);
109
        jButtonMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jButtonMainClass"));
264
        jButtonMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jButtonMainClass")); // NOI18N
110
265
111
        jLabelArgs.setLabelFor(jTextFieldArgs);
266
        jLabelArgs.setLabelFor(jTextFieldArgs);
112
        org.openide.awt.Mnemonics.setLocalizedText(jLabelArgs, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Args_JLabel"));
267
        org.openide.awt.Mnemonics.setLocalizedText(jLabelArgs, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Args_JLabel")); // NOI18N
113
        gridBagConstraints = new java.awt.GridBagConstraints();
268
        gridBagConstraints = new java.awt.GridBagConstraints();
114
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
269
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
115
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
270
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
116
        add(jLabelArgs, gridBagConstraints);
271
        mainPanel.add(jLabelArgs, gridBagConstraints);
117
272
118
        gridBagConstraints = new java.awt.GridBagConstraints();
273
        gridBagConstraints = new java.awt.GridBagConstraints();
119
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
274
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
120
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
275
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
121
        gridBagConstraints.weightx = 1.0;
276
        gridBagConstraints.weightx = 1.0;
122
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
277
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
123
        add(jTextFieldArgs, gridBagConstraints);
278
        mainPanel.add(jTextFieldArgs, gridBagConstraints);
124
        jTextFieldArgs.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldArgs"));
279
        jTextFieldArgs.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldArgs")); // NOI18N
125
280
126
        jLabelWorkingDirectory.setLabelFor(jTextWorkingDirectory);
281
        jLabelWorkingDirectory.setLabelFor(jTextWorkingDirectory);
127
        org.openide.awt.Mnemonics.setLocalizedText(jLabelWorkingDirectory, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory"));
282
        org.openide.awt.Mnemonics.setLocalizedText(jLabelWorkingDirectory, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory")); // NOI18N
128
        gridBagConstraints = new java.awt.GridBagConstraints();
283
        gridBagConstraints = new java.awt.GridBagConstraints();
129
        gridBagConstraints.gridy = 2;
284
        gridBagConstraints.gridy = 2;
130
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
285
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
131
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
286
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
132
        add(jLabelWorkingDirectory, gridBagConstraints);
287
        mainPanel.add(jLabelWorkingDirectory, gridBagConstraints);
133
288
134
        gridBagConstraints = new java.awt.GridBagConstraints();
289
        gridBagConstraints = new java.awt.GridBagConstraints();
135
        gridBagConstraints.gridy = 2;
290
        gridBagConstraints.gridy = 2;
Lines 137-146 Link Here
137
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
292
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
138
        gridBagConstraints.weightx = 1.0;
293
        gridBagConstraints.weightx = 1.0;
139
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 5, 0);
294
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 5, 0);
140
        add(jTextWorkingDirectory, gridBagConstraints);
295
        mainPanel.add(jTextWorkingDirectory, gridBagConstraints);
141
        jTextWorkingDirectory.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle").getString("AD_CustomizeRun_Run_Working_Directory "));
296
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle"); // NOI18N
297
        jTextWorkingDirectory.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizeRun_Run_Working_Directory ")); // NOI18N
142
298
143
        org.openide.awt.Mnemonics.setLocalizedText(jButtonWorkingDirectoryBrowse, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory_Browse"));
299
        org.openide.awt.Mnemonics.setLocalizedText(jButtonWorkingDirectoryBrowse, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory_Browse")); // NOI18N
144
        jButtonWorkingDirectoryBrowse.addActionListener(new java.awt.event.ActionListener() {
300
        jButtonWorkingDirectoryBrowse.addActionListener(new java.awt.event.ActionListener() {
145
            public void actionPerformed(java.awt.event.ActionEvent evt) {
301
            public void actionPerformed(java.awt.event.ActionEvent evt) {
146
                jButtonWorkingDirectoryBrowseActionPerformed(evt);
302
                jButtonWorkingDirectoryBrowseActionPerformed(evt);
Lines 152-176 Link Here
152
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
308
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
153
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
309
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
154
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
310
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
155
        add(jButtonWorkingDirectoryBrowse, gridBagConstraints);
311
        mainPanel.add(jButtonWorkingDirectoryBrowse, gridBagConstraints);
156
        jButtonWorkingDirectoryBrowse.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle").getString("AD_CustomizeRun_Run_Working_Directory_Browse"));
312
        jButtonWorkingDirectoryBrowse.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizeRun_Run_Working_Directory_Browse")); // NOI18N
157
313
158
        jLabelVMOptions.setLabelFor(jTextVMOptions);
314
        jLabelVMOptions.setLabelFor(jTextVMOptions);
159
        org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptions, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options"));
315
        org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptions, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options")); // NOI18N
160
        gridBagConstraints = new java.awt.GridBagConstraints();
316
        gridBagConstraints = new java.awt.GridBagConstraints();
161
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
317
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
162
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
318
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
163
        add(jLabelVMOptions, gridBagConstraints);
319
        mainPanel.add(jLabelVMOptions, gridBagConstraints);
164
320
165
        gridBagConstraints = new java.awt.GridBagConstraints();
321
        gridBagConstraints = new java.awt.GridBagConstraints();
166
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
322
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
167
        gridBagConstraints.weightx = 1.0;
323
        gridBagConstraints.weightx = 1.0;
168
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
324
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
169
        add(jTextVMOptions, gridBagConstraints);
325
        mainPanel.add(jTextVMOptions, gridBagConstraints);
170
        jTextVMOptions.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle").getString("AD_CustomizeRun_Run_VM_Options"));
326
        jTextVMOptions.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizeRun_Run_VM_Options")); // NOI18N
171
327
172
        jLabelVMOptionsExample.setLabelFor(jTextFieldMainClass);
328
        jLabelVMOptionsExample.setLabelFor(jTextFieldMainClass);
173
        org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptionsExample, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options_Example"));
329
        org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptionsExample, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options_Example")); // NOI18N
174
        gridBagConstraints = new java.awt.GridBagConstraints();
330
        gridBagConstraints = new java.awt.GridBagConstraints();
175
        gridBagConstraints.gridx = 1;
331
        gridBagConstraints.gridx = 1;
176
        gridBagConstraints.gridy = 4;
332
        gridBagConstraints.gridy = 4;
Lines 179-189 Link Here
179
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
335
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
180
        gridBagConstraints.weighty = 1.0;
336
        gridBagConstraints.weighty = 1.0;
181
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
337
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
182
        add(jLabelVMOptionsExample, gridBagConstraints);
338
        mainPanel.add(jLabelVMOptionsExample, gridBagConstraints);
183
        jLabelVMOptionsExample.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle").getString("LBL_CustomizeRun_Run_VM_Options_Example"));
339
        jLabelVMOptionsExample.getAccessibleContext().setAccessibleDescription(bundle.getString("LBL_CustomizeRun_Run_VM_Options_Example")); // NOI18N
184
340
185
    }
341
        gridBagConstraints = new java.awt.GridBagConstraints();
186
    // </editor-fold>//GEN-END:initComponents
342
        gridBagConstraints.gridx = 0;
343
        gridBagConstraints.gridy = 2;
344
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
345
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
346
        gridBagConstraints.weightx = 1.0;
347
        gridBagConstraints.weighty = 1.0;
348
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
349
        add(mainPanel, gridBagConstraints);
350
351
    }// </editor-fold>//GEN-END:initComponents
352
353
    private void configDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configDelActionPerformed
354
        String config = (String) configCombo.getSelectedItem();
355
        assert config != null;
356
        configs.put(config, null);
357
        configChanged(null);
358
        uiProperties.activeConfig = null;
359
    }//GEN-LAST:event_configDelActionPerformed
360
361
    private void configNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configNewActionPerformed
362
        NotifyDescriptor.InputLine d = new NotifyDescriptor.InputLine(
363
                NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.input.prompt"),
364
                NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.input.title"));
365
        if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.OK_OPTION) {
366
            return;
367
        }
368
        String name = d.getInputText();
369
        String config = name.replaceAll("[^a-zA-Z0-9_.-]", "_"); // NOI18N
370
        if (configs.containsKey(config)) {
371
            // XXX complain?
372
            return;
373
        }
374
        Map m = new HashMap();
375
        if (!name.equals(config)) {
376
            m.put("$label", name); // NOI18N
377
        }
378
        configs.put(config, m);
379
        configChanged(config);
380
        uiProperties.activeConfig = config;
381
    }//GEN-LAST:event_configNewActionPerformed
382
383
    private void configComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configComboActionPerformed
384
        String config = (String) configCombo.getSelectedItem();
385
        if (config.length() == 0) {
386
            config = null;
387
        }
388
        configChanged(config);
389
        uiProperties.activeConfig = config;
390
    }//GEN-LAST:event_configComboActionPerformed
187
391
188
    private void jButtonWorkingDirectoryBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWorkingDirectoryBrowseActionPerformed
392
    private void jButtonWorkingDirectoryBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWorkingDirectoryBrowseActionPerformed
189
        JFileChooser chooser = new JFileChooser();
393
        JFileChooser chooser = new JFileChooser();
Lines 202-210 Link Here
202
            jTextWorkingDirectory.setText(file.getAbsolutePath());
406
            jTextWorkingDirectory.setText(file.getAbsolutePath());
203
        }
407
        }
204
    }//GEN-LAST:event_jButtonWorkingDirectoryBrowseActionPerformed
408
    }//GEN-LAST:event_jButtonWorkingDirectoryBrowseActionPerformed
409
410
    private void configChanged(String activeConfig) {
411
        DefaultComboBoxModel model = new DefaultComboBoxModel();
412
        model.addElement("");
413
        SortedSet alphaConfigs = new TreeSet(new Comparator() {
414
            Collator coll = Collator.getInstance();
415
            public int compare(Object o1, Object o2) {
416
                return coll.compare(label(o1), label(o2));
417
            }
418
            private String label(Object o) {
419
                String c = (String) o;
420
                Map m = (Map) configs.get(c);
421
                String label = (String) m.get("$label"); // NOI18N
422
                return label != null ? label : c;
423
            }
424
        });
425
        Iterator it = configs.keySet().iterator();
426
        while (it.hasNext()) {
427
            String config = (String) it.next();
428
            if (config != null && configs.get(config) != null) {
429
                alphaConfigs.add(config);
430
            }
431
        }
432
        it = alphaConfigs.iterator();
433
        while (it.hasNext()) {
434
            model.addElement(it.next());
435
        }
436
        configCombo.setModel(model);
437
        configCombo.setSelectedItem(activeConfig != null ? activeConfig : "");
438
        Map m = (Map) configs.get(activeConfig);
439
        Map def = (Map) configs.get(null);
440
        if (m != null) {
441
            for (int i = 0; i < data.length; i++) {
442
                String v = (String) m.get(keys[i]);
443
                if (v == null) {
444
                    // display default value
445
                    v = (String) def.get(keys[i]);
446
                }
447
                data[i].setText(v);
448
            }
449
        } // else ??
450
        configDel.setEnabled(activeConfig != null);
451
    }
205
    
452
    
206
    
453
    
207
    // Variables declaration - do not modify//GEN-BEGIN:variables
454
    // Variables declaration - do not modify//GEN-BEGIN:variables
455
    private javax.swing.JComboBox configCombo;
456
    private javax.swing.JButton configDel;
457
    private javax.swing.JLabel configLabel;
458
    private javax.swing.JButton configNew;
459
    private javax.swing.JPanel configPanel;
460
    private javax.swing.JSeparator configSep;
208
    private javax.swing.JButton jButtonMainClass;
461
    private javax.swing.JButton jButtonMainClass;
209
    private javax.swing.JButton jButtonWorkingDirectoryBrowse;
462
    private javax.swing.JButton jButtonWorkingDirectoryBrowse;
210
    private javax.swing.JLabel jLabelArgs;
463
    private javax.swing.JLabel jLabelArgs;
Lines 216-221 Link Here
216
    private javax.swing.JTextField jTextFieldMainClass;
469
    private javax.swing.JTextField jTextFieldMainClass;
217
    private javax.swing.JTextField jTextVMOptions;
470
    private javax.swing.JTextField jTextVMOptions;
218
    private javax.swing.JTextField jTextWorkingDirectory;
471
    private javax.swing.JTextField jTextWorkingDirectory;
472
    private javax.swing.JPanel mainPanel;
219
    // End of variables declaration//GEN-END:variables
473
    // End of variables declaration//GEN-END:variables
220
    
474
    
221
    
475
    
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SECompositePanelProvider.java (-4 / +1 lines)
Lines 30-38 Link Here
30
 * @author mkleint
30
 * @author mkleint
31
 */
31
 */
32
public class J2SECompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider {
32
public class J2SECompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider {
33
    // Names of categories
34
    private static final String BUILD_CATEGORY = "BuildCategory";
35
    private static final String RUN_CATEGORY = "RunCategory";
36
    
33
    
37
    private static final String SOURCES = "Sources";
34
    private static final String SOURCES = "Sources";
38
    static final String LIBRARIES = "Libraries";
35
    static final String LIBRARIES = "Libraries";
Lines 41-47 Link Here
41
//    private static final String BUILD_TESTS = "BuildTests";
38
//    private static final String BUILD_TESTS = "BuildTests";
42
    private static final String JAR = "Jar";
39
    private static final String JAR = "Jar";
43
    private static final String JAVADOC = "Javadoc";
40
    private static final String JAVADOC = "Javadoc";
44
    private static final String RUN = "Run";    
41
    public static final String RUN = "Run";
45
//    private static final String RUN_TESTS = "RunTests";
42
//    private static final String RUN_TESTS = "RunTests";
46
    
43
    
47
    private static final String WEBSERVICECLIENTS = "WebServiceClients";
44
    private static final String WEBSERVICECLIENTS = "WebServiceClients";
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java (-18 / +119 lines)
Lines 20-26 Link Here
20
import java.util.HashMap;
20
import java.util.HashMap;
21
import java.util.HashSet;
21
import java.util.HashSet;
22
import java.util.Iterator;
22
import java.util.Iterator;
23
import java.util.List;
23
import java.util.Map;
24
import java.util.Map.Entry;
24
import java.util.Properties;
25
import java.util.Properties;
25
import java.util.Set;
26
import java.util.Set;
26
import java.util.Vector;
27
import java.util.Vector;
Lines 34-40 Link Here
34
import javax.swing.text.BadLocationException;
35
import javax.swing.text.BadLocationException;
35
import javax.swing.text.Document;
36
import javax.swing.text.Document;
36
import org.netbeans.api.project.ProjectManager;
37
import org.netbeans.api.project.ProjectManager;
37
import org.netbeans.api.queries.CollocationQuery;
38
import org.netbeans.modules.java.j2seproject.J2SEProject;
38
import org.netbeans.modules.java.j2seproject.J2SEProject;
39
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil;
39
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil;
40
import org.netbeans.modules.java.j2seproject.SourceRoots;
40
import org.netbeans.modules.java.j2seproject.SourceRoots;
Lines 44-50 Link Here
44
import org.netbeans.spi.project.support.ant.EditableProperties;
44
import org.netbeans.spi.project.support.ant.EditableProperties;
45
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
45
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
46
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
46
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
47
import org.netbeans.spi.project.support.ant.PropertyUtils;
48
import org.netbeans.spi.project.support.ant.ReferenceHelper;
47
import org.netbeans.spi.project.support.ant.ReferenceHelper;
49
import org.netbeans.spi.project.support.ant.ui.StoreGroup;
48
import org.netbeans.spi.project.support.ant.ui.StoreGroup;
50
import org.openide.DialogDisplayer;
49
import org.openide.DialogDisplayer;
Lines 52-61 Link Here
52
import org.openide.NotifyDescriptor;
51
import org.openide.NotifyDescriptor;
53
import org.openide.filesystems.FileObject;
52
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileUtil;
53
import org.openide.filesystems.FileUtil;
55
import org.openide.modules.SpecificationVersion;
56
import org.openide.util.Mutex;
54
import org.openide.util.Mutex;
57
import org.openide.util.MutexException;
55
import org.openide.util.MutexException;
58
import org.openide.util.NbBundle;
56
import org.openide.util.NbBundle;
57
import org.openide.util.Utilities;
59
58
60
/**
59
/**
61
 * @author Petr Hrebejk
60
 * @author Petr Hrebejk
Lines 185-195 Link Here
185
    Document JAVADOC_ADDITIONALPARAM_MODEL;
184
    Document JAVADOC_ADDITIONALPARAM_MODEL;
186
185
187
    // CustomizerRun
186
    // CustomizerRun
188
    Document MAIN_CLASS_MODEL;
187
    Map/*<String|null,Map<String,String|null>|null>*/ RUN_CONFIGS;
189
    Document APPLICATION_ARGS_MODEL;
188
    String activeConfig;
190
    Document RUN_JVM_ARGS_MODEL;
191
    Document RUN_WORK_DIR_MODEL;
192
193
189
194
    // CustomizerRunTest
190
    // CustomizerRunTest
195
191
Lines 283-292 Link Here
283
        
279
        
284
        JAVADOC_ADDITIONALPARAM_MODEL = projectGroup.createStringDocument( evaluator, JAVADOC_ADDITIONALPARAM );
280
        JAVADOC_ADDITIONALPARAM_MODEL = projectGroup.createStringDocument( evaluator, JAVADOC_ADDITIONALPARAM );
285
        // CustomizerRun
281
        // CustomizerRun
286
        MAIN_CLASS_MODEL = projectGroup.createStringDocument( evaluator, MAIN_CLASS ); 
282
        RUN_CONFIGS = readRunConfigs();
287
        APPLICATION_ARGS_MODEL = privateGroup.createStringDocument( evaluator, APPLICATION_ARGS );
283
        activeConfig = evaluator.getProperty("config");
288
        RUN_JVM_ARGS_MODEL = projectGroup.createStringDocument( evaluator, RUN_JVM_ARGS );
289
        RUN_WORK_DIR_MODEL = privateGroup.createStringDocument( evaluator, RUN_WORK_DIR );
290
                
284
                
291
    }
285
    }
292
    
286
    
Lines 357-362 Link Here
357
        projectGroup.store( projectProperties );        
351
        projectGroup.store( projectProperties );        
358
        privateGroup.store( privateProperties );
352
        privateGroup.store( privateProperties );
359
        
353
        
354
        storeRunConfigs(RUN_CONFIGS, projectProperties, privateProperties);
355
        EditableProperties ep = updateHelper.getProperties("nbproject/private/config.properties");
356
        if (activeConfig == null) {
357
            ep.remove("config");
358
        } else {
359
            ep.setProperty("config", activeConfig);
360
        }
361
        updateHelper.putProperties("nbproject/private/config.properties", ep);
362
        
360
        //Hotfix of the issue #70058
363
        //Hotfix of the issue #70058
361
        //Should use the StoreGroup when the StoreGroup SPI will be extended to allow false default value in ToggleButtonModel
364
        //Should use the StoreGroup when the StoreGroup SPI will be extended to allow false default value in ToggleButtonModel
362
        //Save javac.debug
365
        //Save javac.debug
Lines 381-390 Link Here
381
            projectProperties.remove( NO_DEPENDENCIES ); // Remove the property completely if not set
384
            projectProperties.remove( NO_DEPENDENCIES ); // Remove the property completely if not set
382
        }
385
        }
383
386
384
        if ( getDocumentText( RUN_WORK_DIR_MODEL ).trim().equals( "" ) ) { // NOI18N
385
            privateProperties.remove( RUN_WORK_DIR ); // Remove the property completely if not set
386
        }
387
                
388
        storeAdditionalProperties(projectProperties);
387
        storeAdditionalProperties(projectProperties);
389
        
388
        
390
        // Store the property changes into the project
389
        // Store the property changes into the project
Lines 458-464 Link Here
458
                changed = true;
457
                changed = true;
459
            }
458
            }
460
        }
459
        }
461
        File projDir = FileUtil.toFile(updateHelper.getAntProjectHelper().getProjectDirectory());
462
        for( Iterator it = added.iterator(); it.hasNext(); ) {
460
        for( Iterator it = added.iterator(); it.hasNext(); ) {
463
            ClassPathSupport.Item item = (ClassPathSupport.Item)it.next();
461
            ClassPathSupport.Item item = (ClassPathSupport.Item)it.next();
464
            if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY && !item.isBroken()) {
462
            if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY && !item.isBroken()) {
Lines 547-552 Link Here
547
        JToggleButton.ToggleButtonModel bm = new JToggleButton.ToggleButtonModel();
545
        JToggleButton.ToggleButtonModel bm = new JToggleButton.ToggleButtonModel();
548
        bm.setSelected(isSelected );
546
        bm.setSelected(isSelected );
549
        return bm;
547
        return bm;
548
    }
549
    
550
    /**
551
     * A mess.
552
     */
553
    private Map/*<String|null,Map<String,String>>*/ readRunConfigs() {
554
        Map m = new HashMap();
555
        Map def = new HashMap();
556
        String[] PROPS = {MAIN_CLASS, APPLICATION_ARGS, RUN_JVM_ARGS, RUN_WORK_DIR};
557
        for (int i = 0; i < PROPS.length; i++) {
558
            String v = updateHelper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH).getProperty(PROPS[i]);
559
            if (v == null) {
560
                v = updateHelper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH).getProperty(PROPS[i]);
561
            }
562
            if (v != null) {
563
                def.put(PROPS[i], v);
564
            }
565
        }
566
        m.put(null, def);
567
        FileObject configs = project.getProjectDirectory().getFileObject("nbproject/configs");
568
        if (configs != null) {
569
            FileObject[] kids = configs.getChildren();
570
            for (int i = 0; i < kids.length; i++) {
571
                if (!kids[i].hasExt("properties")) {
572
                    continue;
573
                }
574
                m.put(kids[i].getName(), new HashMap(updateHelper.getProperties(FileUtil.getRelativePath(project.getProjectDirectory(), kids[i]))));
575
            }
576
        }
577
        configs = project.getProjectDirectory().getFileObject("nbproject/private/configs");
578
        if (configs != null) {
579
            FileObject[] kids = configs.getChildren();
580
            for (int i = 0; i < kids.length; i++) {
581
                if (!kids[i].hasExt("properties")) {
582
                    continue;
583
                }
584
                Map c = (Map) m.get(kids[i].getName());
585
                if (c == null) {
586
                    continue;
587
                }
588
                c.putAll(new HashMap(updateHelper.getProperties(FileUtil.getRelativePath(project.getProjectDirectory(), kids[i]))));
589
            }
590
        }
591
        //System.err.println("readRunConfigs: " + m);
592
        return m;
593
    }
594
    
595
    /**
596
     * A royal mess.
597
     */
598
    private void storeRunConfigs(Map/*<String|null,Map<String,String|null>|null>*/ configs,
599
            EditableProperties projectProperties, EditableProperties privateProperties) throws IOException {
600
        //System.err.println("storeRunConfigs: " + configs);
601
        Map def = (Map) configs.get(null);
602
        String[] PROPS = {MAIN_CLASS, APPLICATION_ARGS, RUN_JVM_ARGS, RUN_WORK_DIR};
603
        for (int i = 0; i < PROPS.length; i++) {
604
            String prop = PROPS[i];
605
            String v = (String) def.get(prop);
606
            EditableProperties ep = (prop.equals(APPLICATION_ARGS) || prop.equals(RUN_WORK_DIR)) ?
607
                privateProperties : projectProperties;
608
            if (!Utilities.compareObjects(v, ep.getProperty(prop))) {
609
                if (v != null && v.length() > 0) {
610
                    ep.setProperty(prop, v);
611
                } else {
612
                    ep.remove(prop);
613
                }
614
            }
615
        }
616
        Iterator it = configs.entrySet().iterator();
617
        while (it.hasNext()) {
618
            Map.Entry entry = (Entry) it.next();
619
            String config = (String) entry.getKey();
620
            if (config == null) {
621
                continue;
622
            }
623
            String sharedPath = "nbproject/configs/" + config + ".properties"; // NOI18N
624
            String privatePath = "nbproject/private/configs/" + config + ".properties"; // NOI18N
625
            Map c = (Map) entry.getValue();
626
            if (c == null) {
627
                updateHelper.putProperties(sharedPath, null);
628
                updateHelper.putProperties(privatePath, null);
629
                continue;
630
            }
631
            Iterator it2 = c.entrySet().iterator();
632
            while (it2.hasNext()) {
633
                Map.Entry entry2 = (Entry) it2.next();
634
                String prop = (String) entry2.getKey();
635
                String v = (String) entry2.getValue();
636
                String path = (prop.equals(APPLICATION_ARGS) || prop.equals(RUN_WORK_DIR)) ?
637
                    privatePath : sharedPath;
638
                EditableProperties ep = updateHelper.getProperties(path);
639
                if (!Utilities.compareObjects(v, ep.getProperty(prop))) {
640
                    if (v != null && v.length() > 0) {
641
                        ep.setProperty(prop, v);
642
                    } else {
643
                        ep.remove(prop);
644
                    }
645
                    updateHelper.putProperties(path, ep);
646
                }
647
            }
648
            // Make sure the definition file is always created, even if it is empty.
649
            updateHelper.putProperties(sharedPath, updateHelper.getProperties(sharedPath));
650
        }
550
    }
651
    }
551
    
652
    
552
}
653
}
(-)java/j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/J2SEConfigurationProviderTest.java (+199 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.Collections;
23
import java.util.HashSet;
24
import java.util.List;
25
import java.util.Locale;
26
import java.util.Properties;
27
import java.util.Set;
28
import org.netbeans.api.project.ProjectManager;
29
import org.netbeans.junit.NbTestCase;
30
import org.netbeans.spi.project.ProjectConfiguration;
31
import org.netbeans.spi.project.ProjectConfigurationProvider;
32
import org.netbeans.spi.project.support.ant.EditableProperties;
33
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
34
import org.openide.filesystems.FileObject;
35
import org.openide.filesystems.FileUtil;
36
37
/**
38
 * @author Jesse Glick
39
 */
40
public class J2SEConfigurationProviderTest extends NbTestCase {
41
42
    public J2SEConfigurationProviderTest(String name) {
43
        super(name);
44
    }
45
46
    private FileObject d;
47
    private J2SEProject p;
48
    private ProjectConfigurationProvider cp;
49
50
    protected void setUp() throws Exception {
51
        super.setUp();
52
        clearWorkDir();
53
        d = J2SEProjectGenerator.createProject(getWorkDir(), "test", null, null).getProjectDirectory();
54
        p = (J2SEProject) ProjectManager.getDefault().findProject(d);
55
        cp = (ProjectConfigurationProvider) p.getLookup().lookup(ProjectConfigurationProvider.class);
56
        assertNotNull(cp);
57
        Locale.setDefault(Locale.US);
58
    }
59
60
    public void testInitialState() throws Exception {
61
        assertEquals(1, cp.getConfigurations().size());
62
        assertNotNull(cp.getActiveConfiguration());
63
        assertEquals(cp.getActiveConfiguration(), cp.getConfigurations().iterator().next());
64
        assertEquals("<default>", cp.getActiveConfiguration().getDisplayName());
65
        assertTrue(cp.hasCustomizer());
66
    }
67
68
    public void testConfigurations() throws Exception {
69
        TestListener l = new TestListener();
70
        cp.addPropertyChangeListener(l);
71
        Properties p = new Properties();
72
        p.setProperty("$label", "Debug");
73
        write(p, d, "nbproject/configs/debug.properties");
74
        p = new Properties();
75
        p.setProperty("$label", "Release");
76
        write(p, d, "nbproject/configs/release.properties");
77
        write(new Properties(), d, "nbproject/configs/misc.properties");
78
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATIONS), l.events());
79
        List/*<ProjectConfiguration>*/ configs = new ArrayList(cp.getConfigurations());
80
        assertEquals(4, configs.size());
81
        assertEquals("<default>", ((ProjectConfiguration) configs.get(0)).getDisplayName());
82
        assertEquals("Debug", ((ProjectConfiguration) configs.get(1)).getDisplayName());
83
        assertEquals("misc", ((ProjectConfiguration) configs.get(2)).getDisplayName());
84
        assertEquals("Release", ((ProjectConfiguration) configs.get(3)).getDisplayName());
85
        assertEquals(Collections.emptySet(), l.events());
86
        d.getFileObject("nbproject/configs/debug.properties").delete();
87
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATIONS), l.events());
88
        configs = new ArrayList(cp.getConfigurations());
89
        assertEquals(3, configs.size());
90
        d.getFileObject("nbproject/configs").delete();
91
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATIONS), l.events());
92
        configs = new ArrayList(cp.getConfigurations());
93
        assertEquals(1, configs.size());
94
        write(new Properties(), d, "nbproject/configs/misc.properties");
95
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATIONS), l.events());
96
        configs = new ArrayList(cp.getConfigurations());
97
        assertEquals(2, configs.size());
98
    }
99
100
    public void testActiveConfiguration() throws Exception {
101
        write(new Properties(), d, "nbproject/configs/debug.properties");
102
        write(new Properties(), d, "nbproject/configs/release.properties");
103
        TestListener l = new TestListener();
104
        cp.addPropertyChangeListener(l);
105
        ProjectConfiguration def = cp.getActiveConfiguration();
106
        assertEquals("<default>", def.getDisplayName());
107
        List/*<ProjectConfiguration>*/ configs = new ArrayList(cp.getConfigurations());
108
        assertEquals(3, configs.size());
109
        ProjectConfiguration c = (ProjectConfiguration) configs.get(2);
110
        assertEquals("release", c.getDisplayName());
111
        cp.setActiveConfiguration(c);
112
        assertEquals(c, cp.getActiveConfiguration());
113
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE), l.events());
114
        cp.setActiveConfiguration(c);
115
        assertEquals(c, cp.getActiveConfiguration());
116
        assertEquals(Collections.emptySet(), l.events());
117
        cp.setActiveConfiguration(def);
118
        assertEquals(def, cp.getActiveConfiguration());
119
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE), l.events());
120
        try {
121
            cp.setActiveConfiguration(null);
122
            fail();
123
        } catch (IllegalArgumentException x) {/*OK*/}
124
        assertEquals(Collections.emptySet(), l.events());
125
        try {
126
            cp.setActiveConfiguration(new ProjectConfiguration() {
127
                public String getDisplayName() {
128
                    return "bogus";
129
                }
130
            });
131
            fail();
132
        } catch (IllegalArgumentException x) {/*OK*/}
133
        assertEquals(Collections.emptySet(), l.events());
134
        EditableProperties ep = new EditableProperties();
135
        ep.setProperty("config", "debug");
136
        p.getAntProjectHelper().putProperties("nbproject/private/config.properties", ep);
137
        assertEquals("debug", cp.getActiveConfiguration().getDisplayName());
138
        assertEquals(Collections.singleton(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE), l.events());
139
    }
140
141
    public void testEvaluator() throws Exception {
142
        PropertyEvaluator eval = p.evaluator();
143
        TestListener l = new TestListener();
144
        eval.addPropertyChangeListener(l);
145
        Properties p = new Properties();
146
        p.setProperty("debug", "true");
147
        write(p, d, "nbproject/configs/debug.properties");
148
        p = new Properties();
149
        p.setProperty("debug", "false");
150
        write(p, d, "nbproject/configs/release.properties");
151
        p = new Properties();
152
        p.setProperty("more", "stuff");
153
        write(p, d, "nbproject/private/configs/release.properties");
154
        List/*<ProjectConfiguration>*/ configs = new ArrayList(cp.getConfigurations());
155
        assertEquals(3, configs.size());
156
        ProjectConfiguration c = (ProjectConfiguration) configs.get(1);
157
        assertEquals("debug", c.getDisplayName());
158
        cp.setActiveConfiguration(c);
159
        assertEquals(new HashSet(Arrays.asList(new String[] {"config", "debug"})), l.events());
160
        assertEquals("debug", eval.getProperty("config"));
161
        assertEquals("true", eval.getProperty("debug"));
162
        assertEquals(null, eval.getProperty("more"));
163
        c = (ProjectConfiguration) configs.get(2);
164
        assertEquals("release", c.getDisplayName());
165
        cp.setActiveConfiguration(c);
166
        assertEquals(new HashSet(Arrays.asList(new String[] {"config", "debug", "more"})), l.events());
167
        assertEquals("release", eval.getProperty("config"));
168
        assertEquals("false", eval.getProperty("debug"));
169
        assertEquals("stuff", eval.getProperty("more"));
170
        c = (ProjectConfiguration) configs.get(0);
171
        assertEquals("<default>", c.getDisplayName());
172
        cp.setActiveConfiguration(c);
173
        assertEquals(new HashSet(Arrays.asList(new String[] {"config", "debug", "more"})), l.events());
174
        assertEquals(null, eval.getProperty("config"));
175
        assertEquals(null, eval.getProperty("debug"));
176
        assertEquals(null, eval.getProperty("more"));
177
        // XXX test nbproject/private/configs/*.properties
178
    }
179
180
    private void write(Properties p, FileObject d, String path) throws IOException {
181
        FileObject f = FileUtil.createData(d, path);
182
        OutputStream os = f.getOutputStream();
183
        p.store(os, null);
184
        os.close();
185
    }
186
187
    private static final class TestListener implements PropertyChangeListener {
188
        private Set/*<String>*/ events = new HashSet();
189
        public void propertyChange(PropertyChangeEvent evt) {
190
            events.add(evt.getPropertyName());
191
        }
192
        public Set/*<String>*/ events() {
193
            Set/*<String>*/ copy = events;
194
            events = new HashSet();
195
            return copy;
196
        }
197
    }
198
199
}

Return to bug 49636