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


001:        /*
002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved. 
003:         * http://www.jaspersoft.com.
004:         *
005:         * Unless you have purchased a commercial license agreement from JasperSoft,
006:         * the following license terms apply:
007:         *
008:         * This program is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License version 2 as published by
010:         * the Free Software Foundation.
011:         *
012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014:         * See the 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, see http://www.gnu.org/licenses/gpl.txt
018:         * or write to:
019:         *
020:         * Free Software Foundation, Inc.,
021:         * 59 Temple Place - Suite 330,
022:         * Boston, MA  USA  02111-1307
023:         *
024:         *
025:         *
026:         *
027:         * LibraryPanel.java
028:         * 
029:         * Created on 14 settembre 2004, 23.49
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.gui.library;
034:
035:        import it.businesslogic.ireport.gui.event.ReportSubDatasetChangedEvent;
036:        import it.businesslogic.ireport.gui.library.objects.*;
037:        import it.businesslogic.ireport.gui.*;
038:        import it.businesslogic.ireport.*;
039:        import it.businesslogic.ireport.gui.docking.GenericDragTargetListener;
040:        import it.businesslogic.ireport.util.Misc;
041:        import java.awt.dnd.DropTarget;
042:        import javax.swing.*;
043:        import javax.swing.tree.*;
044:        import java.util.*;
045:        import java.awt.event.ActionEvent;
046:
047:        /**
048:         *
049:         * @author  Administrator
050:         */
051:        public class LibraryPanel extends javax.swing.JPanel
052:                implements 
053:                it.businesslogic.ireport.util.LanguageChangedListener,
054:                it.businesslogic.ireport.gui.event.SubDatasetObjectChangedListener,
055:                it.businesslogic.ireport.gui.event.ReportSubDatasetChangedListener {
056:
057:            //    DefaultMutableTreeNode fieldsNode = null;
058:            //    DefaultMutableTreeNode variablesNode = null;
059:            //    DefaultMutableTreeNode parametersNode = null;
060:            DefaultMutableTreeNode systemObjectsNode = null;
061:
062:            JReportFrame jrf;
063:
064:            /** Creates new form LibraryPanel */
065:            public LibraryPanel() {
066:
067:                initComponents();
068:
069:                jLibraryTree.setCellRenderer(new LibraryTreeCellRenderer());
070:                DefaultMutableTreeNode root = new DefaultMutableTreeNode("Libs");
071:
072:                DefaultTreeModel dtm = new DefaultTreeModel(root);
073:
074:                jLibraryTree.setModel(dtm);
075:                jLibraryTree.setDragEnabled(true);
076:                jLibraryTree.setRootVisible(false);
077:                jLibraryTree.setTransferHandler(new TreeTransfertHandler());
078:
079:                jLibraryTree.setDropTarget(new DropTarget(this ,
080:                        new GenericDragTargetListener()));
081:
082:                jLibraryTree.expandPath(new TreePath(root));
083:
084:                //        fieldsNode = new DefaultMutableTreeNode("Fields",true);
085:                //        root.add( fieldsNode );
086:                //
087:                //        variablesNode = new DefaultMutableTreeNode("Variables",true);
088:                //        root.add( variablesNode );
089:                //
090:                //        parametersNode = new DefaultMutableTreeNode("Parameters",true);
091:                //        root.add( parametersNode );
092:
093:                this .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
094:                        KeyStroke.getKeyStroke("F5"), "refresh");
095:                this .getActionMap().put("refresh",
096:                        new AbstractAction("refresh") {
097:                            public void actionPerformed(ActionEvent evt) {
098:                                setJReportFrame(jrf);
099:                            }
100:                        });
101:                /*
102:                 systemObjectsNode = new DefaultMutableTreeNode("Custom",true);
103:                 root.add( systemObjectsNode );
104:                 */
105:                it.businesslogic.ireport.util.I18n
106:                        .addOnLanguageChangedListener(this );
107:
108:                loadSystemObjects();
109:                loadCustomObjects();
110:
111:                // updateReportObjects();
112:                this .languageChanged(null);
113:            }
114:
115:            /** This method is called from within the constructor to
116:             * initialize the form.
117:             * WARNING: Do NOT modify this code. The content of this method is
118:             * always regenerated by the Form Editor.
119:             */
120:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
121:            private void initComponents() {
122:
123:                jScrollPane1 = new javax.swing.JScrollPane();
124:                jLibraryTree = new javax.swing.JTree();
125:
126:                setLayout(new java.awt.BorderLayout());
127:
128:                jScrollPane1
129:                        .addMouseListener(new java.awt.event.MouseAdapter() {
130:                            public void mouseClicked(
131:                                    java.awt.event.MouseEvent evt) {
132:                                jScrollPane1MouseClicked(evt);
133:                            }
134:                        });
135:
136:                jLibraryTree.setDragEnabled(true);
137:                jLibraryTree
138:                        .addMouseListener(new java.awt.event.MouseAdapter() {
139:                            public void mouseClicked(
140:                                    java.awt.event.MouseEvent evt) {
141:                                jLibraryTreeMouseClicked(evt);
142:                            }
143:                        });
144:                jScrollPane1.setViewportView(jLibraryTree);
145:
146:                add(jScrollPane1, java.awt.BorderLayout.CENTER);
147:            }// </editor-fold>//GEN-END:initComponents
148:
149:            /**
150:             *   return the dataset to wich refer the current selection in the tree
151:             **/
152:            private SubDataset getSelectedSubDataset() {
153:                if (jrf == null)
154:                    return null;
155:
156:                SubDataset sd = jrf.getReport();
157:                TreePath[] paths = jLibraryTree.getSelectionPaths();
158:                if (paths != null && paths.length == 1) {
159:                    if (paths[0].getLastPathComponent() instanceof  DefaultMutableTreeNode) {
160:                        if (paths[0].getPath().length >= 2) {
161:                            Object osd = ((DefaultMutableTreeNode) paths[0]
162:                                    .getPath()[1]).getUserObject();
163:                            if (osd instanceof  SubDataset) {
164:                                sd = (SubDataset) osd;
165:                            }
166:                        }
167:                    }
168:                }
169:
170:                return sd;
171:            }
172:
173:            private void jScrollPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPane1MouseClicked
174:                jLibraryTreeMouseClicked(evt);
175:            }//GEN-LAST:event_jScrollPane1MouseClicked
176:
177:            private void jLibraryTreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLibraryTreeMouseClicked
178:
179:            }//GEN-LAST:event_jLibraryTreeMouseClicked
180:
181:            public void languageChanged(
182:                    it.businesslogic.ireport.util.LanguageChangedEvent evt) {
183:
184:                jLibraryTree.updateUI();
185:            }
186:
187:            public void setJReportFrame(JReportFrame jrf) {
188:                this .jrf = jrf;
189:            }
190:
191:            private void loadCustomObjects() {
192:
193:            }
194:
195:            private void loadSystemObjects() {
196:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) jLibraryTree
197:                        .getModel().getRoot();
198:                root.add(new DefaultMutableTreeNode(new PageNumberObject()));
199:                root.add(new DefaultMutableTreeNode(new TotalPagesObject()));
200:                root.add(new DefaultMutableTreeNode(new PageXYObject()));
201:                root.add(new DefaultMutableTreeNode(new TotalObject()));
202:                root.add(new DefaultMutableTreeNode(new DateObject()));
203:                root.add(new DefaultMutableTreeNode(new PercentageObject()));
204:            }
205:
206:            private void addLibraryObject(String folder,
207:                    AbstractLibraryObject obj) {
208:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) jLibraryTree
209:                        .getModel().getRoot();
210:                if (folder == null || folder.length() == 0) {
211:                    root
212:                            .add(new DefaultMutableTreeNode(
213:                                    new PageNumberObject()));
214:                } else {
215:                    // Look for folder...
216:                    Enumeration enum_childrens = root.children();
217:                    while (enum_childrens.hasMoreElements()) {
218:                        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) enum_childrens
219:                                .nextElement();
220:                        if (("" + dmtn.getUserObject())
221:                                .equalsIgnoreCase(folder)) {
222:                            dmtn.add(new DefaultMutableTreeNode(obj));
223:                        }
224:                    }
225:                }
226:            }
227:
228:            public void updateReportObjects() {
229:                /*
230:                this.fieldsNode.removeAllChildren();
231:                this.parametersNode.removeAllChildren();
232:                this.variablesNode.removeAllChildren();
233:
234:                if (jrf == null) {
235:
236:                   jLibraryTree.updateUI();
237:                   return;
238:                }
239:
240:                java.util.Enumeration e = jrf.getReport().getFields().elements();
241:                while (e.hasMoreElements())
242:                {
243:                     fieldsNode.add(new DefaultMutableTreeNode(e.nextElement()));
244:                }
245:                e = jrf.getReport().getParameters().elements();
246:                while (e.hasMoreElements())
247:                {
248:                     parametersNode.add(new DefaultMutableTreeNode(e.nextElement()));
249:                }
250:
251:                e = jrf.getReport().getVariables().elements();
252:                while (e.hasMoreElements())
253:                {
254:                     variablesNode.add(new DefaultMutableTreeNode(e.nextElement()));
255:                }
256:
257:                jLibraryTree.updateUI();
258:                 */
259:            }
260:
261:            // Variables declaration - do not modify//GEN-BEGIN:variables
262:            private javax.swing.JTree jLibraryTree;
263:            private javax.swing.JScrollPane jScrollPane1;
264:
265:            // End of variables declaration//GEN-END:variables
266:
267:            public void subDatasetObjectChanged(
268:                    it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent evt) {
269:
270:                //         if (evt != null && evt.getSource() instanceof Report)
271:                //         {
272:                //            this.updateReportObjects();
273:                //         }
274:                //         else
275:                //         {
276:                //             updateSubDatasetNode( evt.getSource() );
277:                //         }
278:
279:            }
280:
281:            //    public void reportSubDatasetChanged(it.businesslogic.ireport.gui.event.ReportSubDatasetChangedEvent evt) {
282:            //    
283:            //        DefaultMutableTreeNode root = (DefaultMutableTreeNode)jLibraryTree.getModel().getRoot();
284:            //        if (evt.getAction() == evt.ADDED &&
285:            //           evt.getObjectType() == evt.OBJECT_SUBDATASET)
286:            //       {
287:            //           int lastDatasourceIndex = 3;
288:            //           for (lastDatasourceIndex=3; root.getChildCount() > lastDatasourceIndex; lastDatasourceIndex++)
289:            //           {
290:            //               if ( ((DefaultMutableTreeNode)root.getChildAt(lastDatasourceIndex)).getUserObject() instanceof SubDataset) continue;
291:            //               break;
292:            //           }
293:            //
294:            //           for (int i=0; i<evt.getElements().size(); ++i)
295:            //           {
296:            //            DefaultMutableTreeNode subDatasetNode = new DefaultMutableTreeNode(evt.getElements().elementAt(i));
297:            //            root.insert(subDatasetNode, lastDatasourceIndex);
298:            //            updateSubDatasetNode( subDatasetNode );
299:            //            lastDatasourceIndex++;
300:            //           }
301:            //       } else if (evt.getAction() == evt.REMOVED &&
302:            //           evt.getObjectType() == evt.OBJECT_SUBDATASET)
303:            //       {
304:            //
305:            //            DefaultMutableTreeNode subDatasetNode = null;
306:            //             for (int i=0; i<evt.getElements().size(); ++i)
307:            //             {
308:            //                // 1. Find the datasource...
309:            //                 for (int k=0; k< root.getChildCount(); ++k)
310:            //                 {
311:            //                     if (((DefaultMutableTreeNode)root.getChildAt(k)).getUserObject() == evt.getElements().elementAt(i))
312:            //                     {
313:            //                         root.remove(k);
314:            //                         break;
315:            //                     }
316:            //                 }
317:            //             }
318:            //
319:            //           jLibraryTree.updateUI();
320:            //
321:            //       } else if (evt.getAction() == evt.CHANGED &&
322:            //           evt.getObjectType() == evt.OBJECT_SUBDATASET)
323:            //       {
324:            //           jLibraryTree.updateUI();
325:            //       }
326:            //     
327:            //    }
328:            //
329:            //
330:            //    public void updateSubDatasetNode(SubDataset subDataset)
331:            //    {
332:            //        DefaultMutableTreeNode root = (DefaultMutableTreeNode)jLibraryTree.getModel().getRoot();
333:            //        for (int k=0; k< root.getChildCount(); ++k)
334:            //        {
335:            //             if (((DefaultMutableTreeNode)root.getChildAt(k)).getUserObject() == subDataset)
336:            //             {
337:            //                 updateSubDatasetNode((DefaultMutableTreeNode)root.getChildAt(k));
338:            //                 return;
339:            //             }
340:            //        }
341:            //
342:            //    }
343:            //
344:            //    public void updateSubDatasetNode(DefaultMutableTreeNode subDatasetNode )
345:            //    {
346:            //        DefaultMutableTreeNode dsFieldsNode = null;
347:            //        DefaultMutableTreeNode dsVariablesNode = null;
348:            //        DefaultMutableTreeNode dsParametersNode = null;
349:            //
350:            //        SubDataset subDataset = (SubDataset)subDatasetNode.getUserObject();
351:            //
352:            //        if (subDatasetNode.getChildCount() == 0)
353:            //        {
354:            //            dsFieldsNode = new DefaultMutableTreeNode(it.businesslogic.ireport.util.I18n.getString("gui.library.fields","Fields"),true);
355:            //            subDatasetNode.add( dsFieldsNode );
356:            //
357:            //            dsVariablesNode = new DefaultMutableTreeNode(it.businesslogic.ireport.util.I18n.getString("gui.library.variables","Variables"),true);
358:            //            subDatasetNode.add( dsVariablesNode );
359:            //
360:            //            dsParametersNode = new DefaultMutableTreeNode(it.businesslogic.ireport.util.I18n.getString("gui.library.parameters","Parameters"),true);
361:            //            subDatasetNode.add( dsParametersNode );
362:            //        }
363:            //        else
364:            //        {
365:            //            dsFieldsNode = (DefaultMutableTreeNode)subDatasetNode.getChildAt(0);
366:            //            dsVariablesNode = (DefaultMutableTreeNode)subDatasetNode.getChildAt(1);
367:            //            dsParametersNode = (DefaultMutableTreeNode)subDatasetNode.getChildAt(2);
368:            //        }
369:            //
370:            //        dsFieldsNode.removeAllChildren();
371:            //        dsVariablesNode.removeAllChildren();
372:            //        dsParametersNode.removeAllChildren();
373:            //
374:            //        java.util.Enumeration e = subDataset.getFields().elements();
375:            //        while (e.hasMoreElements())
376:            //        {
377:            //             dsFieldsNode.add(new DefaultMutableTreeNode(e.nextElement()));
378:            //        }
379:            //        e = subDataset.getParameters().elements();
380:            //        while (e.hasMoreElements())
381:            //        {
382:            //             dsParametersNode.add(new DefaultMutableTreeNode(e.nextElement()));
383:            //       }
384:            //
385:            //        e = subDataset.getVariables().elements();
386:            //       while (e.hasMoreElements())
387:            //       {
388:            //             dsVariablesNode.add(new DefaultMutableTreeNode(e.nextElement()));
389:            //       }
390:            //
391:            //       jLibraryTree.updateUI();
392:            //    }
393:            //
394:            //    public void updateSubDatasets()
395:            //    {
396:            //        DefaultMutableTreeNode root = (DefaultMutableTreeNode)jLibraryTree.getModel().getRoot();
397:            //        for (int k=0; k< root.getChildCount(); ++k)
398:            //        {
399:            //             if (((DefaultMutableTreeNode)root.getChildAt(k)).getUserObject() instanceof SubDataset)
400:            //             {
401:            //                 root.remove(k);
402:            //                 k--;
403:            //             }
404:            //        }
405:            //
406:            //        if (jrf != null)
407:            //        {
408:            //            int lastDatasourceIndex = 3;
409:            //            for (int i=0; i< jrf.getReport().getSubDatasets().size(); ++i)
410:            //            {
411:            //                DefaultMutableTreeNode subDatasetNode = new DefaultMutableTreeNode(jrf.getReport().getSubDatasets().elementAt(i));
412:            //                root.insert(subDatasetNode, lastDatasourceIndex);
413:            //                updateSubDatasetNode( subDatasetNode );
414:            //                lastDatasourceIndex++;
415:            //            }
416:            //        }
417:            //
418:            //        jLibraryTree.updateUI();
419:            //    }
420:
421:            public void applyI18n() {
422:                // Start autogenerated code ----------------------
423:                // End autogenerated code ----------------------
424:            }
425:
426:            public void setSelectedObject(Object obj) {
427:                DefaultMutableTreeNode mtd = Misc.findNodeWithUserObject(obj,
428:                        (TreeNode) this .jLibraryTree.getModel().getRoot());
429:
430:                if (mtd != null) {
431:                    TreePath path = new TreePath(mtd.getPath());
432:                    jLibraryTree.setSelectionPath(path);
433:                    jLibraryTree.scrollPathToVisible(path);
434:                }
435:            }
436:
437:            public void reportSubDatasetChanged(ReportSubDatasetChangedEvent evt) {
438:
439:            }
440:
441:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.