metasim 00/11/20 17:06:17
Modified: src/antidote ChangeLog
src/antidote/org/apache/tools/ant/gui/acs ACSFactory.java
src/antidote/org/apache/tools/ant/gui/command
DisplayErrorCmd.java LoadFileCmd.java
src/antidote/org/apache/tools/ant/gui/resources
antidote.properties
Log:
Cleaned up error reporting for build.xml parse errors.
Revision Changes Path
1.10 +5 -0 jakarta-ant/src/antidote/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /home/cvs/jakarta-ant/src/antidote/ChangeLog,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ChangeLog 2000/11/19 04:21:58 1.9
+++ ChangeLog 2000/11/21 01:06:14 1.10
@@ -1,3 +1,8 @@
+2000-11-20 Simeon H.K. Fitch <[EMAIL PROTECTED]>
+
+ * org/apache/tools/ant/gui/command/DisplayErrorCmd.java: Added
+ code to allow display of stack backtrace if needed.
+
2000-11-18 Simeon H.K. Fitch <[EMAIL PROTECTED]>
* org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java:
1.3 +5 -3
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ACSFactory.java 2000/11/11 04:52:20 1.2
+++ ACSFactory.java 2000/11/21 01:06:15 1.3
@@ -57,6 +57,7 @@
import java.io.File;
import java.io.IOException;
import org.w3c.dom.*;
+import org.xml.sax.SAXException;
import com.sun.xml.parser.Parser;
import com.sun.xml.tree.SimpleElementFactory;
import com.sun.xml.tree.XmlDocument;
@@ -68,7 +69,7 @@
/**
* Factory for loading Ant Construction set elements.
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
* @author Simeon Fitch
*/
public class ACSFactory {
@@ -119,7 +120,7 @@
* @param f File to load.
* @return
*/
- public ACSProjectElement load(File f) throws IOException {
+ public ACSProjectElement load(File f) throws IOException, SAXException {
XmlDocument doc = null;
try {
@@ -139,8 +140,9 @@
sax.parse(f, null);
doc = builder.getDocument();
+
}
- catch(Exception ex) {
+ catch(ParserConfigurationException ex) {
ex.printStackTrace();
throw new IOException(ex.getMessage());
}
1.2 +35 -3
jakarta-ant/src/antidote/org/apache/tools/ant/gui/command/DisplayErrorCmd.java
Index: DisplayErrorCmd.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/command/DisplayErrorCmd.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DisplayErrorCmd.java 2000/11/03 12:04:28 1.1
+++ DisplayErrorCmd.java 2000/11/21 01:06:15 1.2
@@ -53,12 +53,16 @@
*/
package org.apache.tools.ant.gui.command;
import org.apache.tools.ant.gui.AppContext;
-import javax.swing.JOptionPane;
+import org.apache.tools.ant.gui.util.StackFrame;
+import javax.swing.*;
+import java.awt.FlowLayout;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
/**
* Command for displaying an arbitrary error message to the user.
*
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
* @author Simeon H.K. Fitch
*/
public class DisplayErrorCmd implements Command {
@@ -101,7 +105,35 @@
String title = _context.getResources().getString(getClass(),
"title");
JOptionPane.showMessageDialog(
- _context.getParentFrame(), _message,
+ _context.getParentFrame(), new MsgPanel(),
title, JOptionPane.ERROR_MESSAGE);
+ }
+
+ // Panel for assembling the error information.
+ private class MsgPanel extends JPanel implements ActionListener {
+ public MsgPanel() {
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ add(new JLabel(_message));
+ if(_ex != null) {
+ add(new JLabel(_ex.getMessage()));
+ JButton b = new JButton(_context.getResources().
+ getString(DisplayErrorCmd.class,
+ "expand"));
+ b.addActionListener(this);
+ add(Box.createVerticalStrut(20));
+ add(b);
+ }
+ }
+ // Called when the user clicks the expand button.
+ public void actionPerformed(ActionEvent e) {
+ JComponent source = (JComponent) e.getSource();
+ JComponent parent = (JComponent) source.getParent();
+ parent.remove(source);
+ JTextArea text = new JTextArea();
+ text.setEditable(false);
+ text.setText(StackFrame.toString(_ex));
+ parent.add(new JScrollPane(text));
+ SwingUtilities.windowForComponent(parent).pack();
+ }
}
}
1.3 +3 -3
jakarta-ant/src/antidote/org/apache/tools/ant/gui/command/LoadFileCmd.java
Index: LoadFileCmd.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/command/LoadFileCmd.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LoadFileCmd.java 2000/11/06 12:52:46 1.2
+++ LoadFileCmd.java 2000/11/21 01:06:15 1.3
@@ -61,7 +61,7 @@
/**
* Command for reading in a build file and initializing the data model.
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
* @author Simeon Fitch
*/
public class LoadFileCmd implements Command {
@@ -98,13 +98,13 @@
ProjectProxy project = new ProjectProxy(_context, _file);
_context.setProject(project);
}
- catch(IOException ex) {
+ catch(Exception ex) {
String message = _context.getResources().getMessage(
getClass(), "loadError",
new Object[] { _file.toString() });
_context.getEventBus().
- postEvent(new ErrorEvent(_context, message));
+ postEvent(new ErrorEvent(_context, message, ex));
}
}
}
1.13 +2 -1
jakarta-ant/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties
Index: antidote.properties
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/resources/antidote.properties,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- antidote.properties 2000/11/17 22:39:05 1.12
+++ antidote.properties 2000/11/21 01:06:16 1.13
@@ -34,7 +34,8 @@
org.apache.tools.ant.gui.command.LoadFileCmd.noFile=The file "{0}" was not
found.
org.apache.tools.ant.gui.command.LoadFileCmd.loadError=The file "{0}" could
not be loaded.
-org.apache.tools.ant.gui.command.DisplayErrorCmd.title=Error...
+org.apache.tools.ant.gui.command.DisplayErrorCmd.title=Antidote Error...
+org.apache.tools.ant.gui.command.DisplayErrorCmd.expand=Details >>
org.apache.tools.ant.gui.command.SaveCmd.saveError=Could not save to "{0}".
org.apache.tools.ant.gui.command.SaveCmd.noProject=No project to save.