Source Code Cross Referenced for CrosstabMeasuresView.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » crosstab » gui » 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.crosstab.gui 
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:         * CrosstabMeasuresView.java
028:         * 
029:         * Created on January 24, 2006, 10:42 AM
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.crosstab.gui;
034:
035:        import it.businesslogic.ireport.CrosstabReportElement;
036:        import it.businesslogic.ireport.crosstab.CrosstabColumnGroup;
037:        import it.businesslogic.ireport.crosstab.CrosstabGroup;
038:        import it.businesslogic.ireport.crosstab.CrosstabParameter;
039:        import it.businesslogic.ireport.crosstab.CrosstabRowGroup;
040:        import it.businesslogic.ireport.crosstab.GroupTotal;
041:        import it.businesslogic.ireport.crosstab.Measure;
042:        import it.businesslogic.ireport.gui.MainFrame;
043:        import it.businesslogic.ireport.gui.docking.GenericDragTargetListener;
044:        import it.businesslogic.ireport.gui.event.CrosstabLayoutChangedEvent;
045:        import it.businesslogic.ireport.gui.library.LibraryTreeCellRenderer;
046:        import it.businesslogic.ireport.gui.library.TreeTransfertHandler;
047:        import java.awt.dnd.DropTarget;
048:        import javax.swing.tree.DefaultMutableTreeNode;
049:        import javax.swing.tree.DefaultTreeModel;
050:        import javax.swing.tree.TreePath;
051:        import it.businesslogic.ireport.util.I18n;
052:
053:        /**
054:         *
055:         * @author  gtoffoli
056:         */
057:        public class CrosstabMeasuresView extends javax.swing.JPanel
058:                implements 
059:                it.businesslogic.ireport.gui.event.CrosstabLayoutChangedListener {
060:
061:            private CrosstabReportElement crosstabReportElement = null;
062:
063:            /** Creates new form CrosstabMeasuresView */
064:            public CrosstabMeasuresView() {
065:                initComponents();
066:
067:                DefaultMutableTreeNode root = new DefaultMutableTreeNode(
068:                        "measures");
069:
070:                DefaultTreeModel dtm = new DefaultTreeModel(root);
071:
072:                jTree.setModel(dtm);
073:                jTree.setDragEnabled(true);
074:                jTree.setRootVisible(false);
075:                jTree.setTransferHandler(new TreeTransfertHandler());
076:                jTree.setCellRenderer(new LibraryTreeCellRenderer());
077:                jTree.expandPath(new TreePath(root));
078:
079:                jTree.setDropTarget(new DropTarget(this ,
080:                        new GenericDragTargetListener()));
081:
082:            }
083:
084:            public CrosstabReportElement getCrosstabReportElement() {
085:                return crosstabReportElement;
086:            }
087:
088:            public void setCrosstabReportElement(
089:                    CrosstabReportElement crosstabReportElement) {
090:
091:                // Stop to listen to the old crosstab (if not null)
092:                if (this .crosstabReportElement != null
093:                        && this .crosstabReportElement != crosstabReportElement) {
094:                    this .crosstabReportElement
095:                            .removeCrosstabLayoutChangedListener(this );
096:                }
097:
098:                // Start to listen to the new crosstab (if not null)
099:                if (crosstabReportElement != null
100:                        && this .crosstabReportElement != crosstabReportElement) {
101:                    crosstabReportElement
102:                            .addCrosstabLayoutChangedListener(this );
103:                }
104:
105:                this .crosstabReportElement = crosstabReportElement;
106:
107:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) jTree
108:                        .getModel().getRoot();
109:                root.removeAllChildren();
110:
111:                if (crosstabReportElement != null) {
112:
113:                    for (int i = 0; i < crosstabReportElement.getRowGroups()
114:                            .size(); ++i) {
115:                        CrosstabGroup group = (CrosstabGroup) crosstabReportElement
116:                                .getRowGroups().elementAt(i);
117:                        root.add(new DefaultMutableTreeNode(group));
118:                    }
119:
120:                    for (int i = 0; i < crosstabReportElement.getColumnGroups()
121:                            .size(); ++i) {
122:                        CrosstabGroup group = (CrosstabGroup) crosstabReportElement
123:                                .getColumnGroups().elementAt(i);
124:                        root.add(new DefaultMutableTreeNode(group));
125:                    }
126:
127:                    for (int i = 0; i < crosstabReportElement.getMeasures()
128:                            .size(); ++i) {
129:                        Measure measure = (Measure) crosstabReportElement
130:                                .getMeasures().elementAt(i);
131:                        root.add(new DefaultMutableTreeNode(measure));
132:                        for (int j = 0; j < crosstabReportElement
133:                                .getRowGroups().size(); ++j) {
134:                            CrosstabGroup group = (CrosstabGroup) crosstabReportElement
135:                                    .getRowGroups().elementAt(j);
136:                            root.add(new DefaultMutableTreeNode(new GroupTotal(
137:                                    measure.getName(), group.getName(), measure
138:                                            .getClassType())));
139:                        }
140:                        for (int j = 0; j < crosstabReportElement
141:                                .getColumnGroups().size(); ++j) {
142:                            CrosstabGroup group = (CrosstabGroup) crosstabReportElement
143:                                    .getColumnGroups().elementAt(j);
144:                            root.add(new DefaultMutableTreeNode(new GroupTotal(
145:                                    measure.getName(), group.getName(), measure
146:                                            .getClassType())));
147:                        }
148:                    }
149:
150:                    for (int i = 0; i < crosstabReportElement
151:                            .getCrosstabParameters().size(); ++i) {
152:                        CrosstabParameter parameter = (CrosstabParameter) crosstabReportElement
153:                                .getCrosstabParameters().elementAt(i);
154:                        root.add(new DefaultMutableTreeNode(parameter));
155:                    }
156:
157:                }
158:
159:                jTree.expandPath(new TreePath(root));
160:                jTree.updateUI();
161:            }
162:
163:            /** This method is called from within the constructor to
164:             * initialize the form.
165:             * WARNING: Do NOT modify this code. The content of this method is
166:             * always regenerated by the Form Editor.
167:             */
168:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
169:            private void initComponents() {
170:                jPopupMenuMeasures = new javax.swing.JPopupMenu();
171:                jMenuItemEditMeasure = new javax.swing.JMenuItem();
172:                jSeparator4 = new javax.swing.JSeparator();
173:                jMenuItemNewMeasure = new javax.swing.JMenuItem();
174:                jSeparator3 = new javax.swing.JSeparator();
175:                jMenuItemCrosstabProperties = new javax.swing.JMenuItem();
176:                jSeparator1 = new javax.swing.JSeparator();
177:                jMenuItemCut = new javax.swing.JMenuItem();
178:                jMenuItemCopy = new javax.swing.JMenuItem();
179:                jMenuItemPaste = new javax.swing.JMenuItem();
180:                jMenuItemDelete = new javax.swing.JMenuItem();
181:                jSeparator2 = new javax.swing.JSeparator();
182:                jMenuItemRefresh = new javax.swing.JMenuItem();
183:                jScrollPane1 = new javax.swing.JScrollPane();
184:                jTree = new javax.swing.JTree();
185:
186:                jPopupMenuMeasures
187:                        .addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
188:                            public void popupMenuCanceled(
189:                                    javax.swing.event.PopupMenuEvent evt) {
190:                            }
191:
192:                            public void popupMenuWillBecomeInvisible(
193:                                    javax.swing.event.PopupMenuEvent evt) {
194:                            }
195:
196:                            public void popupMenuWillBecomeVisible(
197:                                    javax.swing.event.PopupMenuEvent evt) {
198:                                jPopupMenuMeasuresPopupMenuWillBecomeVisible(evt);
199:                            }
200:                        });
201:
202:                jMenuItemEditMeasure.setIcon(new javax.swing.ImageIcon(""));
203:                jMenuItemEditMeasure.setText("Edit");
204:                jMenuItemEditMeasure.setActionCommand("Modify measure");
205:                jMenuItemEditMeasure.setEnabled(false);
206:                jMenuItemEditMeasure
207:                        .addActionListener(new java.awt.event.ActionListener() {
208:                            public void actionPerformed(
209:                                    java.awt.event.ActionEvent evt) {
210:                                jMenuItemEditMeasureActionPerformed(evt);
211:                            }
212:                        });
213:
214:                jPopupMenuMeasures.add(jMenuItemEditMeasure);
215:
216:                jPopupMenuMeasures.add(jSeparator4);
217:
218:                jMenuItemNewMeasure.setIcon(new javax.swing.ImageIcon(""));
219:                jMenuItemNewMeasure.setText("New measure");
220:                jMenuItemNewMeasure
221:                        .addActionListener(new java.awt.event.ActionListener() {
222:                            public void actionPerformed(
223:                                    java.awt.event.ActionEvent evt) {
224:                                jMenuItemNewMeasureActionPerformed(evt);
225:                            }
226:                        });
227:
228:                jPopupMenuMeasures.add(jMenuItemNewMeasure);
229:
230:                jPopupMenuMeasures.add(jSeparator3);
231:
232:                jMenuItemCrosstabProperties.setIcon(new javax.swing.ImageIcon(
233:                        ""));
234:                jMenuItemCrosstabProperties.setText("Crosstab properties");
235:                jMenuItemCrosstabProperties
236:                        .addActionListener(new java.awt.event.ActionListener() {
237:                            public void actionPerformed(
238:                                    java.awt.event.ActionEvent evt) {
239:                                jMenuItemEditActionPerformed1(evt);
240:                            }
241:                        });
242:
243:                jPopupMenuMeasures.add(jMenuItemCrosstabProperties);
244:
245:                jPopupMenuMeasures.add(jSeparator1);
246:
247:                jMenuItemCut
248:                        .setIcon(new javax.swing.ImageIcon(
249:                                getClass()
250:                                        .getResource(
251:                                                "/it/businesslogic/ireport/icons/menu/cut.png")));
252:                jMenuItemCut.setText("Cut");
253:                jMenuItemCut.setEnabled(false);
254:                jMenuItemCut
255:                        .addActionListener(new java.awt.event.ActionListener() {
256:                            public void actionPerformed(
257:                                    java.awt.event.ActionEvent evt) {
258:                                jMenuItemCutActionPerformed(evt);
259:                            }
260:                        });
261:
262:                jPopupMenuMeasures.add(jMenuItemCut);
263:
264:                jMenuItemCopy
265:                        .setIcon(new javax.swing.ImageIcon(
266:                                getClass()
267:                                        .getResource(
268:                                                "/it/businesslogic/ireport/icons/menu/copy.png")));
269:                jMenuItemCopy.setText("Copy");
270:                jMenuItemCopy.setEnabled(false);
271:                jMenuItemCopy
272:                        .addActionListener(new java.awt.event.ActionListener() {
273:                            public void actionPerformed(
274:                                    java.awt.event.ActionEvent evt) {
275:                                jMenuItemCopyActionPerformed(evt);
276:                            }
277:                        });
278:
279:                jPopupMenuMeasures.add(jMenuItemCopy);
280:
281:                jMenuItemPaste
282:                        .setIcon(new javax.swing.ImageIcon(
283:                                getClass()
284:                                        .getResource(
285:                                                "/it/businesslogic/ireport/icons/menu/paste.png")));
286:                jMenuItemPaste.setText("Paste");
287:                jMenuItemPaste.setEnabled(false);
288:                jMenuItemPaste
289:                        .addActionListener(new java.awt.event.ActionListener() {
290:                            public void actionPerformed(
291:                                    java.awt.event.ActionEvent evt) {
292:                                jMenuItemPasteActionPerformed(evt);
293:                            }
294:                        });
295:
296:                jPopupMenuMeasures.add(jMenuItemPaste);
297:
298:                jMenuItemDelete
299:                        .setIcon(new javax.swing.ImageIcon(
300:                                getClass()
301:                                        .getResource(
302:                                                "/it/businesslogic/ireport/icons/menu/delete.png")));
303:                jMenuItemDelete.setText("Delete");
304:                jMenuItemDelete.setEnabled(false);
305:                jMenuItemDelete
306:                        .addActionListener(new java.awt.event.ActionListener() {
307:                            public void actionPerformed(
308:                                    java.awt.event.ActionEvent evt) {
309:                                jMenuItemDeleteActionPerformed(evt);
310:                            }
311:                        });
312:
313:                jPopupMenuMeasures.add(jMenuItemDelete);
314:
315:                jPopupMenuMeasures.add(jSeparator2);
316:
317:                jMenuItemRefresh.setText("Refresh");
318:                jMenuItemRefresh
319:                        .addActionListener(new java.awt.event.ActionListener() {
320:                            public void actionPerformed(
321:                                    java.awt.event.ActionEvent evt) {
322:                                jMenuItemRefreshActionPerformed(evt);
323:                            }
324:                        });
325:
326:                jPopupMenuMeasures.add(jMenuItemRefresh);
327:
328:                setLayout(new java.awt.BorderLayout());
329:
330:                jTree.addMouseListener(new java.awt.event.MouseAdapter() {
331:                    public void mouseClicked(java.awt.event.MouseEvent evt) {
332:                        jTreeMouseClicked(evt);
333:                    }
334:                });
335:
336:                jScrollPane1.setViewportView(jTree);
337:
338:                add(jScrollPane1, java.awt.BorderLayout.CENTER);
339:
340:            }// </editor-fold>//GEN-END:initComponents
341:
342:            private void jTreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTreeMouseClicked
343:
344:                if (evt.getClickCount() == 1 && evt.getButton() == evt.BUTTON3) {
345:                    jPopupMenuMeasures.show(jTree, evt.getX(), evt.getY());
346:                } else if (evt.getClickCount() == 2
347:                        && evt.getButton() == evt.BUTTON1) {
348:                    jMenuItemEditMeasureActionPerformed(null);
349:                }
350:            }//GEN-LAST:event_jTreeMouseClicked
351:
352:            private void jMenuItemEditActionPerformed1(
353:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemEditActionPerformed1
354:                it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog cpd = new it.businesslogic.ireport.crosstab.gui.CrosstabPropertiesDialog(
355:                        MainFrame.getMainInstance(), true);
356:                cpd.setCurrentCrosstabReportElement(getCrosstabReportElement());
357:                cpd.setVisible(true);
358:            }//GEN-LAST:event_jMenuItemEditActionPerformed1
359:
360:            private void jPopupMenuMeasuresPopupMenuWillBecomeVisible(
361:                    javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_jPopupMenuMeasuresPopupMenuWillBecomeVisible
362:
363:                jMenuItemNewMeasure.setEnabled(true);
364:                jMenuItemRefresh.setEnabled(true);
365:
366:                // Edit is able only if a single valid object is selected...
367:                TreePath[] paths = jTree.getSelectionPaths();
368:
369:                if (paths == null || paths.length == 0) {
370:                    jMenuItemCut.setEnabled(false);
371:                    jMenuItemCopy.setEnabled(false);
372:                    jMenuItemDelete.setEnabled(false);
373:                    jMenuItemPaste.setEnabled(false);
374:                    jMenuItemEditMeasure.setEnabled(false);
375:                    return;
376:                }
377:
378:                if (paths.length == 1
379:                        && paths[0].getLastPathComponent() instanceof  DefaultMutableTreeNode
380:                        && ((((DefaultMutableTreeNode) paths[0]
381:                                .getLastPathComponent()).getUserObject() instanceof  Measure))
382:                        || ((((DefaultMutableTreeNode) paths[0]
383:                                .getLastPathComponent()).getUserObject() instanceof  CrosstabGroup))) {
384:                    jMenuItemEditMeasure.setEnabled(true);
385:                    jMenuItemCut.setEnabled(true);
386:                    jMenuItemCopy.setEnabled(true);
387:                    jMenuItemDelete.setEnabled(true);
388:                } else {
389:                    jMenuItemEditMeasure.setEnabled(false);
390:                    jMenuItemCut.setEnabled(false);
391:                    jMenuItemCopy.setEnabled(false);
392:                    jMenuItemDelete.setEnabled(false);
393:                }
394:
395:                jMenuItemPaste.setEnabled(false);
396:
397:                if (MainFrame.getMainInstance().getMeasuresClipBoard().size() > 0) {
398:                    jMenuItemPaste.setEnabled(true);
399:                }
400:
401:            }//GEN-LAST:event_jPopupMenuMeasuresPopupMenuWillBecomeVisible
402:
403:            private void jMenuItemRefreshActionPerformed(
404:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRefreshActionPerformed
405:                this .setCrosstabReportElement(this .crosstabReportElement);
406:            }//GEN-LAST:event_jMenuItemRefreshActionPerformed
407:
408:            private void jMenuItemDeleteActionPerformed(
409:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDeleteActionPerformed
410:                TreePath[] paths = jTree.getSelectionPaths();
411:
412:                for (int i = 0; i < paths.length; ++i) {
413:                    try {
414:                        if (paths[i].getLastPathComponent() instanceof  DefaultMutableTreeNode) {
415:                            Object obj = ((DefaultMutableTreeNode) paths[i]
416:                                    .getLastPathComponent()).getUserObject();
417:                            if (obj instanceof  Measure) {
418:                                if (getCrosstabReportElement().getMeasures()
419:                                        .size() > 0) {
420:                                    getCrosstabReportElement().removeMeasure(
421:                                            (Measure) obj);
422:                                }
423:                            }
424:                        }
425:                    } catch (Exception ex) {
426:                        ex.printStackTrace();
427:                    }
428:                }
429:            }//GEN-LAST:event_jMenuItemDeleteActionPerformed
430:
431:            private void jMenuItemPasteActionPerformed(
432:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteActionPerformed
433:                TreePath[] paths = jTree.getSelectionPaths();
434:
435:                if (paths.length == 1) {
436:                    if (paths[0].getLastPathComponent() instanceof  DefaultMutableTreeNode) {
437:
438:                        for (int i = 0; i < MainFrame.getMainInstance()
439:                                .getMeasuresClipBoard().size(); ++i) {
440:                            Measure measure = (Measure) MainFrame
441:                                    .getMainInstance().getMeasuresClipBoard()
442:                                    .elementAt(i);
443:                            measure = measure.cloneMe();
444:
445:                            // ---------------
446:                            String base_name = measure.getName();
447:                            java.util.Vector measures = getCrosstabReportElement()
448:                                    .getMeasures();
449:
450:                            for (int j = 0;; ++j) {
451:
452:                                boolean found = false;
453:
454:                                for (int k = 0; k < measures.size(); ++k) {
455:
456:                                    Measure measure1 = (Measure) measures
457:                                            .elementAt(k);
458:
459:                                    if (j == 0) {
460:
461:                                        if (measure1.getName()
462:                                                .equals(base_name)) {
463:                                            found = true;
464:
465:                                            break;
466:                                        }
467:                                    } else {
468:
469:                                        if (measure1.getName().equals(
470:                                                base_name + "_" + j)) {
471:                                            found = true;
472:
473:                                            break;
474:                                        }
475:                                    }
476:                                }
477:
478:                                if (!found) {
479:                                    measure.setName(base_name
480:                                            + ((j == 0) ? "" : "_" + j));
481:
482:                                    break;
483:                                }
484:                            }
485:                            //----------------------
486:
487:                            getCrosstabReportElement().addMeasure(measure);
488:                        }
489:                    }
490:                }
491:            }//GEN-LAST:event_jMenuItemPasteActionPerformed
492:
493:            private void jMenuItemCopyActionPerformed(
494:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCopyActionPerformed
495:                TreePath[] paths = jTree.getSelectionPaths();
496:
497:                boolean clearedMeasuresClipboard = false;
498:
499:                for (int i = 0; i < paths.length; ++i) {
500:
501:                    if (paths[i].getLastPathComponent() instanceof  DefaultMutableTreeNode) {
502:                        Object obj = ((DefaultMutableTreeNode) paths[i]
503:                                .getLastPathComponent()).getUserObject();
504:
505:                        if (obj instanceof  Measure) {
506:                            if (!clearedMeasuresClipboard) {
507:                                clearedMeasuresClipboard = true;
508:                                MainFrame.getMainInstance()
509:                                        .getMeasuresClipBoard()
510:                                        .removeAllElements();
511:                            }
512:                            MainFrame.getMainInstance().getMeasuresClipBoard()
513:                                    .add(((Measure) obj).cloneMe());
514:                        }
515:                    }
516:                }
517:            }//GEN-LAST:event_jMenuItemCopyActionPerformed
518:
519:            private void jMenuItemCutActionPerformed(
520:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCutActionPerformed
521:                TreePath[] paths = jTree.getSelectionPaths();
522:
523:                boolean clearedMeasuresClipboard = false;
524:
525:                for (int i = 0; i < paths.length; ++i) {
526:
527:                    if (paths[i].getLastPathComponent() instanceof  DefaultMutableTreeNode) {
528:                        Object obj = ((DefaultMutableTreeNode) paths[i]
529:                                .getLastPathComponent()).getUserObject();
530:                        if (obj instanceof  Measure) {
531:                            if (!clearedMeasuresClipboard) {
532:                                clearedMeasuresClipboard = true;
533:                                MainFrame.getMainInstance()
534:                                        .getMeasuresClipBoard()
535:                                        .removeAllElements();
536:                            }
537:                            MainFrame.getMainInstance().getMeasuresClipBoard()
538:                                    .add(((Measure) obj).cloneMe());
539:                            getCrosstabReportElement().removeMeasure(
540:                                    (Measure) obj);
541:                        }
542:                    }
543:                }
544:            }//GEN-LAST:event_jMenuItemCutActionPerformed
545:
546:            private void jMenuItemNewMeasureActionPerformed(
547:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewMeasureActionPerformed
548:
549:                MeasureDialog jrpd = new MeasureDialog(null, MainFrame
550:                        .getMainInstance(), true);
551:                jrpd.setExpressionContext(((this .getCrosstabReportElement()
552:                        .isUseDataset() && this .getCrosstabReportElement()
553:                        .getDataset() != null) ? this 
554:                        .getCrosstabReportElement().getDataset()
555:                        .getSubDataset() : null));
556:                jrpd.setVisible(true);
557:
558:                if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
559:                    Measure measure = jrpd.getMeasure();
560:                    getCrosstabReportElement().addMeasure(measure);
561:                }
562:
563:            }//GEN-LAST:event_jMenuItemNewMeasureActionPerformed
564:
565:            private void jMenuItemEditMeasureActionPerformed(
566:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemEditMeasureActionPerformed
567:            // We have to see what type of item we have selected...
568:                TreePath[] paths = jTree.getSelectionPaths();
569:
570:                if (paths == null || paths.length == 0) {
571:                    return;
572:                }
573:
574:                if (paths.length == 1
575:                        && paths[0].getLastPathComponent() instanceof  DefaultMutableTreeNode) {
576:                    Object obj = ((DefaultMutableTreeNode) paths[0]
577:                            .getLastPathComponent()).getUserObject();
578:                    if (obj instanceof  Measure) {
579:                        MeasureDialog jrpd = new MeasureDialog(null, MainFrame
580:                                .getMainInstance(), true);
581:                        jrpd
582:                                .setExpressionContext(((this 
583:                                        .getCrosstabReportElement()
584:                                        .isUseDataset() && this 
585:                                        .getCrosstabReportElement()
586:                                        .getDataset() != null) ? this 
587:                                        .getCrosstabReportElement()
588:                                        .getDataset().getSubDataset() : null));
589:                        jrpd.setMeasure((Measure) obj);
590:                        jrpd.setVisible(true);
591:
592:                        if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
593:                            Measure measure = (Measure) obj;
594:                            measure.setName(jrpd.getMeasure().getName());
595:                            measure.setExpression(jrpd.getMeasure()
596:                                    .getExpression());
597:                            measure.setClassType(jrpd.getMeasure()
598:                                    .getClassType());
599:                            measure.setCalculation(jrpd.getMeasure()
600:                                    .getCalculation());
601:                            measure.setIncrementerFactoryClass(jrpd
602:                                    .getMeasure().getIncrementerFactoryClass());
603:                            measure.setPercentageCalculatorClass(jrpd
604:                                    .getMeasure()
605:                                    .getPercentageCalculatorClass());
606:                            measure.setPercentageOf(jrpd.getMeasure()
607:                                    .getPercentageOf());
608:                            getCrosstabReportElement().measureModified(measure);
609:                            setCrosstabReportElement(this .crosstabReportElement);
610:                        }
611:                    } else if (obj instanceof  CrosstabGroup) {
612:                        CrosstabGroup rg = (CrosstabGroup) obj;
613:                        CrosstabGroupDialog jrpd = new CrosstabGroupDialog(
614:                                (rg instanceof  CrosstabColumnGroup) ? CrosstabGroupDialog.COLUMNGROUP
615:                                        : CrosstabGroupDialog.ROWGROUP,
616:                                MainFrame.getMainInstance(), true);
617:                        jrpd
618:                                .setExpressionContext(((this 
619:                                        .getCrosstabReportElement()
620:                                        .isUseDataset() && this 
621:                                        .getCrosstabReportElement()
622:                                        .getDataset() != null) ? this 
623:                                        .getCrosstabReportElement()
624:                                        .getDataset().getSubDataset() : null));
625:                        jrpd.setGroup(rg);
626:                        jrpd.setVisible(true);
627:
628:                        if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
629:
630:                            CrosstabGroup group = jrpd.getGroup();
631:                            String oldName = rg.getName();
632:                            rg.setName(group.getName());
633:                            rg.setBucketComparatorExpression(group
634:                                    .getBucketComparatorExpression());
635:                            rg.setBucketExpression(group.getBucketExpression());
636:                            rg.setBucketExpressionClass(group
637:                                    .getBucketExpressionClass());
638:                            rg.setBucketOrder(group.getBucketOrder());
639:                            rg.setHeaderPosition(group.getHeaderPosition());
640:                            rg.setTotalPosition(group.getTotalPosition());
641:                            rg.setName(group.getName());
642:                            rg.setSize(group.getSize());
643:                            rg.setHasHeader(group.isHasHeader());
644:                            rg.setHasTotal(group.isHasTotal());
645:                            if (rg instanceof  CrosstabColumnGroup)
646:                                getCrosstabReportElement().modifyGroup(oldName,
647:                                        (CrosstabColumnGroup) rg);
648:                            if (rg instanceof  CrosstabRowGroup)
649:                                getCrosstabReportElement().modifyGroup(oldName,
650:                                        (CrosstabRowGroup) rg);
651:                        }
652:                    }
653:
654:                    /*
655:                    if (obj instanceof JRField ) { MainFrame.getMainInstance().getValuesDialog().getValuesPanel().modifyField((JRField)obj ); }
656:                    if (obj instanceof JRParameter ) { MainFrame.getMainInstance().getValuesDialog().getValuesPanel().modifyParameter((JRParameter)obj ); }
657:                    if (obj instanceof SubDataset ) {
658:                        java.awt.Frame parent = Misc.frameFromComponent(this);
659:                        SubDatasetDialog cd = new SubDatasetDialog(parent,true);
660:                        cd.setSubDataset( (SubDataset)obj );
661:                        cd.setVisible(true);
662:                    }
663:                     */
664:                }
665:            }//GEN-LAST:event_jMenuItemEditMeasureActionPerformed
666:
667:            public void crosstabLayoutChanged(CrosstabLayoutChangedEvent evt) {
668:                setCrosstabReportElement(crosstabReportElement);
669:            }
670:
671:            public void crosstabMeasureChanged(CrosstabLayoutChangedEvent evt) {
672:                setCrosstabReportElement(crosstabReportElement);
673:            }
674:
675:            // Variables declaration - do not modify//GEN-BEGIN:variables
676:            private javax.swing.JMenuItem jMenuItemCopy;
677:            private javax.swing.JMenuItem jMenuItemCrosstabProperties;
678:            private javax.swing.JMenuItem jMenuItemCut;
679:            private javax.swing.JMenuItem jMenuItemDelete;
680:            private javax.swing.JMenuItem jMenuItemEditMeasure;
681:            private javax.swing.JMenuItem jMenuItemNewMeasure;
682:            private javax.swing.JMenuItem jMenuItemPaste;
683:            private javax.swing.JMenuItem jMenuItemRefresh;
684:            private javax.swing.JPopupMenu jPopupMenuMeasures;
685:            private javax.swing.JScrollPane jScrollPane1;
686:            private javax.swing.JSeparator jSeparator1;
687:            private javax.swing.JSeparator jSeparator2;
688:            private javax.swing.JSeparator jSeparator3;
689:            private javax.swing.JSeparator jSeparator4;
690:            private javax.swing.JTree jTree;
691:
692:            // End of variables declaration//GEN-END:variables
693:
694:            public void applyI18n() {
695:                // Start autogenerated code ----------------------
696:                jMenuItemCopy.setText(I18n.getString(
697:                        "crosstabMeasuresView.menuItemCopy", "Copy"));
698:                jMenuItemCrosstabProperties.setText(I18n.getString(
699:                        "crosstabMeasuresView.menuItemCrosstabProperties",
700:                        "Crosstab properties"));
701:                jMenuItemCut.setText(I18n.getString(
702:                        "crosstabMeasuresView.menuItemCut", "Cut"));
703:                jMenuItemDelete.setText(I18n.getString(
704:                        "crosstabMeasuresView.menuItemDelete", "Delete"));
705:                jMenuItemEditMeasure.setText(I18n.getString(
706:                        "crosstabMeasuresView.menuItemEditMeasure", "Edit"));
707:                jMenuItemNewMeasure.setText(I18n.getString(
708:                        "crosstabMeasuresView.menuItemNewMeasure",
709:                        "New measure"));
710:                jMenuItemPaste.setText(I18n.getString(
711:                        "crosstabMeasuresView.menuItemPaste", "Paste"));
712:                jMenuItemRefresh.setText(I18n.getString(
713:                        "crosstabMeasuresView.menuItemRefresh", "Refresh"));
714:                // End autogenerated code ----------------------
715:            }
716:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.