diff --git a/j2ee.clientproject/nbproject/project.xml b/j2ee.clientproject/nbproject/project.xml
--- a/j2ee.clientproject/nbproject/project.xml
+++ b/j2ee.clientproject/nbproject/project.xml
@@ -161,6 +161,15 @@ made subject to such option by the copyr
41.29
+
+
+
+ org.netbeans.modules.java.api.common
+
+
+
+ 0-1
+ 1.0
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientActionProvider.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientActionProvider.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientActionProvider.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientActionProvider.java
@@ -77,6 +77,7 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.ActionProvider;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
@@ -342,7 +343,7 @@ class AppClientActionProvider implements
result=isSetMainClass(project.getSourceRoots().getRoots(), mainClass);
} while (result != MainClassStatus.SET_AND_VALID);
try {
- if (updateHelper.requestSave()) {
+ if (updateHelper.requestUpdate()) {
updateHelper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
ProjectManager.getDefault().saveProject(project);
} else {
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientFileBuiltQuery.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientFileBuiltQuery.java
deleted file mode 100644
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/AppClientFileBuiltQuery.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.j2ee.clientproject;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import org.openide.filesystems.FileObject;
-import org.netbeans.api.queries.FileBuiltQuery;
-import org.netbeans.spi.queries.FileBuiltQueryImplementation;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
-
-
-
-
-
-public class AppClientFileBuiltQuery implements FileBuiltQueryImplementation, PropertyChangeListener {
-
- private FileBuiltQueryImplementation delegate;
- private final AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
- private final SourceRoots sourceRoots;
- private final SourceRoots testRoots;
-
- AppClientFileBuiltQuery (AntProjectHelper helper, PropertyEvaluator evaluator,
- SourceRoots sourceRoots, SourceRoots testRoots) {
- assert helper != null && evaluator != null && sourceRoots != null && testRoots != null;
- this.helper = helper;
- this.evaluator = evaluator;
- this.sourceRoots = sourceRoots;
- this.testRoots = testRoots;
- this.sourceRoots.addPropertyChangeListener (this);
- this.testRoots.addPropertyChangeListener (this);
- }
-
- public synchronized FileBuiltQuery.Status getStatus(FileObject file) {
- if (this.delegate == null) {
- this.delegate = createDelegate ();
- }
- return this.delegate.getStatus (file);
- }
-
-
- private FileBuiltQueryImplementation createDelegate () {
- String[] srcRoots = this.sourceRoots.getRootProperties();
- String[] tstRoots = this.testRoots.getRootProperties();
- String[] from = new String [srcRoots.length + tstRoots.length];
- String[] to = new String [srcRoots.length + tstRoots.length];
- for (int i=0; i< srcRoots.length; i++) {
- from[i] = "${" + srcRoots[i] + "}/*.java"; // NOI18N
- to[i] = "${" + AppClientProjectProperties.BUILD_CLASSES_DIR + "}/*.class"; // NOI18N
- }
- for (int i=0; i() {
- public Integer run() {
- synchronized (AppClientSharabilityQuery.this) {
- if (delegate == null) {
- delegate = createDelegate ();
- }
- return new Integer(delegate.getSharability (file));
- }
- }
- });
- return ret.intValue();
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (SourceRoots.PROP_ROOT_PROPERTIES.equals(evt.getPropertyName())) {
- synchronized (this) {
- this.delegate = null;
- }
- }
- }
-
- private SharabilityQueryImplementation createDelegate () {
- String[] srcProps = srcRoots.getRootProperties();
- String[] testProps = testRoots.getRootProperties();
- String[] props = new String [srcProps.length + testProps.length + 1];
- for (int i=0; i sourceRootProperties;
- private List sourceRootNames;
- private List sourceRoots;
- private List sourceRootURLs;
- private final PropertyChangeSupport support;
- private final ProjectMetadataListener listener;
- private final boolean isTest;
- private final File projectDir;
-
- /**
- * Creates new SourceRoots
- * @param helper
- * @param evaluator
- * @param elementName the name of XML element under which are declared the roots
- * @param newRootNameTemplate template for new property name of source root
- */
- SourceRoots (UpdateHelper helper, PropertyEvaluator evaluator, ReferenceHelper refHelper, String elementName, boolean isTest, String newRootNameTemplate) {
- assert helper != null && evaluator != null && refHelper != null && elementName != null && newRootNameTemplate != null;
- this.helper = helper;
- this.evaluator = evaluator;
- this.refHelper = refHelper;
- this.elementName = elementName;
- this.isTest = isTest;
- this.newRootNameTemplate = newRootNameTemplate;
- this.projectDir = FileUtil.toFile(this.helper.getAntProjectHelper().getProjectDirectory());
- this.support = new PropertyChangeSupport(this);
- this.listener = new ProjectMetadataListener();
- this.evaluator.addPropertyChangeListener (WeakListeners.propertyChange(this.listener,this.evaluator));
- this.helper.getAntProjectHelper().addAntProjectListener(WeakListeners.create(AntProjectListener.class, this.listener,this.helper));
- }
-
-
- /**
- * Returns the display names of soruce roots
- * The returned array has the same length as an array returned by the getRootProperties.
- * It may contain empty strings but not null.
- * @return an array of String
- */
- public String[] getRootNames() {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public String[] run() {
- synchronized (SourceRoots.this) {
- if (sourceRootNames == null) {
- readProjectMetadata();
- }
- }
- return sourceRootNames.toArray(new String[sourceRootNames.size()]);
- }
- });
- }
-
- /**
- * Returns names of Ant properties in the project.properties file holding the source roots.
- * @return an array of String
- */
- public String[] getRootProperties () {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public String[] run() {
- synchronized (SourceRoots.this) {
- if (sourceRootProperties == null) {
- readProjectMetadata();
- }
- }
- return sourceRootProperties.toArray(new String[sourceRootProperties.size()]);
- }
- });
- }
-
- /**
- * Returns the source roots
- * @return an array of FileObject
- */
- public FileObject[] getRoots () {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public FileObject[] run () {
- synchronized (this) {
- //Local caching
- if (sourceRoots == null) {
- String[] srcProps = getRootProperties();
- List result = new ArrayList();
- for (int i = 0; i() {
- public URL[] run() {
- synchronized (this) {
- //Local caching
- if (sourceRootURLs == null) {
- String[] srcProps = getRootProperties();
- List result = new ArrayList();
- for (int i = 0; i oldRoots2props = new HashMap();
- for (int i=0; i newRoots2lab = new HashMap();
- for (int i=0; i0) {
- Element root = (Element) rootsNodes.item(0);
- ownerElement.removeChild(root);
- }
- //Remove all unused root properties
- List newRoots = Arrays.asList(roots);
- Map propsToRemove = new HashMap(oldRoots2props);
- propsToRemove.keySet().removeAll(newRoots);
- EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- for (Iterator it = propsToRemove.values().iterator(); it.hasNext();) {
- String propName = it.next();
- props.remove(propName);
- }
- helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,props);
- //Add the new roots
- Document doc = ownerElement.getOwnerDocument();
- oldRoots2props.keySet().retainAll(newRoots);
- for (Iterator it = newRoots.iterator(); it.hasNext();) {
- URL newRoot = (URL) it.next ();
- String rootName = oldRoots2props.get (newRoot);
- if (rootName == null) {
- //Root is new generate property for it
- props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- String[] names = newRoot.getPath().split("/"); //NOI18N
- rootName = MessageFormat.format(newRootNameTemplate,new Object[]{names[names.length-1],""}); //NOI18N
- int rootIndex = 1;
- while (props.containsKey(rootName)) {
- rootIndex++;
- rootName = MessageFormat.format(newRootNameTemplate,new Object[]{names[names.length-1],new Integer(rootIndex)});
- }
- File f = FileUtil.normalizeFile(new File(URI.create(newRoot.toExternalForm())));
- File projDir = FileUtil.toFile(helper.getAntProjectHelper().getProjectDirectory());
- String path = f.getAbsolutePath();
- String prjPath = projDir.getAbsolutePath()+File.separatorChar;
- if (path.startsWith(prjPath)) {
- path = path.substring(prjPath.length());
- }
- else {
- path = refHelper.createForeignFileReference(f, JavaProjectConstants.SOURCES_TYPE_JAVA);
- props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- }
- props.put(rootName,path);
- helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,props);
- }
- Element newRootNode = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE, "root"); //NOI18N
- newRootNode.setAttribute("id",rootName); //NOI18N
- String label = newRoots2lab.get (newRoot);
- if (label != null && label.length()>0 && !label.equals (getRootDisplayName(null,rootName))) { //NOI18N
- newRootNode.setAttribute("name",label); //NOI18N
- }
- ownerElement.appendChild (newRootNode);
- }
- helper.putPrimaryConfigurationData(cfgEl,true);
- }
- }
- );
- }
-
- /**
- * Translates root name into display name of source/test root
- * @param rootName the name of root got from {@link SourceRoots#getRootNames}
- * @param propName the name of property the root is stored in
- * @return the label to be displayed
- */
- public String getRootDisplayName (String rootName, String propName) {
- if (rootName == null || rootName.length() ==0) {
- //If the prop is src.dir use the default name
- if (isTest && "test.src.dir".equals(propName)) { //NOI18N
- rootName = DEFAULT_TEST_LABEL;
- }
- else if (!isTest && "src.dir".equals(propName)) { //NOI18N
- rootName = DEFAULT_SOURCE_LABEL;
- }
- else {
- //If the name is not given, it should be either a relative path in the project dir
- //or absolute path when the root is not under the project dir
- String propValue = evaluator.getProperty(propName);
- File sourceRoot = propValue == null ? null : helper.getAntProjectHelper().resolveFile(propValue);
- rootName = createInitialDisplayName(sourceRoot);
- }
- }
- return rootName;
- }
-
- /**
- * Creates initial display name of source/test root
- * @param sourceRoot the source root
- * @return the label to be displayed
- */
- public String createInitialDisplayName (File sourceRoot) {
- String rootName;
- if (sourceRoot != null) {
- String srPath = sourceRoot.getAbsolutePath();
- String pdPath = projectDir.getAbsolutePath() + File.separatorChar;
- if (srPath.startsWith(pdPath)) {
- rootName = srPath.substring(pdPath.length());
- }
- else {
- rootName = sourceRoot.getAbsolutePath();
- }
- }
- else {
- rootName = isTest ? DEFAULT_TEST_LABEL : DEFAULT_SOURCE_LABEL;
- }
- return rootName;
- }
-
- /**
- * Returns true if this SourceRoots instance represents source roots belonging to
- * the tests compilation unit.
- * @return boolean
- */
- public boolean isTest () {
- return this.isTest;
- }
-
- private void resetCache (boolean isXMLChange, String propName) {
- boolean fire = false;
- synchronized (this) {
- //In case of change reset local cache
- if (isXMLChange) {
- this.sourceRootProperties = null;
- this.sourceRootNames = null;
- this.sourceRoots = null;
- this.sourceRootURLs = null;
- fire = true;
- } else if (propName == null || (sourceRootProperties != null && sourceRootProperties.contains(propName))) {
- this.sourceRoots = null;
- this.sourceRootURLs = null;
- fire = true;
- }
- }
- if (fire) {
- if (isXMLChange) {
- this.support.firePropertyChange (PROP_ROOT_PROPERTIES,null,null);
- }
- this.support.firePropertyChange (PROP_ROOTS,null,null);
- }
- }
-
- private void readProjectMetadata () {
- Element cfgEl = helper.getPrimaryConfigurationData(true);
- NodeList nl = cfgEl.getElementsByTagNameNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE, elementName);
- assert nl.getLength() == 0 || nl.getLength() == 1 : "Illegal project.xml"; //NOI18N
- List rootProps = new ArrayList();
- List rootNames = new ArrayList();
- // It can be 0 in the case when the project is created by J2SEProjectGenerator and not yet customized
- if (nl.getLength()==1) {
- NodeList roots = ((Element)nl.item(0)).getElementsByTagNameNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE, "root"); //NOI18N
- for (int i=0; i 0 : "Illegal project.xml";
- rootProps.add(value);
- value = root.getAttribute("name"); //NOI18N
- rootNames.add (value);
- }
- }
- this.sourceRootProperties = Collections.unmodifiableList(rootProps);
- this.sourceRootNames = Collections.unmodifiableList(rootNames);
- }
-
- private class ProjectMetadataListener implements PropertyChangeListener,AntProjectListener {
-
- public void propertyChange(PropertyChangeEvent evt) {
- resetCache (false,evt.getPropertyName());
- }
-
- public void configurationXmlChanged(AntProjectEvent ev) {
- resetCache (true,null);
- }
-
- public void propertiesChanged(AntProjectEvent ev) {
- //Handled by propertyChange
- }
- }
-
-}
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateHelper.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateHelper.java
deleted file mode 100644
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateHelper.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.j2ee.clientproject;
-
-import java.io.IOException;
-import javax.swing.JButton;
-import org.netbeans.modules.j2ee.clientproject.api.AppClientProjectGenerator;
-import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
-import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.openide.DialogDisplayer;
-import org.openide.NotifyDescriptor;
-import org.openide.util.NbBundle;
-import org.openide.util.Mutex;
-import org.netbeans.api.project.Project;
-import org.netbeans.api.project.ProjectManager;
-import org.netbeans.spi.project.AuxiliaryConfiguration;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.openide.util.Exceptions;
-
-
-/**
- * Proxy for the AntProjectHelper which defers the update of the project metadata
- * to explicit user action. Currently it is hard coded for update from
- * "http://www.netbeans.org/ns/j2se-project/1" to "http://www.netbeans.org/ns/j2se-project/2".
- * In future it should define plugable SPI.
- */
-public class UpdateHelper {
-
- private static final boolean TRANSPARENT_UPDATE = Boolean.getBoolean("carproject.transparentUpdate");
- private static final String BUILD_NUMBER = System.getProperty("netbeans.buildnumber"); // NOI18N
- private static final String MINIMUM_ANT_VERSION_ELEMENT = "minimum-ant-version"; // NOI18N
-
- private final Project project;
- private final AntProjectHelper helper;
- private final AuxiliaryConfiguration cfg;
- private final GeneratedFilesHelper genFileHelper;
- private final Notifier notifier;
- private boolean alreadyAskedInWriteAccess;
- private Boolean isCurrent;
- private Element cachedElement;
-
- /**
- * Creates new UpdateHelper
- * @param project
- * @param helper AntProjectHelper
- * @param cfg AuxiliaryConfiguration
- * @param genFileHelper GeneratedFilesHelper
- * @param notifier used to ask user about project update
- */
- UpdateHelper (Project project, AntProjectHelper helper, AuxiliaryConfiguration cfg, GeneratedFilesHelper genFileHelper, Notifier notifier) {
- assert project != null && helper != null && cfg != null && genFileHelper != null && notifier != null;
- this.project = project;
- this.helper = helper;
- this.cfg = cfg;
- this.genFileHelper = genFileHelper;
- this.notifier = notifier;
- }
-
- /**
- * Returns the AntProjectHelper.getProperties(), {@link AntProjectHelper#getProperties(String)}
- * @param path a relative URI in the project directory.
- * @return a set of properties
- */
- public EditableProperties getProperties (final String path) {
- //Properties are the same in both j2seproject/1 and j2seproject/2
- return ProjectManager.mutex().readAccess(new Mutex.Action(){
- public EditableProperties run() {
- if (!isCurrent() && AntProjectHelper.PROJECT_PROPERTIES_PATH.equals(path)) { //Only project properties were changed
- return getUpdatedProjectProperties ();
- }
- else {
- return helper.getProperties(path);
- }
- }
- });
- }
-
- /**
- * In the case that the project is of current version or the properties are not {@link AntProjectHelper#PROJECT_PROPERTIES_PATH}
- * it calls AntProjectHelper.putProperties(), {@link AntProjectHelper#putProperties(String, EditableProperties)}
- * otherwise it asks user to updata project. If the user agrees with the project update, it does the update and calls
- * AntProjectHelper.putProperties().
- * @param path a relative URI in the project directory.
- * @param props a set of properties
- */
- public void putProperties(final String path, final EditableProperties props) {
- ProjectManager.mutex().writeAccess(new Runnable() {
- public void run() {
- if (isCurrent() || !AntProjectHelper.PROJECT_PROPERTIES_PATH.equals(path)) { //Only project props should cause update
- helper.putProperties(path,props);
- } else if (canUpdate()) {
- try {
- saveUpdate();
- helper.putProperties(path,props);
- } catch (IOException ioe) {
- Exceptions.printStackTrace(ioe);
- }
- }
- }
- });
- }
-
- /**
- * In the case that the project is of current version or shared is false it delegates to
- * AntProjectHelper.getPrimaryConfigurationData(), {@link AntProjectHelper#getPrimaryConfigurationData(boolean)}.
- * Otherwise it creates an in memory update of shared configuration data and returns it.
- * @param shared if true, refers to project.xml, else refers to
- * private.xml
- * @return the configuration data that is available
- */
- public Element getPrimaryConfigurationData (final boolean shared) {
- return ProjectManager.mutex().readAccess(new Mutex.Action(){
- public Element run() {
- if (!shared || isCurrent()) { //Only shared props should cause update
- return helper.getPrimaryConfigurationData(shared);
- }
- return getUpdatedSharedConfigurationData ();
- }
- });
- }
-
- /**
- * In the case that the project is of current version or shared is false it calls AntProjectHelper.putPrimaryConfigurationData(),
- * {@link AntProjectHelper#putPrimaryConfigurationData(Element, boolean)}.
- * Otherwise it asks user to update the project. If the user agrees with the project update, it does the update and calls
- * AntProjectHelper.PrimaryConfigurationData().
- * @param element the configuration data
- * @param shared if true, refers to project.xml, else refers to
- * private.xml
- */
- public void putPrimaryConfigurationData(final Element element, final boolean shared) {
- ProjectManager.mutex().writeAccess(new Runnable() {
- public void run() {
- if (!shared || isCurrent()) {
- helper.putPrimaryConfigurationData(element, shared);
- } else if (canUpdate()) {
- try {
- saveUpdate();
- helper.putPrimaryConfigurationData(element, shared);
- } catch (IOException ioe) {
- Exceptions.printStackTrace(ioe);
- }
- }
- }
- });
- }
-
- /**
- * Returns an AntProjectHelper. The helper may not be used for accessing/storing project metadata.
- * For project metadata manipulation the UpdateHelper must be used.
- * @return AntProjectHelper
- */
- public AntProjectHelper getAntProjectHelper () {
- return this.helper;
- }
-
- /**
- * Request an saving of update. If the project is not of current version the user will be asked to update the project.
- * If the user agrees with an update the project is updated.
- * @return true if the metadata are of current version or updated
- */
- public boolean requestSave () throws IOException{
- if (isCurrent()) {
- return true;
- }
- if (!canUpdate()) {
- return false;
- }
- saveUpdate ();
- return true;
- }
-
- /**
- * Returns true if the project is of current version.
- * @return true if the project is of current version, otherwise false.
- */
- public synchronized boolean isCurrent () {
- /*
- if (this.isCurrent == null) {
- if ((this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/1",true) != null) ||
- (this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/2",true) != null)) {
- this.isCurrent = Boolean.FALSE;
- } else {
- this.isCurrent = Boolean.TRUE;
- }
- }
- return isCurrent.booleanValue();
- */
- //there are no other versions yet => we can always return true
- return true;
- }
-
- private boolean canUpdate () {
- if (TRANSPARENT_UPDATE) {
- return true;
- }
- //Ask just once under a single write access
- if (alreadyAskedInWriteAccess) {
- return false;
- }
- else {
- boolean canUpdate = this.notifier.canUpdate();
- if (!canUpdate) {
- alreadyAskedInWriteAccess = true;
- ProjectManager.mutex().postReadRequest(new Runnable() {
- public void run() {
- alreadyAskedInWriteAccess = false;
- }
- });
- }
- return canUpdate;
- }
- }
-
- private void saveUpdate () throws IOException {
- this.helper.putPrimaryConfigurationData(getUpdatedSharedConfigurationData(),true);
- this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/1",true); //NOI18N
- this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/2",true); //NOI18N
- ProjectManager.getDefault().saveProject (this.project);
- synchronized(this) {
- this.isCurrent = Boolean.TRUE;
- }
- }
-
- private synchronized Element getUpdatedSharedConfigurationData () {
- if (cachedElement == null) {
- Element oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/1",true); //NOI18N
- if (oldRoot != null) {
- Document doc = oldRoot.getOwnerDocument();
- Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
- Element sourceRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
- Element root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
- root.setAttribute ("id","src.dir"); //NOI18N
- sourceRoots.appendChild(root);
- newRoot.appendChild (sourceRoots);
- Element testRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"test-roots"); //NOI18N
- root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
- root.setAttribute ("id","test.src.dir"); //NOI18N
- testRoots.appendChild (root);
- newRoot.appendChild (testRoots);
- cachedElement = updateMinAntVersion (newRoot, doc);
- } else {
- oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/2",true); //NOI18N
- if (oldRoot != null) {
- Document doc = oldRoot.getOwnerDocument();
- Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
- cachedElement = updateMinAntVersion (newRoot, doc);
- }
- }
- }
- return cachedElement;
- }
-
- private synchronized EditableProperties getUpdatedProjectProperties () {
- EditableProperties cachedProperties = this.helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- //The javadoc.additionalparam was not in NB 4.0
- if (cachedProperties.get (AppClientProjectProperties.JAVADOC_ADDITIONALPARAM)==null) {
- cachedProperties.put (AppClientProjectProperties.JAVADOC_ADDITIONALPARAM,""); //NOI18N
- }
- if (cachedProperties.get ("build.generated.dir")==null) { //NOI18N
- cachedProperties.put ("build.generated.dir","${build.dir}/generated"); //NOI18N
- }
- if (cachedProperties.get (AppClientProjectProperties.META_INF)==null) { //NOI18N
- cachedProperties.put (AppClientProjectProperties.META_INF,"${src.dir}/conf"); //NOI18N
- }
- return cachedProperties;
- }
-
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,newElement);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
- private static Element updateMinAntVersion (final Element root, final Document doc) {
- NodeList list = root.getElementsByTagNameNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
- if (list.getLength() == 1) {
- Element me = (Element) list.item(0);
- list = me.getChildNodes();
- if (list.getLength() == 1) {
- me.replaceChild (doc.createTextNode(AppClientProjectGenerator.MINIMUM_ANT_VERSION), list.item(0));
- return root;
- }
- }
- assert false : "Invalid project file"; //NOI18N
- return root;
- }
-
- /**
- * Creates an default Notifier. The default notifier displays a dialog warning user about project update.
- * @return notifier
- */
- public static Notifier createDefaultNotifier () {
- return new Notifier() {
- public boolean canUpdate() {
- JButton updateOption = new JButton (NbBundle.getMessage(UpdateHelper.class, "CTL_UpdateOption"));
- updateOption.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(UpdateHelper.class, "AD_UpdateOption"));
- return DialogDisplayer.getDefault().notify(
- new NotifyDescriptor (NbBundle.getMessage(UpdateHelper.class,"TXT_ProjectUpdate", BUILD_NUMBER),
- NbBundle.getMessage(UpdateHelper.class,"TXT_ProjectUpdateTitle"),
- NotifyDescriptor.DEFAULT_OPTION,
- NotifyDescriptor.WARNING_MESSAGE,
- new Object[] {
- updateOption,
- NotifyDescriptor.CANCEL_OPTION
- },
- updateOption)) == updateOption;
- }
- };
- }
-
- /**
- * Interface used by the UpdateHelper to ask user about
- * the project update.
- */
- public static interface Notifier {
- /**
- * Asks user to update the project
- * @return true if the project should be updated
- */
- public boolean canUpdate ();
- }
-}
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java
new file mode 100644
--- /dev/null
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java
@@ -0,0 +1,251 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 2008 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.j2ee.clientproject;
+
+import java.io.IOException;
+import javax.swing.JButton;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.modules.j2ee.clientproject.api.AppClientProjectGenerator;
+import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
+import org.netbeans.modules.java.api.common.ant.UpdateImplementation;
+import org.netbeans.spi.project.AuxiliaryConfiguration;
+import org.netbeans.spi.project.support.ant.AntProjectHelper;
+import org.netbeans.spi.project.support.ant.EditableProperties;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.util.NbBundle;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ *
+ * @author Tomas Mysik
+ */
+public class UpdateProjectImpl implements UpdateImplementation {
+
+ private static final boolean TRANSPARENT_UPDATE = Boolean.getBoolean("carproject.transparentUpdate");
+ private static final String BUILD_NUMBER = System.getProperty("netbeans.buildnumber"); // NOI18N
+ private static final String MINIMUM_ANT_VERSION_ELEMENT = "minimum-ant-version"; // NOI18N
+
+ private final Project project;
+ private final AntProjectHelper helper;
+ private final AuxiliaryConfiguration cfg;
+ private boolean alreadyAskedInWriteAccess;
+ private boolean isCurrent;
+ private Element cachedElement;
+
+ /**
+ * Creates new UpdateHelper
+ * @param project
+ * @param helper AntProjectHelper
+ * @param cfg AuxiliaryConfiguration
+ * @param genFileHelper GeneratedFilesHelper
+ * @param notifier used to ask user about project update
+ */
+ UpdateProjectImpl(Project project, AntProjectHelper helper, AuxiliaryConfiguration cfg) {
+ assert project != null && helper != null && cfg != null;
+ this.project = project;
+ this.helper = helper;
+ this.cfg = cfg;
+ }
+
+ public boolean isCurrent() {
+ /*
+ if (this.isCurrent == null) {
+ if ((this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/1",true) != null) ||
+ (this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/2",true) != null)) {
+ this.isCurrent = Boolean.FALSE;
+ } else {
+ this.isCurrent = Boolean.TRUE;
+ }
+ }
+ return isCurrent.booleanValue();
+ */
+ //there are no other versions yet => we can always return true
+ return true;
+ }
+
+ public boolean canUpdate() {
+ if (TRANSPARENT_UPDATE) {
+ return true;
+ }
+ //Ask just once under a single write access
+ if (alreadyAskedInWriteAccess) {
+ return false;
+ }
+ else {
+ boolean canUpdate = showUpdateDialog();
+ if (!canUpdate) {
+ alreadyAskedInWriteAccess = true;
+ ProjectManager.mutex().postReadRequest(new Runnable() {
+ public void run() {
+ alreadyAskedInWriteAccess = false;
+ }
+ });
+ }
+ return canUpdate;
+ }
+ }
+
+ public void saveUpdate(EditableProperties props) throws IOException {
+ this.helper.putPrimaryConfigurationData(getUpdatedSharedConfigurationData(),true);
+ this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/1",true); //NOI18N
+ this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/2",true); //NOI18N
+ ProjectManager.getDefault().saveProject (this.project);
+ synchronized(this) {
+ this.isCurrent = Boolean.TRUE;
+ }
+ }
+
+ public Element getUpdatedSharedConfigurationData() {
+ if (cachedElement == null) {
+ Element oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/1",true); //NOI18N
+ if (oldRoot != null) {
+ Document doc = oldRoot.getOwnerDocument();
+ Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
+ copyDocument (doc, oldRoot, newRoot);
+ Element sourceRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
+ Element root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
+ root.setAttribute ("id","src.dir"); //NOI18N
+ sourceRoots.appendChild(root);
+ newRoot.appendChild (sourceRoots);
+ Element testRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"test-roots"); //NOI18N
+ root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
+ root.setAttribute ("id","test.src.dir"); //NOI18N
+ testRoots.appendChild (root);
+ newRoot.appendChild (testRoots);
+ cachedElement = updateMinAntVersion (newRoot, doc);
+ } else {
+ oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/2",true); //NOI18N
+ if (oldRoot != null) {
+ Document doc = oldRoot.getOwnerDocument();
+ Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
+ copyDocument (doc, oldRoot, newRoot);
+ cachedElement = updateMinAntVersion (newRoot, doc);
+ }
+ }
+ }
+ return cachedElement;
+ }
+
+ public EditableProperties getUpdatedProjectProperties() {
+ EditableProperties cachedProperties = this.helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
+ //The javadoc.additionalparam was not in NB 4.0
+ if (cachedProperties.get (AppClientProjectProperties.JAVADOC_ADDITIONALPARAM)==null) {
+ cachedProperties.put (AppClientProjectProperties.JAVADOC_ADDITIONALPARAM,""); //NOI18N
+ }
+ if (cachedProperties.get ("build.generated.dir")==null) { //NOI18N
+ cachedProperties.put ("build.generated.dir","${build.dir}/generated"); //NOI18N
+ }
+ if (cachedProperties.get (AppClientProjectProperties.META_INF)==null) { //NOI18N
+ cachedProperties.put (AppClientProjectProperties.META_INF,"${src.dir}/conf"); //NOI18N
+ }
+ return cachedProperties;
+ }
+
+ private static void copyDocument (Document doc, Element from, Element to) {
+ NodeList nl = from.getChildNodes();
+ int length = nl.getLength();
+ for (int i=0; i< length; i++) {
+ Node node = nl.item (i);
+ Node newNode = null;
+ switch (node.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ Element oldElement = (Element) node;
+ newNode = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
+ NamedNodeMap m = oldElement.getAttributes();
+ Element newElement = (Element) newNode;
+ for (int index = 0; index < m.getLength(); index++) {
+ Node attr = m.item(index);
+ newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
+ }
+ copyDocument(doc,oldElement,newElement);
+ break;
+ case Node.TEXT_NODE:
+ Text oldText = (Text) node;
+ newNode = doc.createTextNode(oldText.getData());
+ break;
+ case Node.COMMENT_NODE:
+ Comment oldComment = (Comment) node;
+ newNode = doc.createComment(oldComment.getData());
+ break;
+ }
+ if (newNode != null) {
+ to.appendChild (newNode);
+ }
+ }
+ }
+
+ private static Element updateMinAntVersion (final Element root, final Document doc) {
+ NodeList list = root.getElementsByTagNameNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
+ if (list.getLength() == 1) {
+ Element me = (Element) list.item(0);
+ list = me.getChildNodes();
+ if (list.getLength() == 1) {
+ me.replaceChild (doc.createTextNode(AppClientProjectGenerator.MINIMUM_ANT_VERSION), list.item(0));
+ return root;
+ }
+ }
+ assert false : "Invalid project file"; //NOI18N
+ return root;
+ }
+
+ private boolean showUpdateDialog() {
+ JButton updateOption = new JButton (NbBundle.getMessage(UpdateProjectImpl.class, "CTL_UpdateOption"));
+ updateOption.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(UpdateHelper.class, "AD_UpdateOption"));
+ return DialogDisplayer.getDefault().notify(
+ new NotifyDescriptor (NbBundle.getMessage(UpdateProjectImpl.class,"TXT_ProjectUpdate", BUILD_NUMBER),
+ NbBundle.getMessage(UpdateProjectImpl.class,"TXT_ProjectUpdateTitle"),
+ NotifyDescriptor.DEFAULT_OPTION,
+ NotifyDescriptor.WARNING_MESSAGE,
+ new Object[] {
+ updateOption,
+ NotifyDescriptor.CANCEL_OPTION
+ },
+ updateOption)) == updateOption;
+ }
+}
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectGenerator.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectGenerator.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectGenerator.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/api/AppClientProjectGenerator.java
@@ -58,10 +58,8 @@ import org.netbeans.modules.j2ee.clientp
import org.netbeans.modules.j2ee.clientproject.AppClientProject;
import org.netbeans.modules.j2ee.clientproject.AppClientProjectType;
import org.netbeans.modules.j2ee.clientproject.AppClientProvider;
-import org.netbeans.modules.j2ee.clientproject.UpdateHelper;
import org.netbeans.modules.j2ee.clientproject.Utils;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
-import org.netbeans.modules.j2ee.clientproject.ui.customizer.PlatformUiSupport;
import org.netbeans.modules.j2ee.dd.api.client.AppClient;
import org.netbeans.modules.j2ee.dd.api.client.DDProvider;
import org.netbeans.modules.j2ee.deployment.devmodules.api.AntDeploymentHelper;
@@ -69,6 +67,8 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
+import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
import org.netbeans.modules.websvc.api.client.WebServicesClientConstants;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
@@ -637,7 +637,7 @@ public class AppClientProjectGenerator {
if (sourceLevel.equals("1.6") || sourceLevel.equals("1.7")) {
srcLevel = "1.5";
}
- PlatformUiSupport.storePlatform(ep, updateHelper, finalPlatformName, srcLevel != null ? new SpecificationVersion(srcLevel) : null);
+ PlatformUiSupport.storePlatform(ep, updateHelper, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE, finalPlatformName, srcLevel != null ? new SpecificationVersion(srcLevel) : null);
helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
ProjectManager.getDefault().saveProject(ProjectManager.getDefault().findProject(helper.getProjectDirectory()));
} catch (IOException e) {
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/AppClientProjectClassPathExtender.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/AppClientProjectClassPathExtender.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/AppClientProjectClassPathExtender.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/AppClientProjectClassPathExtender.java
@@ -62,8 +62,8 @@ import org.netbeans.spi.project.support.
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.netbeans.modules.j2ee.clientproject.UpdateHelper;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AntArtifactChooser;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathProviderImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathProviderImpl.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathProviderImpl.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathProviderImpl.java
@@ -53,8 +53,8 @@ import org.netbeans.spi.java.project.cla
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.netbeans.modules.j2ee.clientproject.SourceRoots;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
+import org.netbeans.modules.java.api.common.SourceRoots;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.WeakListeners;
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/SourcePathImplementation.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/SourcePathImplementation.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/SourcePathImplementation.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/SourcePathImplementation.java
@@ -49,10 +49,10 @@ import java.beans.PropertyChangeListener
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.net.URL;
+import org.netbeans.modules.java.api.common.SourceRoots;
import org.netbeans.spi.java.classpath.ClassPathImplementation;
import org.netbeans.spi.java.classpath.PathResourceImplementation;
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
-import org.netbeans.modules.j2ee.clientproject.SourceRoots;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.openide.util.Exceptions;
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/AppClientProjectEncodingQueryImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/AppClientProjectEncodingQueryImpl.java
deleted file mode 100644
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/AppClientProjectEncodingQueryImpl.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.j2ee.clientproject.queries;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
-import org.netbeans.spi.queries.FileEncodingQueryImplementation;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.openide.filesystems.FileObject;
-
-/**
- *
- * @author Tomas Zezula
- */
-public class AppClientProjectEncodingQueryImpl extends FileEncodingQueryImplementation implements PropertyChangeListener {
-
-
- private final PropertyEvaluator eval;
- private Charset cache;
-
- /** Creates a new instance of J2SEProjectEncodingQueryImpl */
- public AppClientProjectEncodingQueryImpl(final PropertyEvaluator eval) {
- assert eval != null;
- this.eval = eval;
- this.eval.addPropertyChangeListener(this);
- }
-
- public Charset getEncoding(FileObject file) {
- assert file != null;
- synchronized (this) {
- if (cache != null) {
- return cache;
- }
- }
- String enc = eval.getProperty(AppClientProjectProperties.SOURCE_ENCODING);
- synchronized (this) {
- if (cache == null) {
- try {
- cache = enc == null ? Charset.defaultCharset() : Charset.forName(enc);
- } catch (IllegalCharsetNameException exception) {
- return null;
- }
- }
- return cache;
- }
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- String propName = event.getPropertyName();
- if (propName == null || propName.equals(AppClientProjectProperties.SOURCE_ENCODING)) {
- synchronized (this) {
- cache = null;
- }
- }
- }
-
-}
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/CompiledSourceForBinaryQuery.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/CompiledSourceForBinaryQuery.java
deleted file mode 100644
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/CompiledSourceForBinaryQuery.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.j2ee.clientproject.queries;
-
-import java.io.File;
-import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.ChangeEvent;
-
-import org.netbeans.api.java.queries.SourceForBinaryQuery;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.netbeans.modules.j2ee.clientproject.SourceRoots;
-import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
-import org.openide.util.Exceptions;
-
-/**
- * Finds sources corresponding to binaries in a J2SE project.
- * @author Jesse Glick, Tomas Zezula
- */
-public class CompiledSourceForBinaryQuery implements SourceForBinaryQueryImplementation {
-
- private final AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
- private final SourceRoots sourceRoots;
- private final SourceRoots testRoots;
- private Map cache = new HashMap();
-
- public CompiledSourceForBinaryQuery(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots srcRoots, SourceRoots testRoots) {
- this.helper = helper;
- this.evaluator = evaluator;
- this.sourceRoots = srcRoots;
- this.testRoots = testRoots;
- }
-
- public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) {
- if (FileUtil.getArchiveFile(binaryRoot) != null) {
- binaryRoot = FileUtil.getArchiveFile(binaryRoot);
- // XXX check whether this is really the root
- }
- SourceForBinaryQuery.Result res = cache.get(binaryRoot);
- if (res != null) {
- return res;
- }
- SourceRoots src = null;
- if (hasSources(binaryRoot, AppClientProjectProperties.BUILD_CLASSES_DIR)) {
- src = this.sourceRoots;
- } else if (hasSources(binaryRoot, AppClientProjectProperties.DIST_JAR)) {
- src = this.sourceRoots;
- } else if (hasSources(binaryRoot, AppClientProjectProperties.BUILD_TEST_CLASSES_DIR)) {
- src = this.testRoots;
- }
- if (src == null) {
- return null;
- } else {
- res = new Result(src);
- cache.put(binaryRoot, res);
- return res;
- }
- }
-
-
- private boolean hasSources(URL binaryRoot, String binaryProperty) {
- try {
- String outDir = evaluator.getProperty(binaryProperty);
- if (outDir != null) {
- File f = helper.resolveFile(outDir);
- URL url = f.toURI().toURL();
- if (!f.exists() && !f.getPath().toLowerCase().endsWith(".jar")) { // NOI18N
- // non-existing
- assert !url.toExternalForm().endsWith("/") : f; // NOI18N
- url = new URL(url.toExternalForm() + "/"); // NOI18N
- }
- if (url.equals(binaryRoot)) {
- return true;
- }
- }
- } catch (MalformedURLException malformedURL) {
- Exceptions.printStackTrace(malformedURL);
- }
- return false;
- }
-
- private static class Result implements SourceForBinaryQuery.Result, PropertyChangeListener {
-
- private ArrayList listeners;
- private SourceRoots sourceRoots;
-
- public Result(SourceRoots sourceRoots) {
- this.sourceRoots = sourceRoots;
- this.sourceRoots.addPropertyChangeListener(this);
- }
-
- public FileObject[] getRoots() {
- return this.sourceRoots.getRoots(); //No need to cache it, SourceRoots does
- }
-
- public synchronized void addChangeListener(ChangeListener l) {
- if (this.listeners == null) {
- this.listeners = new ArrayList();
- }
- this.listeners.add(l);
- }
-
- public synchronized void removeChangeListener(ChangeListener l) {
- if (this.listeners == null) {
- return;
- }
- this.listeners.remove(l);
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (SourceRoots.PROP_ROOTS.equals(evt.getPropertyName())) {
- this.fireChange();
- }
- }
-
- private void fireChange() {
- Iterator it;
- synchronized (this) {
- if (this.listeners == null) {
- return;
- }
- @SuppressWarnings("unchecked")
- ArrayList cloned = (ArrayList) this.listeners.clone();
- it = cloned.iterator();
- }
- ChangeEvent event = new ChangeEvent(this);
- while (it.hasNext()) {
- (it.next()).stateChanged(event);
- }
- }
-
- }
-
-}
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/JavadocForBinaryQueryImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/JavadocForBinaryQueryImpl.java
deleted file mode 100644
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/JavadocForBinaryQueryImpl.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.j2ee.clientproject.queries;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.event.ChangeEvent;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.openide.filesystems.FileUtil;
-import java.net.URL;
-import java.net.MalformedURLException;
-import javax.swing.event.ChangeListener;
-import org.netbeans.api.java.queries.JavadocForBinaryQuery;
-import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
-import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.openide.util.Exceptions;
-import org.openide.util.WeakListeners;
-
-/**
- * Finds Javadoc (if it is built) corresponding to binaries in J2SE project.
- * @author David Konecny, Jesse Glick
- */
-public class JavadocForBinaryQueryImpl implements JavadocForBinaryQueryImplementation {
-
- private static final String PROP_JAVADOC_DIR = "dist.javadoc.dir"; //NOI18N
-
- private final AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
-
- public JavadocForBinaryQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator) {
- this.helper = helper;
- this.evaluator = evaluator;
- }
-
- public JavadocForBinaryQuery.Result findJavadoc(final URL binaryRoot) {
-
- class R implements JavadocForBinaryQuery.Result, PropertyChangeListener {
-
- private List listeners;
- private URL[] result;
-
- public R () {
- JavadocForBinaryQueryImpl.this.evaluator.addPropertyChangeListener (WeakListeners.propertyChange(this,JavadocForBinaryQueryImpl.this.evaluator));
- }
-
- public synchronized URL[] getRoots() {
- if (this.result == null) {
- String javadocDir = evaluator.getProperty(AppClientProjectProperties.DIST_JAVADOC_DIR);
- if (javadocDir != null) {
- File f = helper.resolveFile(javadocDir);
- try {
- URL url = f.toURI().toURL();
- if (!f.exists()) {
- assert !url.toExternalForm().endsWith("/") : f; // NOI18N
- url = new URL(url.toExternalForm() + "/"); // NOI18N
- }
- this.result = new URL[] {url};
- } catch (MalformedURLException e) {
- this.result = new URL[0];
- Exceptions.printStackTrace(e);
- }
- }
- else {
- this.result = new URL[0];
- }
- }
- return this.result;
- }
- public synchronized void addChangeListener(final ChangeListener l) {
- assert l != null;
- if (this.listeners == null) {
- this.listeners = new ArrayList();
- }
- this.listeners.add (l);
- }
- public synchronized void removeChangeListener(final ChangeListener l) {
- assert l != null;
- if (this.listeners == null) {
- return;
- }
- this.listeners.remove (l);
- }
-
- public void propertyChange (final PropertyChangeEvent event) {
- if (AppClientProjectProperties.DIST_JAVADOC_DIR.equals(event.getPropertyName())) {
- synchronized (this) {
- result = null;
- }
- this.fireChange ();
- }
- }
-
- private void fireChange () {
- ChangeListener[] _listeners;
- synchronized (this) {
- if (this.listeners == null) {
- return;
- }
- _listeners = this.listeners.toArray (new ChangeListener[this.listeners.size()]);
- }
- ChangeEvent event = new ChangeEvent (this);
- for (int i=0; i<_listeners.length; i++) {
- _listeners[i].stateChanged(event);
- }
- }
- }
- if (isRootOwner(binaryRoot, AppClientProjectProperties.BUILD_CLASSES_DIR) || isRootOwner (binaryRoot, AppClientProjectProperties.DIST_JAR)) { //NOI18N
- return new R();
- }
- return null;
- }
-
- private boolean isRootOwner (URL binaryRoot, String binaryProperty) {
- try {
- if (FileUtil.getArchiveFile(binaryRoot) != null) {
- binaryRoot = FileUtil.getArchiveFile(binaryRoot);
- // XXX check whether this is really the root
- }
- String outDir = evaluator.getProperty(binaryProperty);
- if (outDir != null) {
- File f = helper.resolveFile (outDir);
- URL url = f.toURI().toURL();
- if (!f.exists() && !f.getPath().toLowerCase().endsWith(".jar")) { // NOI18N
- assert !url.toExternalForm().endsWith("/") : f; // NOI18N
- url = new URL(url.toExternalForm() + "/"); // NOI18N
- }
- return url.equals(binaryRoot) ||
- binaryRoot.toExternalForm().startsWith(url.toExternalForm());
- }
- } catch (MalformedURLException malformedURL) {
- Exceptions.printStackTrace(malformedURL);
- }
- return false;
- }
-
-// private URL getJavadoc(URL binaryRoot, String binaryProperty, String javadocProperty) {
-// try {
-// if (FileUtil.getArchiveFile(binaryRoot) != null) {
-// binaryRoot = FileUtil.getArchiveFile(binaryRoot);
-// }
-// String outDir = evaluator.getProperty(binaryProperty);
-// if (outDir != null) {
-// File f = helper.resolveFile (outDir);
-// URL url = f.toURI().toURL();
-// if (!f.exists() && !f.getPath().toLowerCase().endsWith(".jar")) {
-// assert !url.toExternalForm().endsWith("/") : f;
-// url = new URL(url.toExternalForm() + "/");
-// }
-// if (url.equals(binaryRoot) ||
-// binaryRoot.toExternalForm().startsWith(url.toExternalForm())) {
-// String javadocDir = evaluator.getProperty(javadocProperty);
-// if (javadocDir != null) {
-// f = helper.resolveFile(javadocDir);
-// return f.toURI().toURL();
-// }
-// }
-// }
-// } catch (MalformedURLException malformedURL) {
-// ErrorManager.getDefault().notify(malformedURL);
-// }
-// return null;
-// }
-
-}
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/SourceLevelQueryImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/SourceLevelQueryImpl.java
deleted file mode 100644
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/SourceLevelQueryImpl.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.j2ee.clientproject.queries;
-
-import org.netbeans.modules.j2ee.clientproject.AppClientProjectUtil;
-import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
-import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.netbeans.spi.project.support.ant.PropertyUtils;
-import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.openide.filesystems.FileObject;
-
-/**
- * Returns source level of project sources.
- * @author David Konecny
- */
-public class SourceLevelQueryImpl implements SourceLevelQueryImplementation {
-
- private final PropertyEvaluator evaluator;
-
- public SourceLevelQueryImpl(PropertyEvaluator evaluator) {
- this.evaluator = evaluator;
- }
-
- public String getSourceLevel(FileObject javaFile) {
- final String activePlatform = evaluator.getProperty (AppClientProjectProperties.JAVA_PLATFORM); //NOI18N
- if (AppClientProjectUtil.getActivePlatform(activePlatform) != null) {
- String sl = evaluator.getProperty("javac.source"); //NOI18N
- if (sl != null && sl.length() > 0) {
- return sl;
- } else {
- return null;
- }
- }
- else {
- EditableProperties props = PropertyUtils.getGlobalProperties();
- String sl = props.get("default.javac.source"); //NOI18N
- if (sl != null && sl.length() > 0) {
- return sl;
- } else {
- return null;
- }
- }
- }
-
-}
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/UnitTestForSourceQueryImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/UnitTestForSourceQueryImpl.java
deleted file mode 100644
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/queries/UnitTestForSourceQueryImpl.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.j2ee.clientproject.queries;
-
-import java.net.URL;
-import org.netbeans.api.project.FileOwnerQuery;
-import org.netbeans.api.project.Project;
-import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
-import org.netbeans.modules.j2ee.clientproject.SourceRoots;
-import org.openide.filesystems.FileObject;
-
-public class UnitTestForSourceQueryImpl implements MultipleRootsUnitTestForSourceQueryImplementation {
-
- private final SourceRoots sourceRoots;
- private final SourceRoots testRoots;
-
- public UnitTestForSourceQueryImpl(SourceRoots sourceRoots, SourceRoots testRoots) {
- this.sourceRoots = sourceRoots;
- this.testRoots = testRoots;
- }
-
- public URL[] findUnitTests(FileObject source) {
- return find(source, sourceRoots, testRoots); // NOI18N
- }
-
- public URL[] findSources(FileObject unitTest) {
- return find(unitTest, testRoots, sourceRoots); // NOI18N
- }
-
- private URL[] find(FileObject file, SourceRoots from, SourceRoots to) {
- Project p = FileOwnerQuery.getOwner(file);
- if (p == null) {
- return null;
- }
- FileObject[] fromRoots = from.getRoots();
- for (int i = 0; i < fromRoots.length; i++) {
- if (fromRoots[i].equals(file)) {
- return to.getRootURLs();
- }
- }
- return null;
- }
-
-}
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/ActionFilterNode.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/ActionFilterNode.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/ActionFilterNode.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/ActionFilterNode.java
@@ -65,8 +65,8 @@ import org.netbeans.api.java.queries.Jav
import org.netbeans.api.java.queries.JavadocForBinaryQuery;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.netbeans.modules.j2ee.clientproject.UpdateHelper;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.openide.nodes.FilterNode.Children;
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/AppClientLogicalViewProvider.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/AppClientLogicalViewProvider.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/AppClientLogicalViewProvider.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/AppClientLogicalViewProvider.java
@@ -81,8 +81,6 @@ import org.netbeans.modules.j2ee.api.ejb
import org.netbeans.modules.j2ee.api.ejbjar.EjbProjectConstants;
import org.netbeans.modules.j2ee.clientproject.AppClientProject;
import org.netbeans.modules.j2ee.clientproject.AppClientProjectUtil;
-import org.netbeans.modules.j2ee.clientproject.SourceRoots;
-import org.netbeans.modules.j2ee.clientproject.UpdateHelper;
import org.netbeans.modules.j2ee.clientproject.classpath.ClassPathSupport;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.CustomizerLibraries;
@@ -95,6 +93,8 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.spi.InstanceListener;
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
import org.netbeans.modules.j2ee.spi.ejbjar.support.J2eeProjectView;
+import org.netbeans.modules.java.api.common.SourceRoots;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.modules.websvc.api.client.WebServicesClientSupport;
import org.netbeans.modules.websvc.api.client.WebServicesClientView;
import org.netbeans.modules.websvc.api.jaxws.client.JAXWSClientSupport;
@@ -632,7 +632,7 @@ public class AppClientLogicalViewProvide
public void actionPerformed(ActionEvent e) {
try {
- helper.requestSave();
+ helper.requestUpdate();
BrokenReferencesSupport.showCustomizer(helper.getAntProjectHelper(), resolver, getBreakableProperties(), new String[] {AppClientProjectProperties.JAVA_PLATFORM});
run();
} catch (IOException ioe) {
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/LibrariesNode.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/LibrariesNode.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/LibrariesNode.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/LibrariesNode.java
@@ -102,11 +102,11 @@ import org.netbeans.spi.project.support.
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.spi.java.project.support.ui.PackageView;
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
-import org.netbeans.modules.j2ee.clientproject.UpdateHelper;
import org.netbeans.modules.j2ee.clientproject.classpath.AppClientProjectClassPathExtender;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AntArtifactChooser;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientClassPathUi;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.LibrariesChooser;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.openide.util.Exceptions;
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/ProjectNode.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/ProjectNode.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/ProjectNode.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/ProjectNode.java
@@ -81,8 +81,8 @@ import org.netbeans.spi.project.support.
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
-import org.netbeans.modules.j2ee.clientproject.UpdateHelper;
import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.openide.filesystems.FileObject;
import org.openide.util.Exceptions;
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/AppClientProjectProperties.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/AppClientProjectProperties.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/AppClientProjectProperties.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/AppClientProjectProperties.java
@@ -71,9 +71,8 @@ import org.netbeans.api.queries.Collocat
import org.netbeans.api.queries.CollocationQuery;
import org.netbeans.api.queries.FileEncodingQuery;
import org.netbeans.modules.j2ee.clientproject.AppClientProject;
+import org.netbeans.modules.j2ee.clientproject.AppClientProjectType;
import org.netbeans.modules.j2ee.clientproject.AppClientProjectUtil;
-import org.netbeans.modules.j2ee.clientproject.SourceRoots;
-import org.netbeans.modules.j2ee.clientproject.UpdateHelper;
import org.netbeans.modules.j2ee.clientproject.Utils;
import org.netbeans.modules.j2ee.clientproject.classpath.ClassPathSupport;
import org.netbeans.modules.j2ee.deployment.devmodules.api.AntDeploymentHelper;
@@ -81,6 +80,9 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
+import org.netbeans.modules.java.api.common.SourceRoots;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
+import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
import org.netbeans.modules.websvc.api.client.WebServicesClientConstants;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
@@ -94,7 +96,6 @@ import org.openide.filesystems.FileObjec
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.filesystems.URLMapper;
-import org.openide.modules.SpecificationVersion;
import org.openide.util.Exceptions;
import org.openide.util.Mutex;
import org.openide.util.MutexException;
@@ -339,7 +340,11 @@ public class AppClientProjectProperties
RUN_TEST_CLASSPATH_MODEL = ClassPathUiSupport.createListModel( cs.itemsIterator(projectProperties.get( RUN_TEST_CLASSPATH ), null ) );
PLATFORM_MODEL = PlatformUiSupport.createPlatformComboBoxModel (evaluator.getProperty(JAVA_PLATFORM));
PLATFORM_LIST_RENDERER = PlatformUiSupport.createPlatformListCellRenderer();
- JAVAC_SOURCE_MODEL = PlatformUiSupport.createSourceLevelComboBoxModel (PLATFORM_MODEL, evaluator.getProperty(JAVAC_SOURCE), evaluator.getProperty(JAVAC_TARGET), evaluator.getProperty(J2EE_PLATFORM));
+ PlatformUiSupport.JDK minimalSourceLevel = null;
+ if (evaluator.getProperty(J2EE_PLATFORM).equals(JAVA_EE_5)) {
+ minimalSourceLevel = PlatformUiSupport.JDK.VERSION_5;
+ }
+ JAVAC_SOURCE_MODEL = PlatformUiSupport.createSourceLevelComboBoxModel(PLATFORM_MODEL, evaluator.getProperty(JAVAC_SOURCE), evaluator.getProperty(JAVAC_TARGET), minimalSourceLevel);
JAVAC_SOURCE_RENDERER = PlatformUiSupport.createSourceLevelListCellRenderer ();
// CustomizerCompile
@@ -472,7 +477,7 @@ public class AppClientProjectProperties
projectProperties.setProperty( RUN_TEST_CLASSPATH, run_test_cp );
//Handle platform selection and javac.source javac.target properties
- PlatformUiSupport.storePlatform (projectProperties, updateHelper,PLATFORM_MODEL.getSelectedItem(), JAVAC_SOURCE_MODEL.getSelectedItem());
+ PlatformUiSupport.storePlatform (projectProperties, updateHelper, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE, PLATFORM_MODEL.getSelectedItem(), JAVAC_SOURCE_MODEL.getSelectedItem());
// Handle other special cases
if ( NO_DEPENDENCIES_MODEL.isSelected() ) { // NOI18N
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/AppClientSourceRootsUi.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/AppClientSourceRootsUi.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/AppClientSourceRootsUi.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/AppClientSourceRootsUi.java
@@ -83,7 +83,7 @@ import org.netbeans.api.project.FileOwne
import org.netbeans.api.project.FileOwnerQuery;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
-import org.netbeans.modules.j2ee.clientproject.SourceRoots;
+import org.netbeans.modules.java.api.common.SourceRoots;
import org.openide.DialogDisplayer;
import org.openide.DialogDescriptor;
import org.openide.filesystems.FileObject;
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerLibraries.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerLibraries.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerLibraries.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerLibraries.java
@@ -55,6 +55,7 @@ import org.netbeans.api.java.platform.Pl
import org.netbeans.api.java.platform.PlatformsCustomizer;
import org.netbeans.modules.j2ee.clientproject.classpath.ClassPathSupport;
import org.netbeans.modules.j2ee.clientproject.ui.AppClientLogicalViewProvider;
+import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerProviderImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerProviderImpl.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerProviderImpl.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerProviderImpl.java
@@ -50,10 +50,9 @@ import java.util.HashMap;
import java.util.HashMap;
import java.util.Map;
import org.netbeans.api.project.Project;
-import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.modules.j2ee.clientproject.AppClientProject;
-import org.netbeans.modules.j2ee.clientproject.UpdateHelper;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerRun.form b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerRun.form
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerRun.form
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/customizer/CustomizerRun.form
@@ -1,8 +1,9 @@
-
+
+ org.netbeans.modules.java.api.common
+
+
+
+ 0-1
+ 1.0
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarFileBuiltQuery.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarFileBuiltQuery.java
deleted file mode 100644
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarFileBuiltQuery.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.j2ee.ejbjarproject;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
-import org.openide.filesystems.FileObject;
-import org.netbeans.api.queries.FileBuiltQuery;
-import org.netbeans.spi.queries.FileBuiltQueryImplementation;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-
-
-public class EjbJarFileBuiltQuery implements FileBuiltQueryImplementation, PropertyChangeListener {
-
- private FileBuiltQueryImplementation delegate;
- private final AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
- private final SourceRoots sourceRoots;
- private final SourceRoots testRoots;
-
- EjbJarFileBuiltQuery (AntProjectHelper helper, PropertyEvaluator evaluator,
- SourceRoots sourceRoots, SourceRoots testRoots) {
- this.helper = helper;
- this.evaluator = evaluator;
- this.sourceRoots = sourceRoots;
- this.testRoots = testRoots;
- }
-
- public synchronized FileBuiltQuery.Status getStatus(FileObject file) {
- if (this.delegate == null) {
- this.delegate = createDelegate ();
- }
- return this.delegate.getStatus (file);
- }
-
- private FileBuiltQueryImplementation createDelegate () {
- String[] srcRoots = this.sourceRoots.getRootProperties();
- String[] tstRoots = this.testRoots.getRootProperties();
- String[] from = new String [srcRoots.length + tstRoots.length];
- String[] to = new String [srcRoots.length + tstRoots.length];
- for (int i=0; i< srcRoots.length; i++) {
- from[i] = "${" + srcRoots[i] + "}/*.java"; // NOI18N
- to[i] = "${" + EjbJarProjectProperties.BUILD_CLASSES_DIR + "}/*.class"; // NOI18N
- }
- for (int i=0; i() {
- public Integer run() {
- synchronized (EjbJarSharabilityQuery.this) {
- if (delegate == null) {
- delegate = createDelegate ();
- }
- return new Integer(delegate.getSharability (file));
- }
- }
- });
- return ret.intValue();
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (SourceRoots.PROP_ROOT_PROPERTIES.equals(evt.getPropertyName())) {
- synchronized (this) {
- this.delegate = null;
- }
- }
- }
-
- private SharabilityQueryImplementation createDelegate () {
- String[] srcProps = srcRoots.getRootProperties();
- String[] testProps = testRoots.getRootProperties();
- String[] props = new String [srcProps.length + testProps.length + 1];
- for (int i=0; i sourceRootProperties;
- private List sourceRootNames;
- private List sourceRoots;
- private List sourceRootURLs;
- private final PropertyChangeSupport support;
- private final ProjectMetadataListener listener;
- private final boolean isTest;
- private final File projectDir;
-
- /**
- * Creates new SourceRoots
- * @param helper
- * @param evaluator
- * @param elementName the name of XML element under which are declared the roots
- * @param newRootNameTemplate template for new property name of source root
- */
- SourceRoots (UpdateHelper helper, PropertyEvaluator evaluator, ReferenceHelper refHelper, String elementName, boolean isTest, String newRootNameTemplate) {
- assert helper != null && evaluator != null && refHelper != null && elementName != null && newRootNameTemplate != null;
- this.helper = helper;
- this.evaluator = evaluator;
- this.refHelper = refHelper;
- this.elementName = elementName;
- this.isTest = isTest;
- this.newRootNameTemplate = newRootNameTemplate;
- this.projectDir = FileUtil.toFile(this.helper.getAntProjectHelper().getProjectDirectory());
- this.support = new PropertyChangeSupport(this);
- this.listener = new ProjectMetadataListener();
- this.evaluator.addPropertyChangeListener (WeakListeners.propertyChange(this.listener,this.evaluator));
- this.helper.getAntProjectHelper().addAntProjectListener(WeakListeners.create(AntProjectListener.class, this.listener, this.helper));
- }
-
-
- /**
- * Returns the display names of soruce roots
- * The returned array has the same length as an array returned by the getRootProperties.
- * It may contain empty strings but not null.
- * @return an array of String
- */
- public String[] getRootNames () {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public String[] run() {
- synchronized (SourceRoots.this) {
- if (sourceRootNames == null) {
- readProjectMetadata();
- }
- }
- return sourceRootNames.toArray(new String[sourceRootNames.size()]);
- }
- });
- }
-
- /**
- * Returns names of Ant properties in the project.properties file holding the source roots.
- * @return an array of String
- */
- public String[] getRootProperties () {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public String[] run() {
- synchronized (SourceRoots.this) {
- if (sourceRootProperties == null) {
- readProjectMetadata();
- }
- }
- return sourceRootProperties.toArray (new String[sourceRootProperties.size()]);
- }
- });
- }
-
- /**
- * Returns the source roots
- * @return an array of FileObject
- */
- public FileObject[] getRoots () {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public FileObject[] run () {
- synchronized (this) {
- //Local caching
- if (sourceRoots == null) {
- String[] srcProps = getRootProperties();
- List result = new ArrayList();
- for (int i = 0; i() {
- public URL[] run () {
- synchronized (this) {
- //Local caching
- if (sourceRootURLs == null) {
- String[] srcProps = getRootProperties();
- List result = new ArrayList();
- for (int i = 0; iunmodifiableList(result);
- }
- }
- return sourceRootURLs.toArray(new URL[sourceRootURLs.size()]);
- }
- });
- }
-
- /**
- * Adds PropertyChangeListener
- * @param listener
- */
- public void addPropertyChangeListener (PropertyChangeListener listener) {
- this.support.addPropertyChangeListener (listener);
- }
-
- /**
- * Removes PropertyChangeListener
- * @param listener
- */
- public void removePropertyChangeListener (PropertyChangeListener listener) {
- this.support.removePropertyChangeListener (listener);
- }
-
-
- /**
- * Replaces the current roots by the new ones
- * @param roots the URLs of new roots
- * @param labels the names of roots
- */
- public void putRoots (final URL[] roots, final String[] labels) {
- ProjectManager.mutex().writeAccess(
- new Runnable() {
- public void run() {
- String[] originalProps = getRootProperties();
- URL[] originalRoots = getRootURLs();
- Map oldRoots2props = new HashMap();
- for (int i=0; i newRoots2lab = new HashMap();
- for (int i=0; i0) {
- Element root = (Element) rootsNodes.item(0);
- ownerElement.removeChild(root);
- }
- //Remove all unused root properties
- List newRoots = Arrays.asList(roots);
- Map propsToRemove = new HashMap(oldRoots2props);
- propsToRemove.keySet().removeAll(newRoots);
- EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- for (Iterator it = propsToRemove.values().iterator(); it.hasNext();) {
- String propName = (String) it.next ();
- props.remove(propName);
- }
- helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,props);
- //Add the new roots
- Document doc = ownerElement.getOwnerDocument();
- oldRoots2props.keySet().retainAll(newRoots);
- for (Iterator it = newRoots.iterator(); it.hasNext();) {
- URL newRoot = (URL) it.next ();
- String rootName = oldRoots2props.get(newRoot);
- if (rootName == null) {
- //Root is new generate property for it
- props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- String[] names = newRoot.getPath().split("/"); //NOI18N
- rootName = MessageFormat.format(newRootNameTemplate,new Object[]{names[names.length-1],""}); //NOI18N
- int rootIndex = 1;
- while (props.containsKey(rootName)) {
- rootIndex++;
- rootName = MessageFormat.format(newRootNameTemplate,new Object[]{names[names.length-1],new Integer(rootIndex)});
- }
- File f = FileUtil.normalizeFile(new File(URI.create(newRoot.toExternalForm())));
- File projDir = FileUtil.toFile(helper.getAntProjectHelper().getProjectDirectory());
- String path = f.getAbsolutePath();
- String prjPath = projDir.getAbsolutePath()+File.separatorChar;
- if (path.startsWith(prjPath)) {
- path = path.substring(prjPath.length());
- }
- else {
- path = refHelper.createForeignFileReference(f, JavaProjectConstants.SOURCES_TYPE_JAVA);
- props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- }
- props.put(rootName,path);
- helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,props);
- }
- Element newRootNode = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "root"); //NOI18N
- newRootNode.setAttribute("id",rootName); //NOI18N
- String label = newRoots2lab.get(newRoot);
- if (label != null && label.length()>0 && !label.equals (getRootDisplayName(null,rootName))) { //NOI18N
- newRootNode.setAttribute("name",label); //NOI18N
- }
- ownerElement.appendChild (newRootNode);
- }
- helper.putPrimaryConfigurationData(cfgEl,true);
- }
- }
- );
- }
-
- /**
- * Translates root name into display name of source/test root
- * @param rootName the name of root got from {@link SourceRoots#getRootNames}
- * @param propName the name of property the root is stored in
- * @return the label to be displayed
- */
- public String getRootDisplayName (String rootName, String propName) {
- if (rootName == null || rootName.length() ==0) {
- //If the prop is src.dir use the default name
- if (isTest && "test.src.dir".equals(propName)) { //NOI18N
- rootName = DEFAULT_TEST_LABEL;
- }
- else if (!isTest && "src.dir".equals(propName)) { //NOI18N
- rootName = DEFAULT_SOURCE_LABEL;
- }
- else {
- //If the name is not given, it should be either a relative path in the project dir
- //or absolute path when the root is not under the project dir
- String propValue = evaluator.getProperty(propName);
- File sourceRoot = propValue == null ? null : helper.getAntProjectHelper().resolveFile(propValue);
- rootName = createInitialDisplayName(sourceRoot);
- }
- }
- return rootName;
- }
-
- /**
- * Creates initial display name of source/test root
- * @param sourceRoot the source root
- * @return the label to be displayed
- */
- public String createInitialDisplayName (File sourceRoot) {
- String rootName;
- if (sourceRoot != null) {
- String srPath = sourceRoot.getAbsolutePath();
- String pdPath = projectDir.getAbsolutePath() + File.separatorChar;
- if (srPath.startsWith(pdPath)) {
- rootName = srPath.substring(pdPath.length());
- }
- else {
- rootName = sourceRoot.getAbsolutePath();
- }
- }
- else {
- rootName = isTest ? DEFAULT_TEST_LABEL : DEFAULT_SOURCE_LABEL;
- }
- return rootName;
- }
-
- private void resetCache (boolean isXMLChange, String propName) {
- boolean fire = false;
- synchronized (this) {
- //In case of change reset local cache
- if (isXMLChange) {
- this.sourceRootProperties = null;
- this.sourceRootNames = null;
- this.sourceRoots = null;
- this.sourceRootURLs = null;
- fire = true;
- } else if (propName == null || (sourceRootProperties != null && sourceRootProperties.contains(propName))) {
- this.sourceRoots = null;
- this.sourceRootURLs = null;
- fire = true;
- }
- }
- if (fire) {
- if (isXMLChange) {
- this.support.firePropertyChange (PROP_ROOT_PROPERTIES,null,null);
- }
- this.support.firePropertyChange (PROP_ROOTS,null,null);
- }
- }
-
- private void readProjectMetadata () {
- Element cfgEl = helper.getPrimaryConfigurationData(true);
- NodeList nl = cfgEl.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, elementName);
- assert nl.getLength() == 0 || nl.getLength() == 1 : "Illegal project.xml"; //NOI18N
- List rootProps = new ArrayList();
- List rootNames = new ArrayList();
- // It can be 0 in the case when the project is created by EjbJarProjectGenerator and not yet customized
- if (nl.getLength()==1) {
- NodeList roots = ((Element)nl.item(0)).getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "root"); //NOI18N
- for (int i=0; i 0 : "Illegal project.xml";
- rootProps.add(value);
- value = root.getAttribute("name"); //NOI18N
- rootNames.add (value);
- }
- }
- this.sourceRootProperties = Collections.unmodifiableList(rootProps);
- this.sourceRootNames = Collections.unmodifiableList(rootNames);
- }
-
- private class ProjectMetadataListener implements PropertyChangeListener,AntProjectListener {
-
- public void propertyChange(PropertyChangeEvent evt) {
- resetCache (false,evt.getPropertyName());
- }
-
- public void configurationXmlChanged(AntProjectEvent ev) {
- resetCache (true,null);
- }
-
- public void propertiesChanged(AntProjectEvent ev) {
- //Handled by propertyChange
- }
- }
-
- public boolean isTest() {
- return isTest;
- }
-}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateHelper.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateHelper.java
deleted file mode 100644
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateHelper.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.j2ee.ejbjarproject;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.netbeans.modules.j2ee.ejbjarproject.api.EjbJarProjectGenerator;
-import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.openide.DialogDisplayer;
-import org.openide.NotifyDescriptor;
-import org.openide.util.NbBundle;
-import org.openide.util.Mutex;
-import org.netbeans.api.project.Project;
-import org.netbeans.api.project.ProjectManager;
-import org.netbeans.api.project.libraries.LibraryManager;
-import org.netbeans.spi.project.AuxiliaryConfiguration;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
-
-
-/**
- * Proxy for the AntProjectHelper which defers the update of the project metadata
- * to explicit user action. Currently it is hard coded for update from
- * "http://www.netbeans.org/ns/j2se-project/1" to "http://www.netbeans.org/ns/j2se-project/2".
- * In future it should define plugable SPI.
- */
-public class UpdateHelper {
-
- private final Project project;
- private final AntProjectHelper helper;
- private final AuxiliaryConfiguration cfg;
- private final GeneratedFilesHelper genFileHelper;
- private final Notifier notifier;
- private boolean alreadyAskedInWriteAccess;
- private Boolean isCurrent;
- private Element cachedElement;
-
- private static final String BUILD_NUMBER = System.getProperty("netbeans.buildnumber"); // NOI18N
- private static final String INCLUDED_LIBRARY_ELEMENT = "included-library"; //NOI18N
- private static final String MINIMUM_ANT_VERSION_ELEMENT = "minimum-ant-version"; // NOI18N
- private static final String ATTR_FILES = "files"; //NOI18N
- private static final String ATTR_DIRS = "dirs"; //NOI18N
-
- /**
- * Creates new UpdateHelper
- * @param project
- * @param helper AntProjectHelper
- * @param cfg AuxiliaryConfiguration
- * @param genFileHelper GeneratedFilesHelper
- * @param notifier used to ask user about project update
- */
- UpdateHelper (Project project, AntProjectHelper helper, AuxiliaryConfiguration cfg, GeneratedFilesHelper genFileHelper, Notifier notifier) {
- assert project != null && helper != null && cfg != null && genFileHelper != null && notifier != null;
- this.project = project;
- this.helper = helper;
- this.cfg = cfg;
- this.genFileHelper = genFileHelper;
- this.notifier = notifier;
- }
-
- /**
- * Returns the AntProjectHelper.getProperties(), {@link AntProjectHelper#getProperties(String)}
- * @param path a relative URI in the project directory.
- * @return a set of properties
- */
- public EditableProperties getProperties (String path) {
- //Properties are the same in both j2seproject/1 and j2seproject/2
- return this.helper.getProperties(path);
- }
-
- /**
- * In the case that the project is of current version or the properties are not {@link AntProjectHelper#PROJECT_PROPERTIES_PATH}
- * it calls AntProjectHelper.putProperties(), {@link AntProjectHelper#putProperties(String, EditableProperties)}
- * otherwise it asks user to updata project. If the user agrees with the project update, it does the update and calls
- * AntProjectHelper.putProperties().
- * @param path a relative URI in the project directory.
- * @param props a set of properties
- */
- public void putProperties(final String path, final EditableProperties props) {
- ProjectManager.mutex().writeAccess(new Runnable() {
- public void run() {
- if (isCurrent() || !AntProjectHelper.PROJECT_PROPERTIES_PATH.equals(path)) { //Only project props should cause update
- helper.putProperties(path,props);
- } else if (canUpdate()) {
- try {
- saveUpdate(props);
- helper.putProperties(path,props);
- } catch (IOException ioe) {
- Exceptions.printStackTrace(ioe);
- }
- }
- }
- });
- }
-
- /**
- * In the case that the project is of current version or shared is false it delegates to
- * AntProjectHelper.getPrimaryConfigurationData(), {@link AntProjectHelper#getPrimaryConfigurationData(boolean)}.
- * Otherwise it creates an in memory update of shared configuration data and returns it.
- * @param shared if true, refers to project.xml, else refers to
- * private.xml
- * @return the configuration data that is available
- */
- public Element getPrimaryConfigurationData (final boolean shared) {
- return ProjectManager.mutex().readAccess(new Mutex.Action(){
- public Element run() {
- if (!shared || isCurrent()) { //Only shared props should cause update
- return helper.getPrimaryConfigurationData(shared);
- }
- return getUpdatedSharedConfigurationData();
- }
- });
- }
-
- /**
- * In the case that the project is of current version or shared is false it calls AntProjectHelper.putPrimaryConfigurationData(),
- * {@link AntProjectHelper#putPrimaryConfigurationData(Element, boolean)}.
- * Otherwise it asks user to update the project. If the user agrees with the project update, it does the update and calls
- * AntProjectHelper.PrimaryConfigurationData().
- * @param element the configuration data
- * @param shared if true, refers to project.xml, else refers to
- * private.xml
- */
- public void putPrimaryConfigurationData(final Element element, final boolean shared) {
- ProjectManager.mutex().writeAccess(new Runnable() {
- public void run() {
- if (!shared || isCurrent()) {
- helper.putPrimaryConfigurationData(element, shared);
- } else if (canUpdate()) {
- try {
- saveUpdate(null);
- helper.putPrimaryConfigurationData(element, shared);
- } catch (IOException ioe) {
- Exceptions.printStackTrace(ioe);
- }
- }
- }
- });
- }
-
- /**
- * Returns an AntProjectHelper. The helper may not be used for accessing/storing project metadata.
- * For project metadata manipulation the UpdateHelper must be used.
- * @return AntProjectHelper
- */
- public AntProjectHelper getAntProjectHelper () {
- return this.helper;
- }
-
- /**
- * Request an saving of update. If the project is not of current version the user will be asked to update the project.
- * If the user agrees with an update the project is updated.
- */
- public boolean requestSave () throws IOException{
- if (isCurrent()) {
- return true;
- }
- if (!canUpdate()) {
- return false;
- }
- saveUpdate (null);
- return true;
- }
-
- /**
- * Returns true if the project is of current version.
- * @return true if the project is of current version, otherwise false.
- */
- public synchronized boolean isCurrent () {
- if (this.isCurrent == null) {
- this.isCurrent = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/1",true) == null
- && this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/2",true) == null? //NOI18N
- Boolean.TRUE : Boolean.FALSE;
- }
- return isCurrent.booleanValue();
- }
-
- private boolean canUpdate () {
- //Ask just once under a single write access
- if (alreadyAskedInWriteAccess) {
- return false;
- }
- else {
- boolean canUpdate = this.notifier.canUpdate();
- if (!canUpdate) {
- alreadyAskedInWriteAccess = true;
- ProjectManager.mutex().postReadRequest(new Runnable() {
- public void run() {
- alreadyAskedInWriteAccess = false;
- }
- });
- }
- return canUpdate;
- }
- }
-
- private void saveUpdate (EditableProperties props) throws IOException {
- this.helper.putPrimaryConfigurationData(getUpdatedSharedConfigurationData(),true);
- if (this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/1",true) != null) { //NOI18N
- //version 1
- this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/1",true); //NOI18N
- } else {
- //version 2
- this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/2",true); //NOI18N
- }
-
- boolean putProps = false;
-
- // AB: fix for #55597: should not update the project without adding the properties
- // update is only done once, so if we don't add the properties now, we don't get another chance to do so
- if (props == null) {
- props = getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- putProps = true;
- }
-
- //add properties needed by 4.1 project
- if(props != null) {
- props.put("test.src.dir", "test"); //NOI18N
- }
-
- if (putProps) {
- helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
- }
-
- ProjectManager.getDefault().saveProject (this.project);
- this.genFileHelper.refreshBuildScript(GeneratedFilesHelper.BUILD_IMPL_XML_PATH, UpdateHelper.class.getResource("resources/build-impl.xsl"),
- true);
- synchronized(this) {
- this.isCurrent = Boolean.TRUE;
- }
- }
-
- private synchronized Element getUpdatedSharedConfigurationData () {
- if (cachedElement == null) {
- Element oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/1",true); //NOI18N
-
- int version = 1;
- if (oldRoot == null) {
- version = 2;
- oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/2",true); //NOI18N
- }
- final String ns = version == 1 ? "http://www.netbeans.org/ns/j2ee-ejbjarproject/1" : "http://www.netbeans.org/ns/j2ee-ejbjarproject/2"; //NOI18N
-
- if (oldRoot != null) {
- Document doc = oldRoot.getOwnerDocument();
- Element newRoot = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
- if(version == 1) {
- //1=>2 upgrade
- Element sourceRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
- Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
- root.setAttribute ("id","src.dir"); //NOI18N
- sourceRoots.appendChild(root);
- newRoot.appendChild (sourceRoots);
- Element testRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"test-roots"); //NOI18N
- root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
- root.setAttribute ("id","test.src.dir"); //NOI18N
- testRoots.appendChild (root);
- newRoot.appendChild (testRoots);
- }
- if(version == 1 || version == 2) {
- //2=>3 upgrade
- NodeList libList = newRoot.getElementsByTagNameNS(ns, INCLUDED_LIBRARY_ELEMENT);
- for (int i = 0; i < libList.getLength(); i++) {
- if (libList.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element library = (Element) libList.item(i);
- String fileText = findText(library);
- if (fileText.startsWith ("libs.")) {
- String libName = fileText.substring(6, fileText.indexOf(".classpath")); //NOI18N
- List/**/ roots = LibraryManager.getDefault().getLibrary(libName).getContent("classpath"); //NOI18N
- ArrayList files = new ArrayList();
- ArrayList dirs = new ArrayList();
- for (Iterator it = roots.iterator(); it.hasNext();) {
- URL rootUrl = (URL) it.next();
- FileObject root = org.openide.filesystems.URLMapper.findFileObject (rootUrl);
- if ("jar".equals(rootUrl.getProtocol())) { //NOI18N
- root = FileUtil.getArchiveFile (root);
- }
- if (root != null) {
- if (root.isData()) {
- files.add(root);
- } else {
- dirs.add(root);
- }
- }
- }
- if (files.size() > 0) {
- library.setAttribute(ATTR_FILES, "" + files.size()); //NOI18N
- }
- if (dirs.size() > 0) {
- library.setAttribute(ATTR_DIRS, "" + dirs.size()); //NOI18N
- }
- }
- }
- }
- }
-
- cachedElement = updateMinAntVersion(newRoot, doc);
- }
- }
- return cachedElement;
- }
-
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- //copy attributes
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,(Element)newNode);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
- private static Element updateMinAntVersion (final Element root, final Document doc) {
- NodeList list = root.getElementsByTagNameNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
- if (list.getLength() == 1) {
- Element me = (Element) list.item(0);
- list = me.getChildNodes();
- if (list.getLength() == 1) {
- me.replaceChild (doc.createTextNode(EjbJarProjectGenerator.MINIMUM_ANT_VERSION), list.item(0));
- return root;
- }
- }
- assert false : "Invalid project file"; //NOI18N
- return root;
- }
-
- /**
- * Creates an default Notifier. The default notifier displays a dialog warning user about project update.
- * @return notifier
- */
- public static Notifier createDefaultNotifier () {
- return new Notifier() {
- public boolean canUpdate() {
- return DialogDisplayer.getDefault().notify(
- new NotifyDescriptor.Confirmation (NbBundle.getMessage(UpdateHelper.class,"TXT_ProjectUpdate",BUILD_NUMBER),
- NbBundle.getMessage(UpdateHelper.class,"TXT_ProjectUpdateTitle"),
- NotifyDescriptor.YES_NO_OPTION)) == NotifyDescriptor.YES_OPTION;
- }
- };
- }
-
- /**
- * Extract nested text from a node.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent node
- * @return the nested text, or null if none was found
- */
- private static String findText(Node parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
-
- /**
- * Interface used by the UpdateHelper to ask user about
- * the project update.
- */
- public static interface Notifier {
- /**
- * Asks user to update the project
- * @return true if the project should be updated
- */
- public boolean canUpdate ();
- }
-}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateProjectImpl.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateProjectImpl.java
new file mode 100644
--- /dev/null
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateProjectImpl.java
@@ -0,0 +1,327 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 2008 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.j2ee.ejbjarproject;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.project.libraries.LibraryManager;
+import org.netbeans.modules.j2ee.ejbjarproject.api.EjbJarProjectGenerator;
+import org.netbeans.modules.java.api.common.ant.UpdateImplementation;
+import org.netbeans.spi.project.AuxiliaryConfiguration;
+import org.netbeans.spi.project.support.ant.AntProjectHelper;
+import org.netbeans.spi.project.support.ant.EditableProperties;
+import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Mutex;
+import org.openide.util.NbBundle;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ *
+ * @author Tomas Mysik
+ */
+public class UpdateProjectImpl implements UpdateImplementation {
+
+ private static final String BUILD_NUMBER = System.getProperty("netbeans.buildnumber"); // NOI18N
+ private static final String INCLUDED_LIBRARY_ELEMENT = "included-library"; //NOI18N
+ private static final String MINIMUM_ANT_VERSION_ELEMENT = "minimum-ant-version"; // NOI18N
+ private static final String ATTR_FILES = "files"; //NOI18N
+ private static final String ATTR_DIRS = "dirs"; //NOI18N
+
+ private final Project project;
+ private final AntProjectHelper helper;
+ private final AuxiliaryConfiguration cfg;
+ private final GeneratedFilesHelper genFileHelper;
+ private boolean alreadyAskedInWriteAccess;
+ private Boolean isCurrent;
+ private Element cachedElement;
+
+ /**
+ * Creates new UpdateHelper
+ * @param project
+ * @param helper AntProjectHelper
+ * @param cfg AuxiliaryConfiguration
+ * @param genFileHelper GeneratedFilesHelper
+ * @param notifier used to ask user about project update
+ */
+ UpdateProjectImpl(Project project, AntProjectHelper helper, AuxiliaryConfiguration cfg,
+ GeneratedFilesHelper genFileHelper) {
+ assert project != null && helper != null && cfg != null && genFileHelper != null;
+ this.project = project;
+ this.helper = helper;
+ this.cfg = cfg;
+ this.genFileHelper = genFileHelper;
+ }
+
+ public boolean isCurrent() {
+ return ProjectManager.mutex().readAccess(new Mutex.Action() {
+ public Boolean run() {
+ synchronized (this) {
+ if (isCurrent == null) {
+ if ((cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/1",true) != null) ||
+ (cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/2",true) != null)) {
+ isCurrent = Boolean.FALSE;
+ } else {
+ isCurrent = Boolean.TRUE;
+ }
+ }
+ return isCurrent;
+ }
+ }
+ }).booleanValue();
+ }
+
+ public boolean canUpdate() {
+ //Ask just once under a single write access
+ if (alreadyAskedInWriteAccess) {
+ return false;
+ }
+ else {
+ boolean canUpdate = showUpdateDialog();
+ if (!canUpdate) {
+ alreadyAskedInWriteAccess = true;
+ ProjectManager.mutex().postReadRequest(new Runnable() {
+ public void run() {
+ alreadyAskedInWriteAccess = false;
+ }
+ });
+ }
+ return canUpdate;
+ }
+ }
+
+ public void saveUpdate(EditableProperties props) throws IOException {
+ this.helper.putPrimaryConfigurationData(getUpdatedSharedConfigurationData(),true);
+ if (this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/1",true) != null) { //NOI18N
+ //version 1
+ this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/1",true); //NOI18N
+ } else {
+ //version 2
+ this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/2",true); //NOI18N
+ }
+
+ boolean putProps = false;
+
+ // AB: fix for #55597: should not update the project without adding the properties
+ // update is only done once, so if we don't add the properties now, we don't get another chance to do so
+ if (props == null) {
+ props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
+ putProps = true;
+ }
+
+ //add properties needed by 4.1 project
+ if(props != null) {
+ props.put("test.src.dir", "test"); //NOI18N
+ }
+
+ if (putProps) {
+ helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
+ }
+
+ ProjectManager.getDefault().saveProject (this.project);
+ this.genFileHelper.refreshBuildScript(GeneratedFilesHelper.BUILD_IMPL_XML_PATH, UpdateProjectImpl.class.getResource("resources/build-impl.xsl"),
+ true);
+ synchronized(this) {
+ this.isCurrent = Boolean.TRUE;
+ }
+ }
+
+ public Element getUpdatedSharedConfigurationData() {
+ if (cachedElement == null) {
+ Element oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/1",true); //NOI18N
+
+ int version = 1;
+ if (oldRoot == null) {
+ version = 2;
+ oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-ejbjarproject/2",true); //NOI18N
+ }
+ final String ns = version == 1 ? "http://www.netbeans.org/ns/j2ee-ejbjarproject/1" : "http://www.netbeans.org/ns/j2ee-ejbjarproject/2"; //NOI18N
+
+ if (oldRoot != null) {
+ Document doc = oldRoot.getOwnerDocument();
+ Element newRoot = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
+ copyDocument (doc, oldRoot, newRoot);
+ if(version == 1) {
+ //1=>2 upgrade
+ Element sourceRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
+ Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
+ root.setAttribute ("id","src.dir"); //NOI18N
+ sourceRoots.appendChild(root);
+ newRoot.appendChild (sourceRoots);
+ Element testRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"test-roots"); //NOI18N
+ root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
+ root.setAttribute ("id","test.src.dir"); //NOI18N
+ testRoots.appendChild (root);
+ newRoot.appendChild (testRoots);
+ }
+ if(version == 1 || version == 2) {
+ //2=>3 upgrade
+ NodeList libList = newRoot.getElementsByTagNameNS(ns, INCLUDED_LIBRARY_ELEMENT);
+ for (int i = 0; i < libList.getLength(); i++) {
+ if (libList.item(i).getNodeType() == Node.ELEMENT_NODE) {
+ Element library = (Element) libList.item(i);
+ String fileText = findText(library);
+ if (fileText.startsWith ("libs.")) {
+ String libName = fileText.substring(6, fileText.indexOf(".classpath")); //NOI18N
+ List/**/ roots = LibraryManager.getDefault().getLibrary(libName).getContent("classpath"); //NOI18N
+ ArrayList files = new ArrayList();
+ ArrayList dirs = new ArrayList();
+ for (Iterator it = roots.iterator(); it.hasNext();) {
+ URL rootUrl = (URL) it.next();
+ FileObject root = org.openide.filesystems.URLMapper.findFileObject (rootUrl);
+ if ("jar".equals(rootUrl.getProtocol())) { //NOI18N
+ root = FileUtil.getArchiveFile (root);
+ }
+ if (root != null) {
+ if (root.isData()) {
+ files.add(root);
+ } else {
+ dirs.add(root);
+ }
+ }
+ }
+ if (files.size() > 0) {
+ library.setAttribute(ATTR_FILES, "" + files.size()); //NOI18N
+ }
+ if (dirs.size() > 0) {
+ library.setAttribute(ATTR_DIRS, "" + dirs.size()); //NOI18N
+ }
+ }
+ }
+ }
+ }
+
+ cachedElement = updateMinAntVersion(newRoot, doc);
+ }
+ }
+ return cachedElement;
+ }
+
+ public EditableProperties getUpdatedProjectProperties() {
+ // XXX no need to update? original comment was: Properties are the same in both j2seproject/1 and j2seproject/2
+ return helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
+ }
+
+ private static void copyDocument (Document doc, Element from, Element to) {
+ NodeList nl = from.getChildNodes();
+ int length = nl.getLength();
+ for (int i=0; i< length; i++) {
+ Node node = nl.item (i);
+ Node newNode = null;
+ switch (node.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ Element oldElement = (Element) node;
+ newNode = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
+ //copy attributes
+ NamedNodeMap m = oldElement.getAttributes();
+ Element newElement = (Element) newNode;
+ for (int index = 0; index < m.getLength(); index++) {
+ Node attr = m.item(index);
+ newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
+ }
+ copyDocument(doc,oldElement,(Element)newNode);
+ break;
+ case Node.TEXT_NODE:
+ Text oldText = (Text) node;
+ newNode = doc.createTextNode(oldText.getData());
+ break;
+ case Node.COMMENT_NODE:
+ Comment oldComment = (Comment) node;
+ newNode = doc.createComment(oldComment.getData());
+ break;
+ }
+ if (newNode != null) {
+ to.appendChild (newNode);
+ }
+ }
+ }
+
+ private static Element updateMinAntVersion (final Element root, final Document doc) {
+ NodeList list = root.getElementsByTagNameNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
+ if (list.getLength() == 1) {
+ Element me = (Element) list.item(0);
+ list = me.getChildNodes();
+ if (list.getLength() == 1) {
+ me.replaceChild (doc.createTextNode(EjbJarProjectGenerator.MINIMUM_ANT_VERSION), list.item(0));
+ return root;
+ }
+ }
+ assert false : "Invalid project file"; //NOI18N
+ return root;
+ }
+
+ /**
+ * Extract nested text from a node.
+ * Currently does not handle coalescing text nodes, CDATA sections, etc.
+ * @param parent a parent node
+ * @return the nested text, or null if none was found
+ */
+ private static String findText(Node parent) {
+ NodeList l = parent.getChildNodes();
+ for (int i = 0; i < l.getLength(); i++) {
+ if (l.item(i).getNodeType() == Node.TEXT_NODE) {
+ Text text = (Text)l.item(i);
+ return text.getNodeValue();
+ }
+ }
+ return null;
+ }
+
+ private boolean showUpdateDialog() {
+ return DialogDisplayer.getDefault().notify(
+ new NotifyDescriptor.Confirmation (NbBundle.getMessage(UpdateProjectImpl.class,"TXT_ProjectUpdate",BUILD_NUMBER),
+ NbBundle.getMessage(UpdateProjectImpl.class,"TXT_ProjectUpdateTitle"),
+ NotifyDescriptor.YES_NO_OPTION)) == NotifyDescriptor.YES_OPTION;
+ }
+}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectGenerator.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectGenerator.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectGenerator.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/api/EjbJarProjectGenerator.java
@@ -71,10 +71,10 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject;
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectType;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
import org.netbeans.modules.j2ee.ejbjarproject.Utils;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
-import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.PlatformUiSupport;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
+import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants;
import org.openide.filesystems.FileSystem;
import org.openide.filesystems.FileSystem.AtomicAction;
@@ -510,7 +510,7 @@ public class EjbJarProjectGenerator {
finalPlatformName = JavaPlatformManager.getDefault().getDefaultPlatform().getDisplayName();
}
- PlatformUiSupport.storePlatform(ep, updateHelper, finalPlatformName, sourceLevel != null ? new SpecificationVersion(sourceLevel) : null);
+ PlatformUiSupport.storePlatform(ep, updateHelper, EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, finalPlatformName, sourceLevel != null ? new SpecificationVersion(sourceLevel) : null);
helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
ProjectManager.getDefault().saveProject(ProjectManager.getDefault().findProject(helper.getProjectDirectory()));
} catch (IOException e) {
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/ClassPathProviderImpl.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/ClassPathProviderImpl.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/ClassPathProviderImpl.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/ClassPathProviderImpl.java
@@ -47,7 +47,7 @@ import java.util.HashMap;
import org.netbeans.api.java.classpath.ClassPath;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
-import org.netbeans.modules.j2ee.ejbjarproject.SourceRoots;
+import org.netbeans.modules.java.api.common.SourceRoots;
import org.netbeans.spi.java.classpath.ClassPathFactory;
import org.netbeans.spi.java.classpath.ClassPathProvider;
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/EjbJarProjectClassPathExtender.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/EjbJarProjectClassPathExtender.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/EjbJarProjectClassPathExtender.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/EjbJarProjectClassPathExtender.java
@@ -58,12 +58,12 @@ import org.netbeans.api.project.ant.AntA
import org.netbeans.api.project.ant.AntArtifact;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.project.Project;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/SourcePathImplementation.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/SourcePathImplementation.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/SourcePathImplementation.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/SourcePathImplementation.java
@@ -51,8 +51,8 @@ import java.net.URL;
import java.net.URL;
import java.util.Iterator;
import java.util.StringTokenizer;
-import org.netbeans.modules.j2ee.ejbjarproject.SourceRoots;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
+import org.netbeans.modules.java.api.common.SourceRoots;
import org.netbeans.spi.java.classpath.ClassPathImplementation;
import org.netbeans.spi.java.classpath.PathResourceImplementation;
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/CompiledSourceForBinaryQuery.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/CompiledSourceForBinaryQuery.java
deleted file mode 100644
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/CompiledSourceForBinaryQuery.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.j2ee.ejbjarproject.queries;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import javax.swing.event.ChangeEvent;
-import org.netbeans.modules.j2ee.ejbjarproject.SourceRoots;
-import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
-import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.openide.filesystems.FileObject;
-import java.net.URL;
-import java.net.MalformedURLException;
-import javax.swing.event.ChangeListener;
-import org.netbeans.api.java.queries.SourceForBinaryQuery;
-import java.util.Map;
-import java.util.HashMap;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
-
-/**
- * Finds sources corresponding to binaries in a J2SE project.
- * @author Jesse Glick, Tomas Zezula
- */
-public class CompiledSourceForBinaryQuery implements SourceForBinaryQueryImplementation {
-
- private AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
- private final SourceRoots sourceRoots;
- private final SourceRoots testRoots;
- private Map cache = new HashMap();
-
- public CompiledSourceForBinaryQuery (AntProjectHelper helper,PropertyEvaluator evaluator,
- SourceRoots srcRoots, SourceRoots testRoots) {
- this.helper = helper;
- this.evaluator = evaluator;
- this.sourceRoots = srcRoots;
- this.testRoots = testRoots;
- }
-
- public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) {
- if (FileUtil.getArchiveFile(binaryRoot) != null) {
- binaryRoot = FileUtil.getArchiveFile(binaryRoot);
- // XXX check whether this is really the root
- }
- SourceForBinaryQuery.Result res = cache.get(binaryRoot);
- if (res != null) {
- return res;
- }
- SourceRoots src = null;
- if (hasSources(binaryRoot, EjbJarProjectProperties.BUILD_CLASSES_DIR)) { //NOI18N
- src = this.sourceRoots;
- }
- else if (hasSources (binaryRoot, EjbJarProjectProperties.DIST_JAR)) { //NOI18N
- src = this.sourceRoots;
- }
- else if (hasSources (binaryRoot, EjbJarProjectProperties.BUILD_TEST_CLASSES_DIR)) { //NOI18N
- src = this.testRoots;
- }
- if (src == null) {
- return null;
- }
- else {
- res = new Result (src);
- cache.put (binaryRoot, res);
- return res;
- }
- }
-
-
- private boolean hasSources (URL binaryRoot, String binaryProperty) {
- try {
- //TODO: Fix this. Use FileUtil.getArchiveFile.
- if (binaryRoot.getProtocol().equals("jar")) { // NOI18N
- // We are interested in the JAR file itself.
- // Note that this impl therefore accepts *both* file:/tmp/foo.jar
- // and jar:file:/tmp/foo.jar!/ as equivalent (like URLClassLoader).
- String surl = binaryRoot.toExternalForm();
- if (surl.endsWith("!/")) { // NOI18N
- binaryRoot = new URL(surl.substring(4, surl.length() - 2));
- } else if (surl.lastIndexOf("!/") == -1) { // NOI18N
- // Legal??
- binaryRoot = new URL(surl.substring(4));
- } else {
- // Some specific path, e.g. jar:file:/tmp/foo.jar!/foo/,
- // which we do not support.
- }
- }
- String outDir = helper.getStandardPropertyEvaluator ().getProperty (binaryProperty);
- if (outDir != null) {
- File f = helper.resolveFile (outDir);
- URL url = f.toURI().toURL();
- if (!f.exists() && !f.getPath().toLowerCase().endsWith(".jar")) { // NOI18N
- // non-existing
- assert !url.toExternalForm().endsWith("/") : f; // NOI18N
- url = new URL(url.toExternalForm() + "/"); // NOI18N
- }
- if (url.equals (binaryRoot)) {
- return true;
- }
- }
- } catch (MalformedURLException malformedURL) {
- Exceptions.printStackTrace(malformedURL);
- }
- return false;
- }
-
- private static class Result implements SourceForBinaryQuery.Result, PropertyChangeListener {
-
- private ArrayList listeners;
- private SourceRoots sourceRoots;
-
- public Result (SourceRoots sourceRoots) {
- this.sourceRoots = sourceRoots;
- this.sourceRoots.addPropertyChangeListener(this);
- }
-
- public FileObject[] getRoots () {
- return this.sourceRoots.getRoots(); //No need to cache it, SourceRoots does
- }
-
- public void addChangeListener (ChangeListener l) {
- //TODO: Implement this if needed (source folder can be changed)
- }
-
- public void removeChangeListener (ChangeListener l) {
- //TODO: Implement this if needed (source folder can be changed)
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (SourceRoots.PROP_ROOTS.equals(evt.getPropertyName())) {
- this.fireChange ();
- }
- }
-
- private void fireChange() {
- Iterator it;
- synchronized (this) {
- if (this.listeners == null) {
- return;
- }
- it = ((ArrayList)this.listeners.clone()).iterator();
- }
- ChangeEvent event = new ChangeEvent(this);
- while (it.hasNext()) {
- ((ChangeListener)it.next()).stateChanged(event);
- }
- }
-
- }
-
-}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/EjbJarProjectEncodingQueryImpl.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/EjbJarProjectEncodingQueryImpl.java
deleted file mode 100644
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/EjbJarProjectEncodingQueryImpl.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.j2ee.ejbjarproject.queries;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
-import org.netbeans.spi.queries.FileEncodingQueryImplementation;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.openide.filesystems.FileObject;
-
-/**
- *
- * @author Tomas Zezula
- */
-public class EjbJarProjectEncodingQueryImpl extends FileEncodingQueryImplementation implements PropertyChangeListener {
-
-
- private final PropertyEvaluator eval;
- private Charset cache;
-
- /** Creates a new instance of J2SEProjectEncodingQueryImpl */
- public EjbJarProjectEncodingQueryImpl(final PropertyEvaluator eval) {
- assert eval != null;
- this.eval = eval;
- this.eval.addPropertyChangeListener(this);
- }
-
- public Charset getEncoding(FileObject file) {
- assert file != null;
- synchronized (this) {
- if (cache != null) {
- return cache;
- }
- }
- String enc = eval.getProperty(EjbJarProjectProperties.SOURCE_ENCODING);
- synchronized (this) {
- if (cache == null) {
- try {
- cache = enc == null ? Charset.defaultCharset() : Charset.forName(enc);
- } catch (IllegalCharsetNameException exception) {
- return null;
- }
- }
- return cache;
- }
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- String propName = event.getPropertyName();
- if (propName == null || propName.equals(EjbJarProjectProperties.SOURCE_ENCODING)) {
- synchronized (this) {
- cache = null;
- }
- }
- }
-
-}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/JavadocForBinaryQueryImpl.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/JavadocForBinaryQueryImpl.java
deleted file mode 100644
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/JavadocForBinaryQueryImpl.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.j2ee.ejbjarproject.queries;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import javax.swing.event.ChangeListener;
-import org.netbeans.api.java.queries.JavadocForBinaryQuery;
-import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
-import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.ChangeSupport;
-import org.openide.util.Exceptions;
-import org.openide.util.WeakListeners;
-
-
-/**
- * Finds Javadoc (if it is built) corresponding to binaries in web project.
- * @author David Konecny, Jesse Glick
- */
-public class JavadocForBinaryQueryImpl implements JavadocForBinaryQueryImplementation {
-
- private final AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
-
- public JavadocForBinaryQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator) {
- this.helper = helper;
- this.evaluator = evaluator;
- }
-
- public JavadocForBinaryQuery.Result findJavadoc(final URL binaryRoot) {
-
- class R implements JavadocForBinaryQuery.Result, PropertyChangeListener {
-
- private final ChangeSupport changeSupport = new ChangeSupport(this);
- private URL[] result;
-
- public R () {
- JavadocForBinaryQueryImpl.this.evaluator.addPropertyChangeListener (WeakListeners.propertyChange(this,JavadocForBinaryQueryImpl.this.evaluator));
- }
-
- public synchronized URL[] getRoots() {
- if (this.result == null) {
- String javadocDir = evaluator.getProperty(EjbJarProjectProperties.DIST_JAVADOC_DIR);
- if (javadocDir != null) {
- File f = helper.resolveFile(javadocDir);
- try {
- URL url = f.toURI().toURL();
- if (!f.exists()) {
- assert !url.toExternalForm().endsWith("/") : f; // NOI18N
- url = new URL(url.toExternalForm() + "/"); // NOI18N
- }
- this.result = new URL[] {url};
- } catch (MalformedURLException e) {
- this.result = new URL[0];
- Exceptions.printStackTrace(e);
- }
- }
- else {
- this.result = new URL[0];
- }
- }
- return this.result;
- }
- public void addChangeListener(final ChangeListener l) {
- assert l != null;
- changeSupport.addChangeListener(l);
- }
- public void removeChangeListener(final ChangeListener l) {
- assert l != null;
- changeSupport.removeChangeListener(l);
- }
-
- public void propertyChange (final PropertyChangeEvent event) {
- if (EjbJarProjectProperties.DIST_JAVADOC_DIR.equals(event.getPropertyName())) {
- synchronized (this) {
- result = null;
- }
- this.changeSupport.fireChange ();
- }
- }
- }
- if (isRootOwner(binaryRoot, EjbJarProjectProperties.BUILD_CLASSES_DIR) || isRootOwner (binaryRoot, EjbJarProjectProperties.DIST_JAR)) {
- return new R();
- }
- return null;
- }
-
- private boolean isRootOwner (URL binaryRoot, String binaryProperty) {
- try {
- if (FileUtil.getArchiveFile(binaryRoot) != null) {
- binaryRoot = FileUtil.getArchiveFile(binaryRoot);
- // XXX check whether this is really the root
- }
- String outDir = evaluator.getProperty(binaryProperty);
- if (outDir != null) {
- File f = helper.resolveFile (outDir);
- URL url = f.toURI().toURL();
- if (!f.exists() && !f.getPath().toLowerCase().endsWith(".jar")) { // NOI18N
- assert !url.toExternalForm().endsWith("/") : f; // NOI18N
- url = new URL(url.toExternalForm() + "/"); // NOI18N
- }
- return url.equals(binaryRoot) ||
- binaryRoot.toExternalForm().startsWith(url.toExternalForm());
- }
- } catch (MalformedURLException malformedURL) {
- Exceptions.printStackTrace(malformedURL);
- }
- return false;
- }
-
-// private URL getJavadoc(URL binaryRoot, String binaryProperty, String javadocProperty) {
-// try {
-// if (FileUtil.getArchiveFile(binaryRoot) != null) {
-// binaryRoot = FileUtil.getArchiveFile(binaryRoot);
-// }
-// String outDir = evaluator.getProperty(binaryProperty);
-// if (outDir != null) {
-// File f = helper.resolveFile (outDir);
-// URL url = f.toURI().toURL();
-// if (!f.exists() && !f.getPath().toLowerCase().endsWith(".jar")) {
-// assert !url.toExternalForm().endsWith("/") : f;
-// url = new URL(url.toExternalForm() + "/");
-// }
-// if (url.equals(binaryRoot) ||
-// binaryRoot.toExternalForm().startsWith(url.toExternalForm())) {
-// String javadocDir = evaluator.getProperty(javadocProperty);
-// if (javadocDir != null) {
-// f = helper.resolveFile(javadocDir);
-// return f.toURI().toURL();
-// }
-// }
-// }
-// } catch (MalformedURLException malformedURL) {
-// ErrorManager.getDefault().notify(malformedURL);
-// }
-// return null;
-// }
-
-}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/SourceLevelQueryImpl.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/SourceLevelQueryImpl.java
deleted file mode 100644
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/SourceLevelQueryImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.j2ee.ejbjarproject.queries;
-
-import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.openide.filesystems.FileObject;
-
-/**
- * Returns source level of project sources.
- * @author David Konecny
- */
-public class SourceLevelQueryImpl implements SourceLevelQueryImplementation {
-
- private final AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
-
- public SourceLevelQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator) {
- this.helper = helper;
- this.evaluator = evaluator;
- }
-
- public String getSourceLevel(FileObject javaFile) {
- String sl = evaluator.getProperty("javac.source"); //NOI18N
- if (sl != null && sl.length() > 0) {
- return sl;
- } else {
- return null;
- }
- }
-
-}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/UnitTestForSourceQueryImpl.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/UnitTestForSourceQueryImpl.java
deleted file mode 100644
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/queries/UnitTestForSourceQueryImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.j2ee.ejbjarproject.queries;
-import java.net.URL;
-import org.netbeans.api.project.FileOwnerQuery;
-import org.netbeans.api.project.Project;
-import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
-import org.netbeans.modules.j2ee.ejbjarproject.SourceRoots;
-import org.openide.filesystems.FileObject;
-
-public class UnitTestForSourceQueryImpl implements MultipleRootsUnitTestForSourceQueryImplementation {
-
- private final SourceRoots sourceRoots;
- private final SourceRoots testRoots;
-
- public UnitTestForSourceQueryImpl(SourceRoots sourceRoots, SourceRoots testRoots) {
- this.sourceRoots = sourceRoots;
- this.testRoots = testRoots;
- }
-
- public URL[] findUnitTests(FileObject source) {
- return find(source, sourceRoots, testRoots); // NOI18N
- }
-
- public URL[] findSources(FileObject unitTest) {
- return find(unitTest, testRoots, sourceRoots); // NOI18N
- }
-
- private URL[] find(FileObject file, SourceRoots from, SourceRoots to) {
- Project p = FileOwnerQuery.getOwner(file);
- if (p == null) {
- return null;
- }
- FileObject[] fromRoots = from.getRoots();
- for (int i = 0; i < fromRoots.length; i++) {
- if (fromRoots[i].equals(file)) {
- return to.getRootURLs();
- }
- }
- return null;
- }
-
-}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/EjbJarLogicalViewProvider.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/EjbJarLogicalViewProvider.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/EjbJarLogicalViewProvider.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/EjbJarLogicalViewProvider.java
@@ -67,7 +67,6 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeListener;
import org.netbeans.api.java.platform.JavaPlatformManager;
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
-import org.netbeans.modules.j2ee.ejbjarproject.SourceRoots;
import org.openide.nodes.*;
import org.openide.util.*;
@@ -91,7 +90,6 @@ import org.netbeans.api.project.SourceGr
import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataFolder;
import org.openide.util.lookup.Lookups;
@@ -103,6 +101,8 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.spi.InstanceListener;
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject;
import org.netbeans.modules.j2ee.spi.ejbjar.support.J2eeProjectView;
+import org.netbeans.modules.java.api.common.SourceRoots;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
import org.netbeans.spi.project.ui.support.NodeFactorySupport;
import org.openide.filesystems.FileStateInvalidException;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/LibrariesNodeFactory.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/LibrariesNodeFactory.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/LibrariesNodeFactory.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/LibrariesNodeFactory.java
@@ -53,13 +53,13 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeListener;
import org.netbeans.api.project.Project;
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject;
-import org.netbeans.modules.j2ee.ejbjarproject.SourceRoots;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
import org.netbeans.modules.j2ee.ejbjarproject.classpath.ClassPathSupport;
import org.netbeans.modules.j2ee.ejbjarproject.ui.SourceNodeFactory.PreselectPropertiesAction;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.CustomizerLibraries;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
import org.netbeans.modules.j2ee.ejbjarproject.ui.logicalview.libraries.LibrariesNode;
+import org.netbeans.modules.java.api.common.SourceRoots;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.spi.project.ui.support.NodeFactory;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/CustomizerLibraries.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/CustomizerLibraries.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/CustomizerLibraries.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/CustomizerLibraries.java
@@ -55,6 +55,7 @@ import org.netbeans.api.java.platform.Pl
import org.netbeans.api.java.platform.PlatformsCustomizer;
import org.netbeans.modules.j2ee.ejbjarproject.classpath.ClassPathSupport;
import org.netbeans.modules.j2ee.ejbjarproject.ui.EjbJarLogicalViewProvider;
+import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/CustomizerProviderImpl.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/CustomizerProviderImpl.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/CustomizerProviderImpl.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/CustomizerProviderImpl.java
@@ -52,7 +52,7 @@ import org.netbeans.api.project.Project;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.spi.project.ui.CustomizerProvider;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/EjbJarProjectProperties.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/EjbJarProjectProperties.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/EjbJarProjectProperties.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/EjbJarProjectProperties.java
@@ -67,8 +67,6 @@ import org.netbeans.api.queries.Collocat
import org.netbeans.api.queries.CollocationQuery;
import org.netbeans.api.queries.FileEncodingQuery;
import org.netbeans.modules.j2ee.deployment.devmodules.api.AntDeploymentHelper;
-import org.netbeans.modules.j2ee.ejbjarproject.SourceRoots;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.openide.filesystems.FileUtil;
import org.openide.util.MutexException;
@@ -86,9 +84,13 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
import org.netbeans.modules.j2ee.ejbjarproject.classpath.ClassPathSupport;
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject;
+import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectType;
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectUtil;
import org.netbeans.modules.j2ee.ejbjarproject.Utils;
import org.netbeans.modules.j2ee.ejbjarproject.classpath.ClassPathSupport.Item;
+import org.netbeans.modules.java.api.common.SourceRoots;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
+import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants;
import org.netbeans.spi.project.support.ant.PropertyUtils;
import org.openide.filesystems.FileObject;
@@ -304,7 +306,11 @@ public class EjbJarProjectProperties {
RUN_TEST_CLASSPATH_MODEL = ClassPathUiSupport.createListModel( cs.itemsIterator( projectProperties.get(RUN_TEST_CLASSPATH), null ) );
PLATFORM_MODEL = PlatformUiSupport.createPlatformComboBoxModel (evaluator.getProperty(JAVA_PLATFORM));
PLATFORM_LIST_RENDERER = PlatformUiSupport.createPlatformListCellRenderer();
- JAVAC_SOURCE_MODEL = PlatformUiSupport.createSourceLevelComboBoxModel (PLATFORM_MODEL, evaluator.getProperty(JAVAC_SOURCE), evaluator.getProperty(JAVAC_TARGET), evaluator.getProperty(J2EE_PLATFORM));
+ PlatformUiSupport.JDK minimalSourceLevel = null;
+ if (evaluator.getProperty(J2EE_PLATFORM).equals(JAVA_EE_5)) {
+ minimalSourceLevel = PlatformUiSupport.JDK.VERSION_5;
+ }
+ JAVAC_SOURCE_MODEL = PlatformUiSupport.createSourceLevelComboBoxModel (PLATFORM_MODEL, evaluator.getProperty(JAVAC_SOURCE), evaluator.getProperty(JAVAC_TARGET), minimalSourceLevel);
JAVAC_SOURCE_RENDERER = PlatformUiSupport.createSourceLevelListCellRenderer ();
// CustomizerCompile
@@ -392,7 +398,7 @@ public class EjbJarProjectProperties {
projectProperties.setProperty( RUN_TEST_CLASSPATH, run_test_cp );
//Handle platform selection and javac.source javac.target properties
- PlatformUiSupport.storePlatform (projectProperties, updateHelper, PLATFORM_MODEL.getSelectedItem(), JAVAC_SOURCE_MODEL.getSelectedItem());
+ PlatformUiSupport.storePlatform (projectProperties, updateHelper, EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, PLATFORM_MODEL.getSelectedItem(), JAVAC_SOURCE_MODEL.getSelectedItem());
// Handle other special cases
if ( NO_DEPENDENCIES_MODEL.isSelected() ) { // NOI18N
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/EjbJarSourceRootsUi.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/EjbJarSourceRootsUi.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/EjbJarSourceRootsUi.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/EjbJarSourceRootsUi.java
@@ -80,7 +80,7 @@ import org.netbeans.api.project.FileOwne
import org.netbeans.api.project.FileOwnerQuery;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
-import org.netbeans.modules.j2ee.ejbjarproject.SourceRoots;
+import org.netbeans.modules.java.api.common.SourceRoots;
import org.openide.DialogDisplayer;
import org.openide.DialogDescriptor;
import org.openide.filesystems.FileUtil;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/PlatformUiSupport.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/PlatformUiSupport.java
deleted file mode 100644
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/customizer/PlatformUiSupport.java
+++ /dev/null
@@ -1,694 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.j2ee.ejbjarproject.ui.customizer;
-
-import java.awt.Component;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JButton;
-import javax.swing.JList;
-import javax.swing.ListCellRenderer;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-import org.netbeans.api.java.platform.JavaPlatform;
-import org.netbeans.api.java.platform.JavaPlatformManager;
-import org.netbeans.api.java.platform.Specification;
-import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectType;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
-import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.openide.DialogDisplayer;
-import org.openide.NotifyDescriptor;
-import org.openide.awt.HtmlRenderer;
-import org.openide.modules.SpecificationVersion;
-import org.openide.util.NbBundle;
-import org.openide.util.WeakListeners;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * Support class for {@link JavaPlatform} manipulation in ejbjarproject customizer.
- * @author tzezula
- */
-public class PlatformUiSupport {
-
- private static final SpecificationVersion JDK_5 = new SpecificationVersion ("1.5"); //NOI18N
- private static final SpecificationVersion JDK_6 = new SpecificationVersion ("1.6"); //NOI18N
- private static final Logger LOGGER = Logger.getLogger(PlatformUiSupport.class.getName());
-
- private PlatformUiSupport() {
- }
-
- /**
- * Creates {@link ComboBoxModel} of J2SE platforms.
- * The model listens on the {@link JavaPlatformManager} and update its
- * state according to changes
- * @param activePlatform the active project's platform
- * @return {@link ComboBoxModel}
- */
- public static ComboBoxModel createPlatformComboBoxModel (String activePlatform) {
- return new PlatformComboBoxModel (activePlatform);
- }
-
- /**
- * Creates a {@link ListCellRenderer} for rendering items of the {@link ComboBoxModel}
- * created by the {@link PlatformUiSupport#createPlatformComboBoxModel} method.
- * @return {@link ListCellRenderer}
- */
- public static ListCellRenderer createPlatformListCellRenderer () {
- return new PlatformListCellRenderer ();
- }
-
- /**
- * Like {@link #storePlatform}, but platformName may be null (in which case the default platform is used)
- */
- public static void storePlatform (EditableProperties props, UpdateHelper helper, String platformName, SpecificationVersion sourceLevel) {
- PlatformKey platformKey;
- if (platformName != null) {
- platformKey = new PlatformKey(PlatformUiSupport.findPlatform(platformName));
- } else {
- platformKey = new PlatformKey(JavaPlatformManager.getDefault().getDefaultPlatform());
- }
- storePlatform(props, helper, platformKey, sourceLevel == null ? null : new SourceLevelKey(sourceLevel));
- }
-
- /**
- * Stores active platform, javac.source and javac.target into the project's metadata
- * @param props project's shared properties
- * @param helper to read/update project.xml
- * @param platformKey the PatformKey got from the platform model
- * @param sourceLevel source level
- */
- public static void storePlatform (EditableProperties props, UpdateHelper helper, Object platformKey, Object sourceLevelKey) {
- assert platformKey instanceof PlatformKey;
- PlatformKey pk = (PlatformKey) platformKey;
- JavaPlatform platform = getPlatform(pk);
- //null means active broken (unresolved) platform, no need to do anything
- if (platform != null) {
- SpecificationVersion jdk13 = new SpecificationVersion ("1.3"); //NOI18N
- String platformAntName = platform.getProperties().get("platform.ant.name"); //NOI18N
- assert platformAntName != null;
- props.put(EjbJarProjectProperties.JAVA_PLATFORM, platformAntName);
- Element root = helper.getPrimaryConfigurationData(true);
- boolean defaultPlatform = pk.isDefaultPlatform();
- boolean changed = false;
- NodeList explicitPlatformNodes = root.getElementsByTagNameNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"explicit-platform"); //NOI18N
- if (defaultPlatform) {
- if (explicitPlatformNodes.getLength()==1) {
- root.removeChild(explicitPlatformNodes.item(0));
- changed = true;
- }
- }
- else {
- Element explicitPlatform;
- switch (explicitPlatformNodes.getLength()) {
- case 0:
- explicitPlatform = root.getOwnerDocument().createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "explicit-platform"); //NOI18N
- NodeList sourceRootNodes = root.getElementsByTagNameNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
- assert sourceRootNodes.getLength() == 1 : "Broken project.xml file"; //NOI18N
- root.insertBefore(explicitPlatform, sourceRootNodes.item(0));
- changed = true;
- break;
- case 1:
- explicitPlatform = (Element)explicitPlatformNodes.item(0);
- break;
- default:
- throw new AssertionError("Broken project.xml file"); //NOI18N
- }
- String explicitSourceAttrValue = explicitPlatform.getAttribute("explicit-source-supported"); //NOI18N
- if (jdk13.compareTo(platform.getSpecification().getVersion())>=0 &&
- !"false".equals(explicitSourceAttrValue)) { //NOI18N
- explicitPlatform.setAttribute("explicit-source-supported","false"); //NOI18N
- changed = true;
- }
- else if (jdk13.compareTo(platform.getSpecification().getVersion())<0 &&
- !"true".equals(explicitSourceAttrValue)) { //NOI18N
- explicitPlatform.setAttribute("explicit-source-supported","true"); //NOI18N
- changed = true;
- }
- }
-
- SpecificationVersion sourceLevel;
- if (sourceLevelKey == null) {
- sourceLevel = platform.getSpecification().getVersion();
- }
- else {
- assert sourceLevelKey instanceof SourceLevelKey;
- sourceLevel = ((SourceLevelKey)sourceLevelKey).getSourceLevel();
- }
- String javacSource = sourceLevel.toString();
- String javacTarget = javacSource;
-
- //Issue #116490
- // Customizer value | -source | -targer
- // JDK 1.2 1.2 1.1
- // JDK 1.3 1.3 1.1
- // JDK 1.4 1.4 1.4
- // JDK 5 1.5 1.5
- // JDK 6 1.5 1.6
- // JDK 7 1.7 1.7 - should bring a new language features
- if (jdk13.compareTo(sourceLevel)>=0) {
- javacTarget = "1.1"; //NOI18N
- }
- else if (JDK_6.equals(sourceLevel)) {
- javacSource = JDK_5.toString(); //NOI18N
- }
-
- // #89131: these levels are not actually distinct from 1.5.
- if (javacSource.equals("1.6") || javacSource.equals("1.7")) {
- javacSource = "1.5";
- }
- if (!javacSource.equals(props.getProperty(EjbJarProjectProperties.JAVAC_SOURCE))) {
- props.setProperty (EjbJarProjectProperties.JAVAC_SOURCE, javacSource);
- }
- if (!javacTarget.equals(props.getProperty(EjbJarProjectProperties.JAVAC_TARGET))) {
- props.setProperty (EjbJarProjectProperties.JAVAC_TARGET, javacTarget);
- }
-
- if (changed) {
- helper.putPrimaryConfigurationData(root, true);
- }
- }
- }
-
- public static JavaPlatform findPlatform(String displayName) {
- JavaPlatform[] platforms = JavaPlatformManager.getDefault().getPlatforms(displayName, new Specification("j2se", null)); //NOI18N
- return platforms.length == 0 ? null : platforms[0];
- }
-
-
- /**
- * Returns a {@link JavaPlatform} for an item obtained from the ComboBoxModel created by
- * the {@link PlatformUiSupport#createComboBoxModel} method
- * @param platformKey an item obtained from ComboBoxModel created by {@link PlatformUiSupport#createComboBoxModel}
- * @return JavaPlatform or null in case when platform is broken
- * @exception {@link IllegalArgumentException} is thrown in case when parameter in not an object created by
- * platform combobox model.
- */
- public static JavaPlatform getPlatform (Object platformKey) {
- if (platformKey instanceof PlatformKey) {
- return getPlatform ((PlatformKey)platformKey);
- }
- else {
- throw new IllegalArgumentException ();
- }
- }
-
- /**
- * Creates {@link ComboBoxModel} of source levels for active platform.
- * The model listens on the platform's {@link ComboBoxModel} and update its
- * state according to changes
- * @param platformComboBoxModel the platform's model used for listenning
- * @param initialSourceLevel initial source level value
- * @param initialTargetLevel initial target level value
- * @return {@link ComboBoxModel} of {@link SpecificationVersion}
- */
- public static ComboBoxModel createSourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel, String initialSourceLevel, String initialTargetLevel, String j2eePlatform) {
- return new SourceLevelComboBoxModel(platformComboBoxModel, initialSourceLevel, initialTargetLevel, j2eePlatform);
- }
-
- public static ListCellRenderer createSourceLevelListCellRenderer() {
- return new SourceLevelListCellRenderer();
- }
-
- private static JavaPlatform getPlatform (PlatformKey platformKey) {
- return platformKey.platform;
- }
-
- /**
- * This class represents a JavaPlatform in the {@link ListModel}
- * created by the {@link PlatformUiSupport#createPlatformComboBoxModel}
- * method.
- */
- private static class PlatformKey implements Comparable {
-
- private String name;
- private JavaPlatform platform;
-
- /**
- * Creates a PlatformKey for a broken platform
- * @param name the ant name of the broken platform
- */
- public PlatformKey (String name) {
- assert name != null;
- this.name = name;
- }
-
- /**
- * Creates a PlatformKey for a platform
- * @param platform the {@link JavaPlatform}
- */
- public PlatformKey (JavaPlatform platform) {
- assert platform != null;
- this.platform = platform;
- }
-
- public int compareTo(Object o) {
- return this.getDisplayName().compareTo(((PlatformKey)o).getDisplayName());
- }
-
- @Override
- public boolean equals (Object other) {
- if (other instanceof PlatformKey) {
- PlatformKey otherKey = (PlatformKey)other;
- return (this.platform == null ? otherKey.platform == null : this.platform.equals(otherKey.platform)) &&
- otherKey.getDisplayName().equals (this.getDisplayName());
- }
- else {
- return false;
- }
- }
-
- @Override
- public int hashCode () {
- return getDisplayName ().hashCode ();
- }
-
- @Override
- public String toString () {
- return getDisplayName ();
- }
-
- public synchronized String getDisplayName () {
- if (this.name == null) {
- this.name = this.platform.getDisplayName();
- }
- return this.name;
- }
-
- public boolean isDefaultPlatform () {
- if (this.platform == null) {
- return false;
- }
- return this.platform.equals(JavaPlatformManager.getDefault().getDefaultPlatform());
- }
-
- public boolean isBroken () {
- return this.platform == null;
- }
- }
-
- private static final class SourceLevelKey implements Comparable {
-
- final SpecificationVersion sourceLevel;
- final boolean broken;
-
- public SourceLevelKey (final SpecificationVersion sourceLevel) {
- this (sourceLevel, false);
- }
-
- public SourceLevelKey (final SpecificationVersion sourceLevel, final boolean broken) {
- assert sourceLevel != null : "Source level cannot be null"; //NOI18N
- this.sourceLevel = sourceLevel;
- this.broken = broken;
- }
-
- public SpecificationVersion getSourceLevel () {
- return this.sourceLevel;
- }
-
- public boolean isBroken () {
- return this.broken;
- }
-
- public int compareTo (final Object other) {
- assert other instanceof SourceLevelKey : "Illegal argument of SourceLevelKey.compareTo()"; //NOI18N
- SourceLevelKey otherKey = (SourceLevelKey) other;
- return this.sourceLevel.compareTo(otherKey.sourceLevel);
- }
-
- public @Override boolean equals (final Object other) {
- return (other instanceof SourceLevelKey) &&
- ((SourceLevelKey)other).sourceLevel.equals(this.sourceLevel);
- }
-
- public @Override int hashCode () {
- return this.sourceLevel.hashCode();
- }
-
- public @Override String toString () {
- StringBuffer buffer = new StringBuffer ();
- if (this.broken) {
- buffer.append("Broken: "); //NOI18N
- }
- buffer.append(this.sourceLevel.toString());
- return buffer.toString();
- }
-
- public String getDisplayName () {
- String _tmp = sourceLevel.toString();
- if (JDK_5.compareTo(sourceLevel)<=0) {
- _tmp = _tmp.replaceFirst("^1\\.([5-9]|\\d\\d+)$", "$1"); //NOI18N
- }
- return NbBundle.getMessage(PlatformUiSupport.class, "LBL_JDK",_tmp);
- }
-
- }
-
- private static class PlatformComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener {
- private static final long serialVersionUID = 41647580130743122L;
-
- private final JavaPlatformManager pm;
- private PlatformKey[] platformNamesCache;
- private String initialPlatform;
- private PlatformKey selectedPlatform;
-
- public PlatformComboBoxModel (String initialPlatform) {
- this.pm = JavaPlatformManager.getDefault();
- this.pm.addPropertyChangeListener(WeakListeners.propertyChange(this, this.pm));
- this.initialPlatform = initialPlatform;
- }
-
- public int getSize () {
- PlatformKey[] platformNames = getPlatformNames ();
- return platformNames.length;
- }
-
- public Object getElementAt (int index) {
- PlatformKey[] platformNames = getPlatformNames ();
- assert index >=0 && index< platformNames.length;
- return platformNames[index];
- }
-
- public Object getSelectedItem () {
- this.getPlatformNames(); //Force setting of selectedPlatform if it is not alredy done
- return this.selectedPlatform;
- }
-
- public void setSelectedItem (Object obj) {
- this.selectedPlatform = (PlatformKey) obj;
- this.fireContentsChanged(this, -1, -1);
- }
-
- public void propertyChange (PropertyChangeEvent event) {
- if (JavaPlatformManager.PROP_INSTALLED_PLATFORMS.equals(event.getPropertyName())) {
- synchronized (this) {
- this.platformNamesCache = null;
- }
- this.fireContentsChanged(this, -1, -1);
- }
- }
-
- private synchronized PlatformKey[] getPlatformNames () {
- if (this.platformNamesCache == null) {
- JavaPlatform[] platforms = pm.getPlatforms (null, new Specification("j2se",null)); //NOI18N
- Set orderedNames = new TreeSet();
- boolean activeFound = false;
- for (int i=0; i< platforms.length; i++) {
- if (platforms[i].getInstallFolders().size()>0) {
- PlatformKey pk = new PlatformKey(platforms[i]);
- orderedNames.add (pk);
- if (!activeFound && initialPlatform != null) {
- String antName = platforms[i].getProperties().get("platform.ant.name"); //NOI18N
- if (initialPlatform.equals(antName)) {
- if (this.selectedPlatform == null) {
- this.selectedPlatform = pk;
- initialPlatform = null;
- }
- activeFound = true;
- }
- }
- }
- }
- if (!activeFound) {
- if (initialPlatform == null) {
- if (this.selectedPlatform == null || !orderedNames.contains(this.selectedPlatform)) {
- this.selectedPlatform = new PlatformKey (JavaPlatformManager.getDefault().getDefaultPlatform());
- }
- }
- else {
- PlatformKey pk = new PlatformKey (this.initialPlatform);
- orderedNames.add (pk);
- if (this.selectedPlatform == null) {
- this.selectedPlatform = pk;
- }
- }
- }
- this.platformNamesCache = orderedNames.toArray(new PlatformKey[orderedNames.size()]);
- }
- return this.platformNamesCache;
- }
-
- }
-
- private static class PlatformListCellRenderer extends DefaultListCellRenderer {
- private static final long serialVersionUID = 51419604163086358L;
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- assert value instanceof PlatformKey : "Wrong model"; //NOI18N
- PlatformKey key = (PlatformKey) value;
- String name;
- if (key.isBroken()) {
- name = NbBundle.getMessage (PlatformUiSupport.class,"TXT_BrokenPlatformFmt", key.getDisplayName());
- }
- else {
- name = key.getDisplayName();
- }
- return super.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
- }
- }
-
- private static class SourceLevelComboBoxModel extends AbstractListModel implements ComboBoxModel, ListDataListener {
- private static final long serialVersionUID = 108135581162238931L;
- private static final String VERSION_PREFIX = "1."; //The version prefix
- private static final int INITIAL_VERSION_MINOR = 2; //1.2
- // if project is JAVA EE 5 show only 1.5 and higher
- private static final int INITIAL_VERSION_MINOR_JAVA_EE_5 = 5; // 1.5
-
- private SpecificationVersion selectedSourceLevel;
- private SpecificationVersion originalSourceLevel;
- private SourceLevelKey[] sourceLevelCache;
- private final ComboBoxModel platformComboBoxModel;
- private PlatformKey activePlatform;
- private String j2eePlatform = null;
-
- public SourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel, String initialSourceLevel, String initialTargetLevel) {
- this.platformComboBoxModel = platformComboBoxModel;
- this.activePlatform = (PlatformKey) this.platformComboBoxModel.getSelectedItem();
- this.platformComboBoxModel.addListDataListener(this);
- if (initialSourceLevel != null && initialSourceLevel.length()>0) {
- try {
- originalSourceLevel = new SpecificationVersion (initialSourceLevel);
- } catch (NumberFormatException nfe) {
- // If the javac.source has invalid value, do not preselect and log it.
- LOGGER.log(Level.INFO, "Invalid javac.source: " + initialSourceLevel);
- }
- }
- if (initialTargetLevel != null && initialTargetLevel.length() > 0) {
- try {
- SpecificationVersion originalTargetLevel = new SpecificationVersion (initialTargetLevel);
- if (this.originalSourceLevel == null || this.originalSourceLevel.compareTo(originalTargetLevel)<0) {
- this.originalSourceLevel = originalTargetLevel;
- }
- } catch (NumberFormatException nfe) {
- //If the javac.target has invalid value, do not preselect and log it
- LOGGER.warning("Invalid javac.target: "+initialTargetLevel); //NOI18N
- }
- }
- this.selectedSourceLevel = this.originalSourceLevel;
- }
-
- public SourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel, String initialSourceLevel, String initialTargetLevel, String j2eePlatform) {
- this(platformComboBoxModel, initialSourceLevel, initialTargetLevel);
- this.j2eePlatform = j2eePlatform;
- }
-
- public int getSize() {
- SourceLevelKey[] sLevels = getSourceLevels();
- return sLevels.length;
- }
-
- public Object getElementAt(int index) {
- SourceLevelKey[] sLevels = getSourceLevels();
- assert index >=0 && index< sLevels.length;
- return sLevels[index];
- }
-
- public Object getSelectedItem () {
- SourceLevelKey[] keys = getSourceLevels();
- for (int i=0; i0 &&
- !shouldChangePlatform(selectedSourceLevel, version)) {
- //Restore original
- this.platformComboBoxModel.setSelectedItem(this.activePlatform);
- return;
- }
- else {
- this.originalSourceLevel = null;
- }
- }
- this.activePlatform = selectedPlatform;
- resetCache();
- }
-
- private void resetCache() {
- synchronized (this) {
- this.sourceLevelCache = null;
- }
- this.fireContentsChanged(this, -1, -1);
- }
-
- private SourceLevelKey[] getSourceLevels() {
- if (this.sourceLevelCache == null) {
- PlatformKey selectedPlatform = (PlatformKey) this.platformComboBoxModel.getSelectedItem();
- JavaPlatform platform = getPlatform(selectedPlatform);
- List sLevels = new ArrayList();
- //If platform == null broken platform, the source level range is unknown
- //The source level combo box should be empty and disabled
- boolean selSourceLevelValid = false;
- if (platform != null) {
- SpecificationVersion version = platform.getSpecification().getVersion();
- int index = INITIAL_VERSION_MINOR;
- // #71619 - source level lower than 1.5 won't be shown for Java EE 5 project
- if (j2eePlatform != null && j2eePlatform.equals(EjbJarProjectProperties.JAVA_EE_5)) {
- index = INITIAL_VERSION_MINOR_JAVA_EE_5;
- }
- SpecificationVersion template = new SpecificationVersion (VERSION_PREFIX + Integer.toString (index++));
- boolean origSourceLevelValid = false;
-
- while (template.compareTo(version)<=0) {
- if (template.equals(this.originalSourceLevel)) {
- origSourceLevelValid = true;
- }
- if (template.equals(this.selectedSourceLevel)) {
- selSourceLevelValid = true;
- }
- sLevels.add (new SourceLevelKey (template));
- template = new SpecificationVersion (VERSION_PREFIX + Integer.toString (index++));
- }
- if (this.originalSourceLevel != null && !origSourceLevelValid) {
- if (originalSourceLevel.equals(this.selectedSourceLevel)) {
- selSourceLevelValid = true;
- }
- sLevels.add (new SourceLevelKey(this.originalSourceLevel,true));
- }
- }
- this.sourceLevelCache = sLevels.toArray(new SourceLevelKey[sLevels.size()]);
- if (!selSourceLevelValid) {
- this.selectedSourceLevel = this.sourceLevelCache.length == 0 ?
- null : this.sourceLevelCache[this.sourceLevelCache.length-1].getSourceLevel();
- }
- }
- return this.sourceLevelCache;
- }
-
- private static boolean shouldChangePlatform (SpecificationVersion selectedSourceLevel, SpecificationVersion platformSourceLevel) {
- JButton changeOption = new JButton (NbBundle.getMessage(PlatformUiSupport.class, "CTL_ChangePlatform"));
- changeOption.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PlatformUiSupport.class, "AD_ChangePlatform"));
- String message = MessageFormat.format (NbBundle.getMessage(PlatformUiSupport.class,"TXT_ChangePlatform"),new Object[] {
- selectedSourceLevel.toString(),
- platformSourceLevel.toString(),
- });
- return DialogDisplayer.getDefault().notify(
- new NotifyDescriptor (message,
- NbBundle.getMessage(PlatformUiSupport.class,"TXT_ChangePlatformTitle"),
- NotifyDescriptor.DEFAULT_OPTION,
- NotifyDescriptor.WARNING_MESSAGE,
- new Object[] {
- changeOption,
- NotifyDescriptor.CANCEL_OPTION
- },
- changeOption)) == changeOption;
- }
- }
-
- private static class SourceLevelListCellRenderer implements ListCellRenderer {
-
- ListCellRenderer delegate;
-
- public SourceLevelListCellRenderer() {
- this.delegate = HtmlRenderer.createRenderer();
- }
-
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- String message;
- if (value == null) {
- message = ""; //NOI18N
- }
- else {
- assert value instanceof SourceLevelKey;
- SourceLevelKey key = (SourceLevelKey) value;
- if (key.isBroken()) {
- message = "" + //NOI18N
- NbBundle.getMessage(PlatformUiSupport.class,"TXT_InvalidSourceLevel",key.getDisplayName());
- }
- else {
- message = key.getDisplayName();
- }
- }
- return this.delegate.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
- }
- }
-}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/ActionFilterNode.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/ActionFilterNode.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/ActionFilterNode.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/ActionFilterNode.java
@@ -66,9 +66,9 @@ import org.netbeans.spi.project.support.
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
import org.netbeans.modules.j2ee.ejbjarproject.classpath.ClassPathSupport;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.openide.nodes.FilterNode.Children;
import org.openide.util.Exceptions;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/LibrariesNode.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/LibrariesNode.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/LibrariesNode.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/LibrariesNode.java
@@ -99,12 +99,12 @@ import org.netbeans.spi.project.support.
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.spi.java.project.support.ui.PackageView;
import org.netbeans.modules.j2ee.ejbjarproject.ui.FoldersListSettings;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
import org.netbeans.modules.j2ee.ejbjarproject.classpath.EjbJarProjectClassPathExtender;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.AntArtifactChooser;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarClassPathUi;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.LibrariesChooser;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
import org.openide.util.Exceptions;
import org.openide.util.lookup.Lookups;
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/ProjectNode.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/ProjectNode.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/ProjectNode.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/ui/logicalview/libraries/ProjectNode.java
@@ -78,7 +78,7 @@ import org.netbeans.spi.project.support.
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.modules.j2ee.ejbjarproject.classpath.ClassPathSupport;
import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties;
-import org.netbeans.modules.j2ee.ejbjarproject.UpdateHelper;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.openide.filesystems.FileObject;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
diff --git a/java.commonapi/build.xml b/java.commonapi/build.xml
new file mode 100644
--- /dev/null
+++ b/java.commonapi/build.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
diff --git a/java.commonapi/manifest.mf b/java.commonapi/manifest.mf
new file mode 100644
--- /dev/null
+++ b/java.commonapi/manifest.mf
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: org.netbeans.modules.java.api.common/0
+OpenIDE-Module-Layer: org/netbeans/modules/java/api/common/resources/layer.xml
+OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
diff --git a/java.commonapi/nbproject/project.properties b/java.commonapi/nbproject/project.properties
new file mode 100644
--- /dev/null
+++ b/java.commonapi/nbproject/project.properties
@@ -0,0 +1,3 @@
+is.autoload=true
+javac.compilerargs=-Xlint -Xlint:-serial
+javac.source=1.5
diff --git a/java.commonapi/nbproject/project.xml b/java.commonapi/nbproject/project.xml
new file mode 100644
--- /dev/null
+++ b/java.commonapi/nbproject/project.xml
@@ -0,0 +1,152 @@
+
+
+ org.netbeans.modules.apisupport.project
+
+
+ org.netbeans.modules.java.api.common
+
+
+ org.netbeans.api.java
+
+
+
+ 1
+ 1.14
+
+
+
+ org.netbeans.modules.java.platform
+
+
+
+ 1
+ 1.10
+
+
+
+ org.netbeans.modules.java.project
+
+
+
+ 1
+ 1.13
+
+
+
+ org.netbeans.modules.project.ant
+
+
+
+ 1
+ 1.18
+
+
+
+ org.netbeans.modules.project.libraries
+
+
+
+ 1
+ 1.16
+
+
+
+ org.netbeans.modules.projectapi
+
+
+
+ 1
+ 1.14
+
+
+
+ org.netbeans.modules.queries
+
+
+
+ 1
+ 1.11
+
+
+
+ org.openide.awt
+
+
+
+ 6.12
+
+
+
+ org.openide.dialogs
+
+
+
+ 7.6
+
+
+
+ org.openide.filesystems
+
+
+
+ 7.4
+
+
+
+ org.openide.modules
+
+
+
+ 7.4
+
+
+
+ org.openide.util
+
+
+
+ 7.11
+
+
+
+
+
+ unit
+
+ org.netbeans.modules.diff
+
+
+ org.netbeans.modules.masterfs
+
+
+ org.netbeans.modules.project.ant
+
+
+
+
+ org.netbeans.modules.projectapi
+
+
+
+
+ org.openide.util
+
+
+
+
+
+
+ org.netbeans.modules.j2ee.clientproject
+ org.netbeans.modules.j2ee.common
+ org.netbeans.modules.j2ee.earproject
+ org.netbeans.modules.j2ee.ejbjarproject
+ org.netbeans.modules.java.j2seproject
+ org.netbeans.modules.web.project
+ org.netbeans.modules.java.api.common
+ org.netbeans.modules.java.api.common.ant
+ org.netbeans.modules.java.api.common.queries
+ org.netbeans.modules.java.api.common.ui
+
+
+
+
diff --git a/java.commonapi/src/org/netbeans/modules/java/api/common/Bundle.properties b/java.commonapi/src/org/netbeans/modules/java/api/common/Bundle.properties
new file mode 100644
--- /dev/null
+++ b/java.commonapi/src/org/netbeans/modules/java/api/common/Bundle.properties
@@ -0,0 +1,39 @@
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+#
+# 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. Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 2008 Sun Microsystems, Inc.
+
+NAME_src.dir=Source Packages
+NAME_test.src.dir=Test Packages
diff --git a/java.commonapi/src/org/netbeans/modules/java/api/common/SourceRoots.java b/java.commonapi/src/org/netbeans/modules/java/api/common/SourceRoots.java
new file mode 100644
--- /dev/null
+++ b/java.commonapi/src/org/netbeans/modules/java/api/common/SourceRoots.java
@@ -0,0 +1,144 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 2007 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.java.api.common;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.net.URL;
+import org.openide.filesystems.FileObject;
+import org.openide.util.NbBundle;
+
+/**
+ * Represents a project source roots. It can be used to obtain source roots as Ant properties, {@link FileObject}'s
+ * or {@link URL}s.
+ * All implementations have to be thread safe and have to listen to the changes
+ * in Ant project metadata (see {@link #PROP_ROOT_PROPERTIES}) as well as
+ * in project properties (see {@link #PROP_ROOTS}).
+ * @author Tomas Zezula, Tomas Mysik
+ */
+public interface SourceRoots {
+
+ /**
+ * Property name of a event that has to be fired when Ant project metadata change.
+ */
+ String PROP_ROOT_PROPERTIES = SourceRoots.class.getName() + ".rootProperties"; //NOI18N
+ /**
+ * Property name of a event that has to be fired when project properties change.
+ */
+ String PROP_ROOTS = SourceRoots.class.getName() + ".roots"; //NOI18N
+
+ /**
+ * Default label for sources node used in {@link org.netbeans.spi.project.ui.LogicalViewProvider}.
+ */
+ String DEFAULT_SOURCE_LABEL = NbBundle.getMessage(SourceRoots.class, "NAME_src.dir");
+ /**
+ * Default label for tests node used in {@link org.netbeans.spi.project.ui.LogicalViewProvider}.
+ */
+ String DEFAULT_TEST_LABEL = NbBundle.getMessage(SourceRoots.class, "NAME_test.src.dir");
+
+ /**
+ * Returns the display names of source roots.
+ * The returned array has the same length as an array returned by the {@link #getRootProperties()}.
+ * It may contain empty {@link String}s but not null.
+ * @return an array of source roots names.
+ */
+ String[] getRootNames();
+
+ /**
+ * Returns names of Ant properties in the project.properties file holding the source roots.
+ * @return an array of String.
+ */
+ String[] getRootProperties();
+
+ /**
+ * Returns the source roots in the form of absolute paths.
+ * @return an array of {@link FileObject}s.
+ */
+ FileObject[] getRoots();
+
+ /**
+ * Returns the source roots as {@link URL}s.
+ * @return an array of {@link URL}.
+ */
+ URL[] getRootURLs();
+
+ /**
+ * Adds {@link PropertyChangeListener}, see class description for more information
+ * about listening to the source roots changes.
+ * @param listener a listener to add.
+ */
+ void addPropertyChangeListener(PropertyChangeListener listener);
+
+ /**
+ * Removes {@link PropertyChangeListener}, see class description for more information
+ * about listening to the source roots changes.
+ * @param listener a listener to remove.
+ */
+ void removePropertyChangeListener(PropertyChangeListener listener);
+
+ /**
+ * Replaces the current roots by the given ones.
+ * @param roots the {@link URL}s of the new roots.
+ * @param labels the names of the new roots.
+ */
+ void putRoots(final URL[] roots, final String[] labels);
+
+ /**
+ * Translates root name into display name of source/test root.
+ * @param rootName the name of root got from {@link SourceRoots#getRootNames()}.
+ * @param propName the name of a property the root is stored in.
+ * @return the label to be displayed.
+ */
+ String getRootDisplayName(String rootName, String propName);
+
+ /**
+ * Creates initial display name of source/test root.
+ * @param sourceRoot the source root.
+ * @return the label to be displayed.
+ */
+ String createInitialDisplayName(File sourceRoot);
+
+ /**
+ * Returns true if the current {@link SourceRoots} instance represents source roots belonging to
+ * the test compilation unit.
+ * @return boolean true if the instance belongs to the test compilation unit, false otherwise.
+ */
+ boolean isTest();
+}
diff --git a/java.commonapi/src/org/netbeans/modules/java/api/common/SourceRootsImpl.java b/java.commonapi/src/org/netbeans/modules/java/api/common/SourceRootsImpl.java
new file mode 100644
--- /dev/null
+++ b/java.commonapi/src/org/netbeans/modules/java/api/common/SourceRootsImpl.java
@@ -0,0 +1,427 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package org.netbeans.modules.java.api.common;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.text.MessageFormat;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+import org.openide.util.WeakListeners;
+import org.openide.util.Mutex;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Document;
+import org.netbeans.spi.project.support.ant.AntProjectHelper;
+import org.netbeans.spi.project.support.ant.AntProjectEvent;
+import org.netbeans.spi.project.support.ant.AntProjectListener;
+import org.netbeans.spi.project.support.ant.EditableProperties;
+import org.netbeans.spi.project.support.ant.PropertyEvaluator;
+import org.netbeans.spi.project.support.ant.ReferenceHelper;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.java.project.JavaProjectConstants;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
+
+/**
+ * This class represents a project source roots. It is used to obtain roots as Ant properties, FileObject's
+ * or URLs.
+ * @author Tomas Zezula
+ */
+final class SourceRootsImpl implements SourceRoots {
+
+ private final UpdateHelper helper;
+ private final PropertyEvaluator evaluator;
+ private final ReferenceHelper refHelper;
+ private final String projectConfigurationNamespace;
+ private final String elementName;
+ private final String newRootNameTemplate;
+ private List sourceRootProperties;
+ private List sourceRootNames;
+ private List sourceRoots;
+ private List sourceRootURLs;
+ private final PropertyChangeSupport support;
+ private final ProjectMetadataListener listener;
+ private final boolean isTest;
+ private final File projectDir;
+
+ public SourceRootsImpl(UpdateHelper helper, PropertyEvaluator evaluator, ReferenceHelper refHelper,
+ String projectConfigurationNamespace, String elementName, boolean isTest, String newRootNameTemplate) {
+ assert helper != null;
+ assert evaluator != null;
+ assert refHelper != null;
+ assert projectConfigurationNamespace != null;
+ assert elementName != null;
+ assert newRootNameTemplate != null;
+
+ this.helper = helper;
+ this.evaluator = evaluator;
+ this.refHelper = refHelper;
+ this.projectConfigurationNamespace = projectConfigurationNamespace;
+ this.elementName = elementName;
+ this.isTest = isTest;
+ this.newRootNameTemplate = newRootNameTemplate;
+ this.projectDir = FileUtil.toFile(this.helper.getAntProjectHelper().getProjectDirectory());
+ this.support = new PropertyChangeSupport(this);
+ this.listener = new ProjectMetadataListener();
+ this.evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this.listener, this.evaluator));
+ this.helper.getAntProjectHelper().addAntProjectListener(
+ WeakListeners.create(AntProjectListener.class, this.listener, this.helper));
+ }
+
+
+ public String[] getRootNames() {
+ return ProjectManager.mutex().readAccess(new Mutex.Action() {
+ public String[] run() {
+ synchronized (SourceRootsImpl.this) {
+ if (sourceRootNames == null) {
+ readProjectMetadata();
+ }
+ }
+ return sourceRootNames.toArray(new String[sourceRootNames.size()]);
+ }
+ });
+ }
+
+ public String[] getRootProperties() {
+ return ProjectManager.mutex().readAccess(new Mutex.Action() {
+ public String[] run() {
+ synchronized (SourceRootsImpl.this) {
+ if (sourceRootProperties == null) {
+ readProjectMetadata();
+ }
+ return sourceRootProperties.toArray(new String[sourceRootProperties.size()]);
+ }
+ }
+ });
+ }
+
+ public FileObject[] getRoots() {
+ return ProjectManager.mutex().readAccess(new Mutex.Action() {
+ public FileObject[] run() {
+ synchronized (this) {
+ // local caching
+ if (sourceRoots == null) {
+ String[] srcProps = getRootProperties();
+ List result = new ArrayList();
+ for (String p : srcProps) {
+ String prop = evaluator.getProperty(p);
+ if (prop != null) {
+ FileObject f = helper.getAntProjectHelper().resolveFileObject(prop);
+ if (f == null) {
+ continue;
+ }
+ if (FileUtil.isArchiveFile(f)) {
+ f = FileUtil.getArchiveRoot(f);
+ }
+ result.add(f);
+ }
+ }
+ sourceRoots = Collections.unmodifiableList(result);
+ }
+ }
+ return sourceRoots.toArray(new FileObject[sourceRoots.size()]);
+ }
+ });
+ }
+
+ public URL[] getRootURLs() {
+ return ProjectManager.mutex().readAccess(new Mutex.Action() {
+ public URL[] run() {
+ synchronized (this) {
+ // local caching
+ if (sourceRootURLs == null) {
+ List result = new ArrayList();
+ for (String srcProp : getRootProperties()) {
+ String prop = evaluator.getProperty(srcProp);
+ if (prop != null) {
+ File f = helper.getAntProjectHelper().resolveFile(prop);
+ try {
+ URL url = f.toURI().toURL();
+ if (!f.exists()) {
+ url = new URL(url.toExternalForm() + "/"); // NOI18N
+ } else if (f.isFile()) {
+ // file cannot be a source root (archives are not supported as source roots).
+ continue;
+ }
+ assert url.toExternalForm().endsWith("/") : "#90639 violation for " + url + "; "
+ + f + " exists? " + f.exists() + " dir? " + f.isDirectory()
+ + " file? " + f.isFile();
+ result.add(url);
+ } catch (MalformedURLException e) {
+ Exceptions.printStackTrace(e);
+ }
+ }
+ }
+ sourceRootURLs = Collections.unmodifiableList(result);
+ }
+ }
+ return sourceRootURLs.toArray(new URL[sourceRootURLs.size()]);
+ }
+ });
+ }
+
+ private Map getRootsToProps() {
+ return ProjectManager.mutex().readAccess(new Mutex.Action
+
+ org.netbeans.modules.java.api.common
+
+
+
+ 0-1
+ 1.0
@@ -284,13 +293,31 @@ made subject to such option by the copyr
unit
+ org.netbeans.api.progress
+
+
+ org.netbeans.bootstrap
+
+
+ org.netbeans.core
+
+
+ org.netbeans.core.startup
+
+
+ org.netbeans.libs.xerces
+
+
+ org.netbeans.modules.java.api.common
+
+
+ org.netbeans.modules.java.j2seproject
- org.openide.io
-
+ org.netbeans.modules.masterfsorg.netbeans.modules.projectapi
@@ -298,59 +325,7 @@ made subject to such option by the copyr
- org.netbeans.core
-
-
- org.openide.loaders
-
-
- org.netbeans.modules.masterfs
-
-
- org.netbeans.api.progress
-
-
- org.openide.options
-
-
- org.openide.explorer
-
-
- org.openide.dialogs
-
-
- org.openide.nodes
-
-
- org.openide.text
-
-
- org.openide.awt
-
-
- org.openide.util
-
-
-
-
- org.openide.actions
-
-
- org.openide.modules
-
-
- org.openide.filesystems
-
-
-
-
- org.netbeans.core.startup
-
-
- org.netbeans.bootstrap
-
-
- org.netbeans.libs.xerces
+ org.netbeans.modules.projectuiorg.netbeans.modules.schema2beans
@@ -359,7 +334,45 @@ made subject to such option by the copyr
org.netbeans.modules.xml.retriever
- org.netbeans.modules.projectui
+ org.openide.actions
+
+
+ org.openide.awt
+
+
+ org.openide.dialogs
+
+
+ org.openide.explorer
+
+
+ org.openide.filesystems
+
+
+
+
+ org.openide.io
+
+
+
+ org.openide.loaders
+
+
+ org.openide.modules
+
+
+ org.openide.nodes
+
+
+ org.openide.options
+
+
+ org.openide.text
+
+
+ org.openide.util
+
+
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
@@ -73,6 +73,7 @@ import org.netbeans.api.project.ProjectU
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.modules.java.j2seproject.applet.AppletSupport;
import org.netbeans.modules.java.j2seproject.classpath.ClassPathProviderImpl;
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
@@ -433,7 +434,7 @@ class J2SEActionProvider implements Acti
result=isSetMainClass (project.getSourceRoots().getRoots(), mainClass);
} while (result != MainClassStatus.SET_AND_VALID);
try {
- if (updateHelper.requestSave()) {
+ if (updateHelper.requestUpdate()) {
updateHelper.putProperties(path, ep);
ProjectManager.getDefault().saveProject(project);
}
diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEFileBuiltQuery.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEFileBuiltQuery.java
deleted file mode 100644
--- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEFileBuiltQuery.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.java.j2seproject;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import org.netbeans.api.project.ProjectManager;
-import org.openide.filesystems.FileObject;
-import org.netbeans.api.queries.FileBuiltQuery;
-import org.netbeans.spi.queries.FileBuiltQueryImplementation;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
-import org.openide.util.Mutex.Action;
-
-
-
-
-
-public class J2SEFileBuiltQuery implements FileBuiltQueryImplementation, PropertyChangeListener {
-
- private FileBuiltQueryImplementation delegate;
- private final AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
- private final SourceRoots sourceRoots;
- private final SourceRoots testRoots;
-
- J2SEFileBuiltQuery (AntProjectHelper helper, PropertyEvaluator evaluator,
- SourceRoots sourceRoots, SourceRoots testRoots) {
- assert helper != null && evaluator != null && sourceRoots != null && testRoots != null;
- this.helper = helper;
- this.evaluator = evaluator;
- this.sourceRoots = sourceRoots;
- this.testRoots = testRoots;
- this.sourceRoots.addPropertyChangeListener (this);
- this.testRoots.addPropertyChangeListener (this);
- }
-
- public FileBuiltQuery.Status getStatus(final FileObject file) {
- return ProjectManager.mutex().readAccess(new Action() {
- public FileBuiltQuery.Status run() {
- return getStatusImpl(file);
- }
- });
- }
-
- private synchronized FileBuiltQuery.Status getStatusImpl(FileObject file) {
- if (this.delegate == null) {
- this.delegate = createDelegate ();
- }
- return this.delegate.getStatus (file);
- }
-
-
- private FileBuiltQueryImplementation createDelegate () {
- String[] srcRoots = this.sourceRoots.getRootProperties();
- String[] tstRoots = this.testRoots.getRootProperties();
- String[] from = new String [srcRoots.length + tstRoots.length];
- String[] to = new String [srcRoots.length + tstRoots.length];
- for (int i=0; i< srcRoots.length; i++) {
- from[i] = "${" + srcRoots[i] + "}/*.java"; // NOI18N
- to[i] = "${" + J2SEProjectProperties.BUILD_CLASSES_DIR + "}/*.class"; // NOI18N
- }
- for (int i=0; i() {
- public Integer run() {
- synchronized (J2SESharabilityQuery.this) {
- if (delegate == null) {
- delegate = createDelegate ();
- }
- return delegate.getSharability(file);
- }
- }
- });
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (SourceRoots.PROP_ROOT_PROPERTIES.equals(evt.getPropertyName())) {
- synchronized (this) {
- this.delegate = null;
- }
- }
- }
-
- private SharabilityQueryImplementation createDelegate () {
- String[] srcProps = srcRoots.getRootProperties();
- String[] testProps = testRoots.getRootProperties();
- String[] props = new String [srcProps.length + testProps.length];
- for (int i=0; i mainHandle = main.iterator().next();
newMainClass = mainHandle.getQualifiedName();
}
- if (newMainClass != null && !newMainClass.equals(oldMainClass) && helper.requestSave() &&
+ 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) {
final String newMainClassFinal = newMainClass;
diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/SourceRoots.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/SourceRoots.java
deleted file mode 100644
--- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/SourceRoots.java
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.java.j2seproject;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.text.MessageFormat;
-import org.openide.ErrorManager;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
-import org.openide.util.WeakListeners;
-import org.openide.util.Mutex;
-import org.openide.util.NbBundle;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Document;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.AntProjectEvent;
-import org.netbeans.spi.project.support.ant.AntProjectListener;
-import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.netbeans.spi.project.support.ant.ReferenceHelper;
-import org.netbeans.api.project.ProjectManager;
-import org.netbeans.api.java.project.JavaProjectConstants;
-
-/**
- * This class represents a project source roots. It is used to obtain roots as Ant properties, FileObject's
- * or URLs.
- * @author Tomas Zezula
- */
-public final class SourceRoots {
-
- public static final String PROP_ROOT_PROPERTIES = "rootProperties"; //NOI18N
- public static final String PROP_ROOTS = "roots"; //NOI18N
-
- public static final String DEFAULT_SOURCE_LABEL = NbBundle.getMessage(SourceRoots.class, "NAME_src.dir");
- public static final String DEFAULT_TEST_LABEL = NbBundle.getMessage(SourceRoots.class, "NAME_test.src.dir");
-
- private final UpdateHelper helper;
- private final PropertyEvaluator evaluator;
- private final ReferenceHelper refHelper;
- private final String elementName;
- private final String newRootNameTemplate;
- private List sourceRootProperties;
- private List sourceRootNames;
- private List sourceRoots;
- private List sourceRootURLs;
- private final PropertyChangeSupport support;
- private final ProjectMetadataListener listener;
- private final boolean isTest;
- private final File projectDir;
-
- /**
- * Creates new SourceRoots
- * @param helper
- * @param evaluator
- * @param elementName the name of XML element under which are declared the roots
- * @param newRootNameTemplate template for new property name of source root
- */
- SourceRoots (UpdateHelper helper, PropertyEvaluator evaluator, ReferenceHelper refHelper, String elementName, boolean isTest, String newRootNameTemplate) {
- assert helper != null && evaluator != null && refHelper != null && elementName != null && newRootNameTemplate != null;
- this.helper = helper;
- this.evaluator = evaluator;
- this.refHelper = refHelper;
- this.elementName = elementName;
- this.isTest = isTest;
- this.newRootNameTemplate = newRootNameTemplate;
- this.projectDir = FileUtil.toFile(this.helper.getAntProjectHelper().getProjectDirectory());
- this.support = new PropertyChangeSupport(this);
- this.listener = new ProjectMetadataListener();
- this.evaluator.addPropertyChangeListener (WeakListeners.propertyChange(this.listener,this.evaluator));
- this.helper.getAntProjectHelper().addAntProjectListener(WeakListeners.create(AntProjectListener.class, this.listener, this.helper));
- }
-
-
- /**
- * Returns the display names of soruce roots
- * The returned array has the same length as an array returned by the getRootProperties.
- * It may contain empty strings but not null.
- * @return an array of String
- */
- public String[] getRootNames () {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public String[] run() {
- synchronized (SourceRoots.this) {
- if (sourceRootNames == null) {
- readProjectMetadata();
- }
- }
- return sourceRootNames.toArray (new String[sourceRootNames.size()]);
- }
- });
- }
-
- /**
- * Returns names of Ant properties in the project.properties file holding the source roots.
- * @return an array of String
- */
- public String[] getRootProperties () {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public String[] run() {
- synchronized (SourceRoots.this) {
- if (sourceRootProperties == null) {
- readProjectMetadata();
- }
- return sourceRootProperties.toArray(new String[sourceRootProperties.size()]);
- }
- }
- });
- }
-
- /**
- * Returns the source roots
- * @return an array of FileObject
- */
- public FileObject[] getRoots () {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public FileObject[] run () {
- synchronized (this) {
- //Local caching
- if (sourceRoots == null) {
- String[] srcProps = getRootProperties();
- List result = new ArrayList();
- for (String p : srcProps) {
- String prop = evaluator.getProperty(p);
- if (prop != null) {
- FileObject f = helper.getAntProjectHelper().resolveFileObject(prop);
- if (f == null) {
- continue;
- }
- if (FileUtil.isArchiveFile(f)) {
- f = FileUtil.getArchiveRoot(f);
- }
- result.add(f);
- }
- }
- sourceRoots = Collections.unmodifiableList(result);
- }
- }
- return sourceRoots.toArray(new FileObject[sourceRoots.size()]);
- }
- });
- }
-
- /**
- * Returns the source roots as URLs.
- * @return an array of URL
- */
- public URL[] getRootURLs() {
- return ProjectManager.mutex().readAccess(new Mutex.Action() {
- public URL[] run () {
- synchronized (this) {
- //Local caching
- if (sourceRootURLs == null) {
- String[] srcProps = getRootProperties();
- List result = new ArrayList();
- for (int i = 0; i getRootsToProps () {
- return ProjectManager.mutex().readAccess(new Mutex.Action
+
+ org.netbeans.modules.java.api.common
+
+
+
+ 0-1
+ 1.0
diff --git a/web.project/src/org/netbeans/modules/web/project/ProjectWebModule.java b/web.project/src/org/netbeans/modules/web/project/ProjectWebModule.java
--- a/web.project/src/org/netbeans/modules/web/project/ProjectWebModule.java
+++ b/web.project/src/org/netbeans/modules/web/project/ProjectWebModule.java
@@ -82,6 +82,7 @@ import org.netbeans.modules.j2ee.dd.spi.
import org.netbeans.modules.j2ee.dd.spi.web.WebAppMetadataModelFactory;
import org.netbeans.modules.j2ee.dd.spi.webservices.WebservicesMetadataModelFactory;
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants;
/** A web module implementation on top of project.
diff --git a/web.project/src/org/netbeans/modules/web/project/SourceRoots.java b/web.project/src/org/netbeans/modules/web/project/SourceRoots.java
deleted file mode 100644
--- a/web.project/src/org/netbeans/modules/web/project/SourceRoots.java
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.web.project;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.text.MessageFormat;
-
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.NbBundle;
-import org.openide.util.WeakListeners;
-import org.openide.util.Mutex;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Document;
-
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.AntProjectEvent;
-import org.netbeans.spi.project.support.ant.AntProjectListener;
-import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.netbeans.spi.project.support.ant.ReferenceHelper;
-import org.netbeans.api.project.ProjectManager;
-import org.netbeans.api.java.project.JavaProjectConstants;
-import org.openide.util.Exceptions;
-
-/**
- * This class represents a project source roots. It is used to obtain roots as Ant properties, FileObject's
- * or URLs.
- * @author Tomas Zezula
- */
-public final class SourceRoots {
-
- public static final String PROP_ROOT_PROPERTIES = "rootProperties"; //NOI18N
- public static final String PROP_ROOTS = "roots"; //NOI18N
-
- public static final String DEFAULT_SOURCE_LABEL = NbBundle.getMessage(SourceRoots.class, "NAME_src.dir");
- public static final String DEFAULT_TEST_LABEL = NbBundle.getMessage(SourceRoots.class, "NAME_test.src.dir");
-
- private final UpdateHelper helper;
- private final PropertyEvaluator evaluator;
- private final ReferenceHelper refHelper;
- private final String elementName;
- private final String newRootNameTemplate;
- private List/**/ sourceRootProperties;
- private List/**/ sourceRootNames;
- private List/**/ sourceRoots;
- private List/**/ sourceRootURLs;
- private final PropertyChangeSupport support;
- private final ProjectMetadataListener listener;
- private final boolean isTest;
- private final File projectDir;
-
- /**
- * Creates new SourceRoots
- * @param helper
- * @param evaluator
- * @param elementName the name of XML element under which are declared the roots
- * @param newRootNameTemplate template for new property name of source root
- */
- SourceRoots (UpdateHelper helper, PropertyEvaluator evaluator, ReferenceHelper refHelper, String elementName, boolean isTest, String newRootNameTemplate) {
- assert helper != null && evaluator != null && refHelper != null && elementName != null && newRootNameTemplate != null;
- this.helper = helper;
- this.evaluator = evaluator;
- this.refHelper = refHelper;
- this.elementName = elementName;
- this.isTest = isTest;
- this.newRootNameTemplate = newRootNameTemplate;
- this.projectDir = FileUtil.toFile(this.helper.getAntProjectHelper().getProjectDirectory());
- this.support = new PropertyChangeSupport(this);
- this.listener = new ProjectMetadataListener();
- this.evaluator.addPropertyChangeListener (WeakListeners.propertyChange(this.listener,this.evaluator));
- this.helper.getAntProjectHelper().addAntProjectListener ((AntProjectListener)WeakListeners.create(AntProjectListener.class, this.listener,this.helper));
- }
-
-
- /**
- * Returns the display names of soruce roots
- * The returned array has the same length as an array returned by the getRootProperties.
- * It may contain empty strings but not null.
- * @return an array of String
- */
- public String[] getRootNames () {
- return (String[]) ProjectManager.mutex().readAccess(new Mutex.Action() {
- public Object run() {
- synchronized (SourceRoots.this) {
- if (sourceRootNames == null) {
- readProjectMetadata();
- }
- }
- return sourceRootNames.toArray (new String[sourceRootNames.size()]);
- }
- });
- }
-
- /**
- * Returns names of Ant properties in the project.properties file holding the source roots.
- * @return an array of String
- */
- public String[] getRootProperties () {
- return (String[]) ProjectManager.mutex().readAccess(new Mutex.Action() {
- public Object run() {
- synchronized (SourceRoots.this) {
- if (sourceRootProperties == null) {
- readProjectMetadata();
- }
- }
- return sourceRootProperties.toArray (new String[sourceRootProperties.size()]);
- }
- });
- }
-
- /**
- * Returns the source roots
- * @return an array of FileObject
- */
- public FileObject[] getRoots () {
- return (FileObject[]) ProjectManager.mutex().readAccess(new Mutex.Action () {
- public Object run () {
- synchronized (this) {
- //Local caching
- if (sourceRoots == null) {
- String[] srcProps = getRootProperties();
- List result = new ArrayList();
- for (int i = 0; i0) {
- Element root = (Element) rootsNodes.item(0);
- ownerElement.removeChild(root);
- }
- //Remove all unused root properties
- List newRoots = Arrays.asList(roots);
- Map propsToRemove = new HashMap (oldRoots2props);
- propsToRemove.keySet().removeAll(newRoots);
- EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- for (Iterator it = propsToRemove.values().iterator(); it.hasNext();) {
- String propName = (String) it.next ();
- props.remove(propName);
- }
- helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,props);
- //Add the new roots
- Document doc = ownerElement.getOwnerDocument();
- oldRoots2props.keySet().retainAll(newRoots);
- for (Iterator it = newRoots.iterator(); it.hasNext();) {
- URL newRoot = (URL) it.next ();
- String rootName = (String) oldRoots2props.get (newRoot);
- if (rootName == null) {
- //Root is new generate property for it
- props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- String[] names = newRoot.getPath().split("/"); //NOI18N
- rootName = MessageFormat.format(newRootNameTemplate, new Object[]{names[names.length-1],""}); //NOI18N
- int rootIndex = 1;
- while (props.containsKey(rootName)) {
- rootIndex++;
- rootName = MessageFormat.format(newRootNameTemplate,new Object[]{names[names.length-1], Integer.valueOf(rootIndex)});
- }
- File f = FileUtil.normalizeFile(new File(URI.create(newRoot.toExternalForm())));
- File projDir = FileUtil.toFile(helper.getAntProjectHelper().getProjectDirectory());
- String path = f.getAbsolutePath();
- String prjPath = projDir.getAbsolutePath()+File.separatorChar;
- if (path.startsWith(prjPath)) {
- path = path.substring(prjPath.length());
- }
- else {
- path = refHelper.createForeignFileReference(f, JavaProjectConstants.SOURCES_TYPE_JAVA);
- props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- }
- props.put(rootName,path);
- helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,props);
- }
- Element newRootNode = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, "root"); //NOI18N
- newRootNode.setAttribute("id",rootName); //NOI18N
- String label = (String) newRoots2lab.get (newRoot);
- if (label != null && label.length()>0 && !label.equals (getRootDisplayName(null,rootName))) { //NOI18N
- newRootNode.setAttribute("name",label); //NOI18N
- }
- ownerElement.appendChild (newRootNode);
- }
- helper.putPrimaryConfigurationData(cfgEl,true);
- return null;
- }
- }
- );
- }
-
- /**
- * Translates root name into display name of source/test root
- * @param rootName the name of root got from {@link SourceRoots#getRootNames}
- * @param propName the name of property the root is stored in
- * @return the label to be displayed
- */
- public String getRootDisplayName (String rootName, String propName) {
- if (rootName == null || rootName.length() ==0) {
- //If the prop is src.dir use the default name
- if (isTest && "test.src.dir".equals(propName)) { //NOI18N
- rootName = DEFAULT_TEST_LABEL;
- }
- else if (!isTest && "src.dir".equals(propName)) { //NOI18N
- rootName = DEFAULT_SOURCE_LABEL;
- }
- else {
- //If the name is not given, it should be either a relative path in the project dir
- //or absolute path when the root is not under the project dir
- String propValue = evaluator.getProperty(propName);
- File sourceRoot = propValue == null ? null : helper.getAntProjectHelper().resolveFile(propValue);
- rootName = createInitialDisplayName(sourceRoot);
- }
- }
- return rootName;
- }
-
- public String createInitialDisplayName (File sourceRoot) {
- String rootName;
- if (sourceRoot != null) {
- String srPath = sourceRoot.getAbsolutePath();
- String pdPath = projectDir.getAbsolutePath() + File.separatorChar;
- if (srPath.startsWith(pdPath)) {
- rootName = srPath.substring(pdPath.length());
- }
- else {
- rootName = sourceRoot.getAbsolutePath();
- }
- }
- else {
- rootName = isTest ? DEFAULT_TEST_LABEL : DEFAULT_SOURCE_LABEL;
- }
- return rootName;
- }
-
- private void resetCache (boolean isXMLChange, String propName) {
- boolean fire = false;
- synchronized (this) {
- //In case of change reset local cache
- if (isXMLChange) {
- this.sourceRootProperties = null;
- this.sourceRootNames = null;
- this.sourceRoots = null;
- this.sourceRootURLs = null;
- fire = true;
- } else if (propName == null || (sourceRootProperties != null && sourceRootProperties.contains(propName))) {
- this.sourceRoots = null;
- this.sourceRootURLs = null;
- fire = true;
- }
- }
- if (fire) {
- if (isXMLChange) {
- this.support.firePropertyChange (PROP_ROOT_PROPERTIES,null,null);
- }
- this.support.firePropertyChange (PROP_ROOTS,null,null);
- }
- }
-
- private void readProjectMetadata () {
- Element cfgEl = helper.getPrimaryConfigurationData(true);
- NodeList nl = cfgEl.getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, elementName);
- assert nl.getLength() == 0 || nl.getLength() == 1 : "Illegal project.xml"; //NOI18N
- List rootProps = new ArrayList ();
- List rootNames = new ArrayList ();
- // It can be 0 in the case when the project is created by WebProjectGenerator and not yet customized
- if (nl.getLength()==1) {
- NodeList roots = ((Element)nl.item(0)).getElementsByTagNameNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, "root"); //NOI18N
- for (int i=0; i 0 : "Illegal project.xml";
- rootProps.add(value);
- value = root.getAttribute("name"); //NOI18N
- rootNames.add (value);
- }
- }
- this.sourceRootProperties = Collections.unmodifiableList(rootProps);
- this.sourceRootNames = Collections.unmodifiableList(rootNames);
- }
-
- private class ProjectMetadataListener implements PropertyChangeListener,AntProjectListener {
-
- public void propertyChange(PropertyChangeEvent evt) {
- resetCache (false,evt.getPropertyName());
- }
-
- public void configurationXmlChanged(AntProjectEvent ev) {
- resetCache (true,null);
- }
-
- public void propertiesChanged(AntProjectEvent ev) {
- //Handled by propertyChange
- }
- }
-
- public boolean isTest() {
- return isTest;
- }
-}
diff --git a/web.project/src/org/netbeans/modules/web/project/UpdateHelper.java b/web.project/src/org/netbeans/modules/web/project/UpdateHelper.java
deleted file mode 100644
--- a/web.project/src/org/netbeans/modules/web/project/UpdateHelper.java
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.web.project;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import javax.swing.JButton;
-import org.netbeans.api.project.libraries.LibraryManager;
-import org.netbeans.modules.web.project.api.WebProjectUtilities;
-import org.netbeans.modules.web.project.classpath.ClassPathSupport;
-import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
-import org.netbeans.spi.project.support.ant.ReferenceHelper;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.filesystems.Repository;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.openide.DialogDisplayer;
-import org.openide.NotifyDescriptor;
-import org.openide.util.NbBundle;
-import org.openide.util.Mutex;
-import org.netbeans.api.project.Project;
-import org.netbeans.api.project.ProjectManager;
-import org.netbeans.spi.project.AuxiliaryConfiguration;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.openide.filesystems.URLMapper;
-import org.openide.util.Exceptions;
-
-
-/**
- * Proxy for the AntProjectHelper which defers the update of the project metadata
- * to explicit user action. Currently it is hard coded for update from
- * "http://www.netbeans.org/ns/web-project/1" to "http://www.netbeans.org/ns/web-project/2".
- * In future it should define plugable SPI.
- */
-public class UpdateHelper {
-
- private static final boolean TRANSPARENT_UPDATE = Boolean.getBoolean("webproject.transparentUpdate"); //NOI18N
- private static final String BUILD_NUMBER = System.getProperty("netbeans.buildnumber"); // NOI18N
-
- private final Project project;
- private final AntProjectHelper helper;
- private final AuxiliaryConfiguration cfg;
- private final Notifier notifier;
- private boolean alreadyAskedInWriteAccess;
- private Boolean isCurrent;
- private EditableProperties cachedProperties;
- private Element cachedElement;
- private static final String TAG_MINIMUM_ANT_VERSION = "minimum-ant-version"; // NOI18N
- private static final String TAG_FILE = "file"; //NOI18N
- private static final String TAG_LIBRARY = "library"; //NOI18N
- private static final String ATTR_FILES = "files"; //NOI18N
- private static final String ATTR_DIRS = "dirs"; //NOI18N
-
- /**
- * Creates new UpdateHelper
- * @param project
- * @param helper AntProjectHelper
- * @param cfg AuxiliaryConfiguration
- * @param notifier used to ask user about project update
- */
- UpdateHelper (Project project, AntProjectHelper helper, AuxiliaryConfiguration cfg, Notifier notifier) {
- assert project != null && helper != null && cfg != null && notifier != null;
- this.project = project;
- this.helper = helper;
- this.cfg = cfg;
- this.notifier = notifier;
- }
-
- /**
- * Returns the AntProjectHelper.getProperties(), {@link AntProjectHelper#getProperties(String)}
- * @param path a relative URI in the project directory.
- * @return a set of properties
- */
- public EditableProperties getProperties (final String path) {
- //Properties are the same in both webproject/1 and webproject/2
- return (EditableProperties) ProjectManager.mutex().readAccess(new Mutex.Action (){
- public Object run() {
- if (!isCurrent() && AntProjectHelper.PROJECT_PROPERTIES_PATH.equals(path)) { //Only project properties were changed
- return getUpdatedProjectProperties ();
- }
- else {
- return helper.getProperties(path);
- }
- }
- });
- }
-
- /**
- * In the case that the project is of current version or the properties are not {@link AntProjectHelper#PROJECT_PROPERTIES_PATH}
- * it calls AntProjectHelper.putProperties(), {@link AntProjectHelper#putProperties(String, EditableProperties)}
- * otherwise it asks user to updata project. If the user agrees with the project update, it does the update and calls
- * AntProjectHelper.putProperties().
- * @param path a relative URI in the project directory.
- * @param props a set of properties
- */
- public void putProperties (final String path, final EditableProperties props) {
- ProjectManager.mutex().writeAccess(new Runnable() {
- public void run() {
- if (isCurrent() || !AntProjectHelper.PROJECT_PROPERTIES_PATH.equals(path)) { //Only project props should cause update
- helper.putProperties(path,props);
- } else if (canUpdate()) {
- try {
- saveUpdate(props);
- helper.putProperties(path,props);
- } catch (IOException ioe) {
- Exceptions.printStackTrace(ioe);
- }
- }
- }
- });
- }
-
- /**
- * In the case that the project is of current version or shared is false it delegates to
- * AntProjectHelper.getPrimaryConfigurationData(), {@link AntProjectHelper#getPrimaryConfigurationData(boolean)}.
- * Otherwise it creates an in memory update of shared configuration data and returns it.
- * @param shared if true, refers to project.xml, else refers to
- * private.xml
- * @return the configuration data that is available
- */
- public Element getPrimaryConfigurationData (final boolean shared) {
- return (Element) ProjectManager.mutex().readAccess(new Mutex.Action (){
- public Object run() {
- if (!shared || isCurrent()) { //Only shared props should cause update
- return helper.getPrimaryConfigurationData(shared);
- }
- else {
- return getUpdatedSharedConfigurationData ();
- }
- }
- });
- }
-
- /**
- * In the case that the project is of current version or shared is false it calls AntProjectHelper.putPrimaryConfigurationData(),
- * {@link AntProjectHelper#putPrimaryConfigurationData(Element, boolean)}.
- * Otherwise it asks user to update the project. If the user agrees with the project update, it does the update and calls
- * AntProjectHelper.PrimaryConfigurationData().
- * @param element the configuration data
- * @param shared if true, refers to project.xml, else refers to
- * private.xml
- */
- public void putPrimaryConfigurationData (final Element element, final boolean shared) {
- ProjectManager.mutex().writeAccess(new Runnable() {
- public void run() {
- if (!shared || isCurrent()) {
- helper.putPrimaryConfigurationData(element, shared);
- } else if (canUpdate()) {
- try {
- saveUpdate(null);
- helper.putPrimaryConfigurationData(element, shared);
- } catch (IOException ioe) {
- Exceptions.printStackTrace(ioe);
- }
- }
- }
- });
- }
-
- /**
- * Returns an AntProjectHelper. The helper may not be used for accessing/storing project metadata.
- * For project metadata manipulation the UpdateHelper must be used.
- * @return AntProjectHelper
- */
- public AntProjectHelper getAntProjectHelper () {
- return this.helper;
- }
-
- /**
- * Request an saving of update. If the project is not of current version the user will be asked to update the project.
- * If the user agrees with an update the project is updated.
- * @return true if the metadata are of current version or updated
- */
- public boolean requestSave () throws IOException{
- if (isCurrent()) {
- return true;
- }
- if (!canUpdate()) {
- return false;
- }
- saveUpdate (null);
- return true;
- }
-
- /**
- * Returns true if the project is of current version.
- * @return true if the project is of current version, otherwise false.
- */
- public synchronized boolean isCurrent () {
- if (this.isCurrent == null) {
- this.isCurrent = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/1",true) == null //NOI18N
- && this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/2",true) == null? //NOI18N
- Boolean.TRUE : Boolean.FALSE;
- }
- return isCurrent.booleanValue();
- }
-
- private boolean canUpdate () {
- if (TRANSPARENT_UPDATE) {
- return true;
- }
- //Ask just once under a single write access
- if (alreadyAskedInWriteAccess) {
- return false;
- }
- else {
- boolean canUpdate = this.notifier.canUpdate();
- if (!canUpdate) {
- alreadyAskedInWriteAccess = true;
- ProjectManager.mutex().postReadRequest(new Runnable() {
- public void run() {
- alreadyAskedInWriteAccess = false;
- }
- });
- }
- return canUpdate;
- }
- }
-
- private void saveUpdate (EditableProperties props) throws IOException {
- this.helper.putPrimaryConfigurationData(getUpdatedSharedConfigurationData(),true);
- if (this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/1",true) != null) { //NOI18N
- this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/web-project/1",true); //NOI18N
- } else {
- this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/web-project/2",true); //NOI18N
- }
-
- boolean putProps = false;
-
- // AB: fix for #55597: should not update the project without adding the properties
- // update is only done once, so if we don't add the properties now, we don't get another chance to do so
- if (props == null) {
- props = getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- putProps = true;
- }
-
- //add properties needed by 4.1 project
- if(props != null) {
- props.put("test.src.dir", "test"); //NOI18N
- props.put("build.test.classes.dir", "${build.dir}/test/classes"); //NOI18N
- props.put("build.test.results.dir", "${build.dir}/test/results"); //NOI18N
- props.put("conf.dir","${source.root}/conf"); //NOI18N
- props.put("jspcompilation.classpath", "${jspc.classpath}:${javac.classpath}");
-
- props.setProperty(WebProjectProperties.JAVAC_TEST_CLASSPATH, new String[] {
- "${javac.classpath}:", // NOI18N
- "${build.classes.dir}:", // NOI18N
- "${libs.junit.classpath}:", // NOI18N
- "${libs.junit_4.classpath}", // NOI18N
- });
- props.setProperty(WebProjectProperties.RUN_TEST_CLASSPATH, new String[] {
- "${javac.test.classpath}:", // NOI18N
- "${build.test.classes.dir}", // NOI18N
- });
- props.setProperty(WebProjectProperties.DEBUG_TEST_CLASSPATH, new String[] {
- "${run.test.classpath}", // NOI18N
- });
-
- props.put(WebProjectProperties.WAR_EAR_NAME, props.getProperty(WebProjectProperties.WAR_NAME));
- props.put(WebProjectProperties.DIST_WAR_EAR, "${dist.dir}/${war.ear.name}");
-
- if (props.getProperty(WebProjectProperties.LIBRARIES_DIR) == null) {
- props.setProperty(WebProjectProperties.LIBRARIES_DIR, "${" + WebProjectProperties.WEB_DOCBASE_DIR + "}/WEB-INF/lib"); //NOI18N
- }
- }
-
- if(props != null) {
- //remove jsp20 and servlet24 libraries
- ReferenceHelper refHelper = new ReferenceHelper(helper, cfg, helper.getStandardPropertyEvaluator());
- ClassPathSupport cs = new ClassPathSupport( helper.getStandardPropertyEvaluator(), refHelper, helper,
- WebProjectProperties.WELL_KNOWN_PATHS,
- WebProjectProperties.LIBRARY_PREFIX,
- WebProjectProperties.LIBRARY_SUFFIX,
- WebProjectProperties.ANT_ARTIFACT_PREFIX );
- Iterator items = cs.itemsIterator((String)props.get( WebProjectProperties.JAVAC_CLASSPATH ), ClassPathSupport.TAG_WEB_MODULE_LIBRARIES);
- ArrayList cpItems = new ArrayList();
- while(items.hasNext()) {
- ClassPathSupport.Item cpti = (ClassPathSupport.Item)items.next();
- String propertyName = cpti.getReference();
- if(propertyName != null) {
- String libname = propertyName.substring("${libs.".length());
- if(libname.indexOf(".classpath}") != -1) libname = libname.substring(0, libname.indexOf(".classpath}"));
-
- if(!("servlet24".equals(libname) || "jsp20".equals(libname))) { //NOI18N
- cpItems.add(cpti);
- }
- }
- }
- String[] javac_cp = cs.encodeToStrings(cpItems.iterator(), ClassPathSupport.TAG_WEB_MODULE_LIBRARIES );
- props.setProperty( WebProjectProperties.JAVAC_CLASSPATH, javac_cp );
- }
-
- if (putProps) {
- helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
- }
-
- ProjectManager.getDefault().saveProject (this.project);
- synchronized(this) {
- this.isCurrent = Boolean.TRUE;
- }
-
- //fire project updated
- if(projectUpdateListener != null) projectUpdateListener.projectUpdated();
-
- //create conf dir if doesn't exist and copy default manifest inside
- try {
- //I cannot use ${conf.dir} since the PE doesn't know about it
- //String confDir = helper.getStandardPropertyEvaluator().evaluate("${source.root}/conf"); //NOI18N
- FileObject prjFO = project.getProjectDirectory();
- // folder creation will throw IOE if already exists
- // use the hard coded string due to issue #54882 - since the 4.0 supports creation of only jakarta structure projects the conf dir is always in project root
- FileObject confDirFO = prjFO.createFolder("conf");//NOI18N
- // copyfile will throw IOE if the file already exists
- FileUtil.copyFile(Repository.getDefault().getDefaultFileSystem().findResource("org-netbeans-modules-web-project/MANIFEST.MF"), confDirFO, "MANIFEST"); //NOI18N
- }catch(IOException e) {
- //just ignore
- }
-
- }
-
- private synchronized Element getUpdatedSharedConfigurationData () {
- if (cachedElement == null) {
- int version = 1;
- Element oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/1",true); //NOI18N
- if (oldRoot == null) {
- version = 2;
- oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/2",true); //NOI18N
- }
- final String ns = version == 1 ? "http://www.netbeans.org/ns/web-project/1" : "http://www.netbeans.org/ns/web-project/2"; //NOI18N
- if (oldRoot != null) {
- Document doc = oldRoot.getOwnerDocument();
- Element newRoot = doc.createElementNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
- if (version == 1) {
- //1->2 upgrade
- Element sourceRoots = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
- Element root = doc.createElementNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
- root.setAttribute ("id","src.dir"); //NOI18N
- sourceRoots.appendChild(root);
- newRoot.appendChild (sourceRoots);
- Element testRoots = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"test-roots"); //NOI18N
- root = doc.createElementNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
- root.setAttribute ("id","test.src.dir"); //NOI18N
- testRoots.appendChild (root);
- newRoot.appendChild (testRoots);
- }
- if (version == 1 || version == 2) {
- //2->3 upgrade
- NodeList libList = newRoot.getElementsByTagNameNS(ns, TAG_LIBRARY);
- for (int i = 0; i < libList.getLength(); i++) {
- if (libList.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element library = (Element) libList.item(i);
- Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
- //remove ${ and } from the beginning and end
- String webFileText = findText(webFile);
- webFileText = webFileText.substring(2, webFileText.length() - 1);
-// warIncludesMap.put(webFileText, pathInWarElements.getLength() > 0 ? findText((Element) pathInWarElements.item(0)) : Item.PATH_IN_WAR_NONE);
- if (webFileText.startsWith ("lib.")) {
- String libName = webFileText.substring(6, webFileText.indexOf(".classpath")); //NOI18N
- List/**/ roots = LibraryManager.getDefault().getLibrary(libName).getContent("classpath"); //NOI18N
- ArrayList files = new ArrayList ();
- ArrayList dirs = new ArrayList ();
- for (Iterator it = roots.iterator(); it.hasNext();) {
- URL rootUrl = (URL) it.next();
- FileObject root = URLMapper.findFileObject (rootUrl);
- if ("jar".equals(rootUrl.getProtocol())) { //NOI18N
- root = FileUtil.getArchiveFile (root);
- }
- if (root != null) {
- if (root.isData()) {
- files.add(root);
- } else {
- dirs.add(root);
- }
- }
- }
- if (files.size() > 0) {
- library.setAttribute(ATTR_FILES, "" + files.size());
- }
- if (dirs.size() > 0) {
- library.setAttribute(ATTR_DIRS, "" + dirs.size());
- }
- }
- }
- }
- }
- cachedElement = updateMinAntVersion(newRoot, doc);
- }
- }
- return cachedElement;
- }
-
- private synchronized EditableProperties getUpdatedProjectProperties () {
- if (cachedProperties == null) {
- cachedProperties = this.helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
- //The javadoc.additionalparam was not in NB 4.0
- if (cachedProperties.get (WebProjectProperties.JAVADOC_ADDITIONALPARAM)==null) {
- cachedProperties.put (WebProjectProperties.JAVADOC_ADDITIONALPARAM,""); //NOI18N
- }
- }
- return this.cachedProperties;
- }
-
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,(Element)newNode);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
- private static Element updateMinAntVersion (final Element root, final Document doc) {
- NodeList list = root.getElementsByTagNameNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,TAG_MINIMUM_ANT_VERSION);
- if (list.getLength() == 1) {
- Element me = (Element) list.item(0);
- list = me.getChildNodes();
- if (list.getLength() == 1) {
- me.replaceChild (doc.createTextNode(WebProjectUtilities.MINIMUM_ANT_VERSION), list.item(0));
- return root;
- }
- }
- assert false : "Invalid project file"; //NOI18N
- return root;
- }
-
- /**
- * Creates an default Notifier. The default notifier displays a dialog warning user about project update.
- * @return notifier
- */
- public static Notifier createDefaultNotifier () {
- return new Notifier() {
- public boolean canUpdate() {
- JButton updateOption = new JButton (NbBundle.getMessage(UpdateHelper.class, "CTL_UpdateOption"));
- return DialogDisplayer.getDefault().notify(
- new NotifyDescriptor (NbBundle.getMessage(UpdateHelper.class,"TXT_ProjectUpdate", BUILD_NUMBER),
- NbBundle.getMessage(UpdateHelper.class,"TXT_ProjectUpdateTitle"),
- NotifyDescriptor.DEFAULT_OPTION,
- NotifyDescriptor.WARNING_MESSAGE,
- new Object[] {
- updateOption,
- NotifyDescriptor.CANCEL_OPTION
- },
- updateOption)) == updateOption;
- }
- };
- }
-
- /**
- * Extract nested text from a node.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent node
- * @return the nested text, or null if none was found
- */
- private static String findText(Node parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- /**
- * Interface used by the UpdateHelper to ask user about
- * the project update.
- */
- public static interface Notifier {
- /**
- * Asks user to update the project
- * @return true if the project should be updated
- */
- public boolean canUpdate ();
- }
-
- private ProjectUpdateListener projectUpdateListener = null;
-
- public void setProjectUpdateListener(ProjectUpdateListener l) {
- this.projectUpdateListener = l;
- }
-
- /** Used to notify someone that the project needs to be updated.
- * A workaround for #54077 - Import 4.0 project - remove Servlet/JSP APIs */
- public static interface ProjectUpdateListener {
- public void projectUpdated();
- }
-
-}
diff --git a/web.project/src/org/netbeans/modules/web/project/UpdateProjectImpl.java b/web.project/src/org/netbeans/modules/web/project/UpdateProjectImpl.java
new file mode 100644
--- /dev/null
+++ b/web.project/src/org/netbeans/modules/web/project/UpdateProjectImpl.java
@@ -0,0 +1,431 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 2008 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.web.project;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.swing.JButton;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.project.libraries.LibraryManager;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
+import org.netbeans.modules.java.api.common.ant.UpdateImplementation;
+import org.netbeans.modules.web.project.api.WebProjectUtilities;
+import org.netbeans.modules.web.project.classpath.ClassPathSupport;
+import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
+import org.netbeans.spi.project.AuxiliaryConfiguration;
+import org.netbeans.spi.project.support.ant.AntProjectHelper;
+import org.netbeans.spi.project.support.ant.EditableProperties;
+import org.netbeans.spi.project.support.ant.ReferenceHelper;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.Repository;
+import org.openide.filesystems.URLMapper;
+import org.openide.util.Mutex;
+import org.openide.util.NbBundle;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ *
+ * @author Tomas Mysik
+ */
+public class UpdateProjectImpl implements UpdateImplementation {
+
+ private static final boolean TRANSPARENT_UPDATE = Boolean.getBoolean("webproject.transparentUpdate");
+ private static final String BUILD_NUMBER = System.getProperty("netbeans.buildnumber"); // NOI18N
+ private static final String TAG_MINIMUM_ANT_VERSION = "minimum-ant-version"; // NOI18N
+ private static final String TAG_FILE = "file"; //NOI18N
+ private static final String TAG_LIBRARY = "library"; //NOI18N
+ private static final String ATTR_FILES = "files"; //NOI18N
+ private static final String ATTR_DIRS = "dirs"; //NOI18N
+
+ private final Project project;
+ private final AntProjectHelper helper;
+ private final AuxiliaryConfiguration cfg;
+ private boolean alreadyAskedInWriteAccess;
+ private Boolean isCurrent;
+ private Element cachedElement;
+ private ProjectUpdateListener projectUpdateListener = null;
+ private UpdateHelper updateHelper;
+ private EditableProperties cachedProperties;
+
+ /**
+ * Creates new UpdateHelper
+ * @param project
+ * @param helper AntProjectHelper
+ * @param cfg AuxiliaryConfiguration
+ * @param genFileHelper GeneratedFilesHelper
+ * @param notifier used to ask user about project update
+ */
+ UpdateProjectImpl(Project project, AntProjectHelper helper, AuxiliaryConfiguration cfg) {
+ assert project != null && helper != null && cfg != null;
+ this.project = project;
+ this.helper = helper;
+ this.cfg = cfg;
+ }
+
+ public void setUpdateHelper(UpdateHelper updateHelper) {
+ this.updateHelper = updateHelper;
+ }
+
+ public boolean isCurrent() {
+ return ProjectManager.mutex().readAccess(new Mutex.Action() {
+ public Boolean run() {
+ synchronized (this) {
+ if (isCurrent == null) {
+ if ((cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/1",true) != null) || // NOI18N
+ (cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/2",true) != null)) { // NOI18N
+ isCurrent = Boolean.FALSE;
+ } else {
+ isCurrent = Boolean.TRUE;
+ }
+ }
+ return isCurrent;
+ }
+ }
+ }).booleanValue();
+ }
+
+ public boolean canUpdate () {
+ if (TRANSPARENT_UPDATE) {
+ return true;
+ }
+ //Ask just once under a single write access
+ if (alreadyAskedInWriteAccess) {
+ return false;
+ }
+ else {
+ boolean canUpdate = showUpdateDialog();
+ if (!canUpdate) {
+ alreadyAskedInWriteAccess = true;
+ ProjectManager.mutex().postReadRequest(new Runnable() {
+ public void run() {
+ alreadyAskedInWriteAccess = false;
+ }
+ });
+ }
+ return canUpdate;
+ }
+ }
+
+ public void saveUpdate(EditableProperties props) throws IOException {
+ this.helper.putPrimaryConfigurationData(getUpdatedSharedConfigurationData(),true);
+ if (this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/1",true) != null) { //NOI18N
+ this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/web-project/1",true); //NOI18N
+ } else {
+ this.cfg.removeConfigurationFragment("data","http://www.netbeans.org/ns/web-project/2",true); //NOI18N
+ }
+
+ boolean putProps = false;
+
+ // AB: fix for #55597: should not update the project without adding the properties
+ // update is only done once, so if we don't add the properties now, we don't get another chance to do so
+ if (props == null) {
+ assert updateHelper != null;
+ props = updateHelper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
+ putProps = true;
+ }
+
+ //add properties needed by 4.1 project
+ if(props != null) {
+ props.put("test.src.dir", "test"); //NOI18N
+ props.put("build.test.classes.dir", "${build.dir}/test/classes"); //NOI18N
+ props.put("build.test.results.dir", "${build.dir}/test/results"); //NOI18N
+ props.put("conf.dir","${source.root}/conf"); //NOI18N
+ props.put("jspcompilation.classpath", "${jspc.classpath}:${javac.classpath}");
+
+ props.setProperty(WebProjectProperties.JAVAC_TEST_CLASSPATH, new String[] {
+ "${javac.classpath}:", // NOI18N
+ "${build.classes.dir}:", // NOI18N
+ "${libs.junit.classpath}:", // NOI18N
+ "${libs.junit_4.classpath}", // NOI18N
+ });
+ props.setProperty(WebProjectProperties.RUN_TEST_CLASSPATH, new String[] {
+ "${javac.test.classpath}:", // NOI18N
+ "${build.test.classes.dir}", // NOI18N
+ });
+ props.setProperty(WebProjectProperties.DEBUG_TEST_CLASSPATH, new String[] {
+ "${run.test.classpath}", // NOI18N
+ });
+
+ props.put(WebProjectProperties.WAR_EAR_NAME, props.getProperty(WebProjectProperties.WAR_NAME));
+ props.put(WebProjectProperties.DIST_WAR_EAR, "${dist.dir}/${war.ear.name}");
+
+ if (props.getProperty(WebProjectProperties.LIBRARIES_DIR) == null) {
+ props.setProperty(WebProjectProperties.LIBRARIES_DIR, "${" + WebProjectProperties.WEB_DOCBASE_DIR + "}/WEB-INF/lib"); //NOI18N
+ }
+ }
+
+ if(props != null) {
+ //remove jsp20 and servlet24 libraries
+ ReferenceHelper refHelper = new ReferenceHelper(helper, cfg, helper.getStandardPropertyEvaluator());
+ ClassPathSupport cs = new ClassPathSupport( helper.getStandardPropertyEvaluator(), refHelper, helper,
+ WebProjectProperties.WELL_KNOWN_PATHS,
+ WebProjectProperties.LIBRARY_PREFIX,
+ WebProjectProperties.LIBRARY_SUFFIX,
+ WebProjectProperties.ANT_ARTIFACT_PREFIX );
+ Iterator items = cs.itemsIterator((String)props.get( WebProjectProperties.JAVAC_CLASSPATH ), ClassPathSupport.TAG_WEB_MODULE_LIBRARIES);
+ ArrayList cpItems = new ArrayList();
+ while(items.hasNext()) {
+ ClassPathSupport.Item cpti = (ClassPathSupport.Item)items.next();
+ String propertyName = cpti.getReference();
+ if(propertyName != null) {
+ String libname = propertyName.substring("${libs.".length());
+ if(libname.indexOf(".classpath}") != -1) libname = libname.substring(0, libname.indexOf(".classpath}"));
+
+ if(!("servlet24".equals(libname) || "jsp20".equals(libname))) { //NOI18N
+ cpItems.add(cpti);
+ }
+ }
+ }
+ String[] javac_cp = cs.encodeToStrings(cpItems.iterator(), ClassPathSupport.TAG_WEB_MODULE_LIBRARIES );
+ props.setProperty( WebProjectProperties.JAVAC_CLASSPATH, javac_cp );
+ }
+
+ if (putProps) {
+ helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
+ }
+
+ ProjectManager.getDefault().saveProject (this.project);
+ synchronized(this) {
+ this.isCurrent = Boolean.TRUE;
+ }
+
+ //fire project updated
+ if(projectUpdateListener != null) projectUpdateListener.projectUpdated();
+
+ //create conf dir if doesn't exist and copy default manifest inside
+ try {
+ //I cannot use ${conf.dir} since the PE doesn't know about it
+ //String confDir = helper.getStandardPropertyEvaluator().evaluate("${source.root}/conf"); //NOI18N
+ FileObject prjFO = project.getProjectDirectory();
+ // folder creation will throw IOE if already exists
+ // use the hard coded string due to issue #54882 - since the 4.0 supports creation of only jakarta structure projects the conf dir is always in project root
+ FileObject confDirFO = prjFO.createFolder("conf");//NOI18N
+ // copyfile will throw IOE if the file already exists
+ FileUtil.copyFile(Repository.getDefault().getDefaultFileSystem().findResource("org-netbeans-modules-web-project/MANIFEST.MF"), confDirFO, "MANIFEST"); //NOI18N
+ }catch(IOException e) {
+ //just ignore
+ }
+ }
+
+ public synchronized Element getUpdatedSharedConfigurationData () {
+ if (cachedElement == null) {
+ int version = 1;
+ Element oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/1",true); //NOI18N
+ if (oldRoot == null) {
+ version = 2;
+ oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/web-project/2",true); //NOI18N
+ }
+ final String ns = version == 1 ? "http://www.netbeans.org/ns/web-project/1" : "http://www.netbeans.org/ns/web-project/2"; //NOI18N
+ if (oldRoot != null) {
+ Document doc = oldRoot.getOwnerDocument();
+ Element newRoot = doc.createElementNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
+ copyDocument (doc, oldRoot, newRoot);
+ if (version == 1) {
+ //1->2 upgrade
+ Element sourceRoots = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
+ Element root = doc.createElementNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
+ root.setAttribute ("id","src.dir"); //NOI18N
+ sourceRoots.appendChild(root);
+ newRoot.appendChild (sourceRoots);
+ Element testRoots = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"test-roots"); //NOI18N
+ root = doc.createElementNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
+ root.setAttribute ("id","test.src.dir"); //NOI18N
+ testRoots.appendChild (root);
+ newRoot.appendChild (testRoots);
+ }
+ if (version == 1 || version == 2) {
+ //2->3 upgrade
+ NodeList libList = newRoot.getElementsByTagNameNS(ns, TAG_LIBRARY);
+ for (int i = 0; i < libList.getLength(); i++) {
+ if (libList.item(i).getNodeType() == Node.ELEMENT_NODE) {
+ Element library = (Element) libList.item(i);
+ Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
+ //remove ${ and } from the beginning and end
+ String webFileText = findText(webFile);
+ webFileText = webFileText.substring(2, webFileText.length() - 1);
+// warIncludesMap.put(webFileText, pathInWarElements.getLength() > 0 ? findText((Element) pathInWarElements.item(0)) : Item.PATH_IN_WAR_NONE);
+ if (webFileText.startsWith ("lib.")) {
+ String libName = webFileText.substring(6, webFileText.indexOf(".classpath")); //NOI18N
+ List/**/ roots = LibraryManager.getDefault().getLibrary(libName).getContent("classpath"); //NOI18N
+ ArrayList files = new ArrayList ();
+ ArrayList dirs = new ArrayList ();
+ for (Iterator it = roots.iterator(); it.hasNext();) {
+ URL rootUrl = (URL) it.next();
+ FileObject root = URLMapper.findFileObject (rootUrl);
+ if ("jar".equals(rootUrl.getProtocol())) { //NOI18N
+ root = FileUtil.getArchiveFile (root);
+ }
+ if (root != null) {
+ if (root.isData()) {
+ files.add(root);
+ } else {
+ dirs.add(root);
+ }
+ }
+ }
+ if (files.size() > 0) {
+ library.setAttribute(ATTR_FILES, "" + files.size());
+ }
+ if (dirs.size() > 0) {
+ library.setAttribute(ATTR_DIRS, "" + dirs.size());
+ }
+ }
+ }
+ }
+ }
+ cachedElement = updateMinAntVersion(newRoot, doc);
+ }
+ }
+ return cachedElement;
+ }
+
+ public synchronized EditableProperties getUpdatedProjectProperties () {
+ if (cachedProperties == null) {
+ cachedProperties = this.helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
+ //The javadoc.additionalparam was not in NB 4.0
+ if (cachedProperties.get (WebProjectProperties.JAVADOC_ADDITIONALPARAM)==null) {
+ cachedProperties.put (WebProjectProperties.JAVADOC_ADDITIONALPARAM,""); //NOI18N
+ }
+ }
+ return this.cachedProperties;
+ }
+
+ /**
+ * Extract nested text from a node.
+ * Currently does not handle coalescing text nodes, CDATA sections, etc.
+ * @param parent a parent node
+ * @return the nested text, or null if none was found
+ */
+ private static String findText(Node parent) {
+ NodeList l = parent.getChildNodes();
+ for (int i = 0; i < l.getLength(); i++) {
+ if (l.item(i).getNodeType() == Node.TEXT_NODE) {
+ Text text = (Text)l.item(i);
+ return text.getNodeValue();
+ }
+ }
+ return null;
+ }
+
+ private static void copyDocument (Document doc, Element from, Element to) {
+ NodeList nl = from.getChildNodes();
+ int length = nl.getLength();
+ for (int i=0; i< length; i++) {
+ Node node = nl.item (i);
+ Node newNode = null;
+ switch (node.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ Element oldElement = (Element) node;
+ newNode = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
+ NamedNodeMap m = oldElement.getAttributes();
+ Element newElement = (Element) newNode;
+ for (int index = 0; index < m.getLength(); index++) {
+ Node attr = m.item(index);
+ newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
+ }
+ copyDocument(doc,oldElement,(Element)newNode);
+ break;
+ case Node.TEXT_NODE:
+ Text oldText = (Text) node;
+ newNode = doc.createTextNode(oldText.getData());
+ break;
+ case Node.COMMENT_NODE:
+ Comment oldComment = (Comment) node;
+ newNode = doc.createComment(oldComment.getData());
+ break;
+ }
+ if (newNode != null) {
+ to.appendChild (newNode);
+ }
+ }
+ }
+
+ private static Element updateMinAntVersion (final Element root, final Document doc) {
+ NodeList list = root.getElementsByTagNameNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,TAG_MINIMUM_ANT_VERSION);
+ if (list.getLength() == 1) {
+ Element me = (Element) list.item(0);
+ list = me.getChildNodes();
+ if (list.getLength() == 1) {
+ me.replaceChild (doc.createTextNode(WebProjectUtilities.MINIMUM_ANT_VERSION), list.item(0));
+ return root;
+ }
+ }
+ assert false : "Invalid project file"; //NOI18N
+ return root;
+ }
+
+ private boolean showUpdateDialog() {
+ JButton updateOption = new JButton (NbBundle.getMessage(UpdateProjectImpl.class, "CTL_UpdateOption"));
+ updateOption.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(UpdateProjectImpl.class, "AD_UpdateOption"));
+ return DialogDisplayer.getDefault().notify(
+ new NotifyDescriptor (NbBundle.getMessage(UpdateProjectImpl.class,"TXT_ProjectUpdate", BUILD_NUMBER),
+ NbBundle.getMessage(UpdateProjectImpl.class,"TXT_ProjectUpdateTitle"),
+ NotifyDescriptor.DEFAULT_OPTION,
+ NotifyDescriptor.WARNING_MESSAGE,
+ new Object[] {
+ updateOption,
+ NotifyDescriptor.CANCEL_OPTION
+ },
+ updateOption)) == updateOption;
+ }
+
+ public void setProjectUpdateListener(ProjectUpdateListener l) {
+ this.projectUpdateListener = l;
+ }
+
+ /** Used to notify someone that the project needs to be updated.
+ * A workaround for #54077 - Import 4.0 project - remove Servlet/JSP APIs */
+ public static interface ProjectUpdateListener {
+ public void projectUpdated();
+ }
+}
diff --git a/web.project/src/org/netbeans/modules/web/project/WebActionProvider.java b/web.project/src/org/netbeans/modules/web/project/WebActionProvider.java
--- a/web.project/src/org/netbeans/modules/web/project/WebActionProvider.java
+++ b/web.project/src/org/netbeans/modules/web/project/WebActionProvider.java
@@ -86,9 +86,8 @@ import org.netbeans.modules.web.api.webm
import org.netbeans.modules.web.api.webmodule.WebModule;
import org.netbeans.modules.web.api.webmodule.WebProjectConstants;
import java.util.HashSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.netbeans.api.fileinfo.NonRecursiveFolder;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.modules.web.api.webmodule.RequestParametersQuery;
import org.netbeans.modules.web.jsps.parserapi.JspParserAPI;
import org.netbeans.modules.web.jsps.parserapi.JspParserFactory;
@@ -98,7 +97,6 @@ import org.netbeans.modules.websvc.api.w
import org.netbeans.modules.websvc.api.webservices.WebServicesSupport;
import org.netbeans.modules.websvc.api.webservices.WsCompileEditorSupport;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.project.support.ant.PropertyUtils;
import org.openide.DialogDescriptor;
import org.openide.util.Exceptions;
diff --git a/web.project/src/org/netbeans/modules/web/project/WebFileBuiltQuery.java b/web.project/src/org/netbeans/modules/web/project/WebFileBuiltQuery.java
deleted file mode 100644
--- a/web.project/src/org/netbeans/modules/web/project/WebFileBuiltQuery.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.web.project;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import org.openide.filesystems.FileObject;
-import org.netbeans.api.queries.FileBuiltQuery;
-import org.netbeans.spi.queries.FileBuiltQueryImplementation;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
-
-public class WebFileBuiltQuery implements FileBuiltQueryImplementation, PropertyChangeListener {
-
- private FileBuiltQueryImplementation delegate;
- private final AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
- private final SourceRoots sourceRoots;
- private final SourceRoots testRoots;
-
- WebFileBuiltQuery (AntProjectHelper helper, PropertyEvaluator evaluator,
- SourceRoots sourceRoots, SourceRoots testRoots) {
- this.helper = helper;
- this.evaluator = evaluator;
- this.sourceRoots = sourceRoots;
- this.testRoots = testRoots;
- }
-
- public synchronized FileBuiltQuery.Status getStatus(FileObject file) {
- if (this.delegate == null) {
- this.delegate = createDelegate ();
- }
- return this.delegate.getStatus (file);
- }
-
- private FileBuiltQueryImplementation createDelegate () {
- String[] srcRoots = this.sourceRoots.getRootProperties();
- String[] tstRoots = this.testRoots.getRootProperties();
- String[] from = new String [srcRoots.length + tstRoots.length];
- String[] to = new String [srcRoots.length + tstRoots.length];
- for (int i=0; i< srcRoots.length; i++) {
- from[i] = "${" + srcRoots[i] + "}/*.java"; // NOI18N
- to[i] = "${" + WebProjectProperties.BUILD_CLASSES_DIR + "}/*.class"; // NOI18N
- }
- for (int i=0; i*/ cache = new HashMap ();
-
- public CompiledSourceForBinaryQuery (AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots srcRoots, SourceRoots testRoots) {
- this.helper = helper;
- this.evaluator = evaluator;
- this.sourceRoots = srcRoots;
- this.testRoots = testRoots;
- }
-
- public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) {
- if (FileUtil.getArchiveFile(binaryRoot) != null) {
- binaryRoot = FileUtil.getArchiveFile(binaryRoot);
- // XXX check whether this is really the root
- }
- SourceForBinaryQuery.Result res = (SourceForBinaryQuery.Result) cache.get (binaryRoot);
- if (res != null) {
- return res;
- }
- SourceRoots src = null;
- if (hasSources(binaryRoot, WebProjectProperties.BUILD_CLASSES_DIR)) { //NOI18N
- src = this.sourceRoots;
- }
- else if (hasSources (binaryRoot, WebProjectProperties.DIST_WAR)) { //NOI18N
- src = this.sourceRoots;
- }
- else if (hasSources (binaryRoot, WebProjectProperties.BUILD_TEST_CLASSES_DIR)) { //NOI18N
- src = this.testRoots;
- }
- if (src == null) {
- return null;
- }
- else {
- res = new Result (src);
- cache.put (binaryRoot, res);
- return res;
- }
- }
-
-
- private boolean hasSources (URL binaryRoot, String binaryProperty) {
- try {
- String outDir = evaluator.getProperty(binaryProperty);
- if (outDir != null) {
- File f = helper.resolveFile (outDir);
- URL url = f.toURI().toURL();
- if (!f.exists() && !f.getPath().toLowerCase().endsWith(".jar")) { // NOI18N
- // non-existing
- assert !url.toExternalForm().endsWith("/") : f; // NOI18N
- url = new URL(url.toExternalForm() + "/"); // NOI18N
- }
- if (url.equals (binaryRoot)) {
- return true;
- }
- }
- } catch (MalformedURLException malformedURL) {
- Exceptions.printStackTrace(malformedURL);
- }
- return false;
- }
-
- private static class Result implements SourceForBinaryQuery.Result, PropertyChangeListener {
-
- private final ChangeSupport changeSupport = new ChangeSupport(this);
- private SourceRoots sourceRoots;
-
- public Result (SourceRoots sourceRoots) {
- this.sourceRoots = sourceRoots;
- this.sourceRoots.addPropertyChangeListener(this);
- }
-
- public FileObject[] getRoots () {
- return this.sourceRoots.getRoots(); //No need to cache it, SourceRoots does
- }
-
- public void addChangeListener (ChangeListener l) {
- changeSupport.addChangeListener(l);
- }
-
- public void removeChangeListener (ChangeListener l) {
- changeSupport.removeChangeListener(l);
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (SourceRoots.PROP_ROOTS.equals(evt.getPropertyName())) {
- this.changeSupport.fireChange ();
- }
- }
-
- }
-
-}
diff --git a/web.project/src/org/netbeans/modules/web/project/queries/JavadocForBinaryQueryImpl.java b/web.project/src/org/netbeans/modules/web/project/queries/JavadocForBinaryQueryImpl.java
deleted file mode 100644
--- a/web.project/src/org/netbeans/modules/web/project/queries/JavadocForBinaryQueryImpl.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.web.project.queries;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.openide.filesystems.FileUtil;
-import java.net.URL;
-import java.net.MalformedURLException;
-import javax.swing.event.ChangeListener;
-import org.netbeans.api.java.queries.JavadocForBinaryQuery;
-import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
-import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.openide.util.ChangeSupport;
-import org.openide.util.Exceptions;
-import org.openide.util.WeakListeners;
-
-/**
- * Finds Javadoc (if it is built) corresponding to binaries in web project.
- * @author David Konecny, Jesse Glick
- */
-public class JavadocForBinaryQueryImpl implements JavadocForBinaryQueryImplementation {
-
- private final AntProjectHelper helper;
- private final PropertyEvaluator evaluator;
-
- public JavadocForBinaryQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator) {
- this.helper = helper;
- this.evaluator = evaluator;
- }
-
- public JavadocForBinaryQuery.Result findJavadoc(final URL binaryRoot) {
-
- class R implements JavadocForBinaryQuery.Result, PropertyChangeListener {
-
- private final ChangeSupport changeSupport = new ChangeSupport(this);
- private URL[] result;
-
- public R () {
- JavadocForBinaryQueryImpl.this.evaluator.addPropertyChangeListener (WeakListeners.propertyChange(this,JavadocForBinaryQueryImpl.this.evaluator));
- }
-
- public synchronized URL[] getRoots() {
- if (this.result == null) {
- String javadocDir = evaluator.getProperty(WebProjectProperties.DIST_JAVADOC_DIR);
- if (javadocDir != null) {
- File f = helper.resolveFile(javadocDir);
- try {
- URL url = f.toURI().toURL();
- if (!f.exists()) {
- assert !url.toExternalForm().endsWith("/") : f; // NOI18N
- url = new URL(url.toExternalForm() + "/"); // NOI18N
- }
- this.result = new URL[] {url};
- } catch (MalformedURLException e) {
- this.result = new URL[0];
- Exceptions.printStackTrace(e);
- }
- }
- else {
- this.result = new URL[0];
- }
- }
- return this.result;
- }
- public void addChangeListener(final ChangeListener l) {
- assert l != null;
- changeSupport.addChangeListener(l);
- }
- public void removeChangeListener(final ChangeListener l) {
- assert l != null;
- changeSupport.removeChangeListener(l);
- }
-
- public void propertyChange (final PropertyChangeEvent event) {
- if (WebProjectProperties.DIST_JAVADOC_DIR.equals(event.getPropertyName())) {
- synchronized (this) {
- result = null;
- }
- this.changeSupport.fireChange ();
- }
- }
- }
- if (isRootOwner(binaryRoot, WebProjectProperties.BUILD_CLASSES_DIR) || isRootOwner (binaryRoot, WebProjectProperties.DIST_WAR)) {
- return new R();
- }
- return null;
- }
-
- private boolean isRootOwner (URL binaryRoot, String binaryProperty) {
- try {
- if (FileUtil.getArchiveFile(binaryRoot) != null) {
- binaryRoot = FileUtil.getArchiveFile(binaryRoot);
- // XXX check whether this is really the root
- }
- String outDir = evaluator.getProperty(binaryProperty);
- if (outDir != null) {
- File f = helper.resolveFile (outDir);
- URL url = f.toURI().toURL();
- if (!f.exists() && !f.getPath().toLowerCase().endsWith(".jar")) { // NOI18N
- assert !url.toExternalForm().endsWith("/") : f; // NOI18N
- url = new URL(url.toExternalForm() + "/"); // NOI18N
- }
- return url.equals(binaryRoot) ||
- binaryRoot.toExternalForm().startsWith(url.toExternalForm());
- }
- } catch (MalformedURLException malformedURL) {
- Exceptions.printStackTrace(malformedURL);
- }
- return false;
- }
-
-// private URL getJavadoc(URL binaryRoot, String binaryProperty, String javadocProperty) {
-// try {
-// if (FileUtil.getArchiveFile(binaryRoot) != null) {
-// binaryRoot = FileUtil.getArchiveFile(binaryRoot);
-// }
-// String outDir = evaluator.getProperty(binaryProperty);
-// if (outDir != null) {
-// File f = helper.resolveFile (outDir);
-// URL url = f.toURI().toURL();
-// if (!f.exists() && !f.getPath().toLowerCase().endsWith(".jar")) {
-// assert !url.toExternalForm().endsWith("/") : f;
-// url = new URL(url.toExternalForm() + "/");
-// }
-// if (url.equals(binaryRoot) ||
-// binaryRoot.toExternalForm().startsWith(url.toExternalForm())) {
-// String javadocDir = evaluator.getProperty(javadocProperty);
-// if (javadocDir != null) {
-// f = helper.resolveFile(javadocDir);
-// return f.toURI().toURL();
-// }
-// }
-// }
-// } catch (MalformedURLException malformedURL) {
-// ErrorManager.getDefault().notify(malformedURL);
-// }
-// return null;
-// }
-
-}
diff --git a/web.project/src/org/netbeans/modules/web/project/queries/SourceLevelQueryImpl.java b/web.project/src/org/netbeans/modules/web/project/queries/SourceLevelQueryImpl.java
deleted file mode 100644
--- a/web.project/src/org/netbeans/modules/web/project/queries/SourceLevelQueryImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.web.project.queries;
-
-import org.openide.filesystems.FileObject;
-
-import org.netbeans.api.java.platform.JavaPlatform;
-import org.netbeans.api.java.platform.JavaPlatformManager;
-import org.netbeans.api.java.platform.Specification;
-import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.netbeans.spi.project.support.ant.PropertyUtils;
-import org.netbeans.spi.project.support.ant.EditableProperties;
-
-/**
- * Returns source level of project sources.
- * @author David Konecny
- */
-public class SourceLevelQueryImpl implements SourceLevelQueryImplementation {
-
- private final PropertyEvaluator evaluator;
-
- public SourceLevelQueryImpl(PropertyEvaluator evaluator) {
- this.evaluator = evaluator;
- }
-
- public String getSourceLevel(FileObject javaFile) {
- boolean platformExists = false;
- String activePlatform = evaluator.getProperty ("platform.active"); //NOI18N
- if (activePlatform != null && activePlatform.length()>0) {
- JavaPlatform[] j2sePlatforms = JavaPlatformManager.getDefault().getPlatforms(null, new Specification("j2se",null)); //NOI18N
- for (int i=0; i< j2sePlatforms.length; i++) {
- String antName = (String) j2sePlatforms[i].getProperties().get("platform.ant.name"); //NOI18N
- if (antName != null && antName.equals(activePlatform)) {
- platformExists = true;
- break;
- }
- }
- }
- if (platformExists) {
- String sl = evaluator.getProperty("javac.source"); //NOI18N
- if (sl != null && sl.length() > 0) {
- return sl;
- } else {
- return null;
- }
- }
- else {
- EditableProperties props = PropertyUtils.getGlobalProperties();
- String sl = (String) props.get("default.javac.source"); //NOI18N
- if (sl != null && sl.length() > 0) {
- return sl;
- } else {
- return null;
- }
- }
- }
-
-}
diff --git a/web.project/src/org/netbeans/modules/web/project/queries/UnitTestForSourceQueryImpl.java b/web.project/src/org/netbeans/modules/web/project/queries/UnitTestForSourceQueryImpl.java
deleted file mode 100644
--- a/web.project/src/org/netbeans/modules/web/project/queries/UnitTestForSourceQueryImpl.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-package org.netbeans.modules.web.project.queries;
-
-import java.net.URL;
-import org.netbeans.api.project.FileOwnerQuery;
-import org.netbeans.api.project.Project;
-import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
-import org.netbeans.modules.web.project.SourceRoots;
-import org.openide.filesystems.FileObject;
-
-public class UnitTestForSourceQueryImpl implements MultipleRootsUnitTestForSourceQueryImplementation {
-
- private final SourceRoots sourceRoots;
- private final SourceRoots testRoots;
-
- public UnitTestForSourceQueryImpl(SourceRoots sourceRoots, SourceRoots testRoots) {
- this.sourceRoots = sourceRoots;
- this.testRoots = testRoots;
- }
-
- public URL[] findUnitTests(FileObject source) {
- return find(source, sourceRoots, testRoots); // NOI18N
- }
-
- public URL[] findSources(FileObject unitTest) {
- return find(unitTest, testRoots, sourceRoots); // NOI18N
- }
-
- private URL[] find(FileObject file, SourceRoots from, SourceRoots to) {
- Project p = FileOwnerQuery.getOwner(file);
- if (p == null) {
- return null;
- }
- FileObject[] fromRoots = from.getRoots();
- for (int i = 0; i < fromRoots.length; i++) {
- if (fromRoots[i].equals(file)) {
- return to.getRootURLs();
- }
- }
- return null;
- }
-
-}
diff --git a/web.project/src/org/netbeans/modules/web/project/queries/WebProjectEncodingQueryImpl.java b/web.project/src/org/netbeans/modules/web/project/queries/WebProjectEncodingQueryImpl.java
deleted file mode 100644
--- a/web.project/src/org/netbeans/modules/web/project/queries/WebProjectEncodingQueryImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.web.project.queries;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import org.netbeans.api.queries.FileEncodingQuery;
-import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
-import org.netbeans.spi.queries.FileEncodingQueryImplementation;
-import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.openide.filesystems.FileObject;
-
-/**
- *
- * @author Tomas Zezula
- */
-public class WebProjectEncodingQueryImpl extends FileEncodingQueryImplementation implements PropertyChangeListener {
-
-
- private final PropertyEvaluator eval;
- private Charset cache;
-
- /** Creates a new instance of J2SEProjectEncodingQueryImpl */
- public WebProjectEncodingQueryImpl(final PropertyEvaluator eval) {
- assert eval != null;
- this.eval = eval;
- this.eval.addPropertyChangeListener(this);
- }
-
- public Charset getEncoding(FileObject file) {
- assert file != null;
- synchronized (this) {
- if (cache != null) {
- return cache;
- }
- }
- String enc = eval.getProperty(WebProjectProperties.SOURCE_ENCODING);
- synchronized (this) {
- if (cache == null) {
- try {
- cache = enc == null ? Charset.defaultCharset() : Charset.forName(enc);
- } catch (IllegalCharsetNameException exception) {
- return null;
- }
- }
- return cache;
- }
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- String propName = event.getPropertyName();
- if (propName == null || propName.equals(WebProjectProperties.SOURCE_ENCODING)) {
- synchronized (this) {
- cache = null;
- }
- }
- }
-
-}
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/ActionFilterNode.java b/web.project/src/org/netbeans/modules/web/project/ui/ActionFilterNode.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/ActionFilterNode.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/ActionFilterNode.java
@@ -65,12 +65,12 @@ import org.netbeans.api.project.FileOwne
import org.netbeans.api.project.FileOwnerQuery;
import org.netbeans.api.project.Project;
import org.netbeans.api.java.queries.JavadocForBinaryQuery;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
-import org.netbeans.modules.web.project.UpdateHelper;
import org.netbeans.modules.web.project.classpath.ClassPathSupport;
import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
import org.openide.nodes.FilterNode.Children;
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/DocBaseNodeFactory.java b/web.project/src/org/netbeans/modules/web/project/ui/DocBaseNodeFactory.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/DocBaseNodeFactory.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/DocBaseNodeFactory.java
@@ -58,7 +58,7 @@ import org.netbeans.api.project.Project;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.queries.VisibilityQuery;
-import org.netbeans.modules.web.project.UpdateHelper;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.modules.web.project.WebProject;
import org.netbeans.modules.web.project.ui.SourceNodeFactory.PreselectPropertiesAction;
import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/LibrariesNode.java b/web.project/src/org/netbeans/modules/web/project/ui/LibrariesNode.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/LibrariesNode.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/LibrariesNode.java
@@ -92,6 +92,7 @@ import org.netbeans.api.java.classpath.C
import org.netbeans.api.java.classpath.ClassPath;
import org.netbeans.api.java.project.JavaProjectConstants;
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
@@ -99,14 +100,12 @@ import org.netbeans.spi.project.support.
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.spi.java.project.support.ui.PackageView;
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
-import org.netbeans.modules.web.project.UpdateHelper;
import org.netbeans.modules.web.api.webmodule.WebModule;
import org.netbeans.modules.web.project.WebProject;
import org.netbeans.modules.web.project.ui.customizer.AntArtifactChooser;
import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
import org.netbeans.modules.web.project.ui.customizer.LibrariesChooser;
import org.netbeans.spi.project.libraries.support.LibrariesSupport;
-import org.openide.ErrorManager;
import org.openide.util.Exceptions;
import org.openide.util.lookup.Lookups;
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/LibrariesNodeFactory.java b/web.project/src/org/netbeans/modules/web/project/ui/LibrariesNodeFactory.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/LibrariesNodeFactory.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/LibrariesNodeFactory.java
@@ -52,8 +52,8 @@ import javax.swing.SwingUtilities;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeListener;
import org.netbeans.api.project.Project;
-import org.netbeans.modules.web.project.SourceRoots;
-import org.netbeans.modules.web.project.UpdateHelper;
+import org.netbeans.modules.java.api.common.SourceRoots;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.modules.web.project.WebProject;
import org.netbeans.modules.web.project.ui.customizer.CustomizerLibraries;
import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/ProjectNode.java b/web.project/src/org/netbeans/modules/web/project/ui/ProjectNode.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/ProjectNode.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/ProjectNode.java
@@ -72,12 +72,12 @@ import org.netbeans.api.project.ant.AntA
import org.netbeans.api.project.ant.AntArtifact;
import org.netbeans.api.project.ui.OpenProjects;
import org.netbeans.api.java.queries.JavadocForBinaryQuery;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
-import org.netbeans.modules.web.project.UpdateHelper;
import org.openide.filesystems.FileObject;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/WebLogicalViewProvider.java b/web.project/src/org/netbeans/modules/web/project/ui/WebLogicalViewProvider.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/WebLogicalViewProvider.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/WebLogicalViewProvider.java
@@ -108,9 +108,9 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.deployment.devmodules.spi.InstanceListener;
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
+import org.netbeans.modules.java.api.common.SourceRoots;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.modules.web.api.webmodule.WebProjectConstants;
-import org.netbeans.modules.web.project.SourceRoots;
-import org.netbeans.modules.web.project.UpdateHelper;
import org.netbeans.modules.web.project.WebProject;
import org.netbeans.modules.web.project.ui.customizer.WebProjectProperties;
import org.netbeans.spi.project.AuxiliaryConfiguration;
@@ -581,7 +581,7 @@ public class WebLogicalViewProvider impl
public void actionPerformed(ActionEvent e) {
try {
- helper.requestSave();
+ helper.requestUpdate();
BrokenReferencesSupport.showCustomizer(helper.getAntProjectHelper(), resolver, getBreakableProperties(), new String[]{WebProjectProperties.JAVA_PLATFORM});
run();
} catch (IOException ioe) {
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerLibraries.java b/web.project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerLibraries.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerLibraries.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerLibraries.java
@@ -53,6 +53,7 @@ import javax.swing.table.TableColumn;
import javax.swing.table.TableColumn;
import org.netbeans.api.java.platform.JavaPlatform;
import org.netbeans.api.java.platform.PlatformsCustomizer;
+import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
import org.netbeans.modules.web.project.classpath.ClassPathSupport;
import org.netbeans.modules.web.project.ui.WebLogicalViewProvider;
import org.openide.util.HelpCtx;
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerProviderImpl.java b/web.project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerProviderImpl.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerProviderImpl.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/customizer/CustomizerProviderImpl.java
@@ -51,8 +51,8 @@ import java.util.Map;
import java.util.Map;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
import org.netbeans.modules.web.project.WebProject;
-import org.netbeans.modules.web.project.UpdateHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.spi.project.ui.CustomizerProvider;
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/customizer/PlatformUiSupport.java b/web.project/src/org/netbeans/modules/web/project/ui/customizer/PlatformUiSupport.java
deleted file mode 100644
--- a/web.project/src/org/netbeans/modules/web/project/ui/customizer/PlatformUiSupport.java
+++ /dev/null
@@ -1,690 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
- *
- * 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. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * 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.
- */
-
-package org.netbeans.modules.web.project.ui.customizer;
-
-import java.awt.Component;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JButton;
-import javax.swing.JList;
-import javax.swing.ListCellRenderer;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-import org.netbeans.api.java.platform.JavaPlatform;
-import org.netbeans.api.java.platform.JavaPlatformManager;
-import org.netbeans.api.java.platform.Specification;
-import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
-import org.netbeans.modules.web.project.WebProjectType;
-import org.netbeans.modules.web.project.UpdateHelper;
-import org.netbeans.spi.project.support.ant.EditableProperties;
-import org.openide.DialogDisplayer;
-import org.openide.NotifyDescriptor;
-import org.openide.awt.HtmlRenderer;
-import org.openide.modules.SpecificationVersion;
-import org.openide.util.NbBundle;
-import org.openide.util.WeakListeners;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * Support class for {@link JavaPlatform} manipulation in webproject customizer.
- * @author tzezula
- */
-public class PlatformUiSupport {
-
- private static final SpecificationVersion JDK_5 = new SpecificationVersion ("1.5"); //NOI18N
- private static final SpecificationVersion JDK_6 = new SpecificationVersion ("1.6"); //NOI18N
- private static final Logger LOGGER = Logger.getLogger(PlatformUiSupport.class.getName());
-
- private PlatformUiSupport() {
- }
-
- /**
- * Creates {@link ComboBoxModel} of J2SE platforms.
- * The model listens on the {@link JavaPlatformManager} and update its
- * state according to changes
- * @param activePlatform the active project's platform
- * @return {@link ComboBoxModel}
- */
- public static ComboBoxModel createPlatformComboBoxModel (String activePlatform) {
- return new PlatformComboBoxModel (activePlatform);
- }
-
- /**
- * Creates a {@link ListCellRenderer} for rendering items of the {@link ComboBoxModel}
- * created by the {@link PlatformUiSupport#createPlatformComboBoxModel} method.
- * @return {@link ListCellRenderer}
- */
- public static ListCellRenderer createPlatformListCellRenderer () {
- return new PlatformListCellRenderer ();
- }
-
- /**
- * Like {@link #storePlatform}, but platformName may be null (in which case the default platform is used)
- */
- public static void storePlatform (EditableProperties props, UpdateHelper helper, String platformName, SpecificationVersion sourceLevel) {
- PlatformKey platformKey;
- if (platformName != null) {
- platformKey = new PlatformKey(PlatformUiSupport.findPlatform(platformName));
- } else {
- platformKey = new PlatformKey(JavaPlatformManager.getDefault().getDefaultPlatform());
- }
- storePlatform(props, helper, platformKey, sourceLevel == null ? null : new SourceLevelKey(sourceLevel));
- }
-
- /**
- * Stores active platform, javac.source and javac.target into the project's metadata
- * @param props project's shared properties
- * @param helper to read/update project.xml
- * @param platformKey the PatformKey got from the platform model
- * @param sourceLevel source level
- */
- public static void storePlatform (EditableProperties props, UpdateHelper helper, Object platformKey, Object sourceLevelKey) {
- assert platformKey instanceof PlatformKey;
- PlatformKey pk = (PlatformKey) platformKey;
- JavaPlatform platform = getPlatform(pk);
- //null means active broken (unresolved) platform, no need to do anything
- if (platform != null) {
- SpecificationVersion jdk13 = new SpecificationVersion ("1.3"); //NOI18N
- String platformAntName = platform.getProperties().get("platform.ant.name"); //NOI18N
- assert platformAntName != null;
- props.put(WebProjectProperties.JAVA_PLATFORM, platformAntName);
- Element root = helper.getPrimaryConfigurationData(true);
- boolean defaultPlatform = pk.isDefaultPlatform();
- boolean changed = false;
- NodeList explicitPlatformNodes = root.getElementsByTagNameNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"explicit-platform"); //NOI18N
- if (defaultPlatform) {
- if (explicitPlatformNodes.getLength()==1) {
- root.removeChild(explicitPlatformNodes.item(0));
- changed = true;
- }
- }
- else {
- Element explicitPlatform;
- switch (explicitPlatformNodes.getLength()) {
- case 0:
- explicitPlatform = root.getOwnerDocument().createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, "explicit-platform"); //NOI18N
- NodeList sourceRootNodes = root.getElementsByTagNameNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
- assert sourceRootNodes.getLength() == 1 : "Broken project.xml file"; //NOI18N
- root.insertBefore(explicitPlatform, sourceRootNodes.item(0));
- changed = true;
- break;
- case 1:
- explicitPlatform = (Element)explicitPlatformNodes.item(0);
- break;
- default:
- throw new AssertionError("Broken project.xml file"); //NOI18N
- }
- String explicitSourceAttrValue = explicitPlatform.getAttribute("explicit-source-supported"); //NOI18N
- if (jdk13.compareTo(platform.getSpecification().getVersion())>=0 &&
- !"false".equals(explicitSourceAttrValue)) { //NOI18N
- explicitPlatform.setAttribute("explicit-source-supported","false"); //NOI18N
- changed = true;
- }
- else if (jdk13.compareTo(platform.getSpecification().getVersion())<0 &&
- !"true".equals(explicitSourceAttrValue)) { //NOI18N
- explicitPlatform.setAttribute("explicit-source-supported","true"); //NOI18N
- changed = true;
- }
- }
-
- SpecificationVersion sourceLevel;
- if (sourceLevelKey == null) {
- sourceLevel = platform.getSpecification().getVersion();
- }
- else {
- assert sourceLevelKey instanceof SourceLevelKey;
- sourceLevel = ((SourceLevelKey)sourceLevelKey).getSourceLevel();
- }
- String javacSource = sourceLevel.toString();
- String javacTarget = javacSource;
-
- //Issue #116490
- // Customizer value | -source | -targer
- // JDK 1.2 1.2 1.1
- // JDK 1.3 1.3 1.1
- // JDK 1.4 1.4 1.4
- // JDK 5 1.5 1.5
- // JDK 6 1.5 1.6
- // JDK 7 1.7 1.7 - should bring a new language features
- if (jdk13.compareTo(sourceLevel)>=0) {
- javacTarget = "1.1"; //NOI18N
- }
- else if (JDK_6.equals(sourceLevel)) {
- javacSource = JDK_5.toString(); //NOI18N
- }
-
- // #89131: these levels are not actually distinct from 1.5.
- if (javacSource.equals("1.6") || javacSource.equals("1.7")) {
- javacSource = "1.5";
- }
- if (!javacSource.equals(props.getProperty(WebProjectProperties.JAVAC_SOURCE))) {
- props.setProperty (WebProjectProperties.JAVAC_SOURCE, javacSource);
- }
- if (!javacTarget.equals(props.getProperty(WebProjectProperties.JAVAC_TARGET))) {
- props.setProperty (WebProjectProperties.JAVAC_TARGET, javacTarget);
- }
-
- if (changed) {
- helper.putPrimaryConfigurationData(root, true);
- }
- }
- }
-
- public static JavaPlatform findPlatform(String displayName) {
- JavaPlatform[] platforms = JavaPlatformManager.getDefault().getPlatforms(displayName, new Specification("j2se", null)); //NOI18N
- return platforms.length == 0 ? null : platforms[0];
- }
-
-
- /**
- * Returns a {@link JavaPlatform} for an item obtained from the ComboBoxModel created by
- * the {@link PlatformUiSupport#createComboBoxModel} method
- * @param platformKey an item obtained from ComboBoxModel created by {@link PlatformUiSupport#createComboBoxModel}
- * @return JavaPlatform or null in case when platform is broken
- * @exception {@link IllegalArgumentException} is thrown in case when parameter in not an object created by
- * platform combobox model.
- */
- public static JavaPlatform getPlatform (Object platformKey) {
- if (platformKey instanceof PlatformKey) {
- return getPlatform ((PlatformKey)platformKey);
- }
- else {
- throw new IllegalArgumentException ();
- }
- }
-
- /**
- * Creates {@link ComboBoxModel} of source levels for active platform.
- * The model listens on the platform's {@link ComboBoxModel} and update its
- * state according to changes
- * @param platformComboBoxModel the platform's model used for listenning
- * @param initialSourceLevel initial source level value
- * @param initialTargetLevel initial target level value
- * @return {@link ComboBoxModel} of {@link SpecificationVersion}
- */
- public static ComboBoxModel createSourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel, String initialSourceLevel, String initialTargetLevel, String j2eePlatform) {
- return new SourceLevelComboBoxModel(platformComboBoxModel, initialSourceLevel, initialTargetLevel, j2eePlatform);
- }
-
- public static ListCellRenderer createSourceLevelListCellRenderer() {
- return new SourceLevelListCellRenderer();
- }
-
- private static JavaPlatform getPlatform (PlatformKey platformKey) {
- return platformKey.platform;
- }
-
- /**
- * This class represents a JavaPlatform in the {@link ListModel}
- * created by the {@link PlatformUiSupport#createPlatformComboBoxModel}
- * method.
- */
- private static class PlatformKey implements Comparable {
-
- private String name;
- private JavaPlatform platform;
-
- /**
- * Creates a PlatformKey for a broken platform
- * @param name the ant name of the broken platform
- */
- public PlatformKey (String name) {
- assert name != null;
- this.name = name;
- }
-
- /**
- * Creates a PlatformKey for a platform
- * @param platform the {@link JavaPlatform}
- */
- public PlatformKey (JavaPlatform platform) {
- assert platform != null;
- this.platform = platform;
- }
-
- public int compareTo(Object o) {
- return this.getDisplayName().compareTo(((PlatformKey)o).getDisplayName());
- }
-
- public boolean equals (Object other) {
- if (other instanceof PlatformKey) {
- PlatformKey otherKey = (PlatformKey)other;
- return (this.platform == null ? otherKey.platform == null : this.platform.equals(otherKey.platform)) &&
- otherKey.getDisplayName().equals (this.getDisplayName());
- }
- else {
- return false;
- }
- }
-
- public int hashCode () {
- return getDisplayName ().hashCode ();
- }
-
- public String toString () {
- return getDisplayName ();
- }
-
- public synchronized String getDisplayName () {
- if (this.name == null) {
- this.name = this.platform.getDisplayName();
- }
- return this.name;
- }
-
- public boolean isDefaultPlatform () {
- if (this.platform == null) {
- return false;
- }
- return this.platform.equals(JavaPlatformManager.getDefault().getDefaultPlatform());
- }
-
- public boolean isBroken () {
- return this.platform == null;
- }
-
- }
-
- private static final class SourceLevelKey implements Comparable {
-
- final SpecificationVersion sourceLevel;
- final boolean broken;
-
- public SourceLevelKey (final SpecificationVersion sourceLevel) {
- this (sourceLevel, false);
- }
-
- public SourceLevelKey (final SpecificationVersion sourceLevel, final boolean broken) {
- assert sourceLevel != null : "Source level cannot be null"; //NOI18N
- this.sourceLevel = sourceLevel;
- this.broken = broken;
- }
-
- public SpecificationVersion getSourceLevel () {
- return this.sourceLevel;
- }
-
- public boolean isBroken () {
- return this.broken;
- }
-
- public int compareTo (final Object other) {
- assert other instanceof SourceLevelKey : "Illegal argument of SourceLevelKey.compareTo()"; //NOI18N
- SourceLevelKey otherKey = (SourceLevelKey) other;
- return this.sourceLevel.compareTo(otherKey.sourceLevel);
- }
-
- public @Override boolean equals (final Object other) {
- return (other instanceof SourceLevelKey) &&
- ((SourceLevelKey)other).sourceLevel.equals(this.sourceLevel);
- }
-
- public @Override int hashCode () {
- return this.sourceLevel.hashCode();
- }
-
- public @Override String toString () {
- StringBuffer buffer = new StringBuffer ();
- if (this.broken) {
- buffer.append("Broken: "); //NOI18N
- }
- buffer.append(this.sourceLevel.toString());
- return buffer.toString();
- }
-
- public String getDisplayName () {
- String _tmp = sourceLevel.toString();
- if (JDK_5.compareTo(sourceLevel)<=0) {
- _tmp = _tmp.replaceFirst("^1\\.([5-9]|\\d\\d+)$", "$1"); //NOI18N
- }
- return NbBundle.getMessage(PlatformUiSupport.class, "LBL_JDK",_tmp);
- }
-
- }
-
- private static class PlatformComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener {
-
- private final JavaPlatformManager pm;
- private PlatformKey[] platformNamesCache;
- private String initialPlatform;
- private PlatformKey selectedPlatform;
-
- public PlatformComboBoxModel (String initialPlatform) {
- this.pm = JavaPlatformManager.getDefault();
- this.pm.addPropertyChangeListener(WeakListeners.propertyChange(this, this.pm));
- this.initialPlatform = initialPlatform;
- }
-
- public int getSize () {
- PlatformKey[] platformNames = getPlatformNames ();
- return platformNames.length;
- }
-
- public Object getElementAt (int index) {
- PlatformKey[] platformNames = getPlatformNames ();
- assert index >=0 && index< platformNames.length;
- return platformNames[index];
- }
-
- public Object getSelectedItem () {
- this.getPlatformNames(); //Force setting of selectedPlatform if it is not alredy done
- return this.selectedPlatform;
- }
-
- public void setSelectedItem (Object obj) {
- this.selectedPlatform = (PlatformKey) obj;
- this.fireContentsChanged(this, -1, -1);
- }
-
- public void propertyChange (PropertyChangeEvent event) {
- if (JavaPlatformManager.PROP_INSTALLED_PLATFORMS.equals(event.getPropertyName())) {
- synchronized (this) {
- this.platformNamesCache = null;
- }
- this.fireContentsChanged(this, -1, -1);
- }
- }
-
- private synchronized PlatformKey[] getPlatformNames () {
- if (this.platformNamesCache == null) {
- JavaPlatform[] platforms = pm.getPlatforms (null, new Specification("j2se",null)); //NOI18N
- Set/**/ orderedNames = new TreeSet ();
- boolean activeFound = false;
- for (int i=0; i< platforms.length; i++) {
- if (platforms[i].getInstallFolders().size()>0) {
- PlatformKey pk = new PlatformKey(platforms[i]);
- orderedNames.add (pk);
- if (!activeFound && initialPlatform != null) {
- String antName = (String) platforms[i].getProperties().get("platform.ant.name"); //NOI18N
- if (initialPlatform.equals(antName)) {
- if (this.selectedPlatform == null) {
- this.selectedPlatform = pk;
- initialPlatform = null;
- }
- activeFound = true;
- }
- }
- }
- }
- if (!activeFound) {
- if (initialPlatform == null) {
- if (this.selectedPlatform == null || !orderedNames.contains(this.selectedPlatform)) {
- this.selectedPlatform = new PlatformKey (JavaPlatformManager.getDefault().getDefaultPlatform());
- }
- }
- else {
- PlatformKey pk = new PlatformKey (this.initialPlatform);
- orderedNames.add (pk);
- if (this.selectedPlatform == null) {
- this.selectedPlatform = pk;
- }
- }
- }
- this.platformNamesCache = (PlatformKey[]) orderedNames.toArray(new PlatformKey[orderedNames.size()]);
- }
- return this.platformNamesCache;
- }
-
- }
-
- private static class PlatformListCellRenderer extends DefaultListCellRenderer {
-
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- assert value instanceof PlatformKey : "Wrong model"; //NOI18N
- PlatformKey key = (PlatformKey) value;
- String name;
- if (key.isBroken()) {
- name = NbBundle.getMessage (PlatformUiSupport.class,"TXT_BrokenPlatformFmt", key.getDisplayName());
- }
- else {
- name = key.getDisplayName();
- }
- return super.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus);
- }
- }
-
- private static class SourceLevelComboBoxModel extends AbstractListModel implements ComboBoxModel, ListDataListener {
-
- private static final String VERSION_PREFIX = "1."; //The version prefix
- private static final int INITIAL_VERSION_MINOR = 2; //1.2
- // if project is JAVA EE 5 show only 1.5 and higher
- private static final int INITIAL_VERSION_MINOR_JAVA_EE_5 = 5; // 1.5
-
- private SpecificationVersion selectedSourceLevel;
- private SpecificationVersion originalSourceLevel;
- private SourceLevelKey[] sourceLevelCache;
- private final ComboBoxModel platformComboBoxModel;
- private PlatformKey activePlatform;
- private String j2eePlatform = null;
-
- public SourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel, String initialSourceLevel, String initialTargetLevel) {
- this.platformComboBoxModel = platformComboBoxModel;
- this.activePlatform = (PlatformKey) this.platformComboBoxModel.getSelectedItem();
- this.platformComboBoxModel.addListDataListener(this);
- if (initialSourceLevel != null && initialSourceLevel.length()>0) {
- try {
- originalSourceLevel = new SpecificationVersion (initialSourceLevel);
- } catch (NumberFormatException nfe) {
- // If the javac.source has invalid value, do not preselect and log it.
- LOGGER.log(Level.INFO, "Invalid javac.source: " + initialSourceLevel);
- }
- }
- if (initialTargetLevel != null && initialTargetLevel.length() > 0) {
- try {
- SpecificationVersion originalTargetLevel = new SpecificationVersion (initialTargetLevel);
- if (this.originalSourceLevel == null || this.originalSourceLevel.compareTo(originalTargetLevel)<0) {
- this.originalSourceLevel = originalTargetLevel;
- }
- } catch (NumberFormatException nfe) {
- //If the javac.target has invalid value, do not preselect and log it
- LOGGER.warning("Invalid javac.target: "+initialTargetLevel); //NOI18N
- }
- }
- this.selectedSourceLevel = this.originalSourceLevel;
- }
-
- public SourceLevelComboBoxModel(ComboBoxModel platformComboBoxModel, String initialSourceLevel, String initialTargetLevel, String j2eePlatform) {
- this(platformComboBoxModel, initialSourceLevel, initialTargetLevel);
- this.j2eePlatform = j2eePlatform;
- }
-
- public int getSize() {
- SourceLevelKey[] sLevels = getSourceLevels();
- return sLevels.length;
- }
-
- public Object getElementAt(int index) {
- SourceLevelKey[] sLevels = getSourceLevels();
- assert index >=0 && index< sLevels.length;
- return sLevels[index];
- }
-
- public Object getSelectedItem () {
- SourceLevelKey[] keys = getSourceLevels();
- for (int i=0; i0 &&
- !shouldChangePlatform(selectedSourceLevel, version)) {
- //Restore original
- this.platformComboBoxModel.setSelectedItem(this.activePlatform);
- return;
- }
- else {
- this.originalSourceLevel = null;
- }
- }
- this.activePlatform = selectedPlatform;
- resetCache();
- }
-
- private void resetCache() {
- synchronized (this) {
- this.sourceLevelCache = null;
- }
- this.fireContentsChanged(this, -1, -1);
- }
-
- private SourceLevelKey[] getSourceLevels() {
- if (this.sourceLevelCache == null) {
- PlatformKey selectedPlatform = (PlatformKey) this.platformComboBoxModel.getSelectedItem();
- JavaPlatform platform = getPlatform(selectedPlatform);
- List sLevels = new ArrayList();
- //If platform == null broken platform, the source level range is unknown
- //The source level combo box should be empty and disabled
- boolean selSourceLevelValid = false;
- if (platform != null) {
- SpecificationVersion version = platform.getSpecification().getVersion();
- int index = INITIAL_VERSION_MINOR;
- // #71619 - source level lower than 1.5 won't be shown for Java EE 5 project
- if (j2eePlatform != null && j2eePlatform.equals(J2eeModule.JAVA_EE_5)) {
- index = INITIAL_VERSION_MINOR_JAVA_EE_5;
- }
- SpecificationVersion template = new SpecificationVersion (VERSION_PREFIX + Integer.toString (index++));
- boolean origSourceLevelValid = false;
-
- while (template.compareTo(version)<=0) {
- if (template.equals(this.originalSourceLevel)) {
- origSourceLevelValid = true;
- }
- if (template.equals(this.selectedSourceLevel)) {
- selSourceLevelValid = true;
- }
- sLevels.add (new SourceLevelKey (template));
- template = new SpecificationVersion (VERSION_PREFIX + Integer.toString (index++));
- }
- if (this.originalSourceLevel != null && !origSourceLevelValid) {
- if (originalSourceLevel.equals(this.selectedSourceLevel)) {
- selSourceLevelValid = true;
- }
- sLevels.add (new SourceLevelKey(this.originalSourceLevel,true));
- }
- }
- this.sourceLevelCache = sLevels.toArray(new SourceLevelKey[sLevels.size()]);
- if (!selSourceLevelValid) {
- this.selectedSourceLevel = this.sourceLevelCache.length == 0 ?
- null : this.sourceLevelCache[this.sourceLevelCache.length-1].getSourceLevel();
- }
- }
- return this.sourceLevelCache;
- }
-
- private static boolean shouldChangePlatform (SpecificationVersion selectedSourceLevel, SpecificationVersion platformSourceLevel) {
- JButton changeOption = new JButton (NbBundle.getMessage(PlatformUiSupport.class, "CTL_ChangePlatform"));
- changeOption.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PlatformUiSupport.class, "AD_ChangePlatform"));
- String message = MessageFormat.format (NbBundle.getMessage(PlatformUiSupport.class,"TXT_ChangePlatform"),new Object[] {
- selectedSourceLevel.toString(),
- platformSourceLevel.toString(),
- });
- return DialogDisplayer.getDefault().notify(
- new NotifyDescriptor (message,
- NbBundle.getMessage(PlatformUiSupport.class,"TXT_ChangePlatformTitle"),
- NotifyDescriptor.DEFAULT_OPTION,
- NotifyDescriptor.WARNING_MESSAGE,
- new Object[] {
- changeOption,
- NotifyDescriptor.CANCEL_OPTION
- },
- changeOption)) == changeOption;
- }
- }
-
- private static class SourceLevelListCellRenderer implements ListCellRenderer {
-
- ListCellRenderer delegate;
-
- public SourceLevelListCellRenderer() {
- this.delegate = HtmlRenderer.createRenderer();
- }
-
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- String message;
- if (value == null) {
- message = ""; //NOI18N
- }
- else {
- assert value instanceof SourceLevelKey;
- SourceLevelKey key = (SourceLevelKey) value;
- if (key.isBroken()) {
- message = "" + //NOI18N
- NbBundle.getMessage(PlatformUiSupport.class,"TXT_InvalidSourceLevel",key.getDisplayName());
- }
- else {
- message = key.getDisplayName();
- }
- }
- return this.delegate.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
- }
- }
-}
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/customizer/WebProjectProperties.java b/web.project/src/org/netbeans/modules/web/project/ui/customizer/WebProjectProperties.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/customizer/WebProjectProperties.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/customizer/WebProjectProperties.java
@@ -65,14 +65,12 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.api.AntDeploymentHelper;
import org.netbeans.modules.web.project.ProjectWebModule;
-import org.netbeans.modules.web.project.SourceRoots;
import org.netbeans.modules.web.project.classpath.ClassPathSupport;
import org.netbeans.modules.web.spi.webmodule.WebModuleExtender;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.ui.StoreGroup;
import org.openide.filesystems.FileUtil;
-import org.openide.modules.SpecificationVersion;
import org.openide.util.MutexException;
import org.openide.util.Mutex;
import org.netbeans.api.project.Project;
@@ -82,16 +80,19 @@ import org.netbeans.modules.j2ee.deploym
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
+import org.netbeans.modules.java.api.common.SourceRoots;
+import org.netbeans.modules.java.api.common.ant.UpdateHelper;
+import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
+import org.netbeans.modules.web.project.UpdateProjectImpl;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.project.support.ant.PropertyUtils;
import org.netbeans.spi.project.support.ant.ReferenceHelper;
import org.netbeans.modules.web.project.WebProjectUtil;
-import org.netbeans.modules.web.project.UpdateHelper;
import org.netbeans.modules.web.project.Utils;
import org.netbeans.modules.web.project.WebProject;
+import org.netbeans.modules.web.project.WebProjectType;
import org.netbeans.modules.web.project.classpath.ClassPathSupport.Item;
-import org.netbeans.modules.web.spi.webmodule.WebFrameworkProvider;
import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.URLMapper;
@@ -292,7 +293,7 @@ public class WebProjectProperties {
this.updateHelper = updateHelper;
//this is called from updatehelper when user confirms the project update
- updateHelper.setProjectUpdateListener(new UpdateHelper.ProjectUpdateListener() {
+ project.getUpdateImplementation().setProjectUpdateListener(new UpdateProjectImpl.ProjectUpdateListener() {
public void projectUpdated() {
needsUpdate = true;
}
@@ -337,7 +338,11 @@ public class WebProjectProperties {
RUN_TEST_CLASSPATH_MODEL = ClassPathUiSupport.createListModel( cs.itemsIterator( (String)projectProperties.get( RUN_TEST_CLASSPATH ), null ) );
PLATFORM_MODEL = PlatformUiSupport.createPlatformComboBoxModel (evaluator.getProperty(JAVA_PLATFORM));
PLATFORM_LIST_RENDERER = PlatformUiSupport.createPlatformListCellRenderer();
- JAVAC_SOURCE_MODEL = PlatformUiSupport.createSourceLevelComboBoxModel (PLATFORM_MODEL, evaluator.getProperty(JAVAC_SOURCE), evaluator.getProperty(JAVAC_TARGET), evaluator.getProperty(J2EE_PLATFORM));
+ PlatformUiSupport.JDK minimalSourceLevel = null;
+ if (evaluator.getProperty(J2EE_PLATFORM).equals(J2eeModule.JAVA_EE_5)) {
+ minimalSourceLevel = PlatformUiSupport.JDK.VERSION_5;
+ }
+ JAVAC_SOURCE_MODEL = PlatformUiSupport.createSourceLevelComboBoxModel (PLATFORM_MODEL, evaluator.getProperty(JAVAC_SOURCE), evaluator.getProperty(JAVAC_TARGET), minimalSourceLevel);
JAVAC_SOURCE_RENDERER = PlatformUiSupport.createSourceLevelListCellRenderer ();
// CustomizerCompile
@@ -530,7 +535,7 @@ public class WebProjectProperties {
projectProperties.setProperty( WAR_CONTENT_ADDITIONAL, war_includes );
//Handle platform selection and javac.source javac.target properties
- PlatformUiSupport.storePlatform (projectProperties, updateHelper, PLATFORM_MODEL.getSelectedItem(), JAVAC_SOURCE_MODEL.getSelectedItem());
+ PlatformUiSupport.storePlatform (projectProperties, updateHelper, WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, PLATFORM_MODEL.getSelectedItem(), JAVAC_SOURCE_MODEL.getSelectedItem());
// Handle other special cases
if ( NO_DEPENDENCIES_MODEL.isSelected() ) { // NOI18N
diff --git a/web.project/src/org/netbeans/modules/web/project/ui/customizer/WebSourceRootsUi.java b/web.project/src/org/netbeans/modules/web/project/ui/customizer/WebSourceRootsUi.java
--- a/web.project/src/org/netbeans/modules/web/project/ui/customizer/WebSourceRootsUi.java
+++ b/web.project/src/org/netbeans/modules/web/project/ui/customizer/WebSourceRootsUi.java
@@ -64,7 +64,7 @@ import org.netbeans.api.project.FileOwne
import org.netbeans.api.project.FileOwnerQuery;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
-import org.netbeans.modules.web.project.SourceRoots;
+import org.netbeans.modules.java.api.common.SourceRoots;
import org.openide.DialogDisplayer;
import org.openide.DialogDescriptor;
import org.openide.filesystems.FileUtil;
diff --git a/web.project/test/unit/src/org/netbeans/modules/web/project/SourceRootsTest.java b/web.project/test/unit/src/org/netbeans/modules/web/project/SourceRootsTest.java
--- a/web.project/test/unit/src/org/netbeans/modules/web/project/SourceRootsTest.java
+++ b/web.project/test/unit/src/org/netbeans/modules/web/project/SourceRootsTest.java
@@ -53,6 +53,7 @@ import org.netbeans.junit.NbTestCase;
import org.netbeans.junit.NbTestCase;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.project.Project;
+import org.netbeans.modules.java.api.common.SourceRoots;
import org.netbeans.modules.web.project.test.TestBase;
import org.netbeans.modules.web.project.test.TestUtil;
import org.netbeans.spi.project.support.ant.AntProjectHelper;