KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > data > EJBQLBeanInspectorPanel


1 /*
2  * Copyright (C) 2006 JasperSoft http://www.jaspersoft.com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed WITHOUT ANY WARRANTY; and without the
10  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15  * or write to:
16  *
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330,
19  * Boston, MA USA 02111-1307
20  *
21  *
22  * EJBQLBeanInspectorPanel.java
23  *
24  * Created on December 7, 2006, 1:27 PM
25  *
26  * To change this template, choose Tools | Template Manager
27  * and open the template in the editor.
28  */

29
30 package it.businesslogic.ireport.data;
31
32 import it.businesslogic.ireport.JRField;
33 import it.businesslogic.ireport.data.ejbql.EJBQLFieldsReader;
34 import it.businesslogic.ireport.gui.MainFrame;
35 import java.util.ArrayList JavaDoc;
36 import java.util.List JavaDoc;
37 import java.util.Vector JavaDoc;
38
39 /**
40  *
41  * @author gtoffoli
42  */

43 public class EJBQLBeanInspectorPanel extends BeanInspectorPanel {
44     
45     /** Creates a new instance of EJBQLBeanInspectorPanel */
46     public EJBQLBeanInspectorPanel() {
47         super();
48         
49     }
50     
51     /**
52      * Ad hoc queryChanged method for EJBQL queries....
53      */

54     public void queryChanged(String JavaDoc newQuery) {
55     
56         lastExecution++;
57         int thisExecution = lastExecution;
58         // Execute a thread to perform the query change...
59

60         String JavaDoc error_msg = "";
61         lastExecution++;
62             
63         int in = lastExecution;
64             
65         getReportQueryDialog().getJLabelStatusSQL().setText("Executing EJBQL query....");
66         /////////////////////////////
67

68         try {
69         Thread.currentThread().setContextClassLoader( MainFrame.getMainInstance().getReportClassLoader());
70         } catch (Exception JavaDoc ex)
71         {
72             ex.printStackTrace();
73         }
74             
75         if (in < lastExecution) return; //Abort, new execution requested
76

77         EJBQLFieldsReader ejbqlFR = new EJBQLFieldsReader(newQuery, getReportQueryDialog().getSubDataset().getParameters());
78             
79             try {
80                 Vector JavaDoc fields = ejbqlFR.readFields();
81                 
82                 List JavaDoc columns = new ArrayList JavaDoc();
83                 for (int i=0; i<fields.size(); ++i)
84                 {
85                     JRField field = (JRField)fields.elementAt(i);
86                     columns.add( new Object JavaDoc[]{field, field.getClassType(), field.getDescription()} );
87                 }
88                 Vector JavaDoc v = null;
89                 if (ejbqlFR.getSingleClassName() != null)
90                 {
91                     v = new Vector JavaDoc();
92                     v.add( ejbqlFR.getSingleClassName() );
93                 }
94                 
95                 System.out.println("Single class name: " + ejbqlFR.getSingleClassName());
96                 
97                 setBeanExplorerFromWorker(v,true,false);
98                 setColumnsFromWorker(columns);
99                 
100             } catch (Exception JavaDoc ex)
101             {
102                 ex.printStackTrace();
103                 setBeanExplorerFromWorker(null,true,false);
104                 setColumnErrorFromWork( "Error: " + ex.getMessage() );
105             }
106         
107         getReportQueryDialog().getJLabelStatusSQL().setText("Ready");
108     }
109     
110 }
111
Popular Tags