Source Code Cross Referenced for ErrorLocator.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » compiler » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » iReport 2.0.5 » it.businesslogic.ireport.compiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright (C) 2005-2007 JasperSoft http://www.jaspersoft.com
0003:         *
0004:         * This program is free software; you can redistribute it and/or modify
0005:         * it under the terms of the GNU General Public License as published by
0006:         * the Free Software Foundation; either version 2 of the License, or
0007:         * (at your option) any later version.
0008:         *
0009:         * This program is distributed WITHOUT ANY WARRANTY; and without the
0010:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0011:         * See the GNU General Public License for more details.
0012:         *
0013:         * You should have received a copy of the GNU General Public License
0014:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
0015:         * or write to:
0016:         *
0017:         * Free Software Foundation, Inc.,
0018:         * 59 Temple Place - Suite 330,
0019:         * Boston, MA  USA  02111-1307
0020:         *
0021:         *
0022:         * ErrorLocator.java
0023:         *
0024:         * Created on March 14, 2007, 4:19 PM
0025:         *
0026:         * To change this template, choose Tools | Template Manager
0027:         * and open the template in the editor.
0028:         */
0029:
0030:        package it.businesslogic.ireport.compiler;
0031:
0032:        import it.businesslogic.ireport.Band;
0033:        import it.businesslogic.ireport.ChartReportElement2;
0034:        import it.businesslogic.ireport.CrosstabReportElement;
0035:        import it.businesslogic.ireport.Group;
0036:        import it.businesslogic.ireport.HyperLinkableReportElement;
0037:        import it.businesslogic.ireport.ImageReportElement;
0038:        import it.businesslogic.ireport.JRField;
0039:        import it.businesslogic.ireport.JRParameter;
0040:        import it.businesslogic.ireport.JRVariable;
0041:        import it.businesslogic.ireport.Report;
0042:        import it.businesslogic.ireport.ReportElement;
0043:        import it.businesslogic.ireport.Style;
0044:        import it.businesslogic.ireport.SubDataset;
0045:        import it.businesslogic.ireport.SubReportElement;
0046:        import it.businesslogic.ireport.TextFieldReportElement;
0047:        import it.businesslogic.ireport.chart.AreaChart;
0048:        import it.businesslogic.ireport.chart.Bar3DChart;
0049:        import it.businesslogic.ireport.chart.BarChart;
0050:        import it.businesslogic.ireport.chart.BubbleChart;
0051:        import it.businesslogic.ireport.chart.CandlestickChart;
0052:        import it.businesslogic.ireport.chart.CategoryDataset;
0053:        import it.businesslogic.ireport.chart.CategoryDatasetPanel;
0054:        import it.businesslogic.ireport.chart.CategorySeriesDialog;
0055:        import it.businesslogic.ireport.chart.Chart;
0056:        import it.businesslogic.ireport.chart.HighLowChart;
0057:        import it.businesslogic.ireport.chart.HighLowDatasetPanel;
0058:        import it.businesslogic.ireport.chart.LineChart;
0059:        import it.businesslogic.ireport.chart.MeterChart;
0060:        import it.businesslogic.ireport.chart.MultiAxisChart;
0061:        import it.businesslogic.ireport.chart.Pie3DChart;
0062:        import it.businesslogic.ireport.chart.PieChart;
0063:        import it.businesslogic.ireport.chart.PieDatasetPanel;
0064:        import it.businesslogic.ireport.chart.ScatterChart;
0065:        import it.businesslogic.ireport.chart.StackedAreaChart;
0066:        import it.businesslogic.ireport.chart.StackedBar3DChart;
0067:        import it.businesslogic.ireport.chart.StackedBarChart;
0068:        import it.businesslogic.ireport.chart.ThermometerChart;
0069:        import it.businesslogic.ireport.chart.TimePeriodDatasetPanel;
0070:        import it.businesslogic.ireport.chart.TimePeriodSeriesDialog;
0071:        import it.businesslogic.ireport.chart.TimeSeriesChart;
0072:        import it.businesslogic.ireport.chart.TimeSeriesDatasetPanel;
0073:        import it.businesslogic.ireport.chart.TimeSeriesDialog;
0074:        import it.businesslogic.ireport.chart.ValueDatasetPanel;
0075:        import it.businesslogic.ireport.chart.XYAreaChart;
0076:        import it.businesslogic.ireport.chart.XYBarChart;
0077:        import it.businesslogic.ireport.chart.XYDatasetPanel;
0078:        import it.businesslogic.ireport.chart.XYLineChart;
0079:        import it.businesslogic.ireport.chart.XYSeriesDialog;
0080:        import it.businesslogic.ireport.chart.XYZDatasetPanel;
0081:        import it.businesslogic.ireport.chart.XYZSeriesDialog;
0082:        import it.businesslogic.ireport.chart.gui.ChartPropertiesDialog;
0083:        import it.businesslogic.ireport.chart.gui.SectionItemHyperlinkPanel;
0084:        import it.businesslogic.ireport.crosstab.CrosstabCell;
0085:        import it.businesslogic.ireport.crosstab.CrosstabGroup;
0086:        import it.businesslogic.ireport.crosstab.gui.CrosstabEditor;
0087:        import it.businesslogic.ireport.crosstab.gui.CrosstabGroupDialog;
0088:        import it.businesslogic.ireport.crosstab.gui.CrosstabParameterDialog;
0089:        import it.businesslogic.ireport.crosstab.gui.MeasureDialog;
0090:        import it.businesslogic.ireport.gui.ElementPropertiesDialog;
0091:        import it.businesslogic.ireport.gui.JRGroupDialog;
0092:        import it.businesslogic.ireport.gui.JRLinkParameterDialog;
0093:        import it.businesslogic.ireport.gui.JRParameterDialog;
0094:        import it.businesslogic.ireport.gui.JRSubreportParameterDialog;
0095:        import it.businesslogic.ireport.gui.JRVariableDialog;
0096:        import it.businesslogic.ireport.gui.JReportFrame;
0097:        import it.businesslogic.ireport.gui.MainFrame;
0098:        import it.businesslogic.ireport.gui.sheet.MeterIntervalDialog;
0099:        import it.businesslogic.ireport.gui.sheet.MeterIntervalsDialog;
0100:        import it.businesslogic.ireport.gui.style.StyleDialog;
0101:        import it.businesslogic.ireport.gui.subdataset.GroupDialog;
0102:        import it.businesslogic.ireport.gui.subdataset.GroupsDialog;
0103:        import it.businesslogic.ireport.gui.subdataset.SubDatasetDialog;
0104:        import java.util.Enumeration;
0105:        import java.util.Vector;
0106:
0107:        /**
0108:         *
0109:         * @author gtoffoli
0110:         * Please not that this class is not thread safe.
0111:         */
0112:        public class ErrorLocator {
0113:
0114:            private String errorString = "";
0115:
0116:            // Update the relative ELEMENTS_CLASS when changing this array!!!
0117:            static final String[] ELEMENTS = new String[] { "break", "line",
0118:                    "rectangle", "ellipse", "image", "staticText", "textField",
0119:                    "subreport", "pieChart", "pie3DChart", "barChart",
0120:                    "bar3DChart", "xyBarChart", "stackedBarChart",
0121:                    "stackedBar3DChart", "lineChart", "xyLineChart",
0122:                    "areaChart", "xyAreaChart", "scatterChart", "bubbleChart",
0123:                    "timeSeriesChart", "highLowChart", "candlestickChart",
0124:                    "meterChart", "thermometerChart", "multiAxisChart",
0125:                    "stackedAreaChart",
0126:                    //"elementGroup",
0127:                    "crosstab", "frame" };
0128:
0129:            static final String[] ELEMENTS_CLASS = new String[] {
0130:                    "BreakReportElement", "LineReportElement",
0131:                    "RectangleReportElement", "EllipseReportElement",
0132:                    "ImageReportElement", "StaticTextReportElement",
0133:                    "TextFieldReportElement", "SubReportElement",
0134:                    "ChartReportElement2", "ChartReportElement2",
0135:                    "ChartReportElement2", "ChartReportElement2",
0136:                    "ChartReportElement2", "ChartReportElement2",
0137:                    "ChartReportElement2", "ChartReportElement2",
0138:                    "ChartReportElement2", "ChartReportElement2",
0139:                    "ChartReportElement2", "ChartReportElement2",
0140:                    "ChartReportElement2", "ChartReportElement2",
0141:                    "ChartReportElement2", "ChartReportElement2",
0142:                    "ChartReportElement2", "ChartReportElement2",
0143:                    "ChartReportElement2", "ChartReportElement2",
0144:                    //"elementGroup",
0145:                    "CrosstabReportElement", "FrameReportElement" };
0146:
0147:            static final String[] BANDS = new String[] { "background", "title",
0148:                    "pageHeader", "pageFooter", "columnHeader", "columnFooter",
0149:                    "detail", "lastPageFooter", "summary" };
0150:
0151:            private JReportFrame jReportFrame = null;
0152:
0153:            /** Creates a new instance of ErrorLocator */
0154:            public ErrorLocator() {
0155:            }
0156:
0157:            /**
0158:             * This method get the index of the first node specified. Please note: node 0 = 1
0159:             * ex:
0160:             *  /variable[1] will return 0
0161:             *  /variable[2] will return 1
0162:             *  /variable will return 0;
0163:             *  /a/b[7] return 0
0164:             *  /a[7] return 6
0165:             *  null return 0
0166:             *  [] return 0
0167:             */
0168:            final public int getNodeIndex(String exp) {
0169:
0170:                if (exp == null || exp.length() == 0)
0171:                    return 0;
0172:                if (exp.startsWith("/"))
0173:                    return getNodeIndex(exp.substring(1));
0174:
0175:                int index = 0;
0176:
0177:                if (exp.indexOf("/") > 0) {
0178:                    return getNodeIndex(exp.substring(0, exp.indexOf("/")));
0179:                }
0180:
0181:                if (exp.indexOf("[") < 0)
0182:                    return 0;
0183:
0184:                try {
0185:                    index = Integer.parseInt(exp.substring(
0186:                            exp.indexOf("[") + 1, exp.lastIndexOf("]")));
0187:                    if (index > 0)
0188:                        index--;
0189:                } catch (Exception ex) {
0190:
0191:                }
0192:
0193:                return index;
0194:            }
0195:
0196:            /**
0197:             * This method get the child node (the next step in the path)
0198:             * ex:
0199:             *  /a/b returns b
0200:             *  a/b  returns b
0201:             *  /    returns ""
0202:             *  /a   returns ""
0203:             *  ""   returns ""
0204:             *  a    returns ""
0205:             *  //b   returns b
0206:             */
0207:            final public String childNode(String exp) {
0208:
0209:                if (exp == null || exp.length() == 0)
0210:                    return "";
0211:                if (exp.startsWith("/"))
0212:                    return childNode(exp.substring(1));
0213:
0214:                if (exp.indexOf("/") > 0) {
0215:                    return exp.substring(exp.indexOf("/"));
0216:                }
0217:
0218:                return "";
0219:            }
0220:
0221:            /**
0222:             * This method get a JReportFrame and an xpath expression and tries to locate the referenced error
0223:             * opening the right windows if necessary and hilighting the error position...
0224:             *
0225:             */
0226:            public void parseError(String xpath, String errormsg) {
0227:                errorString = (errormsg == null) ? "" : errormsg;
0228:
0229:                if (getJReportFrame() == null || xpath == null)
0230:                    return;
0231:
0232:                Report report = getJReportFrame().getReport();
0233:                if (isNode(xpath, "jasperReport")) {
0234:                    parseError(childNode(xpath), errormsg);
0235:                    return;
0236:                }
0237:
0238:                if (isNode(xpath, "field")) {
0239:                    int itemIndex = getNodeIndex(xpath);
0240:                    JRField field = (JRField) report.getFields().get(itemIndex);
0241:
0242:                    // TODO Select the variable in the tree...
0243:                    if (field != null) {
0244:                        MainFrame.getMainInstance().getDocumentStructurePanel()
0245:                                .setSelectedObject(field);
0246:                        MainFrame.getMainInstance().getValuesDialog()
0247:                                .getValuesPanel().modifyField(field, report);
0248:                    }
0249:                } else if (isNode(xpath, "variable")) {
0250:                    int itemIndex = getNodeIndex(xpath);
0251:                    JRVariable var = getVariableAt(report, itemIndex);
0252:
0253:                    // TODO Select the variable in the tree...
0254:                    if (var != null) {
0255:                        MainFrame.getMainInstance().getDocumentStructurePanel()
0256:                                .setSelectedObject(var);
0257:                        parseVariable(report, var, childNode(xpath));
0258:                    }
0259:                } else if (isNode(xpath, "parameter")) {
0260:                    int itemIndex = getNodeIndex(xpath);
0261:                    JRParameter param = getParameterAt(report, itemIndex);
0262:
0263:                    // TODO Select the variable in the tree...
0264:                    if (param != null) {
0265:                        MainFrame.getMainInstance().getDocumentStructurePanel()
0266:                                .setSelectedObject(param);
0267:                        parseParameter(report, param, childNode(xpath));
0268:                    }
0269:                } else if (isNode(xpath, "filterExpression")) {
0270:                    // open the query window...
0271:                    MainFrame.getMainInstance().getReportQueryDialog()
0272:                            .setVisible(true);
0273:                    MainFrame.getMainInstance().getReportQueryDialog()
0274:                            .openFilterExpressionDialog(true);
0275:                } else if (isNode(xpath, "style")) {
0276:                    int itemIndex = getNodeIndex(xpath);
0277:                    Style style = (Style) report.getStyles().get(itemIndex);
0278:                    StyleDialog cd = new StyleDialog(MainFrame
0279:                            .getMainInstance(), true);
0280:                    cd.setStyle(style);
0281:                    xpath = childNode(xpath);
0282:                    if (isNode(xpath, "conditionalStyle")) {
0283:                        itemIndex = getNodeIndex(xpath);
0284:                        String subPath = childNode(xpath);
0285:                        if (isNode(subPath, "conditionExpression")) {
0286:                            cd.setOpenCondition(itemIndex);
0287:                        }
0288:                    }
0289:                    cd.setVisible(true);
0290:                } else if (isNode(xpath, "group")) {
0291:                    int itemIndex = getNodeIndex(xpath);
0292:                    Group group = (Group) report.getGroups().get(itemIndex);
0293:
0294:                    xpath = childNode(xpath);
0295:                    if (isNode(xpath, "groupExpression")) {
0296:
0297:                        MainFrame.getMainInstance().getDocumentStructurePanel()
0298:                                .setSelectedObject(group.getGroupHeader());
0299:                        MainFrame.getMainInstance().getReportSheetPanel()
0300:                                .setPropertyLabelError("groupExpression",
0301:                                        errorString);
0302:
0303:                        /*
0304:                        JRGroupDialog gd = new JRGroupDialog( MainFrame.getMainInstance(),true);
0305:                        gd.setSubdataset( report );
0306:                        gd.setGroup(group);
0307:                        gd.setFocusedExpression( SubDatasetDialog.COMPONENT_FILTER_EXPRESSION );
0308:                        gd.setVisible(true);
0309:                         */
0310:                    } else if (isNode(xpath, "groupHeader")
0311:                            || isNode(xpath, "groupFooter")) {
0312:                        boolean isHeader = isNode(xpath, "groupHeader");
0313:                        xpath = childNode(xpath); // /band
0314:                        xpath = childNode(xpath); // inside the band...
0315:                        parseBand(report, (isHeader) ? group.getGroupHeader()
0316:                                : group.getGroupFooter(), xpath);
0317:                    }
0318:
0319:                } else if (isNode(xpath, "subDataset")) {
0320:                    int itemIndex = getNodeIndex(xpath);
0321:                    SubDataset subdataset = (SubDataset) report
0322:                            .getSubDatasets().get(itemIndex);
0323:                    xpath = childNode(xpath);
0324:
0325:                    parseSubDataset(subdataset, childNode(xpath));
0326:
0327:                } else if (isNode(xpath, BANDS)) {
0328:                    if (xpath.indexOf("[1]") > 0) {
0329:                        String bandName = xpath.substring(1, xpath
0330:                                .indexOf("[1]"));
0331:                        xpath = childNode(xpath); // /band
0332:                        xpath = childNode(xpath); // inside the band...
0333:                        parseBand(report, report.getBandByName(bandName), xpath);
0334:                    }
0335:                }
0336:            }
0337:
0338:            /**
0339:             * Get the variable number "number". Number must be 0 indexed.
0340:             * The method skip all the built-in variables
0341:             */
0342:            private JRVariable getVariableAt(SubDataset ds, int number) {
0343:                Enumeration var_enum = ds.getVariables().elements();
0344:                int count = 0;
0345:                while (var_enum.hasMoreElements()) {
0346:                    JRVariable var = (JRVariable) var_enum.nextElement();
0347:                    if (!var.isBuiltin()) {
0348:                        if (number == count) {
0349:                            return var;
0350:                        }
0351:                        count++;
0352:                    }
0353:                }
0354:
0355:                return null;
0356:            }
0357:
0358:            /**
0359:             * Get the parameter number "number". Number must be 0 indexed.
0360:             * The method skip all the built-in parameters
0361:             */
0362:            private JRParameter getParameterAt(SubDataset ds, int number) {
0363:                Enumeration par_enum = ds.getParameters().elements();
0364:                int count = 0;
0365:                while (par_enum.hasMoreElements()) {
0366:                    JRParameter par = (JRParameter) par_enum.nextElement();
0367:                    if (!par.isBuiltin()) {
0368:                        if (number == count) {
0369:                            return par;
0370:                        }
0371:                        count++;
0372:                    }
0373:                }
0374:
0375:                return null;
0376:            }
0377:
0378:            /**
0379:             * Opens the variable dialog and highlights the bagous expression
0380:             */
0381:            public void parseVariable(SubDataset subDataset,
0382:                    JRVariable variable, String xpath) {
0383:                if (isNode(xpath, "variableExpression")) {
0384:                    MainFrame
0385:                            .getMainInstance()
0386:                            .getValuesDialog()
0387:                            .getValuesPanel()
0388:                            .modifyVariable(
0389:                                    variable,
0390:                                    subDataset,
0391:                                    JRVariableDialog.COMPONENT_VARIABLE_EXPRESSION);
0392:                } else if (isNode(xpath, "initialValueExpression")) {
0393:                    MainFrame
0394:                            .getMainInstance()
0395:                            .getValuesDialog()
0396:                            .getValuesPanel()
0397:                            .modifyVariable(
0398:                                    variable,
0399:                                    subDataset,
0400:                                    JRVariableDialog.COMPONENT_VARIABLE_INIT_EXPRESSION);
0401:                }
0402:            }
0403:
0404:            /**
0405:             * Open the parameter dialog and highlights the bagous expression
0406:             */
0407:            public void parseParameter(SubDataset subDataset,
0408:                    JRParameter param, String xpath) {
0409:                if (isNode(xpath, "defaultValueExpression")) {
0410:                    MainFrame
0411:                            .getMainInstance()
0412:                            .getValuesDialog()
0413:                            .getValuesPanel()
0414:                            .modifyParameter(
0415:                                    param,
0416:                                    subDataset,
0417:                                    JRParameterDialog.COMPONENT_DEFAULT_EXPRESSION);
0418:                } else {
0419:                    MainFrame.getMainInstance().getValuesDialog()
0420:                            .getValuesPanel()
0421:                            .modifyParameter(param, subDataset);
0422:                }
0423:            }
0424:
0425:            public JReportFrame getJReportFrame() {
0426:                return jReportFrame;
0427:            }
0428:
0429:            public void setJReportFrame(JReportFrame jReportFrame) {
0430:                this .jReportFrame = jReportFrame;
0431:            }
0432:
0433:            private void parseSubDataset(SubDataset subdataset, String xpath) {
0434:
0435:                if (isNode(xpath, "filterExpression")) {
0436:                    SubDatasetDialog sdd = new SubDatasetDialog(MainFrame
0437:                            .getMainInstance(), true);
0438:                    sdd.setSubDataset(subdataset);
0439:                    MainFrame.getMainInstance().getDocumentStructurePanel()
0440:                            .setSelectedObject(subdataset);
0441:                    sdd
0442:                            .setFocusedExpression(SubDatasetDialog.COMPONENT_FILTER_EXPRESSION);
0443:                    sdd.setVisible(true);
0444:                } else if (isNode(xpath, "group")) {
0445:                    int itemIndex = getNodeIndex(xpath);
0446:                    Group grp = (Group) subdataset.getGroups().get(itemIndex);
0447:                    //System.out.println("Pre Group child " + xpath);
0448:                    //xpath = childNode(xpath);
0449:
0450:                    if (isNode(xpath, "groupExpression")) {
0451:                        GroupsDialog.modifyGroup(subdataset, grp, MainFrame
0452:                                .getMainInstance(),
0453:                                GroupDialog.COMPONENT_EXPRESSION);
0454:                    }
0455:                }
0456:            }
0457:
0458:            private void parseBand(Report report, Band band, String xpath) {
0459:
0460:                if (isNode(xpath, "printWhenExpression")) {
0461:                    if (this .getJReportFrame().getSelectedCrosstabEditorPanel() != null) {
0462:                        this .getJReportFrame().setSelectedCrosstabEditor(null);
0463:                    }
0464:                    MainFrame.getMainInstance().getDocumentStructurePanel()
0465:                            .setSelectedObject(band);
0466:                    MainFrame.getMainInstance().getReportSheetPanel()
0467:                            .setPropertyLabelError("printWhenExpression",
0468:                                    errorString);
0469:                } else if (isNode(xpath, ELEMENTS)) {
0470:                    // find the right element...
0471:                    Vector bandElements = new Vector();
0472:                    for (int i = 0; i < report.getElements().size(); ++i) {
0473:                        ReportElement bElement = (ReportElement) report
0474:                                .getElements().get(i);
0475:                        if (bElement.getBand() != null
0476:                                && bElement.getBand() == band) {
0477:                            bandElements.add(bElement);
0478:                        }
0479:                    }
0480:                    ReportElement re = findElement(bandElements, xpath);
0481:                    if (re == null)
0482:                        return;
0483:
0484:                    String subXpath = childNode(xpath);
0485:                    if (isNode(subXpath, "reportElement")) {
0486:                        subXpath = childNode(subXpath);
0487:                        parseReportElement(re, subXpath, null);
0488:                    } else if (isNode(subXpath, "chart")) {
0489:                        subXpath = childNode(subXpath);
0490:
0491:                        if (isNode(subXpath, "reportElement")) {
0492:                            subXpath = childNode(subXpath);
0493:                            parseReportElement(re, subXpath, null);
0494:                        } else //if (isNode(subXpath, new String[]{"anchorNameExpression","hyperlinkReferenceExpression","hyperlinkAnchorExpression","hyperlinkPageExpression","hyperlinkTooltipExpression","hyperlinkParameter"}))
0495:                        {
0496:                            parseElement(re, subXpath, null);
0497:                        }
0498:                    } else {
0499:                        parseElement(re, subXpath, null);
0500:                    }
0501:                } else if (isNode(xpath, "elementGroup")) {
0502:                    parseBand(report, band, childNode(xpath));
0503:                }
0504:            }
0505:
0506:            /**
0507:             * parse element specific errors like the content of
0508:             * a crosstab, an image expression, a textfield expression, etc...
0509:             */
0510:            public void parseElement(ReportElement re, String xpath,
0511:                    CrosstabReportElement cre) {
0512:                //String subPath = childNode(xpath);
0513:                if (xpath.length() == 0) {
0514:                    System.out.println("No sub path for xpath " + xpath);
0515:                    if (cre == null) {
0516:                        if (this .getJReportFrame()
0517:                                .getSelectedCrosstabEditorPanel() != null) {
0518:                            this .getJReportFrame().setSelectedCrosstabEditor(
0519:                                    null);
0520:                        }
0521:                        MainFrame.getMainInstance().getDocumentStructurePanel()
0522:                                .setSelectedObject(re);
0523:                    } else {
0524:                        CrosstabEditor ceditor = this .getJReportFrame()
0525:                                .getCrosstabEditor(cre);
0526:                        if (this .getJReportFrame()
0527:                                .getSelectedCrosstabEditorPanel() == null
0528:                                || this .getJReportFrame()
0529:                                        .getSelectedCrosstabEditorPanel() != ceditor
0530:                                        .getPanelEditor()) {
0531:                            this .getJReportFrame().setSelectedCrosstabEditor(
0532:                                    cre);
0533:                        }
0534:                        ceditor.getPanelEditor().setSelectedElement(re);
0535:                    }
0536:                    return;
0537:                }
0538:
0539:                if (re instanceof  HyperLinkableReportElement) {
0540:                    int expressionID = -1;
0541:                    int elementID = -1;
0542:                    int subexpressionID = -1;
0543:
0544:                    if (isNode(xpath, "anchorNameExpression"))
0545:                        expressionID = ElementPropertiesDialog.COMPONENT_ANCHORNAME_EXPRESSION;
0546:                    else if (isNode(xpath, "hyperlinkReferenceExpression"))
0547:                        expressionID = ElementPropertiesDialog.COMPONENT_HYPERLINK_REFERENCE_EXPRESSION;
0548:                    else if (isNode(xpath, "hyperlinkAnchorExpression"))
0549:                        expressionID = ElementPropertiesDialog.COMPONENT_HYPERLINK_ANCHOR_EXPRESSION;
0550:                    else if (isNode(xpath, "hyperlinkPageExpression"))
0551:                        expressionID = ElementPropertiesDialog.COMPONENT_HYPERLINK_PAGE_EXPRESSION;
0552:                    else if (isNode(xpath, "hyperlinkTooltipExpression"))
0553:                        expressionID = ElementPropertiesDialog.COMPONENT_HYPERLINK_TOOLTIP_EXPRESSION;
0554:                    else if (isNode(xpath, "hyperlinkParameter")) {
0555:
0556:                        expressionID = ElementPropertiesDialog.COMPONENT_HYPERLINK_PARAMETERS;
0557:                        elementID = getNodeIndex(xpath);
0558:
0559:                        xpath = childNode(xpath);
0560:                        if (isNode(xpath, "hyperlinkParameterExpression")) {
0561:                            subexpressionID = JRLinkParameterDialog.COMPONENT_PARAM_EXPRESSION;
0562:                        }
0563:                        // ...
0564:                    }
0565:
0566:                    if (expressionID > 0) {
0567:                        if (cre == null) {
0568:                            if (this .getJReportFrame()
0569:                                    .getSelectedCrosstabEditorPanel() != null) {
0570:                                this .getJReportFrame()
0571:                                        .setSelectedCrosstabEditor(null);
0572:                            }
0573:                            MainFrame.getMainInstance()
0574:                                    .getDocumentStructurePanel()
0575:                                    .setSelectedObject(re);
0576:                        } else {
0577:                            CrosstabEditor ceditor = this .getJReportFrame()
0578:                                    .getCrosstabEditor(cre);
0579:                            if (this .getJReportFrame()
0580:                                    .getSelectedCrosstabEditorPanel() == null
0581:                                    || this .getJReportFrame()
0582:                                            .getSelectedCrosstabEditorPanel() != ceditor
0583:                                            .getPanelEditor()) {
0584:                                this .getJReportFrame()
0585:                                        .setSelectedCrosstabEditor(cre);
0586:                            }
0587:                            ceditor.getPanelEditor().setSelectedElement(re);
0588:                        }
0589:                        MainFrame.getMainInstance()
0590:                                .getElementPropertiesDialog().setVisible(true);
0591:                        MainFrame.getMainInstance()
0592:                                .getElementPropertiesDialog()
0593:                                .setFocusedExpression(expressionID, elementID);
0594:                        if (subexpressionID > 0) {
0595:                            MainFrame.getMainInstance()
0596:                                    .getElementPropertiesDialog()
0597:                                    .modifyLinkParameter(subexpressionID);
0598:                        }
0599:                        // path completely resolved
0600:                        return;
0601:                    }
0602:                }
0603:
0604:                if (re instanceof  ImageReportElement) {
0605:                    if (isNode(xpath, "imageExpression")) {
0606:                        if (cre == null) {
0607:                            if (this .getJReportFrame()
0608:                                    .getSelectedCrosstabEditorPanel() != null) {
0609:                                this .getJReportFrame()
0610:                                        .setSelectedCrosstabEditor(null);
0611:                            }
0612:                            MainFrame.getMainInstance()
0613:                                    .getDocumentStructurePanel()
0614:                                    .setSelectedObject(re);
0615:                            MainFrame.getMainInstance().getReportSheetPanel()
0616:                                    .setPropertyLabelError("imageExpression",
0617:                                            errorString);
0618:                        } else {
0619:                            CrosstabEditor ceditor = this .getJReportFrame()
0620:                                    .getCrosstabEditor(cre);
0621:                            if (this .getJReportFrame()
0622:                                    .getSelectedCrosstabEditorPanel() == null
0623:                                    || this .getJReportFrame()
0624:                                            .getSelectedCrosstabEditorPanel() != ceditor
0625:                                            .getPanelEditor()) {
0626:                                this .getJReportFrame()
0627:                                        .setSelectedCrosstabEditor(cre);
0628:                            }
0629:                            ceditor.getPanelEditor().setSelectedElement(re);
0630:                            MainFrame.getMainInstance().getReportSheetPanel()
0631:                                    .setPropertyLabelError("imageExpression",
0632:                                            errorString);
0633:                        }
0634:                    }
0635:                } else if (re instanceof  TextFieldReportElement) {
0636:                    if (isNode(xpath, "textFieldExpression")) {
0637:                        if (cre == null) {
0638:                            if (this .getJReportFrame()
0639:                                    .getSelectedCrosstabEditorPanel() != null) {
0640:                                this .getJReportFrame()
0641:                                        .setSelectedCrosstabEditor(null);
0642:                            }
0643:                            MainFrame.getMainInstance()
0644:                                    .getDocumentStructurePanel()
0645:                                    .setSelectedObject(re);
0646:                            MainFrame.getMainInstance().getReportSheetPanel()
0647:                                    .setPropertyLabelError(
0648:                                            "textfieldExpression", errorString);
0649:                        } else {
0650:                            CrosstabEditor ceditor = this .getJReportFrame()
0651:                                    .getCrosstabEditor(cre);
0652:                            if (this .getJReportFrame()
0653:                                    .getSelectedCrosstabEditorPanel() == null
0654:                                    || this .getJReportFrame()
0655:                                            .getSelectedCrosstabEditorPanel() != ceditor
0656:                                            .getPanelEditor()) {
0657:                                this .getJReportFrame()
0658:                                        .setSelectedCrosstabEditor(cre);
0659:                            }
0660:                            ceditor.getPanelEditor().setSelectedElement(re);
0661:                            MainFrame.getMainInstance().getReportSheetPanel()
0662:                                    .setPropertyLabelError(
0663:                                            "textfieldExpression", errorString);
0664:                        }
0665:                    }
0666:                } else if (re instanceof  ChartReportElement2) {
0667:                    if (this .getJReportFrame().getSelectedCrosstabEditorPanel() != null) {
0668:                        this .getJReportFrame().setSelectedCrosstabEditor(null);
0669:                    }
0670:                    MainFrame.getMainInstance().getDocumentStructurePanel()
0671:                            .setSelectedObject(re);
0672:
0673:                    boolean openChartFrame = false;
0674:                    String errorLabel = null;
0675:                    Object[] expressionInfo = null;
0676:
0677:                    if (isNode(xpath, "chartTitle")) {
0678:                        xpath = childNode(xpath);
0679:                        if (isNode(xpath, "titleExpression")) {
0680:                            openChartFrame = true;
0681:                            errorLabel = "chartTitle";
0682:                        }
0683:                    } else if (isNode(xpath, "chartSubtitle")) {
0684:                        xpath = childNode(xpath);
0685:                        if (isNode(xpath, "subtitleExpression")) {
0686:                            openChartFrame = true;
0687:                            errorLabel = "chartSubTitle";
0688:                        }
0689:                    } else if (isNode(xpath, "barPlot")) {
0690:                        xpath = childNode(xpath);
0691:                        if (isNode(xpath, "categoryAxisLabelExpression")) {
0692:                            errorLabel = "categoryAxisLabelExpressionBarPlot";
0693:                        } else if (isNode(xpath, "valueAxisLabelExpression")) {
0694:                            errorLabel = "valueAxisLabelExpressionBarPlot";
0695:                        }
0696:                        openChartFrame = true;
0697:                    } else if (isNode(xpath, "bar3DPlot")) {
0698:                        xpath = childNode(xpath);
0699:                        if (isNode(xpath, "categoryAxisLabelExpression")) {
0700:                            errorLabel = "categoryAxisLabelExpressionBar3DPlot";
0701:                        } else if (isNode(xpath, "valueAxisLabelExpression")) {
0702:                            errorLabel = "valueAxisLabelExpressionBar3DPlot";
0703:                        }
0704:                        openChartFrame = true;
0705:                    } else if (isNode(xpath, "linePlot")) {
0706:                        xpath = childNode(xpath);
0707:                        if (isNode(xpath, "categoryAxisLabelExpression")) {
0708:                            errorLabel = "categoryAxisLabelExpressionLinePlot";
0709:                        } else if (isNode(xpath, "valueAxisLabelExpression")) {
0710:                            errorLabel = "valueAxisLabelExpressionLinePlot";
0711:                        }
0712:                        openChartFrame = true;
0713:                    } else if (isNode(xpath, "areaPlot")) {
0714:                        xpath = childNode(xpath);
0715:                        if (isNode(xpath, "categoryAxisLabelExpression")) {
0716:                            errorLabel = "categoryAxisLabelExpressionAreaPlot";
0717:                        } else if (isNode(xpath, "valueAxisLabelExpression")) {
0718:                            errorLabel = "valueAxisLabelExpressionAreaPlot";
0719:                        }
0720:                        openChartFrame = true;
0721:                    } else if (isNode(xpath, "scatterPlot")) {
0722:                        xpath = childNode(xpath);
0723:                        if (isNode(xpath, "xAxisLabelExpression")) {
0724:                            errorLabel = "xAxisLabelExpressionScatterPlot";
0725:                        } else if (isNode(xpath, "yAxisLabelExpression")) {
0726:                            errorLabel = "yAxisLabelExpressionScatterPlot";
0727:                        }
0728:                        openChartFrame = true;
0729:                    } else if (isNode(xpath, "bubblePlot")) {
0730:                        xpath = childNode(xpath);
0731:                        if (isNode(xpath, "xAxisLabelExpression")) {
0732:                            errorLabel = "xAxisLabelExpressionBubblePlot";
0733:                        } else if (isNode(xpath, "yAxisLabelExpression")) {
0734:                            errorLabel = "yAxisLabelExpressionBubblePlot";
0735:                        }
0736:                        openChartFrame = true;
0737:                    } else if (isNode(xpath, "timeSeriesPlot")) {
0738:                        xpath = childNode(xpath);
0739:                        if (isNode(xpath, "timeAxisLabelExpression")) {
0740:                            errorLabel = "timeAxisLabelExpressionTimeSeriesPlot";
0741:                        } else if (isNode(xpath, "valueAxisLabelExpression")) {
0742:                            errorLabel = "valueAxisLabelExpressionTimeSeriesPlot";
0743:                        }
0744:                        openChartFrame = true;
0745:                    } else if (isNode(xpath, "highLowPlot")) {
0746:                        xpath = childNode(xpath);
0747:                        if (isNode(xpath, "timeAxisLabelExpression")) {
0748:                            errorLabel = "timeAxisLabelExpressionHighLowPlot";
0749:                        } else if (isNode(xpath, "valueAxisLabelExpression")) {
0750:                            errorLabel = "valueAxisLabelExpressionHighLowPlot";
0751:                        }
0752:                        openChartFrame = true;
0753:                    } else if (isNode(xpath, "candlestickPlot")) {
0754:                        xpath = childNode(xpath);
0755:                        if (isNode(xpath, "timeAxisLabelExpression")) {
0756:                            errorLabel = "timeAxisLabelExpressionCandlestickPlot";
0757:                        } else if (isNode(xpath, "valueAxisLabelExpression")) {
0758:                            errorLabel = "valueAxisLabelExpressionCandlestickPlot";
0759:                        }
0760:                        openChartFrame = true;
0761:                    } else if (isNode(xpath, "meterPlot")) {
0762:                        xpath = childNode(xpath);
0763:                        if (isNode(xpath, "dataRange")) {
0764:                            xpath = childNode(xpath);
0765:                            if (isNode(xpath, "lowExpression")) {
0766:                                errorLabel = "dataRangeLowExpressionMeterPlot";
0767:                            } else if (isNode(xpath, "highExpression")) {
0768:                                errorLabel = "dataRangeHighExpressionMeterPlot";
0769:                            }
0770:                        } else if (isNode(xpath, "meterInterval")) {
0771:                            int intervalIndex = getNodeIndex(xpath);
0772:                            expressionInfo = new Object[] {
0773:                                    new Integer(
0774:                                            ChartPropertiesDialog.COMPONENT_METER_INTERVALS),
0775:                                    errorString,
0776:                                    new Integer(
0777:                                            MeterIntervalsDialog.COMPONENT_INTERVALS_LIST),
0778:                                    new Integer(intervalIndex), };
0779:
0780:                            xpath = childNode(xpath);
0781:                            if (isNode(xpath, "dataRange")) {
0782:                                xpath = childNode(xpath);
0783:                                if (isNode(xpath, "lowExpression"))
0784:                                    expressionInfo = appendToArray(
0785:                                            expressionInfo,
0786:                                            new Integer(
0787:                                                    MeterIntervalDialog.COMPONENT_LOW_EXPRESSION));
0788:                                else if (isNode(xpath, "highExpression"))
0789:                                    expressionInfo = appendToArray(
0790:                                            expressionInfo,
0791:                                            new Integer(
0792:                                                    MeterIntervalDialog.COMPONENT_HIGH_EXPRESSION));
0793:                                else
0794:                                    expressionInfo = appendToArray(
0795:                                            expressionInfo,
0796:                                            new Integer(
0797:                                                    MeterIntervalDialog.COMPONENT_NONE));
0798:
0799:                            } else {
0800:                                expressionInfo = appendToArray(
0801:                                        expressionInfo,
0802:                                        new Integer(
0803:                                                MeterIntervalDialog.COMPONENT_NONE));
0804:                            }
0805:
0806:                            //    errorLabel = "timeAxisLabelExpressionCandlestickPlot";
0807:                        }
0808:                        openChartFrame = true;
0809:                    } else if (isNode(xpath, "thermometerPlot")) {
0810:                        xpath = childNode(xpath);
0811:                        if (isNode(xpath, "dataRange")) {
0812:                            xpath = childNode(xpath);
0813:                            if (isNode(xpath, "lowExpression")) {
0814:                                errorLabel = "dataRangeLowExpressionThermometerPlot";
0815:                            } else if (isNode(xpath, "highExpression")) {
0816:                                errorLabel = "dataRangeHighExpressionThermometerPlot";
0817:                            }
0818:                        } else if (isNode(xpath, "lowRange")) {
0819:                            xpath = childNode(xpath);
0820:                            if (isNode(xpath, "dataRange")) {
0821:                                xpath = childNode(xpath);
0822:                                if (isNode(xpath, "lowExpression")) {
0823:                                    errorLabel = "lowRangeLowExpressionThermometerPlot";
0824:                                } else if (isNode(xpath, "highExpression")) {
0825:                                    errorLabel = "lowRangeHighExpressionThermometerPlot";
0826:                                }
0827:                            }
0828:                        } else if (isNode(xpath, "mediumRange")) {
0829:                            xpath = childNode(xpath);
0830:                            if (isNode(xpath, "dataRange")) {
0831:                                xpath = childNode(xpath);
0832:                                if (isNode(xpath, "lowExpression")) {
0833:                                    errorLabel = "mediumRangeLowExpressionThermometerPlot";
0834:                                } else if (isNode(xpath, "highExpression")) {
0835:                                    errorLabel = "mediumRangeHighExpressionThermometerPlot";
0836:                                }
0837:                            }
0838:                        } else if (isNode(xpath, "highRange")) {
0839:                            xpath = childNode(xpath);
0840:                            if (isNode(xpath, "dataRange")) {
0841:                                xpath = childNode(xpath);
0842:                                if (isNode(xpath, "lowExpression")) {
0843:                                    errorLabel = "highRangeLowExpressionThermometerPlot";
0844:                                } else if (isNode(xpath, "highExpression")) {
0845:                                    errorLabel = "highRangeHighExpressionThermometerPlot";
0846:                                }
0847:                            }
0848:                        }
0849:                        openChartFrame = true;
0850:                    } else if (isNode(xpath, "pieDataset")) {
0851:                        xpath = childNode(xpath);
0852:
0853:                        if (isNode(xpath, "dataset")) {
0854:                            xpath = childNode(xpath);
0855:                            expressionInfo = parseDataset(xpath);
0856:                        } else if (isNode(xpath, "keyExpression")) {
0857:                            expressionInfo = new Object[] {
0858:                                    new Integer(
0859:                                            ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION),
0860:                                    new Integer(
0861:                                            PieDatasetPanel.COMPONENT_KEY_EXPRESSION) };
0862:                        } else if (isNode(xpath, "valueExpression")) {
0863:                            expressionInfo = new Object[] {
0864:                                    new Integer(
0865:                                            ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION),
0866:                                    new Integer(
0867:                                            PieDatasetPanel.COMPONENT_VALUE_EXPRESSION) };
0868:                        } else if (isNode(xpath, "labelExpression")) {
0869:                            expressionInfo = new Object[] {
0870:                                    new Integer(
0871:                                            ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION),
0872:                                    new Integer(
0873:                                            PieDatasetPanel.COMPONENT_LABEL_EXPRESSION) };
0874:                        } else if (isNode(xpath, "sectionHyperlink")) {
0875:                            xpath = childNode(xpath);
0876:                            expressionInfo = new Object[] {
0877:                                    new Integer(
0878:                                            ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION),
0879:                                    new Integer(
0880:                                            PieDatasetPanel.COMPONENT_HYPERLINK) };
0881:
0882:                            expressionInfo = addSectionHyperlinkExpressionsInfo(
0883:                                    expressionInfo, xpath);
0884:                        }
0885:
0886:                    } else if (isNode(xpath, "categoryDataset")) {
0887:                        xpath = childNode(xpath);
0888:                        expressionInfo = new Object[] { new Integer(
0889:                                ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION) };
0890:
0891:                        if (isNode(xpath, "dataset")) {
0892:                            xpath = childNode(xpath);
0893:                            expressionInfo = parseDataset(xpath);
0894:                        } else if (isNode(xpath, "categorySeries")) {
0895:                            expressionInfo = appendToArray(
0896:                                    expressionInfo,
0897:                                    new Integer(
0898:                                            CategoryDatasetPanel.COMPONENT_CATEGORY_SERIES_LIST));
0899:                            expressionInfo = appendToArray(expressionInfo,
0900:                                    new Integer(getNodeIndex(xpath)));
0901:                            xpath = childNode(xpath);
0902:                            if (isNode(xpath, "seriesExpression")) {
0903:                                expressionInfo = appendToArray(
0904:                                        expressionInfo,
0905:                                        new Integer(
0906:                                                CategorySeriesDialog.COMPONENT_SERIES_EXPRESSION));
0907:                            } else if (isNode(xpath, "categoryExpression")) {
0908:                                expressionInfo = appendToArray(
0909:                                        expressionInfo,
0910:                                        new Integer(
0911:                                                CategorySeriesDialog.COMPONENT_CATEGORY_EXPRESSION));
0912:                            } else if (isNode(xpath, "valueExpression")) {
0913:                                expressionInfo = appendToArray(
0914:                                        expressionInfo,
0915:                                        new Integer(
0916:                                                CategorySeriesDialog.COMPONENT_VALUE_EXPRESSION));
0917:                            } else if (isNode(xpath, "labelExpression")) {
0918:                                expressionInfo = appendToArray(
0919:                                        expressionInfo,
0920:                                        new Integer(
0921:                                                CategorySeriesDialog.COMPONENT_LABEL_EXPRESSION));
0922:                            } else if (isNode(xpath, "itemHyperlink")) {
0923:                                xpath = childNode(xpath);
0924:                                expressionInfo = appendToArray(
0925:                                        expressionInfo,
0926:                                        new Integer(
0927:                                                CategorySeriesDialog.COMPONENT_HYPERLINK));
0928:                                expressionInfo = addSectionHyperlinkExpressionsInfo(
0929:                                        expressionInfo, xpath);
0930:                            }
0931:                        }
0932:                    } else if (isNode(xpath, "timePeriodDataset")) {
0933:                        xpath = childNode(xpath);
0934:                        expressionInfo = new Object[] { new Integer(
0935:                                ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION) };
0936:
0937:                        if (isNode(xpath, "dataset")) {
0938:                            xpath = childNode(xpath);
0939:                            expressionInfo = parseDataset(xpath);
0940:                        } else if (isNode(xpath, "timePeriodSeries")) {
0941:                            expressionInfo = appendToArray(
0942:                                    expressionInfo,
0943:                                    new Integer(
0944:                                            TimePeriodDatasetPanel.COMPONENT_PERIOD_SERIES_LIST));
0945:                            expressionInfo = appendToArray(expressionInfo,
0946:                                    new Integer(getNodeIndex(xpath)));
0947:                            xpath = childNode(xpath);
0948:                            if (isNode(xpath, "seriesExpression")) {
0949:                                expressionInfo = appendToArray(
0950:                                        expressionInfo,
0951:                                        new Integer(
0952:                                                TimePeriodSeriesDialog.COMPONENT_SERIES_EXPRESSION));
0953:                            } else if (isNode(xpath, "startDateExpression")) {
0954:                                expressionInfo = appendToArray(
0955:                                        expressionInfo,
0956:                                        new Integer(
0957:                                                TimePeriodSeriesDialog.COMPONENT_START_DATE_EXPRESSION));
0958:                            } else if (isNode(xpath, "endDateExpression")) {
0959:                                expressionInfo = appendToArray(
0960:                                        expressionInfo,
0961:                                        new Integer(
0962:                                                TimePeriodSeriesDialog.COMPONENT_END_DATE_EXPRESSION));
0963:                            } else if (isNode(xpath, "valueExpression")) {
0964:                                expressionInfo = appendToArray(
0965:                                        expressionInfo,
0966:                                        new Integer(
0967:                                                TimePeriodSeriesDialog.COMPONENT_VALUE_EXPRESSION));
0968:                            } else if (isNode(xpath, "labelExpression")) {
0969:                                expressionInfo = appendToArray(
0970:                                        expressionInfo,
0971:                                        new Integer(
0972:                                                TimePeriodSeriesDialog.COMPONENT_LABEL_EXPRESSION));
0973:                            } else if (isNode(xpath, "itemHyperlink")) {
0974:                                xpath = childNode(xpath);
0975:                                expressionInfo = appendToArray(
0976:                                        expressionInfo,
0977:                                        new Integer(
0978:                                                TimePeriodSeriesDialog.COMPONENT_HYPERLINK));
0979:                                expressionInfo = addSectionHyperlinkExpressionsInfo(
0980:                                        expressionInfo, xpath);
0981:                            }
0982:                        }
0983:                    } else if (isNode(xpath, "xyDataset")) {
0984:                        xpath = childNode(xpath);
0985:                        expressionInfo = new Object[] { new Integer(
0986:                                ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION) };
0987:
0988:                        if (isNode(xpath, "dataset")) {
0989:                            xpath = childNode(xpath);
0990:                            expressionInfo = parseDataset(xpath);
0991:                        } else if (isNode(xpath, "xySeries")) {
0992:                            expressionInfo = appendToArray(expressionInfo,
0993:                                    new Integer(
0994:                                            XYDatasetPanel.COMPONENT_XY_LIST));
0995:                            expressionInfo = appendToArray(expressionInfo,
0996:                                    new Integer(getNodeIndex(xpath)));
0997:                            xpath = childNode(xpath);
0998:                            if (isNode(xpath, "seriesExpression")) {
0999:                                expressionInfo = appendToArray(
1000:                                        expressionInfo,
1001:                                        new Integer(
1002:                                                XYSeriesDialog.COMPONENT_SERIES_EXPRESSION));
1003:                            } else if (isNode(xpath, "xValueExpression")) {
1004:                                expressionInfo = appendToArray(
1005:                                        expressionInfo,
1006:                                        new Integer(
1007:                                                XYSeriesDialog.COMPONENT_X_EXPRESSION));
1008:                            } else if (isNode(xpath, "yValueExpression")) {
1009:                                expressionInfo = appendToArray(
1010:                                        expressionInfo,
1011:                                        new Integer(
1012:                                                XYSeriesDialog.COMPONENT_Y_EXPRESSION));
1013:                            } else if (isNode(xpath, "labelExpression")) {
1014:                                expressionInfo = appendToArray(
1015:                                        expressionInfo,
1016:                                        new Integer(
1017:                                                XYSeriesDialog.COMPONENT_LABEL_EXPRESSION));
1018:                            } else if (isNode(xpath, "itemHyperlink")) {
1019:                                xpath = childNode(xpath);
1020:                                expressionInfo = appendToArray(
1021:                                        expressionInfo,
1022:                                        new Integer(
1023:                                                XYSeriesDialog.COMPONENT_HYPERLINK));
1024:                                expressionInfo = addSectionHyperlinkExpressionsInfo(
1025:                                        expressionInfo, xpath);
1026:                            }
1027:                        }
1028:                    } else if (isNode(xpath, "xyzDataset")) {
1029:                        xpath = childNode(xpath);
1030:                        expressionInfo = new Object[] { new Integer(
1031:                                ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION) };
1032:
1033:                        if (isNode(xpath, "dataset")) {
1034:                            xpath = childNode(xpath);
1035:                            expressionInfo = parseDataset(xpath);
1036:                        } else if (isNode(xpath, "xyzSeries")) {
1037:                            expressionInfo = appendToArray(expressionInfo,
1038:                                    new Integer(
1039:                                            XYZDatasetPanel.COMPONENT_XYZ_LIST));
1040:                            expressionInfo = appendToArray(expressionInfo,
1041:                                    new Integer(getNodeIndex(xpath)));
1042:                            xpath = childNode(xpath);
1043:                            if (isNode(xpath, "seriesExpression")) {
1044:                                expressionInfo = appendToArray(
1045:                                        expressionInfo,
1046:                                        new Integer(
1047:                                                XYZSeriesDialog.COMPONENT_SERIES_EXPRESSION));
1048:                            } else if (isNode(xpath, "xValueExpression")) {
1049:                                expressionInfo = appendToArray(
1050:                                        expressionInfo,
1051:                                        new Integer(
1052:                                                XYZSeriesDialog.COMPONENT_X_EXPRESSION));
1053:                            } else if (isNode(xpath, "yValueExpression")) {
1054:                                expressionInfo = appendToArray(
1055:                                        expressionInfo,
1056:                                        new Integer(
1057:                                                XYZSeriesDialog.COMPONENT_Y_EXPRESSION));
1058:                            } else if (isNode(xpath, "zValueExpression")) {
1059:                                expressionInfo = appendToArray(
1060:                                        expressionInfo,
1061:                                        new Integer(
1062:                                                XYZSeriesDialog.COMPONENT_Z_EXPRESSION));
1063:                            } else if (isNode(xpath, "itemHyperlink")) {
1064:                                xpath = childNode(xpath);
1065:                                expressionInfo = appendToArray(
1066:                                        expressionInfo,
1067:                                        new Integer(
1068:                                                XYZSeriesDialog.COMPONENT_HYPERLINK));
1069:                                expressionInfo = addSectionHyperlinkExpressionsInfo(
1070:                                        expressionInfo, xpath);
1071:                            }
1072:                        }
1073:                    } else if (isNode(xpath, "timeSeriesDataset")) {
1074:                        xpath = childNode(xpath);
1075:                        expressionInfo = new Object[] { new Integer(
1076:                                ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION) };
1077:
1078:                        if (isNode(xpath, "dataset")) {
1079:                            xpath = childNode(xpath);
1080:                            expressionInfo = parseDataset(xpath);
1081:                        } else if (isNode(xpath, "timeSeries")) {
1082:                            expressionInfo = appendToArray(
1083:                                    expressionInfo,
1084:                                    new Integer(
1085:                                            TimeSeriesDatasetPanel.COMPONENT_TIME_SERIES_LIST));
1086:                            expressionInfo = appendToArray(expressionInfo,
1087:                                    new Integer(getNodeIndex(xpath)));
1088:                            xpath = childNode(xpath);
1089:                            if (isNode(xpath, "seriesExpression")) {
1090:                                expressionInfo = appendToArray(
1091:                                        expressionInfo,
1092:                                        new Integer(
1093:                                                TimeSeriesDialog.COMPONENT_SERIES_EXPRESSION));
1094:                            } else if (isNode(xpath, "timePeriodExpression")) {
1095:                                expressionInfo = appendToArray(
1096:                                        expressionInfo,
1097:                                        new Integer(
1098:                                                TimeSeriesDialog.COMPONENT_TIME_EXPRESSION));
1099:                            } else if (isNode(xpath, "valueExpression")) {
1100:                                expressionInfo = appendToArray(
1101:                                        expressionInfo,
1102:                                        new Integer(
1103:                                                TimeSeriesDialog.COMPONENT_VALUE_EXPRESSION));
1104:                            } else if (isNode(xpath, "labelExpression")) {
1105:                                expressionInfo = appendToArray(
1106:                                        expressionInfo,
1107:                                        new Integer(
1108:                                                TimeSeriesDialog.COMPONENT_LABEL_EXPRESSION));
1109:                            } else if (isNode(xpath, "itemHyperlink")) {
1110:                                xpath = childNode(xpath);
1111:                                expressionInfo = appendToArray(
1112:                                        expressionInfo,
1113:                                        new Integer(
1114:                                                TimeSeriesDialog.COMPONENT_HYPERLINK));
1115:                                expressionInfo = addSectionHyperlinkExpressionsInfo(
1116:                                        expressionInfo, xpath);
1117:                            }
1118:                        }
1119:                    } else if (isNode(xpath, "highLowDataset")) {
1120:                        xpath = childNode(xpath);
1121:                        expressionInfo = new Object[] { new Integer(
1122:                                ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION) };
1123:
1124:                        if (isNode(xpath, "dataset")) {
1125:                            xpath = childNode(xpath);
1126:                            expressionInfo = parseDataset(xpath);
1127:                        } else if (isNode(xpath, "seriesExpression")) {
1128:                            expressionInfo = appendToArray(
1129:                                    expressionInfo,
1130:                                    new Integer(
1131:                                            HighLowDatasetPanel.COMPONENT_SERIES_EXPRESSION));
1132:                        } else if (isNode(xpath, "seriesExpression")) {
1133:                            expressionInfo = appendToArray(
1134:                                    expressionInfo,
1135:                                    new Integer(
1136:                                            HighLowDatasetPanel.COMPONENT_SERIES_EXPRESSION));
1137:                        } else if (isNode(xpath, "dateExpression")) {
1138:                            expressionInfo = appendToArray(
1139:                                    expressionInfo,
1140:                                    new Integer(
1141:                                            HighLowDatasetPanel.COMPONENT_DATA_EXPRESSION));
1142:                        } else if (isNode(xpath, "highExpression")) {
1143:                            expressionInfo = appendToArray(
1144:                                    expressionInfo,
1145:                                    new Integer(
1146:                                            HighLowDatasetPanel.COMPONENT_HIGH_EXPRESSION));
1147:                        } else if (isNode(xpath, "lowExpression")) {
1148:                            expressionInfo = appendToArray(
1149:                                    expressionInfo,
1150:                                    new Integer(
1151:                                            HighLowDatasetPanel.COMPONENT_LOW_EXPRESSION));
1152:                        } else if (isNode(xpath, "openExpression")) {
1153:                            expressionInfo = appendToArray(
1154:                                    expressionInfo,
1155:                                    new Integer(
1156:                                            HighLowDatasetPanel.COMPONENT_OPEN_EXPRESSION));
1157:                        } else if (isNode(xpath, "closeExpression")) {
1158:                            expressionInfo = appendToArray(
1159:                                    expressionInfo,
1160:                                    new Integer(
1161:                                            HighLowDatasetPanel.COMPONENT_CLOSE_EXPRESSION));
1162:                        } else if (isNode(xpath, "volumeExpression")) {
1163:                            expressionInfo = appendToArray(
1164:                                    expressionInfo,
1165:                                    new Integer(
1166:                                            HighLowDatasetPanel.COMPONENT_VOLUME_EXPRESSION));
1167:                        } else if (isNode(xpath, "itemHyperlink")) {
1168:                            xpath = childNode(xpath);
1169:                            expressionInfo = appendToArray(
1170:                                    expressionInfo,
1171:                                    new Integer(
1172:                                            HighLowDatasetPanel.COMPONENT_HYPERLINK));
1173:                            expressionInfo = addSectionHyperlinkExpressionsInfo(
1174:                                    expressionInfo, xpath);
1175:                        }
1176:                    } else if (isNode(xpath, "valueDataset")) {
1177:                        xpath = childNode(xpath);
1178:                        expressionInfo = new Object[] { new Integer(
1179:                                ChartPropertiesDialog.COMPONENT_DATASET_SPECIFIC_EXPRESSION) };
1180:
1181:                        if (isNode(xpath, "dataset")) {
1182:                            xpath = childNode(xpath);
1183:                            expressionInfo = parseDataset(xpath);
1184:                        } else if (isNode(xpath, "valueExpression")) {
1185:                            expressionInfo = appendToArray(
1186:                                    expressionInfo,
1187:                                    new Integer(
1188:                                            ValueDatasetPanel.COMPONENT_VALUE_EXPRESSION));
1189:                        }
1190:                    }
1191:
1192:                    if (openChartFrame || expressionInfo != null) {
1193:                        it.businesslogic.ireport.chart.gui.ChartPropertiesDialog cpd = new it.businesslogic.ireport.chart.gui.ChartPropertiesDialog(
1194:                                MainFrame.getMainInstance(), true);
1195:
1196:                        try {
1197:                            cpd.setJReportFrame(getJReportFrame());
1198:                            cpd.setChartElement((ChartReportElement2) re);
1199:                            if (errorLabel != null) {
1200:                                cpd.setPropertyLabelError(errorLabel,
1201:                                        errorString);
1202:                            } else if (expressionInfo != null) {
1203:                                cpd.setFocusedExpression(expressionInfo);
1204:                            }
1205:                            cpd.setVisible(true);
1206:                        } catch (Exception ex) {
1207:                            ex.printStackTrace();
1208:                        }
1209:                    }
1210:                } else if (re instanceof  SubReportElement) {
1211:                    int expressionID = -1;
1212:                    int elementID = -1;
1213:                    int subexpressionID = -1;
1214:
1215:                    if (isNode(xpath, "parametersMapExpression"))
1216:                        expressionID = ElementPropertiesDialog.COMPONENT_SUBREPORT_MAP_EXPRESSION;
1217:                    else if (isNode(xpath, "connectionExpression"))
1218:                        expressionID = ElementPropertiesDialog.COMPONENT_SUBREPORT_DS_CONN_EXPRESSION;
1219:                    else if (isNode(xpath, "dataSourceExpression"))
1220:                        expressionID = ElementPropertiesDialog.COMPONENT_SUBREPORT_DS_CONN_EXPRESSION;
1221:                    else if (isNode(xpath, "subreportExpression"))
1222:                        expressionID = ElementPropertiesDialog.COMPONENT_SUBREPORT_EXPRESSION;
1223:                    else if (isNode(xpath, "subreportParameter")) {
1224:
1225:                        expressionID = ElementPropertiesDialog.COMPONENT_SUBREPORT_PARAMETERS;
1226:                        elementID = getNodeIndex(xpath);
1227:
1228:                        xpath = childNode(xpath);
1229:                        if (isNode(xpath, "subreportParameterExpression")) {
1230:                            subexpressionID = JRSubreportParameterDialog.COMPONENT_PARAM_EXPRESSION;
1231:                        }
1232:                        // ...
1233:                    } else if (isNode(xpath, "returnValue")) {
1234:
1235:                        expressionID = ElementPropertiesDialog.COMPONENT_SUBREPORT_RETURN_VALUES;
1236:                        elementID = getNodeIndex(xpath);
1237:
1238:                        //xpath = childNode(xpath);
1239:                        //if (isNode(xpath, "hyperlinkParameterExpression"))
1240:                        // {
1241:                        //    subexpressionID = JRLinkParameterDialog.COMPONENT_PARAM_EXPRESSION;
1242:                        // }
1243:                        // ...
1244:                    }
1245:
1246:                    if (expressionID > 0) {
1247:                        if (cre == null) {
1248:                            if (this .getJReportFrame()
1249:                                    .getSelectedCrosstabEditorPanel() != null) {
1250:                                this .getJReportFrame()
1251:                                        .setSelectedCrosstabEditor(null);
1252:                            }
1253:                            MainFrame.getMainInstance()
1254:                                    .getDocumentStructurePanel()
1255:                                    .setSelectedObject(re);
1256:                        } else {
1257:                            CrosstabEditor ceditor = this .getJReportFrame()
1258:                                    .getCrosstabEditor(cre);
1259:                            if (this .getJReportFrame()
1260:                                    .getSelectedCrosstabEditorPanel() == null
1261:                                    || this .getJReportFrame()
1262:                                            .getSelectedCrosstabEditorPanel() != ceditor
1263:                                            .getPanelEditor()) {
1264:                                this .getJReportFrame()
1265:                                        .setSelectedCrosstabEditor(cre);
1266:                            }
1267:                            ceditor.getPanelEditor().setSelectedElement(re);
1268:                        }
1269:                        MainFrame.getMainInstance()
1270:                                .getElementPropertiesDialog().setVisible(true);
1271:                        MainFrame.getMainInstance()
1272:                                .getElementPropertiesDialog()
1273:                                .setFocusedExpression(expressionID, elementID);
1274:                        if (subexpressionID > 0) {
1275:                            MainFrame.getMainInstance()
1276:                                    .getElementPropertiesDialog()
1277:                                    .modifySubreportParameter(subexpressionID);
1278:                        }
1279:                    }
1280:                } else if (re instanceof  CrosstabReportElement) {
1281:                    int expressionID = -1;
1282:                    int elementID = -1;
1283:                    int subexpressionID = -1;
1284:
1285:                    if (isNode(xpath, "parametersMapExpression"))
1286:                        expressionID = ElementPropertiesDialog.COMPONENT_CROSSTAB_MAP_EXPRESSION;
1287:                    else if (isNode(xpath, "crosstabParameter")) {
1288:
1289:                        expressionID = ElementPropertiesDialog.COMPONENT_CROSSTAB_PARAMETERS;
1290:                        elementID = getNodeIndex(xpath);
1291:
1292:                        xpath = childNode(xpath);
1293:                        if (isNode(xpath, "parameterValueExpression")) {
1294:                            subexpressionID = CrosstabParameterDialog.COMPONENT_PARAM_EXPRESSION;
1295:                        }
1296:                        // ...
1297:                    } else if (xpath.indexOf("/cellContents") >= 0) // check if we are working with the content of a cell...
1298:                    {
1299:                        String cellContentPath = xpath.substring(xpath
1300:                                .indexOf("/cellContents"));
1301:                        cellContentPath = childNode(cellContentPath);
1302:                        CrosstabCell cell = findCell(
1303:                                (CrosstabReportElement) re, xpath);
1304:
1305:                        ReportElement sre = findElement(
1306:                                ((CrosstabReportElement) re).getElements(),
1307:                                cellContentPath, cell);
1308:
1309:                        if (sre != null) {
1310:                            String elementPath = childNode(cellContentPath);
1311:                            if (isNode(elementPath, "reportElement")) {
1312:                                elementPath = childNode(elementPath);
1313:                                parseReportElement(sre, elementPath,
1314:                                        (CrosstabReportElement) re);
1315:                            } else {
1316:                                parseElement(sre, elementPath,
1317:                                        (CrosstabReportElement) re);
1318:                            }
1319:                        }
1320:                    } else if (isNode(xpath, "rowGroup")) // check if we are working with the content of a cell...
1321:                    {
1322:                        int groupIndex = getNodeIndex(xpath);
1323:                        xpath = childNode(xpath);
1324:                        if (this .getJReportFrame()
1325:                                .getSelectedCrosstabEditorPanel() != null) {
1326:                            this .getJReportFrame().setSelectedCrosstabEditor(
1327:                                    null);
1328:                        }
1329:                        MainFrame.getMainInstance().getDocumentStructurePanel()
1330:                                .setSelectedObject(re);
1331:
1332:                        if (isNode(xpath, "bucket")) {
1333:                            xpath = childNode(xpath);
1334:                            int groupExp = CrosstabGroupDialog.COMPONENT_NONE;
1335:                            if (isNode(xpath, "bucketExpression"))
1336:                                groupExp = CrosstabGroupDialog.COMPONENT_BUCKET_EXPRESSION;
1337:                            else if (isNode(xpath, "comparatorExpression"))
1338:                                groupExp = CrosstabGroupDialog.COMPONENT_COMPARATOR_EXPRESSION;
1339:
1340:                            it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog cpd = new it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog(
1341:                                    MainFrame.getMainInstance(), true);
1342:                            cpd
1343:                                    .setCurrentCrosstabReportElement((CrosstabReportElement) re);
1344:                            cpd.openRowBucket(groupIndex, groupExp);
1345:                            cpd.setVisible(true);
1346:                        }
1347:                    } else if (isNode(xpath, "columnGroup")) // check if we are working with the content of a cell...
1348:                    {
1349:                        int groupIndex = getNodeIndex(xpath);
1350:                        xpath = childNode(xpath);
1351:
1352:                        if (this .getJReportFrame()
1353:                                .getSelectedCrosstabEditorPanel() != null) {
1354:                            this .getJReportFrame().setSelectedCrosstabEditor(
1355:                                    null);
1356:                        }
1357:                        MainFrame.getMainInstance().getDocumentStructurePanel()
1358:                                .setSelectedObject(re);
1359:
1360:                        if (isNode(xpath, "bucket")) {
1361:                            xpath = childNode(xpath);
1362:                            int groupExp = CrosstabGroupDialog.COMPONENT_NONE;
1363:                            if (isNode(xpath, "bucketExpression"))
1364:                                groupExp = CrosstabGroupDialog.COMPONENT_BUCKET_EXPRESSION;
1365:                            else if (isNode(xpath, "comparatorExpression"))
1366:                                groupExp = CrosstabGroupDialog.COMPONENT_COMPARATOR_EXPRESSION;
1367:
1368:                            it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog cpd = new it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog(
1369:                                    MainFrame.getMainInstance(), true);
1370:                            cpd
1371:                                    .setCurrentCrosstabReportElement((CrosstabReportElement) re);
1372:                            cpd.openColumnBucket(groupIndex, groupExp);
1373:                            cpd.setVisible(true);
1374:                        }
1375:                    } else if (isNode(xpath, "measure")) // check if we are working with the content of a cell...
1376:                    {
1377:                        int groupIndex = getNodeIndex(xpath);
1378:                        xpath = childNode(xpath);
1379:
1380:                        if (this .getJReportFrame()
1381:                                .getSelectedCrosstabEditorPanel() != null) {
1382:                            this .getJReportFrame().setSelectedCrosstabEditor(
1383:                                    null);
1384:                        }
1385:                        MainFrame.getMainInstance().getDocumentStructurePanel()
1386:                                .setSelectedObject(re);
1387:
1388:                        int measureExp = CrosstabGroupDialog.COMPONENT_NONE;
1389:                        if (isNode(xpath, "measureExpression"))
1390:                            measureExp = MeasureDialog.COMPONENT_MEASURE_EXPRESSION;
1391:
1392:                        it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog cpd = new it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog(
1393:                                MainFrame.getMainInstance(), true);
1394:                        cpd
1395:                                .setCurrentCrosstabReportElement((CrosstabReportElement) re);
1396:                        cpd.openMeasure(groupIndex, measureExp);
1397:                        cpd.setVisible(true);
1398:                    } else if (isNode(xpath, "crosstabDataset")) {
1399:                        xpath = childNode(xpath);
1400:                        if (isNode(xpath, "dataset")) {
1401:                            xpath = childNode(xpath);
1402:                            Object[] expressionInfo = parseDataset(xpath);
1403:                            it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog cpd = new it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog(
1404:                                    MainFrame.getMainInstance(), true);
1405:                            cpd
1406:                                    .setCurrentCrosstabReportElement((CrosstabReportElement) re);
1407:                            cpd.setFocusedExpression(expressionInfo);
1408:                            cpd.setVisible(true);
1409:                        }
1410:                    }
1411:
1412:                    if (expressionID > 0) {
1413:                        if (this .getJReportFrame()
1414:                                .getSelectedCrosstabEditorPanel() != null) {
1415:                            this .getJReportFrame().setSelectedCrosstabEditor(
1416:                                    null);
1417:                        }
1418:                        MainFrame.getMainInstance().getDocumentStructurePanel()
1419:                                .setSelectedObject(re);
1420:
1421:                        MainFrame.getMainInstance()
1422:                                .getElementPropertiesDialog().setVisible(true);
1423:                        MainFrame.getMainInstance()
1424:                                .getElementPropertiesDialog()
1425:                                .setFocusedExpression(expressionID, elementID);
1426:                        if (subexpressionID > 0) {
1427:                            MainFrame.getMainInstance()
1428:                                    .getElementPropertiesDialog()
1429:                                    .modifyCrosstabParameter(subexpressionID);
1430:                        }
1431:                    }
1432:                }
1433:            }
1434:
1435:            /**
1436:             * Return true if xpath starts with one of the strings in the key array
1437:             * If xpath starts with "/", the first character is removed, so
1438:             * 
1439:             * "/test", {"test"} returns true
1440:             * "test", {"/test"} returns false
1441:             */
1442:            final static private boolean isNode(String xpath, String[] keys) {
1443:                if (xpath == null || keys == null)
1444:                    return false;
1445:                if (xpath.startsWith("/"))
1446:                    xpath = xpath.substring(1);
1447:                for (int i = 0; i < keys.length; ++i) {
1448:                    if (isNode(xpath, keys[i]))
1449:                        return true;
1450:                }
1451:                return false;
1452:            }
1453:
1454:            /**
1455:             * Check if the root node of the path is a nodeName...
1456:             *
1457:             * "/test/dsafasfd/asdfa/dsaf", "test" returns true
1458:             * "test", "/test" returns false
1459:             */
1460:            final static private boolean isNode(String xpath, String nodeName) {
1461:                if (xpath == null || nodeName == null || nodeName.length() == 0)
1462:                    return false;
1463:                if (xpath.startsWith("/"))
1464:                    xpath = xpath.substring(1);
1465:                if (xpath.startsWith(nodeName)) {
1466:                    xpath = xpath.substring(nodeName.length());
1467:                    if (xpath.length() == 0 || xpath.startsWith("/")
1468:                            || xpath.startsWith("["))
1469:                        return true;
1470:                }
1471:                return false;
1472:            }
1473:
1474:            /**
1475:             * This method finds the element pointed by the first node of xpath in the given vector
1476:             * In the element is not found, the method returns null
1477:             */
1478:            public ReportElement findElement(Vector elements, String xpath) {
1479:                return findElement(elements, xpath, null);
1480:            }
1481:
1482:            /**
1483:             * This method finds the element pointed by the first node of xpath in the given vector
1484:             * having (if not null) the cell as parent cell
1485:             */
1486:            public ReportElement findElement(Vector elements, String xpath,
1487:                    CrosstabCell cell) {
1488:                if (elements == null || xpath == null)
1489:                    return null;
1490:                int index = getNodeIndex(xpath);
1491:                if (xpath.startsWith("/"))
1492:                    xpath = xpath.substring(1);
1493:                String class_name = null;
1494:                String element_type = null;
1495:                for (int i = 0; i < ELEMENTS.length; ++i) {
1496:                    if (isNode(xpath, ELEMENTS[i])) {
1497:                        class_name = "it.businesslogic.ireport."
1498:                                + ELEMENTS_CLASS[i];
1499:                        element_type = ELEMENTS[i];
1500:                        break;
1501:                    }
1502:                }
1503:
1504:                Class clazz = null;
1505:                try {
1506:                    clazz = Class.forName(class_name);
1507:                } catch (ClassNotFoundException ex) {
1508:                    ex.printStackTrace();
1509:                    return null;
1510:                }
1511:
1512:                // get the right element match...
1513:                for (int i = 0; i < elements.size(); ++i) {
1514:                    ReportElement re = (ReportElement) elements.get(i);
1515:                    if (cell != null && re.getCell() != cell)
1516:                        continue;
1517:
1518:                    if (clazz.isInstance(re)) {
1519:                        if (re instanceof  ChartReportElement2) {
1520:                            // more investigation is required...
1521:                            Chart chart = ((ChartReportElement2) re).getChart();
1522:                            if ((element_type.equals("pie3DChart") && chart instanceof  Pie3DChart)
1523:                                    || (element_type.equals("pieChart") && chart instanceof  PieChart)
1524:                                    || (element_type.equals("barChart") && chart instanceof  BarChart)
1525:                                    || (element_type.equals("bar3DChart") && chart instanceof  Bar3DChart)
1526:                                    || (element_type.equals("xyBarChart") && chart instanceof  XYBarChart)
1527:                                    || (element_type.equals("stackedBarChart") && chart instanceof  StackedBarChart)
1528:                                    || (element_type
1529:                                            .equals("stackedBar3DChart") && chart instanceof  StackedBar3DChart)
1530:                                    || (element_type.equals("lineChart") && chart instanceof  LineChart)
1531:                                    || (element_type.equals("xyLineChart") && chart instanceof  XYLineChart)
1532:                                    || (element_type.equals("areaChart") && chart instanceof  AreaChart)
1533:                                    || (element_type.equals("xyAreaChart") && chart instanceof  XYAreaChart)
1534:                                    || (element_type.equals("scatterChart") && chart instanceof  ScatterChart)
1535:                                    || (element_type.equals("bubbleChart") && chart instanceof  BubbleChart)
1536:                                    || (element_type.equals("timeSeriesChart") && chart instanceof  TimeSeriesChart)
1537:                                    || (element_type.equals("highLowChart") && chart instanceof  HighLowChart)
1538:                                    || (element_type.equals("candlestickChart") && chart instanceof  CandlestickChart)
1539:                                    || (element_type.equals("meterChart") && chart instanceof  MeterChart)
1540:                                    || (element_type.equals("thermometerChart") && chart instanceof  ThermometerChart)
1541:                                    || (element_type.equals("multiAxisChart") && chart instanceof  MultiAxisChart)
1542:                                    || (element_type.equals("stackedAreaChart") && chart instanceof  StackedAreaChart)) {
1543:                                if (index == 0)
1544:                                    return re;
1545:                                index--;
1546:                            }
1547:                        } else {
1548:                            if (index == 0)
1549:                                return re;
1550:                            index--;
1551:                        }
1552:                    }
1553:                }
1554:                return null;
1555:            }
1556:
1557:            private void parseReportElement(ReportElement re, String xpath,
1558:                    CrosstabReportElement cre) {
1559:
1560:                if (isNode(xpath, "printWhenExpression")) {
1561:                    if (cre == null) {
1562:                        if (this .getJReportFrame()
1563:                                .getSelectedCrosstabEditorPanel() != null) {
1564:                            this .getJReportFrame().setSelectedCrosstabEditor(
1565:                                    null);
1566:                        }
1567:                        MainFrame.getMainInstance().getDocumentStructurePanel()
1568:                                .setSelectedObject(re);
1569:                        MainFrame.getMainInstance().getReportSheetPanel()
1570:                                .setPropertyLabelError("printWhenExpression",
1571:                                        errorString);
1572:                    } else {
1573:                        CrosstabEditor ceditor = this .getJReportFrame()
1574:                                .getCrosstabEditor(cre);
1575:                        if (this .getJReportFrame()
1576:                                .getSelectedCrosstabEditorPanel() == null
1577:                                || this .getJReportFrame()
1578:                                        .getSelectedCrosstabEditorPanel() != ceditor
1579:                                        .getPanelEditor()) {
1580:                            this .getJReportFrame().setSelectedCrosstabEditor(
1581:                                    cre);
1582:                        }
1583:                        ceditor.getPanelEditor().setSelectedElement(re);
1584:                        MainFrame.getMainInstance().getReportSheetPanel()
1585:                                .setPropertyLabelError("printWhenExpression",
1586:                                        errorString);
1587:                    }
1588:                }
1589:            }
1590:
1591:            private CrosstabCell findCell(CrosstabReportElement re, String xpath) {
1592:
1593:                if (isNode(xpath, "crosstabHeaderCell")) {
1594:                    for (int i = 0; i < re.getCells().size(); ++i) {
1595:                        CrosstabCell cc = (CrosstabCell) re.getCells().get(i);
1596:                        if (cc.getType() == CrosstabCell.CT_HEADER_CELL)
1597:                            return cc;
1598:                    }
1599:                    return null;
1600:                } else if (isNode(xpath, "rowGroup")) {
1601:                    // get the right row group...
1602:                    int itemIndex = getNodeIndex(xpath);
1603:                    CrosstabGroup cg = (CrosstabGroup) re.getRowGroups().get(
1604:                            itemIndex);
1605:                    // find what cell in this group...
1606:                    xpath = childNode(xpath);
1607:
1608:                    if (isNode(xpath, "crosstabRowHeader")) {
1609:                        return cg.getHeaderCell();
1610:                    } else if (isNode(xpath, "crosstabTotalRowHeader")) {
1611:                        return cg.getTotalCell();
1612:                    }
1613:
1614:                } else if (isNode(xpath, "columnGroup")) {
1615:                    // get the right row group...
1616:                    int itemIndex = getNodeIndex(xpath);
1617:                    CrosstabGroup cg = (CrosstabGroup) re.getColumnGroups()
1618:                            .get(itemIndex);
1619:                    // find what cell in this group...
1620:                    xpath = childNode(xpath);
1621:
1622:                    if (isNode(xpath, "crosstabColumnHeader")) {
1623:                        return cg.getHeaderCell();
1624:                    } else if (isNode(xpath, "crosstabTotalColumnHeader")) {
1625:                        return cg.getTotalCell();
1626:                    }
1627:                } else if (isNode(xpath, "crosstabCell")) {
1628:                    int cellIndex = getNodeIndex(xpath);
1629:                    for (int i = 0; i < re.getCells().size(); ++i) {
1630:                        CrosstabCell cc = (CrosstabCell) re.getCells().get(i);
1631:                        if (cc.getType() == CrosstabCell.DETAIL_CELL) {
1632:                            if (cellIndex == 0)
1633:                                return cc;
1634:                            cellIndex--;
1635:                        }
1636:                    }
1637:                    return null;
1638:                } else if (isNode(xpath, "whenNoDataCell")) {
1639:                    for (int i = 0; i < re.getCells().size(); ++i) {
1640:                        CrosstabCell cc = (CrosstabCell) re.getCells().get(i);
1641:                        if (cc.getType() == CrosstabCell.NODATA_CELL)
1642:                            return cc;
1643:                    }
1644:                    return null;
1645:                }
1646:
1647:                return null;
1648:            }
1649:
1650:            public String getErrorString() {
1651:                return errorString;
1652:            }
1653:
1654:            public void setErrorString(String errorString) {
1655:                this .errorString = errorString;
1656:            }
1657:
1658:            /**
1659:             * Append to startingExpressionInfo all the IDs required to show the error of the sectionHyperlink
1660:             * It is used for charts only.
1661:             */
1662:            public Object[] addSectionHyperlinkExpressionsInfo(
1663:                    Object[] startingExpressionInfo, String xpath) {
1664:                int itemToAppend = SectionItemHyperlinkPanel.COMPONENT_NONE;
1665:                if (isNode(xpath, "hyperlinkReferenceExpression")) {
1666:                    itemToAppend = SectionItemHyperlinkPanel.COMPONENT_HYPERLINK_REFERENCE_EXPRESSION;
1667:                } else if (isNode(xpath, "hyperlinkPageExpression")) {
1668:                    itemToAppend = SectionItemHyperlinkPanel.COMPONENT_HYPERLINK_PAGE_EXPRESSION;
1669:                } else if (isNode(xpath, "hyperlinkAnchorExpression")) {
1670:                    itemToAppend = SectionItemHyperlinkPanel.COMPONENT_HYPERLINK_ANCHOR_EXPRESSION;
1671:                } else if (isNode(xpath, "hyperlinkTooltipExpression")) {
1672:                    itemToAppend = SectionItemHyperlinkPanel.COMPONENT_HYPERLINK_TOOLTIP_EXPRESSION;
1673:                } else if (isNode(xpath, "hyperlinkParameter")) {
1674:                    int paramIndex = getNodeIndex(xpath);
1675:
1676:                    itemToAppend = SectionItemHyperlinkPanel.COMPONENT_HYPERLINK_PARAMETERS;
1677:                    startingExpressionInfo = appendToArray(
1678:                            startingExpressionInfo, new Integer(itemToAppend));
1679:                    startingExpressionInfo = appendToArray(
1680:                            startingExpressionInfo, new Integer(paramIndex));
1681:                    xpath = childNode(xpath);
1682:
1683:                    itemToAppend = JRLinkParameterDialog.COMPONENT_NONE;
1684:                    if (isNode(xpath, "hyperlinkParameterExpression")) {
1685:                        itemToAppend = JRLinkParameterDialog.COMPONENT_PARAM_EXPRESSION;
1686:                    }
1687:                }
1688:
1689:                return appendToArray(startingExpressionInfo, new Integer(
1690:                        itemToAppend));
1691:            }
1692:
1693:            /**
1694:             * Append element at the end of array, returning a new array with lenght
1695:             * equals to array.length + 1
1696:             */
1697:            public static final Object[] appendToArray(Object[] array,
1698:                    Object element) {
1699:                Object[] newArray = new Object[array.length + 1];
1700:                for (int i = 0; i < array.length; ++i) {
1701:                    newArray[i] = array[i];
1702:                }
1703:                newArray[array.length] = element;
1704:                return newArray;
1705:            }
1706:
1707:            public Object[] parseDataset(String xpath) {
1708:                Object[] expressionInfo = null;
1709:                if (isNode(xpath, "incrementWhenExpression")) {
1710:                    expressionInfo = new Object[] { new Integer(
1711:                            ChartPropertiesDialog.COMPONENT_INCREMENT_WHEN_EXPRESSION) };
1712:                } else if (isNode(xpath, "datasetRun")) {
1713:                    xpath = childNode(xpath);
1714:                    if (isNode(xpath, "parametersMapExpression")) {
1715:                        expressionInfo = new Object[] { new Integer(
1716:                                ChartPropertiesDialog.COMPONENT_DATASETRUN_MAP_EXPRESSION) };
1717:                    } else if (isNode(xpath, new String[] {
1718:                            "connectionExpression", "dataSourceExpression" })) {
1719:                        expressionInfo = new Object[] { new Integer(
1720:                                ChartPropertiesDialog.COMPONENT_DATASETRUN_DS_CONN_EXPRESSION) };
1721:                    } else if (isNode(xpath, "datasetParameter")) {
1722:                        int paramIndex = getNodeIndex(xpath);
1723:                        expressionInfo = new Object[] {
1724:                                new Integer(
1725:                                        ChartPropertiesDialog.COMPONENT_DATASETRUN_PARAMETERS),
1726:                                new Integer(paramIndex) };
1727:                        xpath = childNode(xpath);
1728:                        if (isNode(xpath, "datasetParameterExpression")) {
1729:                            expressionInfo = appendToArray(
1730:                                    expressionInfo,
1731:                                    new Integer(
1732:                                            JRSubreportParameterDialog.COMPONENT_PARAM_EXPRESSION));
1733:                        } else {
1734:                            expressionInfo = appendToArray(
1735:                                    expressionInfo,
1736:                                    new Integer(
1737:                                            JRSubreportParameterDialog.COMPONENT_NONE));
1738:                        }
1739:                    }
1740:                }
1741:
1742:                return expressionInfo;
1743:            }
1744:
1745:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.