Source Code Cross Referenced for QueryBuilderDialog.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » data » 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.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * QueryBuilderDialog.java
003:         *
004:         * Created on December 11, 2006, 4:21 PM
005:         */
006:
007:        package it.businesslogic.ireport.data;
008:
009:        import it.businesslogic.ireport.util.I18n;
010:        import it.businesslogic.ireport.util.Misc;
011:        import java.io.IOException;
012:        import javax.swing.JOptionPane;
013:        import javax.swing.SwingUtilities;
014:        import nickyb.sqleonardo.environment.Application;
015:        import nickyb.sqleonardo.querybuilder.QueryActions;
016:        import nickyb.sqleonardo.querybuilder.QueryModel;
017:        import nickyb.sqleonardo.querybuilder.syntax.SQLParser;
018:
019:        /**
020:         *
021:         * @author  gtoffoli
022:         */
023:        public class QueryBuilderDialog extends javax.swing.JDialog {
024:
025:            private String query = null;
026:            private int dialogResult = javax.swing.JOptionPane.CANCEL_OPTION;
027:            private boolean init = false;
028:
029:            /**
030:             * Creates new form QueryBuilderDialog
031:             */
032:            public QueryBuilderDialog(java.awt.Frame parent, boolean modal) {
033:                super (parent, modal);
034:                initAll();
035:            }
036:
037:            /**
038:             * Creates new form QueryBuilderDialog
039:             */
040:            public QueryBuilderDialog(java.awt.Dialog parent, boolean modal) {
041:                super (parent, modal);
042:                initAll();
043:            }
044:
045:            public void applyI18n() {
046:
047:                jTabbedPane1.setTitleAt(0, I18n.getString(
048:                        "application.builder", "Builder"));
049:                jTabbedPane1.setTitleAt(1, I18n.getString("application.syntax",
050:                        "SQL"));
051:
052:                jButtonOk.setText(I18n.getString("ok", "Ok"));
053:                jButtonCancel
054:                        .setText(I18n.getString("cancel", "jButtonCancel"));
055:
056:            }
057:
058:            private void initAll() {
059:                setInit(true);
060:                initComponents();
061:                applyI18n();
062:                setInit(false);
063:                Misc.centerFrame(this );
064:            }
065:
066:            public void setConnection(java.sql.Connection c) {
067:                this .queryBuilder1.setConnection(c);
068:            }
069:
070:            /** This method is called from within the constructor to
071:             * initialize the form.
072:             * WARNING: Do NOT modify this code. The content of this method is
073:             * always regenerated by the Form Editor.
074:             */
075:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
076:            private void initComponents() {
077:                java.awt.GridBagConstraints gridBagConstraints;
078:
079:                jTabbedPane1 = new javax.swing.JTabbedPane();
080:                queryBuilder1 = new nickyb.sqleonardo.querybuilder.QueryBuilder();
081:                jRSQLExpressionArea1 = new it.businesslogic.ireport.gui.JRSQLExpressionArea();
082:                jPanel1 = new javax.swing.JPanel();
083:                jButtonOk = new javax.swing.JButton();
084:                jButtonCancel = new javax.swing.JButton();
085:
086:                getContentPane().setLayout(new java.awt.GridBagLayout());
087:
088:                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
089:                jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
090:                jTabbedPane1
091:                        .addChangeListener(new javax.swing.event.ChangeListener() {
092:                            public void stateChanged(
093:                                    javax.swing.event.ChangeEvent evt) {
094:                                jTabbedPane1StateChanged(evt);
095:                            }
096:                        });
097:
098:                queryBuilder1
099:                        .setPreferredSize(new java.awt.Dimension(600, 483));
100:                jTabbedPane1.addTab("Design", queryBuilder1);
101:
102:                jRSQLExpressionArea1.setBorder(javax.swing.BorderFactory
103:                        .createEtchedBorder());
104:                jRSQLExpressionArea1.setMinimumSize(new java.awt.Dimension(50,
105:                        200));
106:                jRSQLExpressionArea1.setPreferredSize(new java.awt.Dimension(
107:                        661, 340));
108:                jTabbedPane1.addTab("SQL", jRSQLExpressionArea1);
109:
110:                gridBagConstraints = new java.awt.GridBagConstraints();
111:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
112:                gridBagConstraints.weightx = 1.0;
113:                gridBagConstraints.weighty = 1.0;
114:                getContentPane().add(jTabbedPane1, gridBagConstraints);
115:
116:                jPanel1.setLayout(new java.awt.GridBagLayout());
117:
118:                jButtonOk.setText("Ok");
119:                jButtonOk
120:                        .addActionListener(new java.awt.event.ActionListener() {
121:                            public void actionPerformed(
122:                                    java.awt.event.ActionEvent evt) {
123:                                jButtonOkActionPerformed(evt);
124:                            }
125:                        });
126:
127:                gridBagConstraints = new java.awt.GridBagConstraints();
128:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
129:                gridBagConstraints.weightx = 1.0;
130:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 0);
131:                jPanel1.add(jButtonOk, gridBagConstraints);
132:
133:                jButtonCancel.setText("Cancel");
134:                jButtonCancel
135:                        .addActionListener(new java.awt.event.ActionListener() {
136:                            public void actionPerformed(
137:                                    java.awt.event.ActionEvent evt) {
138:                                jButtonCancelActionPerformed(evt);
139:                            }
140:                        });
141:
142:                gridBagConstraints = new java.awt.GridBagConstraints();
143:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
144:                jPanel1.add(jButtonCancel, gridBagConstraints);
145:
146:                gridBagConstraints = new java.awt.GridBagConstraints();
147:                gridBagConstraints.gridx = 0;
148:                gridBagConstraints.gridwidth = 2;
149:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
150:                gridBagConstraints.weightx = 1.0;
151:                getContentPane().add(jPanel1, gridBagConstraints);
152:
153:                pack();
154:            }// </editor-fold>//GEN-END:initComponents
155:
156:            private void jTabbedPane1StateChanged(
157:                    javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
158:
159:                if (isInit())
160:                    return;
161:                if (jTabbedPane1.getSelectedIndex() == 0) {
162:                    String msql = queryBuilder1.getModel().toString(true);
163:                    String tsql = jRSQLExpressionArea1.getText();
164:
165:                    if (!tsql.equals(msql)) {
166:                        if (JOptionPane
167:                                .showConfirmDialog(
168:                                        this ,
169:                                        I18n
170:                                                .getString(
171:                                                        "application.syntaxChanged",
172:                                                        "syntax changed!\ndo you want to apply changes (builder need to reload)?")) == JOptionPane.OK_OPTION) {
173:                            // this thread resolve: IllegalComponentStateException
174:                            new Thread(new Runnable() {
175:                                public void run() {
176:                                    while (!queryBuilder1.isVisible())
177:                                        ;
178:                                    try {
179:                                        QueryModel qm = SQLParser
180:                                                .toQueryModel(jRSQLExpressionArea1
181:                                                        .getText());
182:                                        queryBuilder1.setModel(qm);
183:                                    } catch (IOException e) {
184:                                        JOptionPane
185:                                                .showMessageDialog(
186:                                                        QueryBuilderDialog.this ,
187:                                                        I18n
188:                                                                .getString(
189:                                                                        "errorParsingSQL",
190:                                                                        "I'm sorry, I'm unable to parse the query..."));
191:                                        jTabbedPane1.setSelectedIndex(0);
192:                                    }
193:                                }
194:                            }).start();
195:                        }
196:                    }
197:                } else {
198:                    try {
199:
200:                        jRSQLExpressionArea1.setText(queryBuilder1.getModel()
201:                                .toString(true));
202:
203:                    } catch (Exception ex) {
204:
205:                    }
206:                }
207:
208:            }//GEN-LAST:event_jTabbedPane1StateChanged
209:
210:            private void jButtonCancelActionPerformed(
211:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
212:
213:                this .setVisible(false);
214:                this .dispose();
215:
216:            }//GEN-LAST:event_jButtonCancelActionPerformed
217:
218:            private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOkActionPerformed
219:
220:                if (jTabbedPane1.getSelectedIndex() == 0) {
221:                    query = this .queryBuilder1.getModel().toString(true);
222:                } else {
223:                    query = this .jRSQLExpressionArea1.getText();
224:                }
225:
226:                this .setDialogResult(javax.swing.JOptionPane.OK_OPTION);
227:                this .setVisible(false);
228:                this .dispose();
229:            }//GEN-LAST:event_jButtonOkActionPerformed
230:
231:            public String getQuery() {
232:                return query;
233:            }
234:
235:            public void setQuery(String query) throws Exception {
236:
237:                final QueryModel qm = SQLParser.toQueryModel(query);
238:
239:                SwingUtilities.invokeLater(new Runnable() {
240:                    public void run() {
241:                        if (isVisible()) {
242:                            queryBuilder1.setModel(qm);
243:                        }
244:                    }
245:                });
246:            }
247:
248:            // Variables declaration - do not modify//GEN-BEGIN:variables
249:            private javax.swing.JButton jButtonCancel;
250:            private javax.swing.JButton jButtonOk;
251:            private javax.swing.JPanel jPanel1;
252:            private it.businesslogic.ireport.gui.JRSQLExpressionArea jRSQLExpressionArea1;
253:            private javax.swing.JTabbedPane jTabbedPane1;
254:            private nickyb.sqleonardo.querybuilder.QueryBuilder queryBuilder1;
255:
256:            // End of variables declaration//GEN-END:variables
257:
258:            /** Getter for property dialogResult.
259:             * @return Value of property dialogResult.
260:             *
261:             */
262:            public int getDialogResult() {
263:                return dialogResult;
264:            }
265:
266:            /** Setter for property dialogResult.
267:             * @param dialogResult New value of property dialogResult.
268:             *
269:             */
270:            public void setDialogResult(int dialogResult) {
271:                this .dialogResult = dialogResult;
272:            }
273:
274:            public boolean isInit() {
275:                return init;
276:            }
277:
278:            public void setInit(boolean init) {
279:                this.init = init;
280:            }
281:
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.