01: /*
02: * Copyright (C) 2005-2007 JasperSoft http://www.jaspersoft.com
03: *
04: * This program is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * This program is distributed WITHOUT ANY WARRANTY; and without the
10: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: * See the GNU General Public License for more details.
12: *
13: * You should have received a copy of the GNU General Public License
14: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15: * or write to:
16: *
17: * Free Software Foundation, Inc.,
18: * 59 Temple Place - Suite 330,
19: * Boston, MA USA 02111-1307
20: *
21: *
22: * ErrorsCollector.java
23: *
24: * Created on March 14, 2007, 2:55 PM
25: *
26: * To change this template, choose Tools | Template Manager
27: * and open the template in the editor.
28: */
29:
30: package it.businesslogic.ireport.compiler;
31:
32: import it.businesslogic.ireport.compiler.xml.SourceLocation;
33: import it.businesslogic.ireport.gui.logpane.ProblemItem;
34: import net.sf.jasperreports.engine.design.JRValidationFault;
35: import org.eclipse.jdt.core.compiler.IProblem;
36:
37: /**
38: *
39: * @author gtoffoli
40: */
41: public class ErrorsCollector implements JasperReportErrorHandler {
42:
43: private java.util.List problemItems = null;
44:
45: /** Creates a new instance of ErrorsCollector */
46: public ErrorsCollector() {
47: setProblemItems(new java.util.ArrayList());
48: }
49:
50: public void addMarker(Throwable e) {
51: e.printStackTrace();
52: addMarker(e.getMessage(), null);
53: }
54:
55: public void addMarker(String message, SourceLocation location) {
56: if (location == null) {
57: getProblemItems().add(
58: new ProblemItem(ProblemItem.ERROR, message,
59: location, null));
60: } else {
61: getProblemItems().add(
62: new ProblemItem(ProblemItem.ERROR, message,
63: location, location.getXPath()));
64: }
65: }
66:
67: public void addMarker(IProblem problem, SourceLocation location) {
68: addMarker(problem.getMessage(), location);
69: }
70:
71: public java.util.List getProblemItems() {
72: return problemItems;
73: }
74:
75: public void setProblemItems(java.util.List problemItems) {
76: this.problemItems = problemItems;
77: }
78:
79: }
|