diff --git a/j2me.project/nbproject/project.xml b/j2me.project/nbproject/project.xml --- a/j2me.project/nbproject/project.xml +++ b/j2me.project/nbproject/project.xml @@ -71,7 +71,7 @@ 0-1 - 1.63 + 1.64 diff --git a/j2me.project/src/org/netbeans/modules/j2me/project/J2MEProject.java b/j2me.project/src/org/netbeans/modules/j2me/project/J2MEProject.java --- a/j2me.project/src/org/netbeans/modules/j2me/project/J2MEProject.java +++ b/j2me.project/src/org/netbeans/modules/j2me/project/J2MEProject.java @@ -42,10 +42,7 @@ package org.netbeans.modules.j2me.project; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import org.netbeans.api.annotations.common.NonNull; @@ -55,6 +52,7 @@ import org.netbeans.api.project.SourceGroup; import org.netbeans.api.project.ant.AntBuildExtender; import org.netbeans.modules.j2me.project.ui.customizer.CustomizerProviderImpl; +import org.netbeans.modules.j2me.project.ui.customizer.J2MECompositeCategoryProvider; import org.netbeans.modules.j2me.project.ui.customizer.J2MEProjectProperties; import org.netbeans.modules.java.api.common.Roots; import org.netbeans.modules.java.api.common.SourceRoots; @@ -62,27 +60,25 @@ import org.netbeans.modules.java.api.common.classpath.ClassPathModifier; import org.netbeans.modules.java.api.common.classpath.ClassPathProviderImpl; import org.netbeans.modules.java.api.common.project.BaseActionProvider; +import org.netbeans.modules.java.api.common.project.ProjectConfigurations; import org.netbeans.modules.java.api.common.project.ProjectHooks; import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.java.api.common.project.ui.LogicalViewProviders; import org.netbeans.modules.java.api.common.queries.QuerySupport; import org.netbeans.spi.java.project.support.LookupMergerSupport; +import org.netbeans.spi.project.ActionProvider; import org.netbeans.spi.project.AuxiliaryConfiguration; import org.netbeans.spi.project.ant.AntBuildExtenderFactory; import org.netbeans.spi.project.ant.AntBuildExtenderImplementation; import org.netbeans.spi.project.support.LookupProviderSupport; import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration; import org.netbeans.spi.project.support.ant.AntProjectHelper; -import org.netbeans.spi.project.support.ant.FilterPropertyProvider; import org.netbeans.spi.project.support.ant.GeneratedFilesHelper; import org.netbeans.spi.project.support.ant.PropertyEvaluator; -import org.netbeans.spi.project.support.ant.PropertyProvider; -import org.netbeans.spi.project.support.ant.PropertyUtils; import org.netbeans.spi.project.support.ant.ReferenceHelper; import org.netbeans.spi.project.ui.support.UILookupMergerSupport; import org.netbeans.spi.queries.FileEncodingQueryImplementation; import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; import org.openide.util.ImageUtilities; import org.openide.util.Lookup; import org.openide.util.Parameters; @@ -131,12 +127,13 @@ private final SourceRoots sourceRoots; private final SourceRoots testRoots; + @SuppressWarnings("LeakingThisInConstructor") public J2MEProject(@NonNull final AntProjectHelper helper) { Parameters.notNull("helper", helper); //NOI18N this.helper = helper; this.updateHelper = new UpdateHelper(new J2MEProjectUpdates(helper), helper); this.auxCfg = helper.createAuxiliaryConfiguration(); - this.eval = createPropertyEvaluator(); + this.eval = ProjectConfigurations.createPropertyEvaluator(this, helper); this.refHelper = new ReferenceHelper(helper, auxCfg, eval); final AntBuildExtender buildExtender = AntBuildExtenderFactory.createAntExtender( new J2MEExtenderImplementation(), @@ -296,6 +293,10 @@ buildExtender, new BuildArtifacts(helper, eval), new Templates(), + ProjectConfigurations.createConfigurationProviderBuilder(this, eval, updateHelper). + addConfigurationsAffectActions(ActionProvider.COMMAND_RUN, ActionProvider.COMMAND_DEBUG). + setCustomizerAction(newConfigCustomizerAction()). + build(), LookupMergerSupport.createClassPathProviderMerger(cpProvider), LookupMergerSupport.createSFBLookupMerger(), LookupMergerSupport.createJFBLookupMerger(), @@ -307,26 +308,7 @@ ); return LookupProviderSupport.createCompositeLookup(base, EXTENSION_POINT); } - - @NonNull - private PropertyEvaluator createPropertyEvaluator() { - final PropertyEvaluator baseEval1 = PropertyUtils.sequentialPropertyEvaluator( - helper.getStockPropertyPreprovider(), - helper.getPropertyProvider(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG)); - final PropertyEvaluator baseEval2 = PropertyUtils.sequentialPropertyEvaluator( - helper.getStockPropertyPreprovider(), - helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH)); - return PropertyUtils.sequentialPropertyEvaluator( - helper.getStockPropertyPreprovider(), - helper.getPropertyProvider(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG), - new ConfigPropertyProvider(baseEval1, "nbproject/private/configs", helper), // NOI18N - helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH), - helper.getProjectLibrariesPropertyProvider(), - PropertyUtils.userPropertiesProvider(baseEval2, - "user.properties.file", FileUtil.toFile(getProjectDirectory())), // NOI18N - new ConfigPropertyProvider(baseEval1, "nbproject/configs", helper), // NOI18N - helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH)); - } + private ClassPathModifier.Callback newClassPathModifierCallback() { return new ClassPathModifier.Callback() { @@ -350,6 +332,17 @@ }; } + @NonNull + private Runnable newConfigCustomizerAction() { + return new Runnable() { + @Override + public void run() { + J2MEProject.this.getLookup().lookup(CustomizerProviderImpl.class). + showCustomizer(J2MECompositeCategoryProvider.RUN, null); + } + }; + } + private class J2MEExtenderImplementation implements AntBuildExtenderImplementation { //add targets here as required by the external plugins.. @Override @@ -363,34 +356,4 @@ return J2MEProject.this; } } - - private static final class ConfigPropertyProvider extends FilterPropertyProvider implements PropertyChangeListener { - private final PropertyEvaluator baseEval; - private final String prefix; - private final AntProjectHelper helper; - - @SuppressWarnings("LeakingThisInConstructor") - public ConfigPropertyProvider(PropertyEvaluator baseEval, String prefix, AntProjectHelper helper) { - super(computeDelegate(baseEval, prefix, helper)); - this.baseEval = baseEval; - this.prefix = prefix; - this.helper = helper; - baseEval.addPropertyChangeListener(this); - } - - @Override - public void propertyChange(PropertyChangeEvent ev) { - if (ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG.equals(ev.getPropertyName())) { - setDelegate(computeDelegate(baseEval, prefix, helper)); - } - } - private static PropertyProvider computeDelegate(PropertyEvaluator baseEval, String prefix, AntProjectHelper helper) { - String config = baseEval.getProperty(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG); - if (config != null) { - return helper.getPropertyProvider(prefix + "/" + config + ".properties"); // NOI18N - } else { - return PropertyUtils.fixedPropertyProvider(Collections.emptyMap()); - } - } - } } diff --git a/j2me.project/src/org/netbeans/modules/j2me/project/ui/customizer/J2MECompositeCategoryProvider.java b/j2me.project/src/org/netbeans/modules/j2me/project/ui/customizer/J2MECompositeCategoryProvider.java --- a/j2me.project/src/org/netbeans/modules/j2me/project/ui/customizer/J2MECompositeCategoryProvider.java +++ b/j2me.project/src/org/netbeans/modules/j2me/project/ui/customizer/J2MECompositeCategoryProvider.java @@ -60,7 +60,7 @@ static final String LIBRARIES = "Libraries"; public static final String BUILD = "Build"; private static final String PLATFORM = "Platform"; - private static final String RUN = "Run"; + public static final String RUN = "Run"; private static final String APPLICATION_DESCRIPTOR = "Application Descriptor"; private static final String OBFUSCATING = "Obfuscating"; private static final String SIGNING = "Signing"; diff --git a/java.api.common/apichanges.xml b/java.api.common/apichanges.xml --- a/java.api.common/apichanges.xml +++ b/java.api.common/apichanges.xml @@ -105,6 +105,20 @@ + + + Added ProjectConfigurations support for ProjectConfigurations in Ant base project. + + + + + +

+ Added ProjectConfigurations support for ProjectConfigurations in Ant base project. +

+
+ +
Added LibrariesNode.Builder to create configured LibrariesNode. diff --git a/java.api.common/manifest.mf b/java.api.common/manifest.mf --- a/java.api.common/manifest.mf +++ b/java.api.common/manifest.mf @@ -1,4 +1,4 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.java.api.common/0 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.63 +OpenIDE-Module-Specification-Version: 1.64 diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/project/Bundle.properties b/java.api.common/src/org/netbeans/modules/java/api/common/project/Bundle.properties --- a/java.api.common/src/org/netbeans/modules/java/api/common/project/Bundle.properties +++ b/java.api.common/src/org/netbeans/modules/java/api/common/project/Bundle.properties @@ -39,3 +39,4 @@ # Portions Copyrighted 2013 Sun Microsystems, Inc. ERR_RegenerateProjectFiles=Cannot regenerate project metadata. ERR_ProjectReadOnly=The project folder {0} is read-only. +TXT_DefaultConfig= diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/project/ProjectConfigurations.java b/java.api.common/src/org/netbeans/modules/java/api/common/project/ProjectConfigurations.java new file mode 100644 --- /dev/null +++ b/java.api.common/src/org/netbeans/modules/java/api/common/project/ProjectConfigurations.java @@ -0,0 +1,515 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.java.api.common.project; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.IOException; +import java.io.InputStream; +import java.text.Collator; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; +import java.util.Queue; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.annotations.common.NullAllowed; +import org.netbeans.api.project.Project; +import org.netbeans.api.project.ProjectManager; +import org.netbeans.modules.java.api.common.ant.UpdateHelper; +import org.netbeans.spi.project.ProjectConfiguration; +import org.netbeans.spi.project.ProjectConfigurationProvider; +import org.netbeans.spi.project.support.ant.AntProjectHelper; +import org.netbeans.spi.project.support.ant.EditableProperties; +import org.netbeans.spi.project.support.ant.FilterPropertyProvider; +import org.netbeans.spi.project.support.ant.PropertyEvaluator; +import org.netbeans.spi.project.support.ant.PropertyProvider; +import org.netbeans.spi.project.support.ant.PropertyUtils; +import org.openide.filesystems.FileChangeAdapter; +import org.openide.filesystems.FileChangeListener; +import org.openide.filesystems.FileEvent; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileRenameEvent; +import org.openide.filesystems.FileUtil; +import org.openide.util.NbBundle; +import org.openide.util.Parameters; +import org.openide.util.Utilities; + +/** + * Support for {@link ProjectConfiguration}s in Ant based project. + * @author Jesse Glick + * @author Tomas Zezula + * @since 1.64 + */ +public class ProjectConfigurations { + + private static final Logger LOGGER = Logger.getLogger(ProjectConfigurations.class.getName()); + + /** + * Path to the file holding the active configuration. + */ + public static final String CONFIG_PROPS_PATH = "nbproject/private/config.properties"; // NOI18N + + private ProjectConfigurations() { + throw new IllegalStateException("No instance allowed"); //NOI18N + } + + /** + * Creates a {@link ConfigurationProviderBuilder}. + * @param project the {@link Project} to create builder for + * @param eval the {@link Project}'s {@link PropertyEvaluator} + * @param updateHelper the {@link Project}'s {@link UpdateHelper} + * @return the {@link ConfigurationProviderBuilder} + */ + @NonNull + public static ConfigurationProviderBuilder createConfigurationProviderBuilder( + @NonNull final Project project, + @NonNull final PropertyEvaluator eval, + @NonNull final UpdateHelper updateHelper) { + return new ConfigurationProviderBuilder(project, eval, updateHelper); + } + + /** + * Creates a {@link PropertyEvaluator} with {@link ProjectConfiguration} support. + * @param project the project to create {@link PropertyEvaluator} for + * @param helper the {@link Project}'s {@link AntProjectHelper} + * @param additionalPropertyProviders the additional {@link PropertyProvider}s + * @return a new {@link PropertyEvaluator} + */ + @NonNull + public static PropertyEvaluator createPropertyEvaluator( + @NonNull final Project project, + @NonNull final AntProjectHelper helper, + @NonNull final PropertyProvider... additionalPropertyProviders) { + Parameters.notNull("project", project); //NOI18N + Parameters.notNull("helper", helper); //NOI18N + Parameters.notNull("additionalPropertyProviders", additionalPropertyProviders); //NOI18N + + PropertyEvaluator baseEval1 = PropertyUtils.sequentialPropertyEvaluator( + helper.getStockPropertyPreprovider(), + helper.getPropertyProvider(ProjectConfigurations.CONFIG_PROPS_PATH)); + PropertyEvaluator baseEval2 = PropertyUtils.sequentialPropertyEvaluator( + helper.getStockPropertyPreprovider(), + helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH)); + final Queue providers = new ArrayDeque<>(additionalPropertyProviders.length + 7); + providers.offer(helper.getPropertyProvider(ProjectConfigurations.CONFIG_PROPS_PATH)); + providers.offer(new ConfigPropertyProvider(baseEval1, "nbproject/private/configs", helper)); //NOI18N + providers.offer(helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH)); + providers.offer(helper.getProjectLibrariesPropertyProvider()); + providers.offer(PropertyUtils.userPropertiesProvider(baseEval2, + "user.properties.file", FileUtil.toFile(project.getProjectDirectory()))); //NOI18N + providers.offer(new ConfigPropertyProvider(baseEval1, "nbproject/configs", helper)); //NOI18N + providers.offer(helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH)); + Collections.addAll(providers, additionalPropertyProviders); + return PropertyUtils.sequentialPropertyEvaluator( + helper.getStockPropertyPreprovider(), + providers.toArray(new PropertyProvider[providers.size()])); + } + + /** + * Builder for {@link ProjectConfigurationProvider}. + */ + public static final class ConfigurationProviderBuilder { + + private final Project project; + private final PropertyEvaluator eval; + private final UpdateHelper updateHelper; + private final Set configurationsAffectActions; + private Runnable customizerAction; + + private ConfigurationProviderBuilder( + @NonNull final Project project, + @NonNull final PropertyEvaluator eval, + @NonNull final UpdateHelper updateHelper) { + Parameters.notNull("project", project); //NOI18N + Parameters.notNull("eval", eval); //NOI18N + Parameters.notNull("updateHelper", updateHelper); //NOI18N + this.project = project; + this.eval = eval; + this.updateHelper = updateHelper; + this.configurationsAffectActions = new HashSet<>(); + } + + /** + * Sets actions affected by the configurations. + * @param commands the actions affected by configurations + * @return the {@link ConfigurationProviderBuilder} + */ + @NonNull + public ConfigurationProviderBuilder addConfigurationsAffectActions(@NonNull final String... commands) { + Parameters.notNull("commands", commands); //NOI18N + Collections.addAll(configurationsAffectActions, commands); + return this; + } + + /** + * Sets an action showing the customizer for {@link ProjectConfiguration}s. + * @param action the action + * @return the {@link ConfigurationProviderBuilder} + */ + @NonNull + public ConfigurationProviderBuilder setCustomizerAction(@NonNull final Runnable action) { + Parameters.notNull("action", action); //NOI18N + this.customizerAction = action; + return this; + } + + /** + * Creates a configured {@link ProjectConfigurationProvider}. + * @return a new configured instance of {@link ProjectConfigurationProvider} + */ + @NonNull + public ProjectConfigurationProvider build() { + return new ConfigurationProviderImpl( + project, + eval, + updateHelper, + configurationsAffectActions, + customizerAction); + } + } + + /** + * The {@link ProjectConfiguration} implementation. + */ + public static final class Configuration implements ProjectConfiguration { + private final String name; + private final String displayName; + + private Configuration( + @NullAllowed final String name, + @NonNull final String displayName) { + Parameters.notNull("displayName", displayName); //NOI18N + this.name = name; + this.displayName = displayName; + } + + /** + * Returns the system name of the configuration. + * @return the system name of configuration + */ + @CheckForNull + public String getName() { + return name; + } + + /** + * Checks if the {@link Configuration} is a default one. + * @return true when the {@link Configuration} is default + */ + public boolean isDefault() { + return name == null; + } + + @Override + @NonNull + public String getDisplayName() { + return displayName; + } + + @Override + public int hashCode() { + return Objects.hashCode(name); + } + + @Override + public boolean equals(Object o) { + return (o instanceof Configuration) && Objects.equals(name, ((Configuration) o).name); + } + + @Override + public String toString() { + return "Config[" + name + "," + displayName + "]"; // NOI18N + } + } + + private static final class ConfigurationProviderImpl implements ProjectConfigurationProvider { + + private static final Configuration DEFAULT = new Configuration( + null, + NbBundle.getMessage(ProjectConfigurations.class, "TXT_DefaultConfig")); + + private final Project p; + private final PropertyEvaluator eval; + private final UpdateHelper updateHelper; + private final Set configurationsAffectActions; + private final Runnable customizerAction; + private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + private final FileChangeListener fcl = new FileChangeAdapter() { + @Override + public void fileFolderCreated(@NonNull final FileEvent fe) { + update(fe); + } + + @Override + public void fileDataCreated(@NonNull final FileEvent fe) { + update(fe); + } + + @Override + public void fileDeleted(@NonNull final FileEvent fe) { + update(fe); + } + + @Override + public void fileRenamed(@NonNull final FileRenameEvent fe) { + update(fe); + } + + private void update(@NonNull final FileEvent ev) { + Parameters.notNull("ev", ev); //NOI18N + LOGGER.log(Level.FINEST, "Received {0}", ev); + Set oldConfigs = configs != null ? configs.keySet() : Collections.emptySet(); + configDir = p.getProjectDirectory().getFileObject("nbproject/configs"); // NOI18N + if (configDir != null) { + configDir.removeFileChangeListener(fclWeak); + configDir.addFileChangeListener(fclWeak); + LOGGER.log(Level.FINEST, "(Re-)added listener to {0}", configDir); + } else { + LOGGER.log(Level.FINEST, "No nbproject/configs exists"); + } + calculateConfigs(); + Set newConfigs = configs.keySet(); + if (!oldConfigs.equals(newConfigs)) { + LOGGER.log(Level.FINER, "Firing " + ProjectConfigurationProvider.PROP_CONFIGURATIONS + ": {0} -> {1}", new Object[] {oldConfigs, newConfigs}); + pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATIONS, null, null); + // XXX also fire PROP_ACTIVE_CONFIGURATION? + } + } + }; + private final FileChangeListener fclWeak; + private FileObject configDir; + private Map configs; + private FileObject nbp; + + public ConfigurationProviderImpl( + @NonNull final Project p, + @NonNull final PropertyEvaluator eval, + @NonNull final UpdateHelper updateHelper, + @NonNull final Set configurationsAffectActions, + @NullAllowed final Runnable customizerAction) { + Parameters.notNull("p", p); //NOI18N + Parameters.notNull("eval", eval); //NOI18N + Parameters.notNull("updateHelper", updateHelper); //NOI18N + Parameters.notNull("configurationsAffectActions", configurationsAffectActions); //NOI18N + this.p = p; + this.eval = eval; + this.updateHelper = updateHelper; + this.configurationsAffectActions = configurationsAffectActions; + this.customizerAction = customizerAction; + fclWeak = FileUtil.weakFileChangeListener(fcl, null); + nbp = p.getProjectDirectory().getFileObject("nbproject"); // NOI18N + if (nbp != null) { + nbp.addFileChangeListener(fclWeak); + LOGGER.log(Level.FINEST, "Added listener to {0}", nbp); + configDir = nbp.getFileObject("configs"); // NOI18N + if (configDir != null) { + configDir.addFileChangeListener(fclWeak); + LOGGER.log(Level.FINEST, "Added listener to {0}", configDir); + } + } + eval.addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(@NonNull final PropertyChangeEvent evt) { + if (ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG.equals(evt.getPropertyName())) { + LOGGER.log(Level.FINER, "Refiring " + ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG + " -> " + ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE); + Set oldConfigs = configs != null ? configs.keySet() : Collections.emptySet(); + calculateConfigs(); + Set newConfigs = configs.keySet(); + if (!oldConfigs.equals(newConfigs)) { + LOGGER.log(Level.FINER, "Firing " + ProjectConfigurationProvider.PROP_CONFIGURATIONS + ": {0} -> {1}", new Object[] {oldConfigs, newConfigs}); + pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATIONS, null, null); + } + pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE, null, null); + } + } + }); + } + + private void calculateConfigs() { + configs = new HashMap(); + if (configDir != null) { + for (FileObject kid : configDir.getChildren()) { + if (!kid.hasExt("properties")) { //NOI18N + continue; + } + try { + try (InputStream is = kid.getInputStream()) { + final Properties props = new Properties(); + props.load(is); + final String name = kid.getName(); + final String label = props.getProperty("$label"); // NOI18N + configs.put(name, new Configuration(name, label != null ? label : name)); + } + } catch (IOException x) { + LOGGER.log(Level.INFO, null, x); + } + } + } + LOGGER.log(Level.FINEST, "Calculated configurations: {0}", configs); + } + + @NonNull + @Override + public Collection getConfigurations() { + calculateConfigs(); + List l = new ArrayList(); + l.addAll(configs.values()); + Collections.sort(l, new Comparator() { + Collator c = Collator.getInstance(); + @Override + public int compare(Configuration c1, Configuration c2) { + return c.compare(c1.getDisplayName(), c2.getDisplayName()); + } + }); + l.add(0, DEFAULT); + return l; + } + + @NonNull + @Override + public Configuration getActiveConfiguration() { + calculateConfigs(); + String config = eval.getProperty(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG); + if (config != null && configs.containsKey(config)) { + return configs.get(config); + } else { + return DEFAULT; + } + } + + @Override + public void setActiveConfiguration(@NonNull final Configuration c) throws IllegalArgumentException, IOException { + if (c != DEFAULT && !configs.values().contains(c)) { + throw new IllegalArgumentException(String.valueOf(c)); + } + final String n = c.name; + EditableProperties ep = updateHelper.getProperties(CONFIG_PROPS_PATH); + if (Utilities.compareObjects(n, ep.getProperty(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG))) { + return; + } + if (n != null) { + ep.setProperty(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG, n); + } else { + ep.remove(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG); + } + updateHelper.putProperties(CONFIG_PROPS_PATH, ep); + pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE, null, null); + ProjectManager.getDefault().saveProject(p); + assert p.getProjectDirectory().getFileObject(CONFIG_PROPS_PATH) != null; + } + + @Override + public boolean hasCustomizer() { + return customizerAction != null; + } + + @Override + public void customize() { + if (customizerAction != null) { + customizerAction.run(); + } + } + + + @Override + public boolean configurationsAffectAction(@NonNull final String command) { + return configurationsAffectActions.contains(command); + } + + @Override + public void addPropertyChangeListener(@NonNull final PropertyChangeListener lst) { + Parameters.notNull("lst", lst); //NOI18N + pcs.addPropertyChangeListener(lst); + } + + @Override + public void removePropertyChangeListener(@NonNull final PropertyChangeListener lst) { + Parameters.notNull("lst", lst); //NOI18N + pcs.removePropertyChangeListener(lst); + } + } + + private static final class ConfigPropertyProvider extends FilterPropertyProvider implements PropertyChangeListener { + private final PropertyEvaluator baseEval; + private final String prefix; + private final AntProjectHelper helper; + + @SuppressWarnings("LeakingThisInConstructor") + public ConfigPropertyProvider(PropertyEvaluator baseEval, String prefix, AntProjectHelper helper) { + super(computeDelegate(baseEval, prefix, helper)); + this.baseEval = baseEval; + this.prefix = prefix; + this.helper = helper; + baseEval.addPropertyChangeListener(this); + } + + @Override + public void propertyChange(PropertyChangeEvent ev) { + if (ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG.equals(ev.getPropertyName())) { + setDelegate(computeDelegate(baseEval, prefix, helper)); + } + } + + private static PropertyProvider computeDelegate(PropertyEvaluator baseEval, String prefix, AntProjectHelper helper) { + String config = baseEval.getProperty(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG); + if (config != null) { + return helper.getPropertyProvider(prefix + "/" + config + ".properties"); // NOI18N + } else { + return PropertyUtils.fixedPropertyProvider(Collections.emptyMap()); + } + } + } +} diff --git a/java.j2seproject/nbproject/project.xml b/java.j2seproject/nbproject/project.xml --- a/java.j2seproject/nbproject/project.xml +++ b/java.j2seproject/nbproject/project.xml @@ -142,7 +142,7 @@ 0-1 - 1.62 + 1.64
diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java @@ -62,6 +62,7 @@ import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.java.api.common.project.BaseActionProvider; import org.netbeans.modules.java.api.common.project.BaseActionProvider.Callback3; +import org.netbeans.modules.java.api.common.project.ProjectConfigurations; import org.netbeans.modules.java.j2seproject.api.J2SEBuildPropertiesProvider; import org.netbeans.spi.project.ActionProvider; import org.netbeans.spi.project.LookupProvider; @@ -219,11 +220,11 @@ @Override public String[] getTargetNames(String command, Lookup context, Properties p, boolean doJavaChecks) throws IllegalArgumentException { String names[] = super.getTargetNames(command, context, p, doJavaChecks); - J2SEConfigurationProvider.Config c = context.lookup(J2SEConfigurationProvider.Config.class); + ProjectConfigurations.Configuration c = context.lookup(ProjectConfigurations.Configuration.class); if (c != null) { String config; - if (c.name != null) { - config = c.name; + if (!c.isDefault()) { + config = c.getName(); } else { // Invalid but overrides any valid setting in config.properties. config = ""; diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEConfigurationProvider.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEConfigurationProvider.java deleted file mode 100644 --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEConfigurationProvider.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2011 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2011 Sun Microsystems, Inc. - */ - -package org.netbeans.modules.java.j2seproject; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.IOException; -import java.io.InputStream; -import java.text.Collator; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.netbeans.api.project.ProjectManager; -import org.netbeans.modules.java.api.common.project.ProjectProperties; -import org.netbeans.modules.java.j2seproject.ui.customizer.CustomizerProviderImpl; -import org.netbeans.modules.java.j2seproject.ui.customizer.J2SECompositePanelProvider; -import org.netbeans.spi.project.ActionProvider; -import org.netbeans.spi.project.ProjectConfiguration; -import org.netbeans.spi.project.ProjectConfigurationProvider; -import org.netbeans.spi.project.support.ant.EditableProperties; -import org.openide.filesystems.FileChangeAdapter; -import org.openide.filesystems.FileChangeListener; -import org.openide.filesystems.FileEvent; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileRenameEvent; -import org.openide.filesystems.FileUtil; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; - -/** - * Manages configurations for a Java SE project. - * @author Jesse Glick - */ -final class J2SEConfigurationProvider implements ProjectConfigurationProvider { - - private static final Logger LOGGER = Logger.getLogger(J2SEConfigurationProvider.class.getName()); - - /** - * Ant property name for active config. - */ - public static final String PROP_CONFIG = ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG; - /** - * Ant property file which specified active config. - */ - public static final String CONFIG_PROPS_PATH = "nbproject/private/config.properties"; // NOI18N - - public static final class Config implements ProjectConfiguration { - /** file basename, or null for default config */ - public final String name; - private final String displayName; - public Config(String name, String displayName) { - this.name = name; - this.displayName = displayName; - } - public String getDisplayName() { - return displayName; - } - public int hashCode() { - return name != null ? name.hashCode() : 0; - } - public boolean equals(Object o) { - return (o instanceof Config) && Utilities.compareObjects(name, ((Config) o).name); - } - public String toString() { - return "J2SEConfigurationProvider.Config[" + name + "," + displayName + "]"; // NOI18N - } - } - - private static final Config DEFAULT = new Config(null, - NbBundle.getMessage(J2SEConfigurationProvider.class, "J2SEConfigurationProvider.default.label")); - - private final J2SEProject p; - private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); - private final FileChangeListener fcl = new FileChangeAdapter() { - public void fileFolderCreated(FileEvent fe) { - update(fe); - } - public void fileDataCreated(FileEvent fe) { - update(fe); - } - public void fileDeleted(FileEvent fe) { - update(fe); - } - public void fileRenamed(FileRenameEvent fe) { - update(fe); - } - private void update(FileEvent ev) { - LOGGER.log(Level.FINEST, "Received {0}", ev); - Set oldConfigs = configs != null ? configs.keySet() : Collections.emptySet(); - configDir = p.getProjectDirectory().getFileObject("nbproject/configs"); // NOI18N - if (configDir != null) { - configDir.removeFileChangeListener(fclWeak); - configDir.addFileChangeListener(fclWeak); - LOGGER.log(Level.FINEST, "(Re-)added listener to {0}", configDir); - } else { - LOGGER.log(Level.FINEST, "No nbproject/configs exists"); - } - calculateConfigs(); - Set newConfigs = configs.keySet(); - if (!oldConfigs.equals(newConfigs)) { - LOGGER.log(Level.FINER, "Firing " + ProjectConfigurationProvider.PROP_CONFIGURATIONS + ": {0} -> {1}", new Object[] {oldConfigs, newConfigs}); - pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATIONS, null, null); - // XXX also fire PROP_ACTIVE_CONFIGURATION? - } - } - }; - private final FileChangeListener fclWeak; - private FileObject configDir; - private Map configs; - private FileObject nbp; - - public J2SEConfigurationProvider(J2SEProject p) { - this.p = p; - fclWeak = FileUtil.weakFileChangeListener(fcl, null); - nbp = p.getProjectDirectory().getFileObject("nbproject"); // NOI18N - if (nbp != null) { - nbp.addFileChangeListener(fclWeak); - LOGGER.log(Level.FINEST, "Added listener to {0}", nbp); - configDir = nbp.getFileObject("configs"); // NOI18N - if (configDir != null) { - configDir.addFileChangeListener(fclWeak); - LOGGER.log(Level.FINEST, "Added listener to {0}", configDir); - } - } - p.evaluator().addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (PROP_CONFIG.equals(evt.getPropertyName())) { - LOGGER.log(Level.FINER, "Refiring " + PROP_CONFIG + " -> " + ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE); - Set oldConfigs = configs != null ? configs.keySet() : Collections.emptySet(); - calculateConfigs(); - Set newConfigs = configs.keySet(); - if (!oldConfigs.equals(newConfigs)) { - LOGGER.log(Level.FINER, "Firing " + ProjectConfigurationProvider.PROP_CONFIGURATIONS + ": {0} -> {1}", new Object[] {oldConfigs, newConfigs}); - pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATIONS, null, null); - } - pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE, null, null); - } - } - }); - } - - private void calculateConfigs() { - configs = new HashMap(); - if (configDir != null) { - for (FileObject kid : configDir.getChildren()) { - if (!kid.hasExt("properties")) { - continue; - } - try { - InputStream is = kid.getInputStream(); - try { - Properties p = new Properties(); - p.load(is); - String name = kid.getName(); - String label = p.getProperty("$label"); // NOI18N - configs.put(name, new Config(name, label != null ? label : name)); - } finally { - is.close(); - } - } catch (IOException x) { - LOGGER.log(Level.INFO, null, x); - } - } - } - LOGGER.log(Level.FINEST, "Calculated configurations: {0}", configs); - } - - public Collection getConfigurations() { - calculateConfigs(); - List l = new ArrayList(); - l.addAll(configs.values()); - Collections.sort(l, new Comparator() { - Collator c = Collator.getInstance(); - public int compare(Config c1, Config c2) { - return c.compare(c1.getDisplayName(), c2.getDisplayName()); - } - }); - l.add(0, DEFAULT); - return l; - } - - public Config getActiveConfiguration() { - calculateConfigs(); - String config = p.evaluator().getProperty(PROP_CONFIG); - if (config != null && configs.containsKey(config)) { - return configs.get(config); - } else { - return DEFAULT; - } - } - - public void setActiveConfiguration(Config c) throws IllegalArgumentException, IOException { - if (c != DEFAULT && !configs.values().contains(c)) { - throw new IllegalArgumentException(); - } - final String n = c.name; - EditableProperties ep = p.getUpdateHelper().getProperties(CONFIG_PROPS_PATH); - if (Utilities.compareObjects(n, ep.getProperty(PROP_CONFIG))) { - return; - } - if (n != null) { - ep.setProperty(PROP_CONFIG, n); - } else { - ep.remove(PROP_CONFIG); - } - p.getUpdateHelper().putProperties(CONFIG_PROPS_PATH, ep); - pcs.firePropertyChange(ProjectConfigurationProvider.PROP_CONFIGURATION_ACTIVE, null, null); - ProjectManager.getDefault().saveProject(p); - assert p.getProjectDirectory().getFileObject(CONFIG_PROPS_PATH) != null; - } - - public boolean hasCustomizer() { - return true; - } - - public void customize() { - p.getLookup().lookup(CustomizerProviderImpl.class).showCustomizer(J2SECompositePanelProvider.RUN); - } - - public boolean configurationsAffectAction(String command) { - return command.equals(ActionProvider.COMMAND_RUN) || - command.equals(ActionProvider.COMMAND_DEBUG); - } - - public void addPropertyChangeListener(PropertyChangeListener lst) { - pcs.addPropertyChangeListener(lst); - } - - public void removePropertyChangeListener(PropertyChangeListener lst) { - pcs.removePropertyChangeListener(lst); - } - -} diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java @@ -89,16 +89,19 @@ import org.netbeans.modules.java.api.common.ant.UpdateHelper; import org.netbeans.modules.java.api.common.classpath.ClassPathModifier; import org.netbeans.modules.java.api.common.classpath.ClassPathProviderImpl; +import org.netbeans.modules.java.api.common.project.ProjectConfigurations; import org.netbeans.modules.java.api.common.project.ProjectHooks; import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.java.api.common.project.ui.LogicalViewProviders; import org.netbeans.modules.java.api.common.queries.QuerySupport; import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator; import org.netbeans.modules.java.j2seproject.ui.customizer.CustomizerProviderImpl; +import org.netbeans.modules.java.j2seproject.ui.customizer.J2SECompositePanelProvider; import org.netbeans.modules.project.ui.spi.TemplateCategorySorter; import org.netbeans.spi.java.project.support.ExtraSourceJavadocSupport; import org.netbeans.spi.java.project.support.LookupMergerSupport; import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport; +import org.netbeans.spi.project.ActionProvider; import org.netbeans.spi.project.AuxiliaryConfiguration; import org.netbeans.spi.project.ant.AntArtifactProvider; import org.netbeans.spi.project.ant.AntBuildExtenderFactory; @@ -193,6 +196,7 @@ */ private final ThreadLocal projectPropertiesSave; + @SuppressWarnings("LeakingThisInConstructor") public J2SEProject(AntProjectHelper helper) throws IOException { this.projectPropertiesSave = new ThreadLocal() { @Override @@ -204,7 +208,7 @@ aux = helper.createAuxiliaryConfiguration(); UpdateProjectImpl updateProject = new UpdateProjectImpl(this, helper, aux); this.updateHelper = new UpdateHelper(updateProject, helper); - eval = createEvaluator(); + eval = ProjectConfigurations.createPropertyEvaluator(this, helper, UPDATE_PROPERTIES); for (int v = 4; v < 10; v++) { if (aux.getConfigurationFragment("data", "http://www.netbeans.org/ns/j2se-project/" + v, true) != null) { // NOI18N throw Exceptions.attachLocalizedMessage(new IOException("too new"), // NOI18N @@ -253,60 +257,8 @@ public String toString() { return "J2SEProject[" + FileUtil.getFileDisplayName(getProjectDirectory()) + "]"; // NOI18N } - - private PropertyEvaluator createEvaluator() { - // It is currently safe to not use the UpdateHelper for PropertyEvaluator; UH.getProperties() delegates to APH - // Adapted from APH.getStandardPropertyEvaluator (delegates to ProjectProperties): - PropertyEvaluator baseEval1 = PropertyUtils.sequentialPropertyEvaluator( - helper.getStockPropertyPreprovider(), - helper.getPropertyProvider(J2SEConfigurationProvider.CONFIG_PROPS_PATH)); - PropertyEvaluator baseEval2 = PropertyUtils.sequentialPropertyEvaluator( - helper.getStockPropertyPreprovider(), - helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH)); - return PropertyUtils.sequentialPropertyEvaluator( - helper.getStockPropertyPreprovider(), - helper.getPropertyProvider(J2SEConfigurationProvider.CONFIG_PROPS_PATH), - new ConfigPropertyProvider(baseEval1, "nbproject/private/configs", helper), // NOI18N - helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH), - helper.getProjectLibrariesPropertyProvider(), - PropertyUtils.userPropertiesProvider(baseEval2, - "user.properties.file", FileUtil.toFile(getProjectDirectory())), // NOI18N - new ConfigPropertyProvider(baseEval1, "nbproject/configs", helper), // NOI18N - helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH), - UPDATE_PROPERTIES); - } - private static final class ConfigPropertyProvider extends FilterPropertyProvider implements PropertyChangeListener { - private final PropertyEvaluator baseEval; - private final String prefix; - private final AntProjectHelper helper; - - @SuppressWarnings("LeakingThisInConstructor") - public ConfigPropertyProvider(PropertyEvaluator baseEval, String prefix, AntProjectHelper helper) { - super(computeDelegate(baseEval, prefix, helper)); - this.baseEval = baseEval; - this.prefix = prefix; - this.helper = helper; - baseEval.addPropertyChangeListener(this); - } - - @Override - public void propertyChange(PropertyChangeEvent ev) { - if (J2SEConfigurationProvider.PROP_CONFIG.equals(ev.getPropertyName())) { - setDelegate(computeDelegate(baseEval, prefix, helper)); - } - } - private static PropertyProvider computeDelegate(PropertyEvaluator baseEval, String prefix, AntProjectHelper helper) { - String config = baseEval.getProperty(J2SEConfigurationProvider.PROP_CONFIG); - if (config != null) { - return helper.getPropertyProvider(prefix + "/" + config + ".properties"); // NOI18N - } else { - return PropertyUtils.fixedPropertyProvider(Collections.emptyMap()); - } - } - } - + private static final PropertyProvider UPDATE_PROPERTIES; - static { Map defs = new HashMap(); @@ -400,7 +352,10 @@ buildExtender, cpMod, ops, - new J2SEConfigurationProvider(this), + ProjectConfigurations.createConfigurationProviderBuilder(this, eval, updateHelper). + addConfigurationsAffectActions(ActionProvider.COMMAND_RUN, ActionProvider.COMMAND_DEBUG). + setCustomizerAction(newConfigCustomizerAction()). + build(), new J2SEPersistenceProvider(this, cpProvider), UILookupMergerSupport.createPrivilegedTemplatesMerger(), UILookupMergerSupport.createRecommendedTemplatesMerger(), @@ -983,6 +938,17 @@ } @NonNull + private Runnable newConfigCustomizerAction() { + return new Runnable() { + @Override + public void run() { + J2SEProject.this.getLookup().lookup(CustomizerProviderImpl.class). + showCustomizer(J2SECompositePanelProvider.RUN); + } + }; + } + + @NonNull private LogicalViewProviders.CompileOnSaveBadge newCoSBadge() { return new LogicalViewProviders.CompileOnSaveBadge() { @Override diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperations.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperations.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperations.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectOperations.java @@ -61,6 +61,7 @@ import org.netbeans.api.project.ProjectInformation; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ProjectUtils; +import org.netbeans.modules.java.api.common.project.ProjectConfigurations; import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties; import org.netbeans.spi.project.ActionProvider; @@ -372,7 +373,7 @@ } private void rememberConfigurations () { - FileObject fo = project.getProjectDirectory().getFileObject(J2SEConfigurationProvider.CONFIG_PROPS_PATH); + FileObject fo = project.getProjectDirectory().getFileObject(ProjectConfigurations.CONFIG_PROPS_PATH); if (fo != null) { //Has configurations try { diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/MainClassUpdater.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/MainClassUpdater.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/MainClassUpdater.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/MainClassUpdater.java @@ -62,6 +62,7 @@ import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectManager; import org.netbeans.modules.java.api.common.ant.UpdateHelper; +import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.spi.java.classpath.support.ClassPathSupport; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.EditableProperties; @@ -208,7 +209,7 @@ } if (newMainClass != null && !newMainClass.equals(oldMainClass) && helper.requestUpdate() && // XXX ##84806: ideally should update nbproject/configs/*.properties in this case: - eval.getProperty(J2SEConfigurationProvider.PROP_CONFIG) == null) { + eval.getProperty(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG) == null) { final String newMainClassFinal = newMainClass; ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction() { @Override