You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2012/08/19 17:28:28 UTC
svn commit: r1374768 - in /ant/ivy/ivyde/trunk: doc/
org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/
org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/
org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontai...
Author: hibou
Date: Sun Aug 19 15:28:27 2012
New Revision: 1374768
URL: http://svn.apache.org/viewvc?rev=1374768&view=rev
Log:
IVYDE-317 : save the IvyDE container state ourself since Eclipse doesn't always read its persisted metadata (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=387535)
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java (with props)
Modified:
ant/ivy/ivyde/trunk/doc/release-notes.html
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/IPackageFragmentExtraInfo.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/PreferenceStoreInfo.java
Modified: ant/ivy/ivyde/trunk/doc/release-notes.html
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/doc/release-notes.html?rev=1374768&r1=1374767&r2=1374768&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/doc/release-notes.html (original)
+++ ant/ivy/ivyde/trunk/doc/release-notes.html Sun Aug 19 15:28:27 2012
@@ -142,6 +142,7 @@ List of changes since <a href="/ivy/ivyd
<li>FIX: In case of a multi-resolve, one fail make them all fail (IVYDE-316)</li>
<li>FIX: Cannot change retrieve pattern at the workspace level (IVYDE-301)</li>
<li>FIX: Resolution failure when workspace has project & artifact sub-element exists (IVYDE-296, IVYDE-319)</li>
+ <li>FIX: IvyDE classpath containers become empty on eclipse/MyEclipse startup (IVYDE-317)</li>
</ul>
<!-- samples
<ul>
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java?rev=1374768&r1=1374767&r2=1374768&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java Sun Aug 19 15:28:27 2012
@@ -17,6 +17,7 @@
*/
package org.apache.ivyde.eclipse;
+import java.io.File;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
@@ -26,6 +27,7 @@ import java.util.ResourceBundle;
import org.apache.ivyde.common.ivyfile.IvyFileResourceListener;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerSerializer;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.IPackageFragmentExtraInfo;
import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.PreferenceStoreInfo;
@@ -99,6 +101,8 @@ public class IvyPlugin extends AbstractU
private boolean osgiAvailable;
+ private IvyClasspathContainerSerializer ivyCpcSerializer;
+
/**
* The constructor.
*/
@@ -161,6 +165,13 @@ public class IvyPlugin extends AbstractU
ivyMarkerManager = new IvyMarkerManager();
+ File stateLocation = getStateLocation().toFile();
+ File containersStateDir = new File(stateLocation, "cpstates");
+ if (!containersStateDir.exists()) {
+ containersStateDir.mkdirs();
+ }
+ ivyCpcSerializer = new IvyClasspathContainerSerializer(containersStateDir);
+
log(IStatus.INFO, "IvyDE plugin started", null);
try {
@@ -176,6 +187,7 @@ public class IvyPlugin extends AbstractU
*/
public void stop(BundleContext context) throws Exception {
super.stop(context);
+ ivyCpcSerializer = null;
resourceBundle = null;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.removeSaveParticipant(this);
@@ -388,6 +400,10 @@ public class IvyPlugin extends AbstractU
return ivyMarkerManager;
}
+ public IvyClasspathContainerSerializer getIvyClasspathContainerSerializer() {
+ return ivyCpcSerializer;
+ }
+
public IvyResolveJob getIvyResolveJob() {
return ivyResolveJob;
}
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java?rev=1374768&r1=1374767&r2=1374768&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java Sun Aug 19 15:28:27 2012
@@ -170,6 +170,8 @@ public class IvyClasspathContainer imple
// unless there are some issues with the JDT, this should never happen
IvyPlugin.log(e);
}
+ IvyClasspathContainerSerializer serializer = IvyPlugin.getDefault().getIvyClasspathContainerSerializer();
+ serializer.save(conf.getJavaProject());
}
public URL getReportUrl() {
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java?rev=1374768&r1=1374767&r2=1374768&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java Sun Aug 19 15:28:27 2012
@@ -301,7 +301,7 @@ public class IvyClasspathContainerMapper
return false;
}
- private IPath getSourceAttachment(Path classpathArtifact, Path sourcesArtifact) {
+ static IPath getSourceAttachment(IPath classpathArtifact, IPath sourcesArtifact) {
IPath sourceAttachment = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
.getSourceAttachment(classpathArtifact);
if (sourceAttachment == null) {
@@ -310,7 +310,7 @@ public class IvyClasspathContainerMapper
return sourceAttachment;
}
- private IPath getSourceAttachmentRoot(Path classpathArtifact, Path sourcesArtifact) {
+ static IPath getSourceAttachmentRoot(IPath classpathArtifact, IPath sourcesArtifact) {
IPath sourceAttachment = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
.getSourceAttachmentRoot(classpathArtifact);
if (sourceAttachment == null && sourcesArtifact != null) {
@@ -319,13 +319,13 @@ public class IvyClasspathContainerMapper
return sourceAttachment;
}
- private IClasspathAttribute[] getExtraAttribute(Path classpathArtifact, Path javadocArtifact) {
+ private IClasspathAttribute[] getExtraAttribute(IPath classpathArtifact, IPath javadocArtifact) {
List result = new ArrayList();
URL url = IvyPlugin.getDefault().getPackageFragmentExtraInfo()
.getDocAttachment(classpathArtifact);
if (url == null) {
- Path path = javadocArtifact;
+ IPath path = javadocArtifact;
if (path != null) {
String u;
try {
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java?rev=1374768&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java Sun Aug 19 15:28:27 2012
@@ -0,0 +1,439 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.cpcontainer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class IvyClasspathContainerSerializer {
+
+ private static final String ROOT = "ivydecontainers";
+
+ private static final String IVYCP = "ivycp";
+
+ private static final String PATH = "path";
+
+ private static final String PROJECT = "project";
+
+ private static final String CPENTRIES = "cpentries";
+
+ private static final String CPATTRS = "cpattrs";
+
+ private static final String ATTR = "attr";
+
+ private static final String NAME = "name";
+
+ private static final String VALUE = "value";
+
+ private static final String CPENTRY = "cpentry";
+
+ private static final String KIND = "kind";
+
+ private static final String SOURCE = "kind";
+
+ private static final String ACCESS_RULES = "accessRules";
+
+ private static final String RULE = "rule";
+
+ private static final String PATTERN = "pattern";
+
+ private File containersStateDir;
+
+ public IvyClasspathContainerSerializer(File containersStateDir) {
+ this.containersStateDir = containersStateDir;
+ }
+
+ public void save(IJavaProject project) {
+ List/* <IvyClasspathContainer> */ivycps = IvyClasspathUtil
+ .getIvyClasspathContainers(project);
+ try {
+ FileOutputStream out = new FileOutputStream(new File(containersStateDir, project
+ .getProject().getName() + ".xml"));
+ try {
+ write(out, ivycps);
+ } finally {
+ try {
+ out.close();
+ } catch (IOException e) {
+ // don't care
+ }
+ }
+ } catch (IOException ioe) {
+ IvyPlugin.log(IStatus.ERROR, "IvyDE container states of the project "
+ + project.getProject().getName() + " cound not be saved", ioe);
+ }
+ }
+
+ public Map/* <IPath, IvyClasspathContainer> */read(IJavaProject project) {
+ try {
+ FileInputStream in = new FileInputStream(new File(containersStateDir, project
+ .getProject().getName() + ".xml"));
+ try {
+ return read(in);
+ } finally {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // don't care
+ }
+ }
+ } catch (IOException ioe) {
+ IvyPlugin.log(IStatus.ERROR, "IvyDE container states of the project "
+ + project.getProject().getName() + " cound not be read", ioe);
+ return null;
+ }
+ }
+
+ private void write(OutputStream out, List/* <IvyClasspathContainer> */containers)
+ throws IOException {
+ try {
+ StreamResult result = new StreamResult(out);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.newDocument();
+
+ Node root = document.createElement(ROOT);
+ document.appendChild(root);
+
+ Iterator it = containers.iterator();
+ while (it.hasNext()) {
+ IvyClasspathContainer ivycp = (IvyClasspathContainer) it.next();
+
+ Node node = document.createElement(IVYCP);
+ root.appendChild(node);
+ NamedNodeMap attributes = node.getAttributes();
+ Attr attr = document.createAttribute(PATH);
+ attr.setValue(ivycp.getPath().toString());
+ attributes.setNamedItem(attr);
+
+ attr = document.createAttribute(PROJECT);
+ attr.setValue(ivycp.getConf().getProject().getName());
+ attributes.setNamedItem(attr);
+
+ writeCpEntries(ivycp, document, node, ivycp.getClasspathEntries());
+
+ writeCpAttr(ivycp, document, node, ivycp.getConf().getAttributes());
+ }
+
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ DOMSource source = new DOMSource(document);
+
+ transformer.transform(source, result);
+
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ } catch (TransformerException e) {
+ if (e.getException() instanceof IOException) {
+ throw (IOException) e.getException();
+ }
+ IOException ioe = new IOException(e.getMessage());
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ private void writeCpEntries(IvyClasspathContainer ivycp, Document document, Node node,
+ IClasspathEntry[] classpathEntries) {
+ if (classpathEntries == null) {
+ return;
+ }
+
+ Node cpEntriesNode = document.createElement(CPENTRIES);
+ node.appendChild(cpEntriesNode);
+
+ for (int i = 0; i < classpathEntries.length; i++) {
+ Node cpEntryNode = document.createElement(CPENTRY);
+ cpEntriesNode.appendChild(cpEntryNode);
+
+ int kind = classpathEntries[i].getEntryKind();
+ NamedNodeMap attributes = cpEntryNode.getAttributes();
+ Attr attr = document.createAttribute(KIND);
+ attr.setValue(Integer.toString(kind));
+ attributes.setNamedItem(attr);
+
+ attr = document.createAttribute(PATH);
+ attr.setValue(classpathEntries[i].getPath().toString());
+ attributes.setNamedItem(attr);
+
+ IPath source = classpathEntries[i].getSourceAttachmentPath();
+ if (source != null) {
+ attr = document.createAttribute(SOURCE);
+ attr.setValue(source.toString());
+ attributes.setNamedItem(attr);
+ }
+
+ writeAccessRules(ivycp, document, cpEntryNode, classpathEntries[i].getAccessRules());
+
+ writeCpAttr(ivycp, document, cpEntryNode, classpathEntries[i].getExtraAttributes());
+ }
+ }
+
+ private void writeAccessRules(IvyClasspathContainer ivycp, Document document, Node cpEntryNode,
+ IAccessRule[] accessRules) {
+ if (accessRules == null) {
+ return;
+ }
+ Node accessRulesNode = document.createElement(ACCESS_RULES);
+ cpEntryNode.appendChild(accessRulesNode);
+
+ for (int i = 0; i < accessRules.length; i++) {
+ Node accessRuleNode = document.createElement(RULE);
+ accessRulesNode.appendChild(accessRuleNode);
+
+ NamedNodeMap attributes = accessRuleNode.getAttributes();
+ Attr attr = document.createAttribute(PATTERN);
+ attr.setValue(accessRules[i].getPattern().toString());
+ attributes.setNamedItem(attr);
+
+ attr = document.createAttribute(KIND);
+ attr.setValue(Integer.toString(accessRules[i].getKind()));
+ attributes.setNamedItem(attr);
+
+ }
+ }
+
+ private void writeCpAttr(IvyClasspathContainer ivycp, Document document, Node node,
+ IClasspathAttribute[] attrs) {
+ if (attrs == null) {
+ return;
+ }
+ Node cpAttrsNode = document.createElement(CPATTRS);
+ node.appendChild(cpAttrsNode);
+
+ for (int i = 0; i < attrs.length; i++) {
+ Node attrNode = document.createElement(ATTR);
+ cpAttrsNode.appendChild(attrNode);
+
+ NamedNodeMap attributes = attrNode.getAttributes();
+ Attr attr = document.createAttribute(NAME);
+ attr.setValue(attrs[i].getName());
+ attributes.setNamedItem(attr);
+
+ attr = document.createAttribute(VALUE);
+ attr.setValue(attrs[i].getValue());
+ attributes.setNamedItem(attr);
+ }
+ }
+
+ public Map/* <IPath, IvyClasspathContainer> */read(InputStream in) throws IOException {
+ try {
+ InputSource source = new InputSource(in);
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ Document document = parser.parse(source);
+
+ NodeList elements = document.getElementsByTagName(IVYCP);
+
+ Map/* <IPath, IvyClasspathContainer> */ivycps = new HashMap();
+
+ int count = elements.getLength();
+ for (int i = 0; i != count; i++) {
+ Node node = elements.item(i);
+
+ NamedNodeMap attributes = node.getAttributes();
+ IPath path = new Path(getAttribute(attributes, PATH));
+
+ IProject p = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(getAttribute(attributes, PROJECT));
+ IJavaProject project = JavaCore.create(p);
+
+ IClasspathEntry[] cpEntries = new IClasspathEntry[0];
+ IClasspathAttribute[] cpAttributes = null;
+
+ NodeList children = node.getChildNodes();
+ for (int j = 0; j < children.getLength(); j++) {
+ Node item = children.item(j);
+ if (item.getNodeName().equals(CPENTRIES)) {
+ cpEntries = readCpEntries(item);
+ } else if (item.getNodeName().equals(CPATTRS)) {
+ cpAttributes = readCpAttr(item);
+ }
+ }
+
+ IvyClasspathContainer ivycp = new IvyClasspathContainer(project, path, cpEntries,
+ cpAttributes);
+ ivycps.put(path, ivycp);
+ }
+ return ivycps;
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ } catch (SAXException e) {
+ Throwable t = e.getCause();
+ if (t instanceof IOException) {
+ throw (IOException) t;
+ }
+ if (t == null) {
+ t = e;
+ }
+ IOException ioe = new IOException(t.getMessage());
+ ioe.initCause(t);
+ throw ioe;
+ }
+
+ }
+
+ private IClasspathEntry[] readCpEntries(Node cpEntries) throws SAXException {
+ List/* <IClasspathEntry> */entries = new ArrayList();
+ NodeList children = cpEntries.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node item = children.item(i);
+ if (item.getNodeName().equals(CPENTRY)) {
+ IClasspathEntry cpEntry = readCpEntry(item);
+ if (cpEntry != null) {
+ entries.add(cpEntry);
+ }
+ }
+ }
+ return (IClasspathEntry[]) entries.toArray(new IClasspathEntry[entries.size()]);
+ }
+
+ private IClasspathEntry readCpEntry(Node cpEntryNode) throws SAXException {
+ NamedNodeMap attributes = cpEntryNode.getAttributes();
+ int kind = Integer.parseInt(getAttribute(attributes, KIND));
+ IPath path = new Path(getAttribute(attributes, PATH));
+ String source = getAttribute(attributes, SOURCE);
+ IPath sourcePath = null;
+ if (source != null) {
+ sourcePath = new Path(source);
+ }
+
+ IClasspathAttribute[] cpAttrs = null;
+ IAccessRule[] accessRules = null;
+ NodeList children = cpEntryNode.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node item = children.item(i);
+ if (item.getNodeName().equals(CPATTRS)) {
+ cpAttrs = readCpAttr(item);
+ } else if (item.getNodeName().equals(ACCESS_RULES)) {
+ accessRules = readAccessRules(item);
+ }
+ }
+
+ IClasspathEntry entry;
+ switch (kind) {
+ case IClasspathEntry.CPE_PROJECT:
+ entry = JavaCore.newProjectEntry(path, accessRules, true, cpAttrs, true);
+ break;
+ case IClasspathEntry.CPE_LIBRARY:
+ sourcePath = IvyClasspathContainerMapper.getSourceAttachment(path, sourcePath);
+ IPath sourceRootPath = IvyClasspathContainerMapper.getSourceAttachmentRoot(path,
+ sourcePath);
+ entry = JavaCore.newLibraryEntry(path, sourcePath, sourceRootPath, accessRules,
+ cpAttrs, false);
+ break;
+ default:
+ return null;
+ }
+
+ return entry;
+ }
+
+ private IAccessRule[] readAccessRules(Node accessRulesNode) throws SAXException {
+ List/* <IAccessRule> */rules = new ArrayList();
+ NodeList children = accessRulesNode.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node item = children.item(i);
+ if (item.getNodeName().equals(RULE)) {
+ IAccessRule rule = readAccessRule(item);
+ if (rule != null) {
+ rules.add(rule);
+ }
+ }
+ }
+ return (IAccessRule[]) rules.toArray(new IAccessRule[rules.size()]);
+ }
+
+ private IAccessRule readAccessRule(Node ruleNode) throws SAXException {
+ NamedNodeMap attributes = ruleNode.getAttributes();
+ int kind = Integer.parseInt(getAttribute(attributes, KIND));
+ IPath pattern = new Path(getAttribute(attributes, PATTERN));
+ return JavaCore.newAccessRule(pattern, kind);
+ }
+
+ private IClasspathAttribute[] readCpAttr(Node cpAttrsNode) throws SAXException {
+ List/* <IClasspathAttribute> */attrs = new ArrayList();
+ NodeList children = cpAttrsNode.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node item = children.item(i);
+ if (item.getNodeName().equals(ATTR)) {
+ IClasspathAttribute attr = readAttr(item);
+ if (attr != null) {
+ attrs.add(attr);
+ }
+ }
+ }
+ return (IClasspathAttribute[]) attrs.toArray(new IClasspathAttribute[attrs.size()]);
+ }
+
+ private IClasspathAttribute readAttr(Node attrNode) throws SAXException {
+ NamedNodeMap attributes = attrNode.getAttributes();
+ String name = getAttribute(attributes, NAME);
+ String value = getAttribute(attributes, VALUE);
+ return JavaCore.newClasspathAttribute(name, value);
+ }
+
+ private String getAttribute(NamedNodeMap attributes, String name) throws SAXException {
+ Node node = attributes.getNamedItem(name);
+ if (node == null) {
+ throw new SAXException("Attribute '" + name + "' not found");
+ }
+ return node.getNodeValue();
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerSerializer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java?rev=1374768&r1=1374767&r2=1374768&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java Sun Aug 19 15:28:27 2012
@@ -20,6 +20,7 @@ package org.apache.ivyde.eclipse.cpconta
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import org.apache.ivyde.eclipse.IvyPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -66,7 +67,8 @@ public class IvyClasspathInitializer ext
}
try {
- IvyClasspathContainer ivycp;
+ boolean refresh = false;
+ IvyClasspathContainer ivycp = null;
IClasspathEntry entry = IvyClasspathUtil.getIvyClasspathEntry(containerPath,
project);
IClasspathAttribute[] attributes;
@@ -83,8 +85,19 @@ public class IvyClasspathInitializer ext
ivycp = (IvyClasspathContainer) container;
} else {
if (container == null) {
- ivycp = new IvyClasspathContainer(project, containerPath,
- new IClasspathEntry[0], attributes);
+ // try what the IvyDE plugin saved
+ IvyClasspathContainerSerializer serializer = IvyPlugin.getDefault().getIvyClasspathContainerSerializer();
+ Map ivycps = serializer.read(project);
+ if (ivycps != null) {
+ ivycp = (IvyClasspathContainer) ivycps.get(containerPath);
+ }
+ if (ivycp == null) {
+ // still bad luck or just a new classpath container
+ ivycp = new IvyClasspathContainer(project, containerPath,
+ new IClasspathEntry[0], attributes);
+ // empty, so force refresh at least
+ refresh = true;
+ }
} else {
// this might be the persisted one : reuse the persisted entries
ivycp = new IvyClasspathContainer(project, containerPath,
@@ -104,9 +117,13 @@ public class IvyClasspathInitializer ext
int startupMode = IvyPlugin.getPreferenceStoreHelper().getResolveOnStartup();
if (startupMode == ON_STARTUP_NOTHING) {
- return;
+ if (!refresh) {
+ // unless we force a refresh, actually do nothing
+ return;
+ }
+ } else {
+ refresh = startupMode == ON_STARTUP_REFRESH;
}
- boolean refresh = startupMode == ON_STARTUP_REFRESH;
// now refresh the container to be synchronized with the ivy.xml
ivycp.launchResolve(refresh, null);
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/IPackageFragmentExtraInfo.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/IPackageFragmentExtraInfo.java?rev=1374768&r1=1374767&r2=1374768&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/IPackageFragmentExtraInfo.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/IPackageFragmentExtraInfo.java Sun Aug 19 15:28:27 2012
@@ -20,15 +20,14 @@ package org.apache.ivyde.eclipse.cpconta
import java.net.URL;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
public interface IPackageFragmentExtraInfo {
- public IPath getSourceAttachment(Path path);
+ public IPath getSourceAttachment(IPath path);
- public IPath getSourceAttachmentRoot(Path path);
+ public IPath getSourceAttachmentRoot(IPath path);
- public URL getDocAttachment(Path path);
+ public URL getDocAttachment(IPath path);
public void setSourceAttachmentPath(IPath containerPath, String entryPath, IPath sourcePath);
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/PreferenceStoreInfo.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/PreferenceStoreInfo.java?rev=1374768&r1=1374767&r2=1374768&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/PreferenceStoreInfo.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/fragmentinfo/PreferenceStoreInfo.java Sun Aug 19 15:28:27 2012
@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jface.preference.IPreferenceStore;
public class PreferenceStoreInfo implements IPackageFragmentExtraInfo {
+
private static final String SRC_SUFFIX = "-src";
private static final String SRCROOT_SUFFIX = "-srcroot";
@@ -39,7 +40,7 @@ public class PreferenceStoreInfo impleme
this.preferenceStore = preferenceStore;
}
- public IPath getSourceAttachment(Path path) {
+ public IPath getSourceAttachment(IPath path) {
String srcPath = preferenceStore.getString(path.toPortableString() + SRC_SUFFIX);
if (!"".equals(srcPath)) {
return new Path(srcPath);
@@ -47,7 +48,7 @@ public class PreferenceStoreInfo impleme
return null;
}
- public IPath getSourceAttachmentRoot(Path path) {
+ public IPath getSourceAttachmentRoot(IPath path) {
String srcPath = preferenceStore.getString(path.toPortableString() + SRCROOT_SUFFIX);
if (!"".equals(srcPath)) {
return new Path(srcPath);
@@ -55,7 +56,7 @@ public class PreferenceStoreInfo impleme
return null;
}
- public URL getDocAttachment(Path path) {
+ public URL getDocAttachment(IPath path) {
String srcPath = preferenceStore.getString(path.toPortableString() + DOC_SUFFIX);
if (!"".equals(srcPath)) {
try {