Source Code Cross Referenced for TimePeriodDatasetPanel.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » chart » 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.chart 
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:         * TimePeriodDatasetPanel.java
028:         * 
029:         * Created on 15 agosto 2005, 17.55
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.chart;
034:
035:        import it.businesslogic.ireport.SubDataset;
036:        import java.awt.event.ActionEvent;
037:        import java.util.*;
038:        import it.businesslogic.ireport.util.I18n;
039:
040:        /**
041:         *
042:         * @author  Administrator
043:         */
044:        public class TimePeriodDatasetPanel extends javax.swing.JPanel
045:                implements  ChartDatasetPanel {
046:
047:            private TimePeriodDataset timePeriodDataset = null;
048:            private SubDataset subDataset = null;
049:
050:            /** Creates new form PieDatasetPanel */
051:            public TimePeriodDatasetPanel() {
052:                initComponents();
053:                applyI18n();
054:                jList1.setModel(new javax.swing.DefaultListModel());
055:            }
056:
057:            public void setTimePeriodDataset(TimePeriodDataset timePeriodDataset) {
058:                this .timePeriodDataset = timePeriodDataset;
059:
060:                jButtonModify.setEnabled(false);
061:                jButtonModify.setEnabled(false);
062:                javax.swing.DefaultListModel lm = (javax.swing.DefaultListModel) jList1
063:                        .getModel();
064:
065:                lm.removeAllElements();
066:
067:                Vector v = timePeriodDataset.getTimePeriodSeries();
068:
069:                for (int i = 0; i < v.size(); ++i) {
070:                    lm.addElement(v.elementAt(i));
071:                }
072:
073:            }
074:
075:            public TimePeriodDataset getTimePeriodDataset() {
076:                return timePeriodDataset;
077:            }
078:
079:            /** This method is called from within the constructor to
080:             * initialize the form.
081:             * WARNING: Do NOT modify this code. The content of this method is
082:             * always regenerated by the Form Editor.
083:             */
084:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
085:            private void initComponents() {
086:                java.awt.GridBagConstraints gridBagConstraints;
087:
088:                jPopupMenuSeries = new javax.swing.JPopupMenu();
089:                jMenuItemCopy = new javax.swing.JMenuItem();
090:                jMenuItemPaste = new javax.swing.JMenuItem();
091:                jScrollPane1 = new javax.swing.JScrollPane();
092:                jList1 = new javax.swing.JList();
093:                jPanel1 = new javax.swing.JPanel();
094:                jButtonAdd = new javax.swing.JButton();
095:                jButtonModify = new javax.swing.JButton();
096:                jButtonRemove = new javax.swing.JButton();
097:                jPanel2 = new javax.swing.JPanel();
098:                jLabel1 = new javax.swing.JLabel();
099:
100:                jMenuItemCopy.setText("Copy series");
101:                jMenuItemCopy
102:                        .addActionListener(new java.awt.event.ActionListener() {
103:                            public void actionPerformed(
104:                                    java.awt.event.ActionEvent evt) {
105:                                jMenuItemCopyActionPerformed(evt);
106:                            }
107:                        });
108:
109:                jPopupMenuSeries.add(jMenuItemCopy);
110:
111:                jMenuItemPaste.setText("Paste series");
112:                jMenuItemPaste
113:                        .addActionListener(new java.awt.event.ActionListener() {
114:                            public void actionPerformed(
115:                                    java.awt.event.ActionEvent evt) {
116:                                jMenuItemPasteActionPerformed(evt);
117:                            }
118:                        });
119:
120:                jPopupMenuSeries.add(jMenuItemPaste);
121:
122:                setLayout(new java.awt.GridBagLayout());
123:
124:                addComponentListener(new java.awt.event.ComponentAdapter() {
125:                    public void componentShown(java.awt.event.ComponentEvent evt) {
126:                        formComponentShown(evt);
127:                    }
128:                });
129:
130:                jList1
131:                        .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
132:                            public void valueChanged(
133:                                    javax.swing.event.ListSelectionEvent evt) {
134:                                jList1ValueChanged(evt);
135:                            }
136:                        });
137:                jList1.addMouseListener(new java.awt.event.MouseAdapter() {
138:                    public void mouseClicked(java.awt.event.MouseEvent evt) {
139:                        jList1MouseClicked(evt);
140:                    }
141:                });
142:
143:                jScrollPane1.setViewportView(jList1);
144:
145:                gridBagConstraints = new java.awt.GridBagConstraints();
146:                gridBagConstraints.gridy = 1;
147:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
148:                gridBagConstraints.weightx = 1.0;
149:                gridBagConstraints.weighty = 1.0;
150:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
151:                add(jScrollPane1, gridBagConstraints);
152:
153:                jPanel1.setLayout(new java.awt.GridBagLayout());
154:
155:                jPanel1.setMinimumSize(new java.awt.Dimension(100, 0));
156:                jPanel1.setPreferredSize(new java.awt.Dimension(100, 0));
157:                jButtonAdd.setText("Add");
158:                jButtonAdd
159:                        .addActionListener(new java.awt.event.ActionListener() {
160:                            public void actionPerformed(
161:                                    java.awt.event.ActionEvent evt) {
162:                                jButtonAddActionPerformed(evt);
163:                            }
164:                        });
165:
166:                gridBagConstraints = new java.awt.GridBagConstraints();
167:                gridBagConstraints.gridy = 0;
168:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
169:                gridBagConstraints.weightx = 1.0;
170:                gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 4);
171:                jPanel1.add(jButtonAdd, gridBagConstraints);
172:
173:                jButtonModify.setText("Modify");
174:                jButtonModify
175:                        .addActionListener(new java.awt.event.ActionListener() {
176:                            public void actionPerformed(
177:                                    java.awt.event.ActionEvent evt) {
178:                                jButtonModifyActionPerformed(evt);
179:                            }
180:                        });
181:
182:                gridBagConstraints = new java.awt.GridBagConstraints();
183:                gridBagConstraints.gridy = 1;
184:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
185:                gridBagConstraints.weightx = 1.0;
186:                gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 4);
187:                jPanel1.add(jButtonModify, gridBagConstraints);
188:
189:                jButtonRemove.setText("Remove");
190:                jButtonRemove
191:                        .addActionListener(new java.awt.event.ActionListener() {
192:                            public void actionPerformed(
193:                                    java.awt.event.ActionEvent evt) {
194:                                jButtonRemoveActionPerformed(evt);
195:                            }
196:                        });
197:
198:                gridBagConstraints = new java.awt.GridBagConstraints();
199:                gridBagConstraints.gridy = 2;
200:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
201:                gridBagConstraints.weightx = 1.0;
202:                gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 4);
203:                jPanel1.add(jButtonRemove, gridBagConstraints);
204:
205:                gridBagConstraints = new java.awt.GridBagConstraints();
206:                gridBagConstraints.gridy = 99;
207:                gridBagConstraints.weighty = 1.0;
208:                jPanel1.add(jPanel2, gridBagConstraints);
209:
210:                gridBagConstraints = new java.awt.GridBagConstraints();
211:                gridBagConstraints.gridy = 1;
212:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
213:                add(jPanel1, gridBagConstraints);
214:
215:                jLabel1.setText("Time period series");
216:                gridBagConstraints = new java.awt.GridBagConstraints();
217:                gridBagConstraints.gridwidth = 2;
218:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
219:                gridBagConstraints.weightx = 1.0;
220:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
221:                add(jLabel1, gridBagConstraints);
222:
223:            }// </editor-fold>//GEN-END:initComponents
224:
225:            private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
226:                openExtraWindows();
227:            }//GEN-LAST:event_formComponentShown
228:
229:            private void jMenuItemPasteActionPerformed(
230:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteActionPerformed
231:                Vector v = it.businesslogic.ireport.gui.MainFrame
232:                        .getMainInstance().getChartSeriesClipBoard();
233:
234:                if (v != null && v.size() > 0) {
235:                    for (int i = 0; i < v.size(); ++i) {
236:                        if (v.elementAt(i) instanceof  TimePeriodSeries) {
237:                            TimePeriodSeries cs = (TimePeriodSeries) v
238:                                    .elementAt(i);
239:                            cs = cs.cloneMe();
240:                            timePeriodDataset.getTimePeriodSeries().addElement(
241:                                    cs);
242:                            ((javax.swing.DefaultListModel) jList1.getModel())
243:                                    .addElement(cs);
244:                        }
245:                    }
246:                    jList1.updateUI();
247:                }
248:            }//GEN-LAST:event_jMenuItemPasteActionPerformed
249:
250:            private void jMenuItemCopyActionPerformed(
251:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCopyActionPerformed
252:                Object[] values = jList1.getSelectedValues();
253:                Vector copy_c = new Vector();
254:                for (int i = 0; i < values.length; ++i)
255:                    copy_c.add(((TimePeriodSeries) values[i]).cloneMe());
256:                it.businesslogic.ireport.gui.MainFrame.getMainInstance()
257:                        .setChartSeriesClipBoard(copy_c);
258:            }//GEN-LAST:event_jMenuItemCopyActionPerformed
259:
260:            private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
261:                if (evt.getClickCount() == 1 && evt.getButton() == evt.BUTTON3) {
262:                    jMenuItemCopy.setEnabled(jList1.getSelectedIndex() >= 0);
263:                    jMenuItemPaste
264:                            .setEnabled(it.businesslogic.ireport.gui.MainFrame
265:                                    .getMainInstance()
266:                                    .getChartSeriesClipBoard() != null
267:                                    && it.businesslogic.ireport.gui.MainFrame
268:                                            .getMainInstance()
269:                                            .getChartSeriesClipBoard().size() > 0);
270:
271:                    jPopupMenuSeries.show(jList1, evt.getPoint().x, evt
272:                            .getPoint().y);
273:                } else if (evt.getClickCount() == 2
274:                        && evt.getButton() == evt.BUTTON1) {
275:                    jButtonModifyActionPerformed(null);
276:                }
277:            }//GEN-LAST:event_jList1MouseClicked
278:
279:            private void jButtonModifyActionPerformed(
280:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyActionPerformed
281:
282:                if (jList1.getSelectedIndex() >= 0) {
283:                    TimePeriodSeries cs = (TimePeriodSeries) jList1
284:                            .getSelectedValue();
285:                    TimePeriodSeriesDialog csd = new TimePeriodSeriesDialog(
286:                            it.businesslogic.ireport.gui.MainFrame
287:                                    .getMainInstance(), true);
288:
289:                    csd.setSeriesExpression(cs.getSeriesExpression());
290:                    csd.setStartDateExpression(cs.getStartDateExpression());
291:                    csd.setEndDateExpression(cs.getEndDateExpression());
292:                    csd.setValueExpression(cs.getValueExpression());
293:                    csd.setLabelExpression(cs.getLabelExpression());
294:                    csd.setSectionItemHyperlink(cs.getSectionItemHyperlink());
295:
296:                    csd.setSubDataset(this .getSubDataset());
297:                    if (newInfo != null) {
298:                        csd.setFocusedExpression(newInfo);
299:                    }
300:                    csd.setVisible(true);
301:
302:                    if (csd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
303:                        cs.setSeriesExpression(csd.getSeriesExpression());
304:                        cs.setStartDateExpression(csd.getStartDateExpression());
305:                        cs.setEndDateExpression(csd.getEndDateExpression());
306:                        cs.setValueExpression(csd.getValueExpression());
307:                        cs.setLabelExpression(csd.getLabelExpression());
308:                        cs.setSectionItemHyperlink(csd
309:                                .getSectionItemHyperlink());
310:
311:                        jList1.updateUI();
312:                    }
313:
314:                }
315:            }//GEN-LAST:event_jButtonModifyActionPerformed
316:
317:            private void jButtonAddActionPerformed(
318:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddActionPerformed
319:
320:                TimePeriodSeriesDialog csd = new TimePeriodSeriesDialog(
321:                        it.businesslogic.ireport.gui.MainFrame
322:                                .getMainInstance(), true);
323:                csd.setSubDataset(this .getSubDataset());
324:                csd.setVisible(true);
325:                if (csd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
326:                    TimePeriodSeries cs = new TimePeriodSeries();
327:                    cs.setSeriesExpression(csd.getSeriesExpression());
328:                    cs.setStartDateExpression(csd.getStartDateExpression());
329:                    cs.setEndDateExpression(csd.getEndDateExpression());
330:                    cs.setValueExpression(csd.getValueExpression());
331:                    cs.setLabelExpression(csd.getLabelExpression());
332:                    cs.setSectionItemHyperlink(csd.getSectionItemHyperlink());
333:
334:                    getTimePeriodDataset().getTimePeriodSeries().addElement(cs);
335:                    ((javax.swing.DefaultListModel) jList1.getModel())
336:                            .addElement(cs);
337:                }
338:
339:            }//GEN-LAST:event_jButtonAddActionPerformed
340:
341:            private void jButtonRemoveActionPerformed(
342:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRemoveActionPerformed
343:
344:                while (jList1.getSelectedIndex() >= 0) {
345:                    getTimePeriodDataset().getTimePeriodSeries().remove(
346:                            jList1.getSelectedValue());
347:                    ((javax.swing.DefaultListModel) jList1.getModel())
348:                            .removeElementAt(jList1.getSelectedIndex());
349:                }
350:
351:            }//GEN-LAST:event_jButtonRemoveActionPerformed
352:
353:            private void jList1ValueChanged(
354:                    javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
355:
356:                if (jList1.getSelectedIndex() >= 0) {
357:                    jButtonModify.setEnabled(true);
358:                    jButtonModify.setEnabled(true);
359:                } else {
360:                    jButtonModify.setEnabled(false);
361:                    jButtonModify.setEnabled(false);
362:                }
363:            }//GEN-LAST:event_jList1ValueChanged
364:
365:            // Variables declaration - do not modify//GEN-BEGIN:variables
366:            private javax.swing.JButton jButtonAdd;
367:            private javax.swing.JButton jButtonModify;
368:            private javax.swing.JButton jButtonRemove;
369:            private javax.swing.JLabel jLabel1;
370:            private javax.swing.JList jList1;
371:            private javax.swing.JMenuItem jMenuItemCopy;
372:            private javax.swing.JMenuItem jMenuItemPaste;
373:            private javax.swing.JPanel jPanel1;
374:            private javax.swing.JPanel jPanel2;
375:            private javax.swing.JPopupMenu jPopupMenuSeries;
376:            private javax.swing.JScrollPane jScrollPane1;
377:
378:            // End of variables declaration//GEN-END:variables
379:
380:            public void applyI18n() {
381:                // Start autogenerated code ----------------------
382:                // End autogenerated code ----------------------
383:                // Start autogenerated code ----------------------
384:                jLabel1.setText(I18n.getString("timePeriodDatasetPanel.label1",
385:                        "Time period series"));
386:                // End autogenerated code ----------------------
387:                jButtonAdd.setText(it.businesslogic.ireport.util.I18n
388:                        .getString("charts.newseries", "Add series"));
389:                jButtonModify.setText(it.businesslogic.ireport.util.I18n
390:                        .getString("charts.modifyseries", "Modify series"));
391:                jButtonRemove.setText(it.businesslogic.ireport.util.I18n
392:                        .getString("charts.removeseries", "Remove series"));
393:
394:                jMenuItemCopy.setText(it.businesslogic.ireport.util.I18n
395:                        .getString("charts.copyseries", "Copy series"));
396:                jMenuItemPaste.setText(it.businesslogic.ireport.util.I18n
397:                        .getString("charts.pasteseries", "Paste series"));
398:
399:                this .updateUI();
400:
401:            }
402:
403:            public SubDataset getSubDataset() {
404:                return subDataset;
405:            }
406:
407:            public void setSubDataset(SubDataset subDataset) {
408:                this .subDataset = subDataset;
409:            }
410:
411:            public static final int COMPONENT_NONE = 0;
412:            public static final int COMPONENT_PERIOD_SERIES_LIST = 1;
413:
414:            /**
415:             * This variable is checked by openExtraWindows() called when the component is shown.
416:             * If the value is != 0, the modify button will be action-performed.
417:             */
418:            public Object[] newInfo = null;
419:
420:            /**
421:             * This method set the focus on a specific component.
422:             * 
423:             * For this kind of datasource otherInfo must be:
424:             * [0] = Fixed to COMPONENT_PERIOD_SERIES_LIST (used for future extensions)
425:             * [1] = Integer, the category series to edit
426:             * [2] = The expression id in the category window to focus on 
427:             * [3] = The expression in the hyperlink...
428:             * [4] = The hyperlink parameter
429:             * [5] = The expression of the hyperlink parameter
430:             */
431:            public void setFocusedExpression(Object[] expressionInfo) {
432:                if (expressionInfo == null)
433:                    return;
434:                int expID = ((Integer) expressionInfo[0]).intValue();
435:                switch (expID) {
436:                case COMPONENT_PERIOD_SERIES_LIST:
437:                    int index = ((Integer) expressionInfo[1]).intValue();
438:
439:                    if (index >= 0 && jList1.getModel().getSize() > index) {
440:                        jList1.setSelectedIndex(index);
441:                        newInfo = new Object[expressionInfo.length - 2];
442:                        for (int i = 2; i < expressionInfo.length; ++i)
443:                            newInfo[i - 2] = expressionInfo[i];
444:                        break;
445:                    }
446:                }
447:            }
448:
449:            /**
450:             * This method checks for the variable subExpID. It is called when the component is shown.
451:             * If the value is >= 0, the modify button will be action-performed
452:             */
453:            private void openExtraWindows() {
454:                if (newInfo != null) {
455:                    jButtonModifyActionPerformed(new ActionEvent(jButtonModify,
456:                            0, ""));
457:                }
458:                newInfo = null;
459:            }
460:
461:            public void containerWindowOpened() {
462:                openExtraWindows();
463:            }
464:
465:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.