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

(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/api/J2SECustomPropertySaver.java (+2 lines)
Lines 46-51 Link Here
46
 * if modified by user in Project Properties dialog.
46
 * if modified by user in Project Properties dialog.
47
 * Implementation of the interface should be registered using {@link org.netbeans.spi.project.ProjectServiceProvider}.
47
 * Implementation of the interface should be registered using {@link org.netbeans.spi.project.ProjectServiceProvider}.
48
 * 
48
 * 
49
 * Note: alternatively use org.netbeans.spi.project.ui.support.ProjectCustomizer.Category.setStoreListener
50
 * 
49
 * @author Petr Somol
51
 * @author Petr Somol
50
 * @since 1.46
52
 * @since 1.46
51
 */
53
 */
(-)a/javafx2.project/manifest.mf (-1 / +1 lines)
Lines 3-6 Link Here
3
OpenIDE-Module: org.netbeans.modules.javafx2.project
3
OpenIDE-Module: org.netbeans.modules.javafx2.project
4
OpenIDE-Module-Layer: org/netbeans/modules/javafx2/project/layer.xml
4
OpenIDE-Module-Layer: org/netbeans/modules/javafx2/project/layer.xml
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javafx2/project/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javafx2/project/Bundle.properties
6
OpenIDE-Module-Specification-Version: 1.9
6
OpenIDE-Module-Specification-Version: 1.10
(-)a/javafx2.project/nbproject/project.properties (-1 / +1 lines)
Lines 1-4 Link Here
1
javac.source=1.6
1
javac.source=1.6
2
javac.compilerargs=-Xlint -Xlint:-serial
2
javac.compilerargs=-Xlint -Xlint:-serial
3
3
4
test.config.stable.includes=**/NewJavaFX2ProjectTest.class
4
test.config.stable.includes=**/NewJavaFX2ProjectTest.class
(-)a/javafx2.project/nbproject/project.xml (-1 / +1 lines)
Lines 161-167 Link Here
161
                    <compile-dependency/>
161
                    <compile-dependency/>
162
                    <run-dependency>
162
                    <run-dependency>
163
                        <release-version>1</release-version>
163
                        <release-version>1</release-version>
164
                        <specification-version>1.49.0.8</specification-version>
164
                        <specification-version>1.64</specification-version>
165
                    </run-dependency>
165
                    </run-dependency>
166
                </dependency>
166
                </dependency>
167
                <dependency>
167
                <dependency>
(-)a/javafx2.project/src/org/netbeans/modules/javafx2/project/JFXProjectProperties.java (+3 lines)
Lines 491-497 Link Here
491
     * 
491
     * 
492
     * @param category marker string to indicate which category provider is calling this
492
     * @param category marker string to indicate which category provider is calling this
493
     * @return instance of JFXProjectProperties shared among category panels in the current Project Properties dialog only
493
     * @return instance of JFXProjectProperties shared among category panels in the current Project Properties dialog only
494
     * 
495
     * @deprecated handle cleanup using ProjectCustomizer.Category.setCloseListener instead
494
     */
496
     */
497
    @Deprecated
495
    public static JFXProjectProperties getInstancePerSession(Lookup context, String category) {
498
    public static JFXProjectProperties getInstancePerSession(Lookup context, String category) {
496
        Project proj = context.lookup(Project.class);
499
        Project proj = context.lookup(Project.class);
497
        String projDir = proj.getProjectDirectory().getPath();
500
        String projDir = proj.getProjectDirectory().getPath();
(-)a/javafx2.project/src/org/netbeans/modules/javafx2/project/ui/JFXProjectPropertiesSaver.java (-73 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common Development and
11
 * Distribution License("CDDL") (collectively, the "License"). You may not use
12
 * this file except in compliance with the License. You can obtain a copy of
13
 * the License at http://www.netbeans.org/cddl-gplv2.html or
14
 * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language
15
 * governing permissions and limitations under the License. When distributing
16
 * the software, include this License Header Notice in each file and include
17
 * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
18
 * particular file as subject to the "Classpath" exception as provided by
19
 * Oracle in the GPL Version 2 section of the License file that accompanied
20
 * this code. If applicable, add the following below the License Header, with
21
 * the fields enclosed by brackets [] replaced by your own identifying
22
 * information: "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL or
25
 * only the GPL Version 2, indicate your decision by adding "[Contributor]
26
 * elects to include this software in this distribution under the [CDDL or GPL
27
 * Version 2] license." If you do not indicate a single choice of license, a
28
 * recipient has the option to distribute your version of this file under
29
 * either the CDDL, the GPL Version 2 or to extend the choice of license to its
30
 * licensees as provided above. However, if you add GPL Version 2 code and
31
 * therefore, elected the GPL Version 2 license, then the option applies only
32
 * if the new code is made subject to such option by the copyright holder.
33
 *
34
 * Contributor(s):
35
 *
36
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
37
 */
38
package org.netbeans.modules.javafx2.project.ui;
39
40
import java.io.IOException;
41
import org.netbeans.api.project.Project;
42
import org.netbeans.modules.java.j2seproject.api.J2SECustomPropertySaver;
43
import org.netbeans.modules.javafx2.project.JFXProjectProperties;
44
import org.netbeans.spi.project.ProjectServiceProvider;
45
import org.openide.util.Exceptions;
46
47
/**
48
 * Provides saver service for JavaFX 2.0 specific project properties
49
 * for use in standard J2SE Project Properties dialog so that all properties
50
 * can be properly saved in project.properties and private.properties when 
51
 * OK button is pressed.
52
 * 
53
 * @author Petr Somol
54
 */
55
@ProjectServiceProvider(service=J2SECustomPropertySaver.class, projectType="org-netbeans-modules-java-j2seproject")
56
public class JFXProjectPropertiesSaver implements J2SECustomPropertySaver {
57
   
58
    public JFXProjectPropertiesSaver() {}
59
    
60
    @Override
61
    public void save(Project project) {
62
        JFXProjectProperties prop = JFXProjectProperties.getInstanceIfExists(project.getLookup());
63
        if(prop != null) {
64
            try {
65
                prop.store();
66
                JFXProjectProperties.cleanup(project.getLookup());
67
            } catch (IOException ex) {
68
                Exceptions.printStackTrace(ex);
69
            }
70
        }
71
    }
72
    
73
}
(-)a/javafx2.project/src/org/netbeans/modules/javafx2/project/ui/JFXRunCategoryProvider.java (-4 / +45 lines)
Lines 37-48 Link Here
37
 */
37
 */
38
package org.netbeans.modules.javafx2.project.ui;
38
package org.netbeans.modules.javafx2.project.ui;
39
39
40
import java.awt.event.ActionEvent;
41
import java.awt.event.ActionListener;
42
import java.io.IOException;
43
import java.util.HashMap;
44
import java.util.Map;
40
import javax.swing.JComponent;
45
import javax.swing.JComponent;
41
import org.netbeans.api.project.Project;
46
import org.netbeans.api.project.Project;
42
import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator;
47
import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator;
43
import org.netbeans.modules.javafx2.project.JFXProjectProperties;
48
import org.netbeans.modules.javafx2.project.JFXProjectProperties;
44
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
49
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
45
import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category;
50
import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category;
51
import org.openide.util.Exceptions;
46
import org.openide.util.Lookup;
52
import org.openide.util.Lookup;
47
import org.openide.util.NbBundle;
53
import org.openide.util.NbBundle;
48
54
Lines 56-62 Link Here
56
62
57
    private static final String CAT_RUN = "Run"; // NOI18N
63
    private static final String CAT_RUN = "Run"; // NOI18N
58
    
64
    
59
    private static JFXProjectProperties jfxProps = null;
65
    private static final Map<String, JFXProjectProperties> projectProperties = new HashMap<String, JFXProjectProperties>();
60
       
66
       
61
    @Override
67
    @Override
62
    public Category createCategory(Lookup context) {
68
    public Category createCategory(Lookup context) {
Lines 68-83 Link Here
68
                    && !JFXProjectProperties.isTrue(j2sepe.evaluator().getProperty(JFXProjectProperties.JAVAFX_PRELOADER)); //NOI18N
74
                    && !JFXProjectProperties.isTrue(j2sepe.evaluator().getProperty(JFXProjectProperties.JAVAFX_PRELOADER)); //NOI18N
69
        }
75
        }
70
        if(fxProjectEnabled) {
76
        if(fxProjectEnabled) {
71
            jfxProps = JFXProjectProperties.getInstancePerSession(context, CAT_RUN);
77
            ProjectCustomizer.Category c = ProjectCustomizer.Category.create(CAT_RUN,
72
            return ProjectCustomizer.Category.create(CAT_RUN,
73
                    NbBundle.getMessage(JFXRunCategoryProvider.class, "LBL_Category_Run"), null); //NOI18N
78
                    NbBundle.getMessage(JFXRunCategoryProvider.class, "LBL_Category_Run"), null); //NOI18N
79
            c.setOkButtonListener(new ActionListener() {
80
                @Override
81
                public void actionPerformed(ActionEvent e) {
82
                    if(project != null) {
83
                        JFXProjectProperties prop = JFXProjectProperties.getInstanceIfExists(project.getLookup());
84
                        if(prop != null) {
85
                            projectProperties.put(project.getProjectDirectory().getPath(), prop);
86
                        }
87
                    }
88
                }
89
            });
90
            c.setStoreListener(new ActionListener() {
91
                @Override
92
                public void actionPerformed(ActionEvent e) {
93
                    if(project != null) {
94
                        JFXProjectProperties prop = projectProperties.get(project.getProjectDirectory().getPath());
95
                        if(prop != null) {
96
                            try {
97
                                prop.store();
98
                            } catch (IOException ex) {
99
                                Exceptions.printStackTrace(ex);
100
                            }
101
                        }
102
                        projectProperties.remove(project.getProjectDirectory().getPath());
103
                    }
104
                }
105
            });
106
            c.setCloseListener(new ActionListener() {
107
                @Override
108
                public void actionPerformed(ActionEvent e) {
109
                    if(project != null) {
110
                        JFXProjectProperties.cleanup(project.getLookup());
111
                    }
112
                }
113
            });
114
            return c;
74
        }
115
        }
75
        return null;
116
        return null;
76
    }
117
    }
77
118
78
    @Override
119
    @Override
79
    public JComponent createComponent(Category category, Lookup context) {
120
    public JComponent createComponent(Category category, Lookup context) {
80
        return new JFXRunPanel(jfxProps);
121
        return new JFXRunPanel(JFXProjectProperties.getInstance(context));
81
    }
122
    }
82
123
83
}
124
}
(-)a/javawebstart/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.netbeans.modules.javawebstart
2
OpenIDE-Module: org.netbeans.modules.javawebstart
3
OpenIDE-Module-Layer: org/netbeans/modules/javawebstart/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/javawebstart/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javawebstart/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javawebstart/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.19
5
OpenIDE-Module-Specification-Version: 1.20
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
(-)a/javawebstart/nbproject/project.xml (-1 / +1 lines)
Lines 152-158 Link Here
152
                    <compile-dependency/>
152
                    <compile-dependency/>
153
                    <run-dependency>
153
                    <run-dependency>
154
                        <release-version>1</release-version>
154
                        <release-version>1</release-version>
155
                        <specification-version>1.37</specification-version>
155
                        <specification-version>1.64</specification-version>
156
                    </run-dependency>
156
                    </run-dependency>
157
                </dependency>
157
                </dependency>
158
                <dependency>
158
                <dependency>
(-)a/javawebstart/src/org/netbeans/modules/javawebstart/ui/customizer/Bundle.properties (-1 / +1 lines)
Lines 261-264 Link Here
261
ERR_MissingPlatformLocation=Java platform {0} location property missing. Attempting to switch to default WebStart.
261
ERR_MissingPlatformLocation=Java platform {0} location property missing. Attempting to switch to default WebStart.
262
ERR_MissingPlatformLib=Java platform {0} library {1} could not be located.
262
ERR_MissingPlatformLib=Java platform {0} library {1} could not be located.
263
ERR_LibFileMissing=Library file {0} not found! Switching WebStart off.
263
ERR_LibFileMissing=Library file {0} not found! Switching WebStart off.
264
ERR_ClassPathProblem=Classpath property {0} decoding problem. Paths to WebStart libraries may be decoded wrong.
264
ERR_ClassPathProblem=Classpath property {0} decoding problem. Paths to WebStart libraries may be decoded wrong.
(-)a/javawebstart/src/org/netbeans/modules/javawebstart/ui/customizer/JWSCompositeCategoryProvider.java (-5 / +44 lines)
Lines 44-49 Link Here
44
44
45
package org.netbeans.modules.javawebstart.ui.customizer;
45
package org.netbeans.modules.javawebstart.ui.customizer;
46
46
47
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionListener;
49
import java.util.HashMap;
50
import java.util.Map;
47
import javax.swing.JComponent;
51
import javax.swing.JComponent;
48
import org.netbeans.api.project.Project;
52
import org.netbeans.api.project.Project;
49
import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator;
53
import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator;
Lines 62-69 Link Here
62
66
63
    private static final String CAT_WEBSTART = "WebStart"; // NOI18N
67
    private static final String CAT_WEBSTART = "WebStart"; // NOI18N
64
    
68
    
65
    private static JWSProjectProperties jwsProps = null;
69
    private static final Map<String, JWSProjectProperties> projectProperties = new HashMap<String, JWSProjectProperties>();
66
70
    
67
    public JWSCompositeCategoryProvider() {}
71
    public JWSCompositeCategoryProvider() {}
68
    
72
    
69
    @Override
73
    @Override
Lines 74-87 Link Here
74
            final J2SEPropertyEvaluator j2sepe = project.getLookup().lookup(J2SEPropertyEvaluator.class);
78
            final J2SEPropertyEvaluator j2sepe = project.getLookup().lookup(J2SEPropertyEvaluator.class);
75
            fxOverride = JWSProjectProperties.isTrue(j2sepe.evaluator().getProperty("javafx.enabled")); //NOI18N
79
            fxOverride = JWSProjectProperties.isTrue(j2sepe.evaluator().getProperty("javafx.enabled")); //NOI18N
76
        }
80
        }
77
        jwsProps = JWSProjectProperties.getInstancePerSession(context, CAT_WEBSTART);
81
        if(!fxOverride) {
78
        return fxOverride ? null : ProjectCustomizer.Category.create(CAT_WEBSTART,
82
            ProjectCustomizer.Category c = ProjectCustomizer.Category.create(CAT_WEBSTART,
79
                    NbBundle.getMessage(JWSCompositeCategoryProvider.class, "LBL_Category_WebStart"), null); //NOI18N
83
                    NbBundle.getMessage(JWSCompositeCategoryProvider.class, "LBL_Category_WebStart"), null); //NOI18N
84
            c.setOkButtonListener(new ActionListener() {
85
                @Override
86
                public void actionPerformed(ActionEvent e) {
87
                    if(project != null) {
88
                        JWSProjectProperties prop = JWSProjectProperties.getInstanceIfExists(project.getLookup());
89
                        if(prop != null) {
90
                            projectProperties.put(project.getProjectDirectory().getPath(), prop);
91
                        }
92
                    }
93
                }
94
            });
95
            c.setStoreListener(new ActionListener() {
96
                @Override
97
                public void actionPerformed(ActionEvent e) {
98
                    if(project != null) {
99
                        JWSProjectProperties prop = projectProperties.get(project.getProjectDirectory().getPath());
100
                        if(prop != null) {
101
                            JWSProjectPropertiesUtils.updateMasterFiles(prop, project);
102
                            JWSProjectPropertiesUtils.savePropsAndUpdateMetaFiles(prop, project);
103
                        }
104
                        projectProperties.remove(project.getProjectDirectory().getPath());
105
                    }
106
                }
107
            });
108
            c.setCloseListener(new ActionListener() {
109
                @Override
110
                public void actionPerformed(ActionEvent e) {
111
                    if(project != null) {
112
                        JWSProjectProperties.cleanup(project.getLookup());
113
                    }
114
                }
115
            });
116
            return c;
117
        }
118
        return null;
80
    }
119
    }
81
    
120
    
82
    @Override
121
    @Override
83
    public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) {
122
    public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) {
84
        return new JWSCustomizerPanel(jwsProps);
123
        return new JWSCustomizerPanel(JWSProjectProperties.getInstance(context));
85
    }
124
    }
86
125
87
}
126
}
(-)a/javawebstart/src/org/netbeans/modules/javawebstart/ui/customizer/JWSProjectProperties.java (-3 / +6 lines)
Lines 263-278 Link Here
263
263
264
    /** Factory method 
264
    /** Factory method 
265
     * This is to prevent reuse of the same instance after the properties dialog
265
     * This is to prevent reuse of the same instance after the properties dialog
266
     * has been cancelled. Called by each FX category provider at the time
266
     * has been cancelled. Called by each WS category provider at the time
267
     * when properties dialog is opened, it checks/stores category-specific marker strings. 
267
     * when properties dialog is opened, it checks/stores category-specific marker strings. 
268
     * Previous existence of marker string indicates that properties dialog had been opened
268
     * Previous existence of marker string indicates that properties dialog had been opened
269
     * before and ended by Cancel, otherwise this instance would not exist (OK would
269
     * before and ended by Cancel, otherwise this instance would not exist (OK would
270
     * cause properties to be saved and the instance deleted by a call to JFXProjectProperties.cleanup()).
270
     * cause properties to be saved and the instance deleted by a call to JWSProjectProperties.cleanup()).
271
     * (Note that this is a workaround to avoid adding listener to properties dialog close event.)
271
     * (Note that this is a workaround to avoid adding listener to properties dialog close event.)
272
     * 
272
     * 
273
     * @param category marker string to indicate which category provider is calling this
273
     * @param category marker string to indicate which category provider is calling this
274
     * @return instance of JFXProjectProperties shared among category panels in the current Project Properties dialog only
274
     * @return instance of JWSProjectProperties shared among category panels in the current Project Properties dialog only
275
     * 
276
     * @deprecated handle cleanup using ProjectCustomizer.Category.setCloseListener instead
275
     */
277
     */
278
    @Deprecated
276
    public static JWSProjectProperties getInstancePerSession(Lookup context, String category) {
279
    public static JWSProjectProperties getInstancePerSession(Lookup context, String category) {
277
        Project proj = context.lookup(Project.class);
280
        Project proj = context.lookup(Project.class);
278
        String projDir = proj.getProjectDirectory().getPath();
281
        String projDir = proj.getProjectDirectory().getPath();
(-)a/javawebstart/src/org/netbeans/modules/javawebstart/ui/customizer/JWSProjectPropertiesSaver.java (-71 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.javawebstart.ui.customizer;
43
44
import org.netbeans.api.project.Project;
45
import org.netbeans.modules.java.j2seproject.api.J2SECustomPropertySaver;
46
import org.netbeans.spi.project.ProjectServiceProvider;
47
48
/**
49
 * Provides saver service for WebStart specific project properties
50
 * for use in standard J2SE Project Properties dialog so that all properties
51
 * can be properly saved in project.properties and private.properties when
52
 * OK button is pressed. Note that this enables reaction to change of Java Platform.
53
 *
54
 * @author Petr Somol
55
 */
56
@ProjectServiceProvider(service=J2SECustomPropertySaver.class, projectType="org-netbeans-modules-java-j2seproject")
57
public class JWSProjectPropertiesSaver implements J2SECustomPropertySaver {
58
59
    public JWSProjectPropertiesSaver() {}
60
61
    @Override
62
    public void save(Project project) {
63
        JWSProjectProperties prop = JWSProjectProperties.getInstanceIfExists(project.getLookup());
64
        if(prop != null) {
65
            JWSProjectPropertiesUtils.updateMasterFiles(prop, project);
66
            JWSProjectPropertiesUtils.savePropsAndUpdateMetaFiles(prop, project);
67
            JWSProjectProperties.cleanup(project.getLookup());
68
        }
69
    }
70
71
}
(-)a/projectuiapi/apichanges.xml (+23 lines)
Lines 107-112 Link Here
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
108
109
    <changes>
109
    <changes>
110
        <change id="ProjectCustomizer.Category.CloseListener">
111
            <api name="general"/>
112
            <summary>Added Close listener to ProjectCustomizer.Category.</summary>
113
            <version major="1" minor="64"/>
114
            <date day="1" month="11" year="2012"/>
115
            <author login="psomol"/>
116
            <compatibility addition="yes"/>
117
            <description>
118
                <p>
119
                    Added a Close listener to ProjectCustomizer.Category to enable
120
                    correct memory management when specific project properties are
121
                    to be maintained while Project Properties dialog is displayed,
122
                    containing various, possibly extended, categories. This is the case
123
                    with JWSProjectProperties and JFXProjectProperties, where cleanup
124
                    is needed at the time of dialog closing. The introduction of
125
                    a Close listener here actually enables to deprecate J2SECustomPropertySaver
126
                    interface and thus make the same mechanism available even outside
127
                    J2SE projects.
128
                </p>
129
            </description>
130
            <class package="org.netbeans.spi.project.ui.support" name="ProjectCustomizer"/>
131
            <issue number="219827"/>
132
        </change>
110
        <change id="ProjectProblemsProviderSupport">
133
        <change id="ProjectProblemsProviderSupport">
111
            <api name="general"/>
134
            <api name="general"/>
112
            <summary>Added a support class for ProjectProblemsProvider.</summary>
135
            <summary>Added a support class for ProjectProblemsProvider.</summary>
(-)a/projectuiapi/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javac.compilerargs=-Xlint -Xlint:-serial
43
javac.compilerargs=-Xlint -Xlint:-serial
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=1.63.0
45
spec.version.base=1.64.0
46
is.autoload=true
46
is.autoload=true
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/CustomizerDialog.java (+8 lines)
Lines 101-106 Link Here
101
    private static final String COMMAND_OK = "OK";          // NOI18N
101
    private static final String COMMAND_OK = "OK";          // NOI18N
102
    private static final String COMMAND_CANCEL = "CANCEL";  // NOI18N
102
    private static final String COMMAND_CANCEL = "CANCEL";  // NOI18N
103
103
104
    // Close action
105
    private static final int ACTION_CLOSE = OPTION_CANCEL + 1;
106
104
    private static final String CUSTOMIZER_DIALOG_X = "CustomizerDialog.dialog.x";
107
    private static final String CUSTOMIZER_DIALOG_X = "CustomizerDialog.dialog.x";
105
    private static final String CUSTOMIZER_DIALOG_Y = "CustomizerDialog.dialog.y";
108
    private static final String CUSTOMIZER_DIALOG_Y = "CustomizerDialog.dialog.y";
106
    private static final String CUSTOMIZER_DIALOG_WIDTH = "CustomizerDialog.dialog.width";
109
    private static final String CUSTOMIZER_DIALOG_WIDTH = "CustomizerDialog.dialog.width";
Lines 214-219 Link Here
214
217
215
                    Utilities.removeCategoryChangeSupport(category);
218
                    Utilities.removeCategoryChangeSupport(category);
216
219
220
                    ActionListener listener = category.getCloseListener();
221
                    if (listener != null) {
222
                        listener.actionPerformed(new ActionEvent(this, ACTION_CLOSE, e.paramString()));
223
                    }
224
                    
217
                    if (category.getSubcategories() != null) {
225
                    if (category.getSubcategories() != null) {
218
                        queue.addAll(Arrays.asList(category.getSubcategories()));
226
                        queue.addAll(Arrays.asList(category.getSubcategories()));
219
                    }
227
                    }
(-)a/projectuiapi/src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java (+21 lines)
Lines 422-427 Link Here
422
        private String errorMessage;
422
        private String errorMessage;
423
        private ActionListener okListener;
423
        private ActionListener okListener;
424
        private ActionListener storeListener;
424
        private ActionListener storeListener;
425
        private ActionListener closeListener;
425
        
426
        
426
        /** Private constructor. See the factory method.
427
        /** Private constructor. See the factory method.
427
         */
428
         */
Lines 573-578 Link Here
573
        public ActionListener getStoreListener() {
574
        public ActionListener getStoreListener() {
574
            return storeListener;
575
            return storeListener;
575
        }
576
        }
577
578
        /**
579
         * Set the action listener that will get notified when the customizer is going to be closed
580
         * Listener is executed outside of AWT EventQueue. Usually to be used to do cleanup.
581
         * @param listener ActionListener to notify 
582
         * @since org.netbeans.modules.projectuiapi/1 1.64
583
         */
584
        public void setCloseListener(ActionListener listener) {
585
            closeListener = listener;
586
        }
587
        
588
        /**
589
         * Returns the action listener that is executed outside of AWT EQ and is associated 
590
         * with this category that gets notified when the customizer is going to be closed.
591
         * @return instance of ActionListener or null if not set.
592
         * @since org.netbeans.modules.projectuiapi/1 1.64
593
         */
594
        public ActionListener getCloseListener() {
595
            return closeListener;
596
        }
576
        
597
        
577
    }
598
    }
578
599
(-)a/projectuiapi/test/unit/src/org/netbeans/spi/project/ui/support/ProjectCustomizerListenersTest.java (-11 / +60 lines)
Lines 23-29 Link Here
23
import java.awt.event.ActionListener;
23
import java.awt.event.ActionListener;
24
import java.lang.reflect.InvocationTargetException;
24
import java.lang.reflect.InvocationTargetException;
25
import java.util.ArrayList;
25
import java.util.ArrayList;
26
import java.util.HashMap;
26
import java.util.List;
27
import java.util.List;
28
import java.util.Map;
27
import javax.swing.JButton;
29
import javax.swing.JButton;
28
import javax.swing.JComponent;
30
import javax.swing.JComponent;
29
import javax.swing.JDialog;
31
import javax.swing.JDialog;
Lines 44-52 Link Here
44
import org.openide.util.HelpCtx;
46
import org.openide.util.HelpCtx;
45
47
46
/**
48
/**
47
 * Test of OK and Store listeners of ProjectCustomzier dialog
49
 * Test of OK, Store and Close listeners of ProjectCustomzier dialog
48
 * 
50
 * 
49
 * @author Milan Kubec
51
 * @author Milan Kubec, Petr Somol
50
 */
52
 */
51
public class ProjectCustomizerListenersTest extends NbTestCase {
53
public class ProjectCustomizerListenersTest extends NbTestCase {
52
    
54
    
Lines 55-61 Link Here
55
    }
57
    }
56
58
57
    private List<EventRecord> events = new ArrayList<EventRecord>();
59
    private List<EventRecord> events = new ArrayList<EventRecord>();
58
    private enum LType { OK, STORE };
60
    private enum LType { OK, STORE, CLOSE };
59
    
61
    
60
    public ProjectCustomizerListenersTest(String name) {
62
    public ProjectCustomizerListenersTest(String name) {
61
        super(name);
63
        super(name);
Lines 68-74 Link Here
68
        events.clear();
70
        events.clear();
69
    }
71
    }
70
    
72
    
71
    public void testOKAndStoreListeners() {
73
    public void testAllListeners() {
72
        
74
        
73
        Category testCat1 = Category.create("test1", "test1", null);
75
        Category testCat1 = Category.create("test1", "test1", null);
74
        final Category testCat2 = Category.create("test2", "test2", null, testCat1);
76
        final Category testCat2 = Category.create("test2", "test2", null, testCat1);
Lines 76-95 Link Here
76
        
78
        
77
        testCat1.setOkButtonListener(new Listener(LType.OK, "testCat1", true));
79
        testCat1.setOkButtonListener(new Listener(LType.OK, "testCat1", true));
78
        testCat1.setStoreListener(new Listener(LType.STORE, "testCat1", false));
80
        testCat1.setStoreListener(new Listener(LType.STORE, "testCat1", false));
81
        testCat1.setCloseListener(new Listener(LType.CLOSE, "testCat1", true));
79
        testCat2.setOkButtonListener(new Listener(LType.OK, "testCat2", true));
82
        testCat2.setOkButtonListener(new Listener(LType.OK, "testCat2", true));
80
        testCat2.setStoreListener(new Listener(LType.STORE, "testCat2", false));
83
        testCat2.setStoreListener(new Listener(LType.STORE, "testCat2", false));
84
        testCat2.setCloseListener(new Listener(LType.CLOSE, "testCat2", true));
81
        testCat3.setOkButtonListener(new Listener(LType.OK, "testCat3", true));
85
        testCat3.setOkButtonListener(new Listener(LType.OK, "testCat3", true));
82
        testCat3.setStoreListener(new Listener(LType.STORE, "testCat3", false));
86
        testCat3.setStoreListener(new Listener(LType.STORE, "testCat3", false));
87
        testCat3.setCloseListener(new Listener(LType.CLOSE, "testCat3", true));
83
        
88
        
84
        final Listener mainOKListener = new Listener(LType.OK, "Properties", true);
89
        final Listener mainOKListener = new Listener(LType.OK, "Properties", true);
85
        final Listener mainStoreListener = new Listener(LType.STORE, "Properties", false);
90
        final Listener mainStoreListener = new Listener(LType.STORE, "Properties", false);
86
        
91
        
87
        try {
92
        try {
88
            SwingUtilities.invokeAndWait(new Runnable() {
93
            SwingUtilities.invokeAndWait(new Runnable() {
94
                @Override
89
                public void run() {
95
                public void run() {
90
                    ProjectCustomizer.createCustomizerDialog(new Category[]{ testCat2, testCat3 }, 
96
                    Dialog dialog = ProjectCustomizer.createCustomizerDialog(new Category[]{ testCat2, testCat3 }, 
91
                        new CategoryComponentProviderImpl(), null, mainOKListener, mainStoreListener, 
97
                        new CategoryComponentProviderImpl(), null, mainOKListener, mainStoreListener, 
92
                        HelpCtx.DEFAULT_HELP);
98
                        HelpCtx.DEFAULT_HELP);
99
                    dialog.pack();
100
                    dialog.setVisible(true);
101
                    dialog.dispose();
93
                }
102
                }
94
            });
103
            });
95
        } catch (InterruptedException ex) {
104
        } catch (InterruptedException ex) {
Lines 109-124 Link Here
109
//            System.out.println(er);
118
//            System.out.println(er);
110
//        }
119
//        }
111
        
120
        
112
        assertEquals(8, events.size());
121
        assertEquals(14, events.size());
113
        assertEquals(new EventRecord(LType.OK, "Properties", 0), events.get(0));
122
        assertEquals(new EventRecord(LType.OK, "Properties", 0), events.get(0));
114
        assertEquals(new EventRecord(LType.OK, "testCat2", 0), events.get(1));
123
        assertEquals(new EventRecord(LType.OK, "testCat2", 0), events.get(1));
115
        assertEquals(new EventRecord(LType.OK, "testCat1", 0), events.get(2));
124
        assertEquals(new EventRecord(LType.OK, "testCat1", 0), events.get(2));
116
        assertEquals(new EventRecord(LType.OK, "testCat3", 0), events.get(3));
125
        assertEquals(new EventRecord(LType.OK, "testCat3", 0), events.get(3));
117
        assertEquals(new EventRecord(LType.STORE, "Properties", 0), events.get(4));
126
        // CLOSE and STORE events can theoretically be intermixed
118
        assertEquals(new EventRecord(LType.STORE, "testCat2", 0), events.get(5));
127
        Map<String, Integer> event = new HashMap<String, Integer>();
119
        assertEquals(new EventRecord(LType.STORE, "testCat1", 0), events.get(6));
128
        for(int i = 4; i < 14; i++) {
120
        assertEquals(new EventRecord(LType.STORE, "testCat3", 0), events.get(7));
129
            EventRecord er = events.get(i);
121
        
130
            assertNotNull(er);
131
            assertTrue(er.getType() != LType.OK);
132
            Integer count = event.get(er.getTypeAndId());
133
            if(count == null) {
134
                event.put(er.getTypeAndId(), 1);
135
            } else {
136
                event.put(er.getTypeAndId(), count + 1);
137
            }
138
        }
139
        assertEquals(7, event.size());
140
        assertNotNull(event.get((new EventRecord(LType.STORE, "Properties", 0)).getTypeAndId()));
141
        assertNotNull(event.get((new EventRecord(LType.STORE, "testCat2", 0)).getTypeAndId()));
142
        assertNotNull(event.get((new EventRecord(LType.STORE, "testCat1", 0)).getTypeAndId()));
143
        assertNotNull(event.get((new EventRecord(LType.STORE, "testCat3", 0)).getTypeAndId()));
144
        assertNotNull(event.get((new EventRecord(LType.CLOSE, "testCat2", 0)).getTypeAndId()));
145
        assertNotNull(event.get((new EventRecord(LType.CLOSE, "testCat1", 0)).getTypeAndId()));
146
        assertNotNull(event.get((new EventRecord(LType.CLOSE, "testCat3", 0)).getTypeAndId()));
147
        assertEquals(1, event.get((new EventRecord(LType.STORE, "Properties", 0)).getTypeAndId()).intValue());
148
        assertEquals(1, event.get((new EventRecord(LType.STORE, "testCat2", 0)).getTypeAndId()).intValue());
149
        assertEquals(1, event.get((new EventRecord(LType.STORE, "testCat1", 0)).getTypeAndId()).intValue());
150
        assertEquals(1, event.get((new EventRecord(LType.STORE, "testCat3", 0)).getTypeAndId()).intValue());
151
        assertEquals(2, event.get((new EventRecord(LType.CLOSE, "testCat2", 0)).getTypeAndId()).intValue());
152
        assertEquals(2, event.get((new EventRecord(LType.CLOSE, "testCat1", 0)).getTypeAndId()).intValue());
153
        assertEquals(2, event.get((new EventRecord(LType.CLOSE, "testCat3", 0)).getTypeAndId()).intValue());
122
    }
154
    }
123
    
155
    
124
    public void testOKListener() {
156
    public void testOKListener() {
Lines 135-140 Link Here
135
        
167
        
136
        try {
168
        try {
137
            SwingUtilities.invokeAndWait(new Runnable() {
169
            SwingUtilities.invokeAndWait(new Runnable() {
170
                @Override
138
                public void run() {
171
                public void run() {
139
                    ProjectCustomizer.createCustomizerDialog(new Category[]{ testCat2, testCat3 }, 
172
                    ProjectCustomizer.createCustomizerDialog(new Category[]{ testCat2, testCat3 }, 
140
                        new CategoryComponentProviderImpl(), null, mainOKListener, 
173
                        new CategoryComponentProviderImpl(), null, mainOKListener, 
Lines 225-230 Link Here
225
            this.when = when;
258
            this.when = when;
226
        }
259
        }
227
        
260
        
261
        public LType getType() {
262
            return type;
263
        }
264
        
265
        public String getId() {
266
            return id;
267
        }
268
269
        public long getWhen() {
270
            return when;
271
        }
272
273
        public String getTypeAndId() {
274
            return type + ", " + id;
275
        }
276
228
        @Override
277
        @Override
229
        public String toString() {
278
        public String toString() {
230
            return type + ", " + id + ", " + when;
279
            return type + ", " + id + ", " + when;

Return to bug 219827