metasim 01/01/04 13:11:08
Modified: src/antidote/org/apache/tools/ant/gui/acs ACSFactory.java
ACSProjectElement.java
Log:
Fixed resource problems, and changed mechanism by which resources are passed
to
the actions.
Revision Changes Path
1.5 +23 -6
jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSFactory.java
Index: ACSFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ACSFactory.java 2001/01/03 14:18:17 1.4
+++ ACSFactory.java 2001/01/04 21:11:07 1.5
@@ -54,8 +54,9 @@
package org.apache.tools.ant.gui.acs;
import javax.xml.parsers.*;
-import java.io.File;
import java.io.IOException;
+import java.io.File;
+import java.net.URL;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import com.sun.xml.parser.Parser;
@@ -69,7 +70,7 @@
/**
* Factory for loading Ant Construction set elements.
*
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
* @author Simeon Fitch
*/
public class ACSFactory {
@@ -113,14 +114,26 @@
}
+
+ /**
+ * Load a project from the given XML file.
+ * XXX fix me.
+ *
+ * @param location Location of the file.
+ * @return Loaded project.
+ */
+ public ACSProjectElement load(File location) throws IOException {
+ return load(new URL("file", null, location.getPath()));
+ }
+
/**
* Load a project from the given XML file.
* XXX fix me.
*
- * @param f File to load.
- * @return
+ * @param location Location of the file.
+ * @return Loaded project.
*/
- public ACSProjectElement load(File f) throws IOException, SAXException {
+ public ACSProjectElement load(URL location) throws IOException {
XmlDocument doc = null;
try {
@@ -137,12 +150,16 @@
parser.setEntityResolver(new Resolver());
//parser.setErrorHandler();
- sax.parse(f, null);
+ sax.parse(location.openStream(), null);
doc = builder.getDocument();
}
catch(ParserConfigurationException ex) {
+ ex.printStackTrace();
+ throw new IOException(ex.getMessage());
+ }
+ catch(SAXException ex) {
ex.printStackTrace();
throw new IOException(ex.getMessage());
}
1.6 +27 -2
jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElement.java
Index: ACSProjectElement.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElement.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ACSProjectElement.java 2001/01/03 14:18:17 1.5
+++ ACSProjectElement.java 2001/01/04 21:11:07 1.6
@@ -54,11 +54,12 @@
package org.apache.tools.ant.gui.acs;
import com.sun.xml.tree.ElementNode;
+import java.net.URL;
/**
* Class representing a project element in the build file.
*
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
* @author Simeon Fitch
*/
public class ACSProjectElement extends ACSNamedElement {
@@ -66,8 +67,11 @@
public static final String DEFAULT = "default";
/** The 'basdir' property name. */
public static final String BASEDIR = "basedir";
+ /** Property name of the persistence location. */
+ public static final String LOCATION = "location";
+ /** The location where this project is persisted. */
+ private URL _location = null;
-
/**
* Default ctor.
*
@@ -123,5 +127,26 @@
setAttribute(BASEDIR, baseDir);
firePropertyChange(BASEDIR, old, baseDir);
}
+
+ /**
+ * Get the location where this project is persisted.
+ *
+ * @return Saved location, or null if not persisted.
+ */
+ public URL getLocation() {
+ return _location;
+ }
+
+ /**
+ * Set the loction where the project is persisted.
+ *
+ * @param location Location of project.
+ */
+ public void setLocation(URL location) {
+ URL old = _location;
+ _location = location;
+ firePropertyChange(LOCATION, old, _location);
+ }
+
}