Source Code Cross Referenced for DataReport.java in  » Report » FreeReportBuilder » it » frb » 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 » FreeReportBuilder » it.frb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2004 Giuseppe MANNA
003:         * 
004:         * This file is part of FreeReportBuilder
005:         * 
006:         * FreeReportBuilder is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or (at your option) any later version.
010:         * 
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         * 
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         * 
020:         */
021:
022:        package it.frb;
023:
024:        import it.frb.action.*;
025:        import it.frb.admin.*;
026:        import java.awt.Font;
027:        import java.io.*;
028:        import javax.swing.UIManager;
029:        import it.frb.action.Action_F2;
030:        import java.awt.Dimension;
031:        import java.awt.GridLayout; //import nickyb.fqb.*;
032:        import java.awt.event.ActionListener;
033:        import java.awt.event.ItemListener;
034:        import java.net.URL;
035:
036:        import javax.swing.Action;
037:        import javax.swing.BorderFactory;
038:        import javax.swing.DefaultComboBoxModel;
039:        import javax.swing.ImageIcon;
040:        import javax.swing.JButton;
041:        import javax.swing.JComboBox;
042:        import javax.swing.JToggleButton;
043:        import javax.swing.JToolBar;
044:        import javax.swing.JFrame;
045:
046:        import nicky.querybuilder.QueryBuilder;
047:        import nicky.querybuilder.QuerySyntax;
048:        import nicky.querybuilder.sample.QueryPreview;
049:
050:        public class DataReport extends JFrame implements  ActionListener {
051:            private java.awt.Toolkit objToolkit;
052:            private java.awt.Dimension dScSize;
053:
054:            public java.sql.Connection conn;
055:            public Dragger drg;
056:
057:            private JToolBar toolBar;
058:            private JToolBar toolBarAlign;
059:            private JToolBar toolBarHistory;
060:
061:            private JButton bExecute = null;
062:            private JButton bImport = null;
063:            private JButton bOpen = null;
064:            private JButton bSave = null;
065:            private JButton bProperties = null;
066:            private JButton bConnection = null;
067:            private JButton bQueryBuilder = null;
068:            private JButton bChart = null;
069:            private JButton bHelp = null;
070:            private JButton bUtilities = null;
071:            private JButton bAlignLeft = null;
072:            private JButton bAlignRight = null;
073:            private JButton bAlignTop = null;
074:            private JButton bAlignBottom = null;
075:            private JButton bSpaceH = null;
076:            private JButton bSpaceV = null;
077:            private JButton bEqualW = null;
078:            private JButton bEqualH = null;
079:            private JButton bCenterH = null;
080:            private JButton bCenterV = null;
081:            private JComboBox jComboHistory = null;
082:            private boolean bStartItemChange = true;
083:
084:            public QueryBuilder qb = null;
085:
086:            private static JSplash splash = null;
087:            public static DataPanel dataPanel = null;
088:
089:            public static Font fontBOLD = new Font("Dialog", Font.BOLD,
090:                    ConfigurationProperties.properties().getFontSize(11));
091:            public static Font fontPLAIN = new Font("Dialog", Font.PLAIN,
092:                    ConfigurationProperties.properties().getFontSize(11));
093:            public static Font fontMONO = new Font("Monospaced", Font.PLAIN, 13);
094:
095:            static {
096:                UIManager.getDefaults().put("TextArea.font", fontMONO);
097:                UIManager.getDefaults().put("Button.font", fontPLAIN);
098:                UIManager.getDefaults().put("Button.margin",
099:                        new java.awt.Insets(1, 1, 1, 1));
100:                UIManager.getDefaults().put("ComboBox.font", fontBOLD);
101:                UIManager.getDefaults().put("JComboBox.font", fontBOLD);
102:                UIManager.getDefaults().put("CheckBox.font", fontPLAIN);
103:                UIManager.getDefaults().put("InternalFrame.font", fontBOLD);
104:                UIManager.getDefaults().put("Label.font", fontBOLD);
105:                UIManager.getDefaults().put("Slider.margin",
106:                        new java.awt.Insets(1, 1, 1, 1));
107:                UIManager.getDefaults().put("TabbedPane.font", fontPLAIN);
108:                UIManager.getDefaults().put("ToggleButton.font", fontPLAIN);
109:                UIManager.getDefaults().put("List.font", fontPLAIN);
110:                UIManager.getDefaults().put("Menu.font", fontBOLD);
111:                UIManager.getDefaults().put("MenuItem.font", fontBOLD);
112:                UIManager.getDefaults().put("OptionPane.font", fontPLAIN);
113:                UIManager.getDefaults().put("PopupMenu.font", fontPLAIN);
114:                UIManager.getDefaults().put("SplitPane.dividerSize",
115:                        new Integer(8));
116:                UIManager.getDefaults().put("Table.font", fontPLAIN);
117:                UIManager.getDefaults().put("TableHeader.font", fontPLAIN);
118:                UIManager.getDefaults().put("ToolTip.font", fontPLAIN);
119:                UIManager.getDefaults().put("Tree.rowHeight", new Integer(18));
120:                UIManager.getDefaults().put("Tree.Font", fontPLAIN);
121:
122:                UIManager.LookAndFeelInfo[] lafInfo = UIManager
123:                        .getInstalledLookAndFeels();
124:
125:                boolean isKunststoff = false;
126:
127:                for (int n = 0; n < lafInfo.length; n++) {
128:                    if (lafInfo[n].getName().equalsIgnoreCase("Kunststoff")) {
129:                        isKunststoff = true;
130:                    }
131:                }
132:
133:                if (!isKunststoff) {
134:                    UIManager.installLookAndFeel("Kunststoff",
135:                            "com.incors.plaf.kunststoff.KunststoffLookAndFeel");
136:                }
137:
138:                QueryBuilder.autoAlias = false;
139:                UserSession.load();
140:            }
141:
142:            public DataReport() {
143:                objToolkit = java.awt.Toolkit.getDefaultToolkit();
144:                dScSize = objToolkit.getScreenSize();
145:
146:                this .setBounds(0, 0, (int) dScSize.getWidth(), (int) dScSize
147:                        .getHeight());
148:
149:                this .initDataPanel();
150:                this .getContentPane().add(dataPanel,
151:                        java.awt.BorderLayout.CENTER);
152:
153:                try {
154:                    if (ConfigurationProperties.properties().getLookAndFeel(
155:                            "Metal").equalsIgnoreCase("Windows")) {
156:                        javax.swing.UIManager
157:                                .setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
158:
159:                    } else if (ConfigurationProperties.properties()
160:                            .getLookAndFeel("Metal").equalsIgnoreCase(
161:                                    "CDE/Motif")) {
162:                        javax.swing.UIManager
163:                                .setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
164:
165:                    } else if (ConfigurationProperties.properties()
166:                            .getLookAndFeel("Metal").equalsIgnoreCase("Metal")) {
167:                        javax.swing.UIManager
168:                                .setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
169:
170:                    } else if (ConfigurationProperties.properties()
171:                            .getLookAndFeel("Metal").equalsIgnoreCase(
172:                                    "Kunststoff")) {
173:                        javax.swing.UIManager
174:                                .setLookAndFeel("com.incors.plaf.kunststoff.KunststoffLookAndFeel");
175:                    }
176:
177:                    javax.swing.SwingUtilities
178:                            .updateComponentTreeUI(javax.swing.SwingUtilities
179:                                    .getRoot(this .dataPanel));
180:
181:                } catch (ClassNotFoundException classNotExc) {
182:                } catch (IllegalAccessException illegExc) {
183:                } catch (InstantiationException instExc) {
184:                } catch (javax.swing.UnsupportedLookAndFeelException unsuppExc) {
185:                }
186:
187:                addWindowListener(new java.awt.event.WindowAdapter() {
188:                    public void windowClosing(java.awt.event.WindowEvent evt) {
189:                        exitForm(evt);
190:                    }
191:
192:                    public void windowOpened(java.awt.event.WindowEvent evt) {
193:                        dataPanel.getTextArea().requestFocus();
194:                    }
195:
196:                    public void windowActivated(java.awt.event.WindowEvent evt) {//((javax.swing.JFrame)evt.getSource()).transferFocusDownCycle();
197:                    }
198:                });
199:
200:                try {
201:                    String sURL = "";
202:
203:                    this .setTitle(getTitle() + " URL Database: " + sURL);
204:                    javax.swing.SwingUtilities.updateComponentTreeUI(this );
205:
206:                } catch (java.util.MissingResourceException e) {
207:                    javax.swing.JOptionPane.showMessageDialog(this ,
208:                            "Attention the file of configuration is not correctly planned: ("
209:                                    + e.getMessage() + ")");
210:                }
211:            }
212:
213:            private void initDataPanel() {
214:                dataPanel = new DataPanel();
215:                toolBar = new JToolBar();
216:
217:                URL imgIconURL = DataReport.class
218:                        .getResource("img/execute.png");
219:                bExecute = new JButton(new ImageIcon(imgIconURL));
220:                bExecute.setToolTipText("Execute");
221:                imgIconURL = DataReport.class.getResource("img/import.png");
222:                bImport = new JButton(new ImageIcon(imgIconURL));
223:                bImport.setToolTipText("Import columns");
224:                imgIconURL = DataReport.class.getResource("img/open.png");
225:                bOpen = new JButton(new ImageIcon(imgIconURL));
226:                bOpen.setToolTipText("Open report");
227:                imgIconURL = DataReport.class.getResource("img/saveas.png");
228:                bSave = new JButton(new ImageIcon(imgIconURL));
229:                bSave.setToolTipText("Save report");
230:                imgIconURL = DataReport.class.getResource("img/properties.png");
231:                bProperties = new JButton(new ImageIcon(imgIconURL));
232:                bProperties
233:                        .setToolTipText("Open properties on object selected");
234:                imgIconURL = DataReport.class.getResource("img/connect.png");
235:                bConnection = new JButton(new ImageIcon(imgIconURL));
236:                bConnection.setToolTipText("Connection administrator");
237:                imgIconURL = DataReport.class.getResource("img/queryb.png");
238:                bQueryBuilder = new JButton(new ImageIcon(imgIconURL));
239:                bQueryBuilder.setToolTipText("Open Query Builder");
240:                imgIconURL = DataReport.class.getResource("img/chart.png");
241:                bChart = new JButton(new ImageIcon(imgIconURL));
242:                bChart.setToolTipText("Create chart");
243:                imgIconURL = DataReport.class.getResource("img/utilities.png");
244:                bUtilities = new JButton(new ImageIcon(imgIconURL));
245:                bUtilities.setToolTipText("Options");
246:                imgIconURL = DataReport.class.getResource("img/help.png");
247:                bHelp = new JButton(new ImageIcon(imgIconURL));
248:                bHelp.setToolTipText("Help");
249:
250:                bExecute.addActionListener(this );
251:                bImport.addActionListener(this );
252:                bOpen.addActionListener(this );
253:                bSave.addActionListener(this );
254:                bProperties.addActionListener(this );
255:                bConnection.addActionListener(this );
256:                bQueryBuilder.addActionListener(this );
257:                bChart.addActionListener(this );
258:                bUtilities.addActionListener(this );
259:                bHelp.addActionListener(this );
260:
261:                imgIconURL = DataReport.class.getResource("img/alignleft.png");
262:                bAlignLeft = new JButton(new ImageIcon(imgIconURL));
263:                bAlignLeft.setToolTipText("Align left");
264:
265:                imgIconURL = DataReport.class.getResource("img/alignright.png");
266:                bAlignRight = new JButton(new ImageIcon(imgIconURL));
267:                bAlignRight.setToolTipText("Align right");
268:
269:                imgIconURL = DataReport.class.getResource("img/aligntop.png");
270:                bAlignTop = new JButton(new ImageIcon(imgIconURL));
271:                bAlignTop.setToolTipText("Align top");
272:
273:                imgIconURL = DataReport.class
274:                        .getResource("img/alignbottom.png");
275:                bAlignBottom = new JButton(new ImageIcon(imgIconURL));
276:                bAlignBottom.setToolTipText("Align bottom");
277:
278:                imgIconURL = DataReport.class.getResource("img/spaceh.png");
279:                bSpaceH = new JButton(new ImageIcon(imgIconURL));
280:                bSpaceH.setToolTipText("Space horizontally");
281:
282:                imgIconURL = DataReport.class.getResource("img/spacev.png");
283:                bSpaceV = new JButton(new ImageIcon(imgIconURL));
284:                bSpaceV.setToolTipText("Space vertically");
285:
286:                imgIconURL = DataReport.class.getResource("img/sizeh.png");
287:                bEqualH = new JButton(new ImageIcon(imgIconURL));
288:                bEqualH.setToolTipText("Equal height");
289:
290:                imgIconURL = DataReport.class.getResource("img/sizew.png");
291:                bEqualW = new JButton(new ImageIcon(imgIconURL));
292:                bEqualW.setToolTipText("Equal width");
293:
294:                imgIconURL = DataReport.class.getResource("img/centerh.png");
295:                bCenterH = new JButton(new ImageIcon(imgIconURL));
296:                bCenterH.setToolTipText("Center horizontally");
297:
298:                imgIconURL = DataReport.class.getResource("img/centerv.png");
299:                bCenterV = new JButton(new ImageIcon(imgIconURL));
300:                bCenterV.setToolTipText("Center vertically");
301:
302:                bAlignLeft.addActionListener(this );
303:                bAlignRight.addActionListener(this );
304:                bAlignTop.addActionListener(this );
305:                bAlignBottom.addActionListener(this );
306:                bSpaceH.addActionListener(this );
307:                bSpaceV.addActionListener(this );
308:                bEqualW.addActionListener(this );
309:                bEqualH.addActionListener(this );
310:                bCenterH.addActionListener(this );
311:                bCenterV.addActionListener(this );
312:
313:                toolBarAlign = new JToolBar();
314:                toolBarAlign.add(bAlignLeft);
315:                toolBarAlign.add(bAlignRight);
316:                toolBarAlign.add(bAlignTop);
317:                toolBarAlign.add(bAlignBottom);
318:                toolBarAlign.add(bCenterH);
319:                toolBarAlign.add(bCenterV);
320:                toolBarAlign.add(bSpaceH);
321:                toolBarAlign.add(bSpaceV);
322:                toolBarAlign.add(bEqualW);
323:                toolBarAlign.add(bEqualH);
324:
325:                toolBarHistory = new JToolBar();
326:                jComboHistory = new JComboBox();
327:                jComboHistory.setMaximumRowCount(10);
328:                jComboHistory.setPreferredSize(new Dimension(100, 30));
329:                jComboHistory.setModel(new DefaultComboBoxModel());
330:                jComboHistory.addActionListener(this );
331:                toolBarHistory.add(jComboHistory);
332:                toolBarHistory.setPreferredSize(new Dimension(toolBarHistory
333:                        .getSize().width, 25));
334:                toolBarHistory.setFloatable(false);
335:                //toolBarAlign.add(toolBarHistory);
336:
337:                toolBar.add(bExecute);
338:                toolBar.add(bImport);
339:                toolBar.addSeparator();
340:                toolBar.add(bOpen);
341:                toolBar.add(bSave);
342:                toolBar.addSeparator();
343:                toolBar.add(bProperties);
344:                toolBar.addSeparator();
345:                toolBar.add(bQueryBuilder);
346:                toolBar.add(bChart);
347:                toolBar.add(bConnection);
348:                toolBar.addSeparator();
349:                toolBar.add(bUtilities);
350:                toolBar.add(bHelp);
351:                toolBar.addSeparator();
352:                toolBar.add(toolBarAlign);
353:
354:                drg = dataPanel.getGestoreDragger();
355:
356:                this .getContentPane().add(dataPanel,
357:                        java.awt.BorderLayout.CENTER);
358:                this .getContentPane().add(toolBar, java.awt.BorderLayout.NORTH);
359:                this .getContentPane().add(toolBarHistory,
360:                        java.awt.BorderLayout.SOUTH);
361:            }
362:
363:            private void exitForm(java.awt.event.WindowEvent evt) {
364:                try {
365:                    if (conn != null) {
366:                        if (!conn.isClosed()) {
367:                            conn.close();
368:                        }
369:                    }
370:
371:                    ConnectionPool.closeAllConnection();
372:
373:                    System.exit(0);
374:                } catch (java.sql.SQLException e) {
375:                    javax.swing.JOptionPane.showMessageDialog(this , e
376:                            .getMessage());
377:                }
378:            }
379:
380:            public static void openSplashWindow() {
381:                splash = new JSplash();
382:                splash.setVisible(true);
383:            }
384:
385:            public void close() {
386:                ConfigurationProperties.properties().setWndX(getX());
387:                ConfigurationProperties.properties().setWndY(getY());
388:                ConfigurationProperties.properties().setWndWidth(getWidth());
389:                ConfigurationProperties.properties().setWndHeight(getHeight());
390:            }
391:
392:            public void connectionStablished() {
393:                String sTitle = getTitle();
394:                String sServer = ConnectionPool.getConnectionDefinition()
395:                        .getDriverName();
396:
397:                // Removes title information about current DBMS if any
398:                if (sTitle.indexOf('[') > -1) // Remove 3 extra spaces
399:                    sTitle = sTitle.substring(0, sTitle.indexOf('[') - 1)
400:                            .trim();
401:
402:                setTitle(sTitle + "   [DBMS: " + sServer + ']');
403:            }
404:
405:            public static void main(String args[]) {
406:                if (args.length == 1) {
407:                    if (!((String) args[0]).trim().substring(
408:                            ((String) args[0]).length() - 3).equalsIgnoreCase(
409:                            "dpv")) {
410:                        DataReport oDataRep = new DataReport();
411:
412:                        try {
413:                            openSplashWindow();
414:
415:                            dataPanel.loadXmlToDataPanel(args[0]);
416:                            ActionControl_E action = new ActionControl_E(
417:                                    "Execute");
418:                            action.setDataPanel(dataPanel);
419:                            //L'impostazione a null tra l' altro farà in
420:                            //modo che alla chiusura della finestra del risultato
421:                            //si chiuda anche il thread con System.exit(0)
422:                            action.actionPerformed(null);
423:                            oDataRep.setVisible(false);
424:
425:                        } catch (Exception e) {
426:                            javax.swing.JOptionPane.showMessageDialog(null, e
427:                                    .getMessage());
428:                        } catch (Throwable exc) {
429:
430:                        } finally {
431:                            if (splash != null)
432:                                splash.dispose();
433:                        }
434:                    } else {
435:                        try {
436:                            openSplashWindow();
437:
438:                            DataReportViewer drpv = new DataReportViewer(
439:                                    args[0]);
440:                            new Thread(drpv).start();
441:                        } catch (Throwable exc) {
442:
443:                        } finally {
444:                            if (splash != null)
445:                                splash.dispose();
446:                        }
447:                    }
448:                } else if (args.length == 2) {
449:                    DataReport oDataRep = new DataReport();
450:
451:                    try {
452:                        if (args[1].equals("/O")) {
453:                            dataPanel.loadXmlToDataPanel(args[0]);
454:                            oDataRep.setVisible(true);
455:                            dataPanel.getActionMap().get("F7").actionPerformed(
456:                                    null);
457:                        } else {
458:                            dataPanel.loadXmlToDataPanel(args[0]);
459:                            oDataRep.setVisible(false);
460:                            dataPanel.getActionMap().get("control G")
461:                                    .actionPerformed(null);
462:                        }
463:                    } catch (Exception e) {
464:                        javax.swing.JOptionPane.showMessageDialog(null, e
465:                                .getMessage());
466:                    } catch (Throwable exc) {
467:
468:                    }
469:                } else {
470:                    try {
471:                        openSplashWindow();
472:                        new DataReport().setVisible(true);
473:                        dataPanel.getActionMap().get("F7")
474:                                .actionPerformed(null);
475:                    } catch (Exception exc) {
476:                        System.out.println(exc.getMessage());
477:                    } finally {
478:                        if (splash != null)
479:                            splash.dispose();
480:                    }
481:                }
482:            }
483:
484:            public void actionPerformed(java.awt.event.ActionEvent e) {
485:                if (e.getSource() == bExecute) {
486:                    dataPanel.getActionMap().get("control E")
487:                            .actionPerformed(e);
488:
489:                } else if (e.getSource() == bImport) {
490:                    dataPanel.getActionMap().get("control I")
491:                            .actionPerformed(e);
492:
493:                } else if (e.getSource() == bOpen) {
494:                    bStartItemChange = false;
495:                    dataPanel.getActionMap().get("control O")
496:                            .actionPerformed(e);
497:                    String path = dataPanel.getXmlPathFile();
498:                    boolean b = dataPanel.isLoadNewReport();
499:
500:                    if (b) {
501:                        boolean additem = true;
502:                        for (int i = 0; i < jComboHistory.getItemCount(); i++) {
503:                            if (path
504:                                    .equals((String) jComboHistory.getItemAt(i))) {
505:                                additem = false;
506:                                jComboHistory.setSelectedIndex(i);
507:                                i = jComboHistory.getItemCount();
508:                            }
509:                        }
510:                        if (additem) {
511:                            ((DefaultComboBoxModel) jComboHistory.getModel())
512:                                    .addElement(path);
513:                            jComboHistory.setSelectedItem(path);
514:                            jComboHistory.validate();
515:                        }
516:                    }
517:
518:                    bStartItemChange = true;
519:
520:                } else if (e.getSource() == bSave) {
521:                    dataPanel.getActionMap().get("control S")
522:                            .actionPerformed(e);
523:
524:                } else if (e.getSource() == bProperties) {
525:                    dataPanel.getActionMap().get("control T")
526:                            .actionPerformed(e);
527:
528:                } else if (e.getSource() == bConnection) {
529:                    dataPanel.getActionMap().get("control Q")
530:                            .actionPerformed(e);
531:
532:                } else if (e.getSource() == bQueryBuilder) {
533:                    java.sql.Connection conn = null;
534:                    javax.swing.JFrame jFrameDiagram = new javax.swing.JFrame(
535:                            "FreeQueryBuilder [nickyb@users.sourceforge.net]");
536:
537:                    javax.swing.JButton bSql = new javax.swing.JButton(
538:                            new ImageIcon(DataReport.class
539:                                    .getResource("img/stock_ap.png")));
540:                    bSql.setToolTipText("import syntax on DataPanel");
541:                    bSql.addMouseListener(new java.awt.event.MouseAdapter() {
542:                        public void mouseClicked(java.awt.event.MouseEvent evt) {
543:                            if (qb.getModelClone() != null) {
544:                                String sql = qb.getModelClone().getSyntax();
545:                                //String sql = QuerySyntax.toString(qb.getModel());
546:
547:                                if (sql != null) {
548:                                    dataPanel.setSql(sql);
549:
550:                                    if (dataPanel.getDetailPanel()
551:                                            .getComponentCount() == 0) {
552:                                        dataPanel.getActionMap().get(
553:                                                "control I").actionPerformed(
554:                                                null);
555:                                    }
556:                                }
557:                            }
558:                        }
559:                    });
560:
561:                    javax.swing.JButton prewSql = new javax.swing.JButton(
562:                            new ImageIcon(DataReport.class
563:                                    .getResource("img/preview.png")));
564:                    prewSql.setToolTipText("preview syntax");
565:                    prewSql.addMouseListener(new java.awt.event.MouseAdapter() {
566:                        public void mouseClicked(java.awt.event.MouseEvent evt) {
567:                            if (qb.getModelClone() != null) {
568:                                String sql = qb.getModelClone().getSyntax();
569:                                //String sql = QuerySyntax.toString(qb.getModel());
570:
571:                                if (sql != null) {
572:                                    new QueryPreview(qb.getConnection(), qb
573:                                            .getModelClone()).show();
574:                                }
575:                            }
576:                        }
577:                    });
578:
579:                    conn = Connessione.getConnessione();
580:
581:                    if (conn != null) {
582:                        java.awt.Component comp = javax.swing.SwingUtilities
583:                                .getRoot(dataPanel);
584:
585:                        String driverName = "";
586:                        String url = "";
587:
588:                        try {
589:                            driverName = conn.getMetaData().getDriverName();
590:                            url = conn.getMetaData().getURL();
591:
592:                        } catch (java.sql.SQLException sqle) {
593:                            System.out.println(sqle.getMessage());
594:                        }
595:
596:                        String title = "Driver Name: " + driverName
597:                                + " - Connection: " + url;
598:
599:                        if (comp instanceof  javax.swing.JFrame) {
600:                            ((javax.swing.JFrame) comp).setTitle(title);
601:                        } else {
602:                            ((javax.swing.JInternalFrame) comp).setTitle(title);
603:                        }
604:
605:                        qb = new QueryBuilder(conn);
606:
607:                        qb.getActionMap().get("clear-diagram").putValue(
608:                                Action.SMALL_ICON,
609:                                new ImageIcon(DataReport.class
610:                                        .getResource("img/stock-u7.png")));
611:                        qb.getActionMap().get("select-distinct").putValue(
612:                                Action.SMALL_ICON,
613:                                new ImageIcon(DataReport.class
614:                                        .getResource("img/select_s.png")));
615:                        qb.getActionMap().get("change-work-mode").putValue(
616:                                Action.SMALL_ICON,
617:                                new ImageIcon(DataReport.class
618:                                        .getResource("img/stock-li.png")));
619:
620:                        JToolBar toolbar = new JToolBar(JToolBar.VERTICAL);
621:                        //toolbar.add(customize(new JButton(new ActionPreview())));
622:                        toolbar.add(qb.getActionMap().get("clear-diagram"));
623:                        toolbar.addSeparator();
624:                        JToggleButton jToggleDistinct = new JToggleButton(qb
625:                                .getActionMap().get("select-distinct"));
626:                        jToggleDistinct.setText(null);
627:                        toolbar.add(jToggleDistinct);
628:                        toolbar.addSeparator();
629:                        JToggleButton jToggleJoin = new JToggleButton(qb
630:                                .getActionMap().get("change-work-mode"));
631:                        jToggleJoin.setText(null);
632:                        toolbar.add(jToggleJoin);
633:                        toolbar.addSeparator();
634:                        toolbar.add(prewSql);
635:                        toolbar.add(bSql);
636:
637:                        jFrameDiagram.getContentPane().add(qb);
638:                        jFrameDiagram.getContentPane().add(toolbar,
639:                                java.awt.BorderLayout.EAST);
640:                        jFrameDiagram
641:                                .setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
642:
643:                        jFrameDiagram.setSize(new java.awt.Dimension(800, 500));
644:
645:                        DataEngine.centerWindow(jFrameDiagram,
646:                                javax.swing.SwingUtilities
647:                                        .getWindowAncestor(dataPanel));
648:                        jFrameDiagram.setVisible(true);
649:                    }
650:                } else if (e.getSource() == bChart) {
651:                    dataPanel.getActionMap().get("control G")
652:                            .actionPerformed(e);
653:
654:                } else if (e.getSource() == bHelp) {
655:                    dataPanel.getActionMap().get("F1").actionPerformed(e);
656:
657:                } else if (e.getSource() == bUtilities) {
658:                    dataPanel.getActionMap().get("control F1").actionPerformed(
659:                            e);
660:
661:                } else if (e.getSource() == bAlignTop) {
662:                    DataReport.this .dataPanel.getActionMap().get("align UP")
663:                            .actionPerformed(null);
664:
665:                } else if (e.getSource() == bAlignBottom) {
666:                    DataReport.this .dataPanel.getActionMap().get("align DOWN")
667:                            .actionPerformed(null);
668:
669:                } else if (e.getSource() == bAlignLeft) {
670:                    DataReport.this .dataPanel.getActionMap().get("align LEFT")
671:                            .actionPerformed(null);
672:
673:                } else if (e.getSource() == bAlignRight) {
674:                    DataReport.this .dataPanel.getActionMap().get("align RIGHT")
675:                            .actionPerformed(null);
676:
677:                } else if (e.getSource() == bSpaceH) {
678:                    DataReport.this .dataPanel.getActionMap().get("Space H")
679:                            .actionPerformed(null);
680:
681:                } else if (e.getSource() == bSpaceV) {
682:                    DataReport.this .dataPanel.getActionMap().get("Space V")
683:                            .actionPerformed(null);
684:
685:                } else if (e.getSource() == bEqualH) {
686:                    DataReport.this .dataPanel.getActionMap().get("Equal H")
687:                            .actionPerformed(null);
688:
689:                } else if (e.getSource() == bEqualW) {
690:                    DataReport.this .dataPanel.getActionMap().get("Equal W")
691:                            .actionPerformed(null);
692:
693:                } else if (e.getSource() == bCenterH) {
694:                    DataReport.this .dataPanel.getActionMap().get("Center H")
695:                            .actionPerformed(null);
696:
697:                } else if (e.getSource() == bCenterV) {
698:                    DataReport.this .dataPanel.getActionMap().get("Center V")
699:                            .actionPerformed(null);
700:                } else if (e.getSource() == jComboHistory) {
701:                    if (bStartItemChange) {
702:                        String path = (String) jComboHistory.getSelectedItem();
703:                        DataReport.this.dataPanel.loadXmlToDataPanel(path);
704:                    }
705:                }
706:            }
707:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.