Browse Source

Cleaned up error reporting for build.xml parse errors.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268217 13f79535-47bb-0310-9956-ffa450edef68
master
metasim 24 years ago
parent
commit
40ea40eae5
5 changed files with 47 additions and 7 deletions
  1. +5
    -0
      src/antidote/ChangeLog
  2. +4
    -2
      src/antidote/org/apache/tools/ant/gui/acs/ACSFactory.java
  3. +34
    -2
      src/antidote/org/apache/tools/ant/gui/command/DisplayErrorCmd.java
  4. +2
    -2
      src/antidote/org/apache/tools/ant/gui/command/LoadFileCmd.java
  5. +2
    -1
      src/antidote/org/apache/tools/ant/gui/resources/antidote.properties

+ 5
- 0
src/antidote/ChangeLog View File

@@ -1,3 +1,8 @@
2000-11-20 Simeon H.K. Fitch <simeon@fitch.net>

* 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 <simeon@fitch.net> 2000-11-18 Simeon H.K. Fitch <simeon@fitch.net>


* org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java: * org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java:


+ 4
- 2
src/antidote/org/apache/tools/ant/gui/acs/ACSFactory.java View File

@@ -57,6 +57,7 @@ import javax.xml.parsers.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.w3c.dom.*; import org.w3c.dom.*;
import org.xml.sax.SAXException;
import com.sun.xml.parser.Parser; import com.sun.xml.parser.Parser;
import com.sun.xml.tree.SimpleElementFactory; import com.sun.xml.tree.SimpleElementFactory;
import com.sun.xml.tree.XmlDocument; import com.sun.xml.tree.XmlDocument;
@@ -119,7 +120,7 @@ public class ACSFactory {
* @param f File to load. * @param f File to load.
* @return * @return
*/ */
public ACSProjectElement load(File f) throws IOException {
public ACSProjectElement load(File f) throws IOException, SAXException {
XmlDocument doc = null; XmlDocument doc = null;


try { try {
@@ -139,8 +140,9 @@ public class ACSFactory {
sax.parse(f, null); sax.parse(f, null);


doc = builder.getDocument(); doc = builder.getDocument();

} }
catch(Exception ex) {
catch(ParserConfigurationException ex) {
ex.printStackTrace(); ex.printStackTrace();
throw new IOException(ex.getMessage()); throw new IOException(ex.getMessage());
} }


+ 34
- 2
src/antidote/org/apache/tools/ant/gui/command/DisplayErrorCmd.java View File

@@ -53,7 +53,11 @@
*/ */
package org.apache.tools.ant.gui.command; package org.apache.tools.ant.gui.command;
import org.apache.tools.ant.gui.AppContext; 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. * Command for displaying an arbitrary error message to the user.
@@ -101,7 +105,35 @@ public class DisplayErrorCmd implements Command {
String title = _context.getResources().getString(getClass(), "title"); String title = _context.getResources().getString(getClass(), "title");


JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
_context.getParentFrame(), _message,
_context.getParentFrame(), new MsgPanel(),
title, JOptionPane.ERROR_MESSAGE); 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();
}
}
} }

+ 2
- 2
src/antidote/org/apache/tools/ant/gui/command/LoadFileCmd.java View File

@@ -98,13 +98,13 @@ public class LoadFileCmd implements Command {
ProjectProxy project = new ProjectProxy(_context, _file); ProjectProxy project = new ProjectProxy(_context, _file);
_context.setProject(project); _context.setProject(project);
} }
catch(IOException ex) {
catch(Exception ex) {
String message = _context.getResources().getMessage( String message = _context.getResources().getMessage(
getClass(), "loadError", getClass(), "loadError",
new Object[] { _file.toString() }); new Object[] { _file.toString() });


_context.getEventBus(). _context.getEventBus().
postEvent(new ErrorEvent(_context, message));
postEvent(new ErrorEvent(_context, message, ex));
} }
} }
} }


+ 2
- 1
src/antidote/org/apache/tools/ant/gui/resources/antidote.properties View File

@@ -34,7 +34,8 @@ org.apache.tools.ant.gui.XMLFileFilter.description=XML Files


org.apache.tools.ant.gui.command.LoadFileCmd.noFile=The file "{0}" was not found. 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.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.saveError=Could not save to "{0}".
org.apache.tools.ant.gui.command.SaveCmd.noProject=No project to save. org.apache.tools.ant.gui.command.SaveCmd.noProject=No project to save.


Loading…
Cancel
Save