--- projectui/src/org/netbeans/modules/project/ui/actions/NewProject.java +++ projectui/src/org/netbeans/modules/project/ui/actions/NewProject.java @@ -126,8 +126,9 @@ if (f != null) { wizard.putProperty(CommonProjectActions.PROJECT_PARENT_FOLDER, f); } - //#217087 semi-private contract for maven support that carries over properties like groupId and version when creating new submodule. - String[] moreProps = (String[]) getValue("initialValueProperties"); + // carry over properties like e.g. groupId and version from maven when creating new submodule. + // see aso issue #217087 and #250190 + String[] moreProps = (String[]) getValue(CommonProjectActions.INITIAL_VALUE_PROPERTIES); if (moreProps != null) { for (String key : moreProps) { Object obj = getValue(key); --- projectui/src/org/netbeans/modules/project/ui/api/ProjectTemplates.java +++ projectui/src/org/netbeans/modules/project/ui/api/ProjectTemplates.java @@ -52,8 +52,9 @@ /** * {@link String}-valued action property for a project category (subfolder code name) to select. + * @deprecated use {@link CommonProjectActions.PRESELECT_CATEGORY} instead */ - public static final String PRESELECT_CATEGORY = "PRESELECT_CATEGORY"; + public static final String PRESELECT_CATEGORY = CommonProjectActions.PRESELECT_CATEGORY; /** * {@link String}-valued action property for a project template (code name within a category) to select. --- projectuiapi/apichanges.xml +++ projectuiapi/apichanges.xml @@ -107,6 +107,27 @@ + + + Provide a method to create an action that invokes the new project wizard, + preselects a category and propagates a set of properties to the wizard descriptor. + + + + + +

+ CommonProjectActions.newProjectAction makes it + so far posible to set the new projects parent folder by a + property. It would be also usefull to preselect the category + and to propagate custom properties to the new project wizard + descriptor. +

+
+ + +
+ Split the api into a desktop (swing, awt) and NetBeans dependent and independent part. --- projectuiapi/src/org/netbeans/spi/project/ui/support/CommonProjectActions.java +++ projectuiapi/src/org/netbeans/spi/project/ui/support/CommonProjectActions.java @@ -45,6 +45,7 @@ package org.netbeans.spi.project.ui.support; import java.util.List; +import java.util.Map; import javax.swing.Action; import org.netbeans.modules.project.uiapi.Utilities; import org.netbeans.spi.project.ui.LogicalViewProvider; @@ -71,6 +72,23 @@ */ public static final String PROJECT_PARENT_FOLDER = "projdir"; + /** + * {@link String}-valued action property honored by {@link #newProjectAction} + * that defines the project category (subfolder code name) to be selected. + * + * @since 1.80 + */ + public static final String PRESELECT_CATEGORY = "PRESELECT_CATEGORY"; + + /** + * {@link String}[]-valued action property honored by {@link #newProjectAction} + * for propagating custom properties to the new project wizard's + * {@link org.openide.WizardDescriptor} + * + * @since 1.80 + */ + public static final String INITIAL_VALUE_PROPERTIES = "initialValueProperties"; + private CommonProjectActions() {} /** @@ -206,6 +224,13 @@ * expectations about initial value for wizard * choosers that refers to existing sources location. * + *

{@link #PRESELECT_CATEGORY} keyed action value can carry a {@link String} + * that presents a category path to be selected in the new project wizard. + * + *

{@link #INITIAL_VALUE_PROPERTIES} keyed action value can carry a + * {@link Map} of custom properties which are propagated to + * the new project wizard's {@link org.openide.WizardDescriptor} + * * @return an action * * @since org.netbeans.modules.projectuiapi/1 1.3 @@ -215,6 +240,30 @@ } /** + * Creates action that invokes the New Project wizard, preselects the + * given category path and propagates a set of custom properties the wizard's + * {@link org.openide.WizardDescriptor}. + * + * @param categoryPath the category path to be selected + * @param initialProperties a map of custom properties which are propagated + * to the new project wizard's {@link org.openide.WizardDescriptor} + * + * @since 1.80 + * @return an action + */ + public static Action newProjectAction(String categoryPath, Map initialProperties) { + Action a = newProjectAction(); + + a.putValue(PRESELECT_CATEGORY, categoryPath ); + String[] keys = initialProperties.keySet().toArray(new String[initialProperties.size()]); + a.putValue(INITIAL_VALUE_PROPERTIES, keys); + for (String key : keys) { + a.putValue(key, initialProperties.get(key)); + } + return a; + } + + /** * Creates an action that sets the configuration of the selected project. * It should be displayed with an action context containing * exactly one {@link org.netbeans.api.project.Project}.