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

(-)projectui/src/org/netbeans/modules/project/ui/actions/NewProject.java (-2 / +3 lines)
Lines 126-133 Link Here
126
        if (f != null) {
126
        if (f != null) {
127
            wizard.putProperty(CommonProjectActions.PROJECT_PARENT_FOLDER, f);
127
            wizard.putProperty(CommonProjectActions.PROJECT_PARENT_FOLDER, f);
128
        }
128
        }
129
        //#217087 semi-private contract for maven support that carries over properties like groupId and version when creating new submodule.
129
        // carry over properties like e.g. groupId and version from maven when creating new submodule.
130
        String[] moreProps = (String[]) getValue("initialValueProperties");
130
        // see aso issue #217087 and #250190
131
        String[] moreProps = (String[]) getValue(CommonProjectActions.INITIAL_VALUE_PROPERTIES);
131
        if (moreProps != null) {
132
        if (moreProps != null) {
132
            for (String key : moreProps) {
133
            for (String key : moreProps) {
133
                Object obj = getValue(key);
134
                Object obj = getValue(key);
(-)projectui/src/org/netbeans/modules/project/ui/api/ProjectTemplates.java (-1 / +2 lines)
Lines 52-59 Link Here
52
52
53
    /**
53
    /**
54
     * {@link String}-valued action property for a project category (subfolder code name) to select.
54
     * {@link String}-valued action property for a project category (subfolder code name) to select.
55
     * @deprecated use {@link CommonProjectActions.PRESELECT_CATEGORY} instead
55
     */
56
     */
56
    public static final String PRESELECT_CATEGORY = "PRESELECT_CATEGORY";
57
    public static final String PRESELECT_CATEGORY = CommonProjectActions.PRESELECT_CATEGORY;
57
58
58
    /**
59
    /**
59
     * {@link String}-valued action property for a project template (code name within a category) to select.
60
     * {@link String}-valued action property for a project template (code name within a category) to select.
(-)projectuiapi/apichanges.xml (+21 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="newProjectAction.preselectCategory">
111
            <api name="general"/>
112
            <summary>Provide a method to create an action that invokes the new project wizard, 
113
                preselects a category and propagates a set of properties to the wizard descriptor.</summary>
114
            <version major="1" minor="80"/>
115
            <date day="1" month="4" year="2015"/>
116
            <author login="tstupka"/>
117
            <compatibility addition="yes"/>
118
            <description>
119
                <p>
120
                    <code>CommonProjectActions.newProjectAction</code> makes it 
121
                    so far posible to set the new projects parent folder by a 
122
                    property. It would be also usefull to preselect the category 
123
                    and to propagate custom properties to the new project wizard 
124
                    descriptor.
125
                </p>
126
            </description>
127
            <class package="org.netbeans.spi.project.ui.support" name="CommonProjectActions"/>
128
            <issue number="250190"/>
129
        </change>
130
        
110
        <change id="server.is.free">
131
        <change id="server.is.free">
111
            <api name="general"/>
132
            <api name="general"/>
112
            <summary>Split the api into a desktop (swing, awt) and NetBeans dependent and independent part.</summary>
133
            <summary>Split the api into a desktop (swing, awt) and NetBeans dependent and independent part.</summary>
(-)projectuiapi/src/org/netbeans/spi/project/ui/support/CommonProjectActions.java (+49 lines)
Lines 45-50 Link Here
45
package org.netbeans.spi.project.ui.support;
45
package org.netbeans.spi.project.ui.support;
46
46
47
import java.util.List;
47
import java.util.List;
48
import java.util.Map;
48
import javax.swing.Action;
49
import javax.swing.Action;
49
import org.netbeans.modules.project.uiapi.Utilities;
50
import org.netbeans.modules.project.uiapi.Utilities;
50
import org.netbeans.spi.project.ui.LogicalViewProvider;
51
import org.netbeans.spi.project.ui.LogicalViewProvider;
Lines 71-76 Link Here
71
     */
72
     */
72
    public static final String PROJECT_PARENT_FOLDER = "projdir";
73
    public static final String PROJECT_PARENT_FOLDER = "projdir";
73
    
74
    
75
    /**
76
     * {@link String}-valued action property honored by {@link #newProjectAction} 
77
     * that defines the project category (subfolder code name) to be selected.
78
     * 
79
     * @since 1.80
80
     */
81
    public static final String PRESELECT_CATEGORY = "PRESELECT_CATEGORY";
82
83
    /**
84
     * {@link String}[]-valued action property honored by {@link #newProjectAction} 
85
     * for propagating custom properties to the new project wizard's 
86
     * {@link org.openide.WizardDescriptor}
87
     * 
88
     * @since 1.80
89
     */
90
    public static final String INITIAL_VALUE_PROPERTIES = "initialValueProperties";    
91
    
74
    private CommonProjectActions() {}
92
    private CommonProjectActions() {}
75
        
93
        
76
    /**
94
    /**
Lines 206-211 Link Here
206
     * expectations about initial value for wizard
224
     * expectations about initial value for wizard
207
     * choosers that refers to existing sources location.
225
     * choosers that refers to existing sources location.
208
     * 
226
     * 
227
     * <p>{@link #PRESELECT_CATEGORY} keyed action value can carry a {@link String}
228
     * that presents a category path to be selected in the new project wizard.
229
     * 
230
     * <p>{@link #INITIAL_VALUE_PROPERTIES}  keyed action value can carry a 
231
     * {@link Map<String, Object>} of custom properties which are propagated to 
232
     * the new project wizard's {@link org.openide.WizardDescriptor}
233
     * 
209
     * @return an action
234
     * @return an action
210
     *
235
     *
211
     * @since org.netbeans.modules.projectuiapi/1 1.3
236
     * @since org.netbeans.modules.projectuiapi/1 1.3
Lines 215-220 Link Here
215
    }    
240
    }    
216
241
217
    /**
242
    /**
243
     * Creates action that invokes the <b>New Project</b> wizard, preselects the 
244
     * given category path and propagates a set of custom properties the wizard's 
245
     * {@link org.openide.WizardDescriptor}.
246
     * 
247
     * @param categoryPath the category path to be selected
248
     * @param initialProperties a map of custom properties which are propagated 
249
     * to the new project wizard's {@link org.openide.WizardDescriptor}
250
     *
251
     * @since 1.80
252
     * @return an action
253
     */
254
    public static Action newProjectAction(String categoryPath, Map<String, Object> initialProperties) {
255
        Action a = newProjectAction();
256
        
257
        a.putValue(PRESELECT_CATEGORY, categoryPath );
258
        String[] keys = initialProperties.keySet().toArray(new String[initialProperties.size()]);
259
        a.putValue(INITIAL_VALUE_PROPERTIES, keys);
260
        for (String key : keys) {
261
            a.putValue(key, initialProperties.get(key));
262
        }
263
        return a;
264
    }
265
266
    /**
218
     * Creates an action that sets the configuration of the selected project.
267
     * Creates an action that sets the configuration of the selected project.
219
     * It should be displayed with an action context containing
268
     * It should be displayed with an action context containing
220
     * exactly one {@link org.netbeans.api.project.Project}.
269
     * exactly one {@link org.netbeans.api.project.Project}.

Return to bug 251563