Source Code Cross Referenced for MeterIntervalsDialog.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » gui » sheet » 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.sheet 
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:         * MeterIntervalsDialog.java
028:         * 
029:         * Created on September 27, 2006, 1:16 AM
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.gui.sheet;
034:
035:        import it.businesslogic.ireport.chart.MeterInterval;
036:        import it.businesslogic.ireport.util.Misc;
037:        import java.awt.event.ActionEvent;
038:        import java.text.DecimalFormat;
039:        import javax.swing.DefaultListSelectionModel;
040:        import javax.swing.JOptionPane;
041:        import javax.swing.SwingConstants;
042:        import javax.swing.event.ListSelectionEvent;
043:        import javax.swing.event.ListSelectionListener;
044:        import javax.swing.table.DefaultTableCellRenderer;
045:        import javax.swing.table.DefaultTableColumnModel;
046:        import javax.swing.table.DefaultTableModel;
047:        import it.businesslogic.ireport.util.I18n;
048:
049:        /**
050:         *
051:         * @author  gtoffoli
052:         */
053:        public class MeterIntervalsDialog extends javax.swing.JDialog {
054:
055:            private int dialogResult = javax.swing.JOptionPane.CANCEL_OPTION;
056:            private java.util.List meterIntervals = null;
057:
058:            public static java.util.List clipboard = new java.util.ArrayList();
059:            public static java.util.List lastIntervals = new java.util.ArrayList();
060:
061:            /** Creates new form SeriesColorsDialog */
062:            public MeterIntervalsDialog(java.awt.Frame parent, boolean modal) {
063:                super (parent, modal);
064:                initAll();
065:            }
066:
067:            /** Creates new form SeriesColorsDialog */
068:            public MeterIntervalsDialog(java.awt.Dialog parent, boolean modal) {
069:                super (parent, modal);
070:                initAll();
071:            }
072:
073:            public void initAll() {
074:                initComponents();
075:
076:                applyI18n();
077:                //jList1.setCellRenderer(new ColorsListCellRenderer());
078:
079:                jButtonPasteInterval.setEnabled(clipboard.size() > 0);
080:                jButtonUseLast.setEnabled(lastIntervals.size() > 0);
081:
082:                ((DefaultTableColumnModel) jTable1.getColumnModel()).getColumn(
083:                        0)
084:                        .setCellRenderer(new MeterIntervalTableCellRenderer());
085:                ((DefaultTableColumnModel) jTable1.getColumnModel()).getColumn(
086:                        1).setPreferredWidth(50);
087:                DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
088:                dtcr.setHorizontalAlignment(SwingConstants.CENTER);
089:                ((DefaultTableColumnModel) jTable1.getColumnModel()).getColumn(
090:                        1).setCellRenderer(dtcr);
091:
092:                this .pack();
093:                Misc.centerFrame(this );
094:
095:                jTable1.getSelectionModel().addListSelectionListener(
096:                        new ListSelectionListener() {
097:                            public void valueChanged(ListSelectionEvent e) {
098:                                jTable1ValueChanged(e);
099:                            }
100:                        });
101:            }
102:
103:            private void jTable1ValueChanged(
104:                    javax.swing.event.ListSelectionEvent evt) {
105:
106:                if (jTable1.getSelectedRowCount() > 0) {
107:                    jButtonDelete.setEnabled(true);
108:                    jButtonModify.setEnabled(true);
109:                    jButtonMoveUp.setEnabled(jTable1.getSelectedRow() > 0);
110:                    jButtonMoveDown
111:                            .setEnabled(jTable1.getSelectedRow() < jTable1
112:                                    .getRowCount() - 1);
113:                } else {
114:                    jButtonModify.setEnabled(false);
115:                    jButtonDelete.setEnabled(false);
116:                    jButtonMoveUp.setEnabled(false);
117:                    jButtonMoveDown.setEnabled(false);
118:                }
119:
120:            }
121:
122:            /** This method is called from within the constructor to
123:             * initialize the form.
124:             * WARNING: Do NOT modify this code. The content of this method is
125:             * always regenerated by the Form Editor.
126:             */
127:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
128:            private void initComponents() {
129:                java.awt.GridBagConstraints gridBagConstraints;
130:
131:                jScrollPane1 = new javax.swing.JScrollPane();
132:                jTable1 = new javax.swing.JTable();
133:                jPanel2 = new javax.swing.JPanel();
134:                jButtonAdd = new javax.swing.JButton();
135:                jButtonModify = new javax.swing.JButton();
136:                jButtonDelete = new javax.swing.JButton();
137:                jButtonMoveUp = new javax.swing.JButton();
138:                jButtonMoveDown = new javax.swing.JButton();
139:                jButtonCopyInterval = new javax.swing.JButton();
140:                jButtonPasteInterval = new javax.swing.JButton();
141:                jButtonUseLast = new javax.swing.JButton();
142:                jSeparator1 = new javax.swing.JSeparator();
143:                jPanel1 = new javax.swing.JPanel();
144:                jButtonOk = new javax.swing.JButton();
145:                jButtonCancel = new javax.swing.JButton();
146:
147:                getContentPane().setLayout(new java.awt.GridBagLayout());
148:
149:                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
150:                addWindowListener(new java.awt.event.WindowAdapter() {
151:                    public void windowOpened(java.awt.event.WindowEvent evt) {
152:                        formWindowOpened(evt);
153:                    }
154:                });
155:
156:                jTable1.setModel(new javax.swing.table.DefaultTableModel(
157:                        new Object[][] {
158:
159:                        }, new String[] { "Label", "Alpha", "Low exp",
160:                                "High exp" }) {
161:                    Class[] types = new Class[] { java.lang.String.class,
162:                            java.lang.String.class, java.lang.String.class,
163:                            java.lang.String.class };
164:                    boolean[] canEdit = new boolean[] { false, false, false,
165:                            false };
166:
167:                    public Class getColumnClass(int columnIndex) {
168:                        return types[columnIndex];
169:                    }
170:
171:                    public boolean isCellEditable(int rowIndex, int columnIndex) {
172:                        return canEdit[columnIndex];
173:                    }
174:                });
175:                jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
176:                    public void mouseClicked(java.awt.event.MouseEvent evt) {
177:                        jTable1MouseClicked(evt);
178:                    }
179:                });
180:
181:                jScrollPane1.setViewportView(jTable1);
182:
183:                gridBagConstraints = new java.awt.GridBagConstraints();
184:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
185:                gridBagConstraints.weightx = 1.0;
186:                gridBagConstraints.weighty = 1.0;
187:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
188:                getContentPane().add(jScrollPane1, gridBagConstraints);
189:
190:                jPanel2.setLayout(new java.awt.GridBagLayout());
191:
192:                jPanel2.setMinimumSize(new java.awt.Dimension(150, 150));
193:                jPanel2.setPreferredSize(new java.awt.Dimension(100, 283));
194:                jButtonAdd.setText("Add");
195:                jButtonAdd.setMargin(new java.awt.Insets(2, 8, 2, 8));
196:                jButtonAdd
197:                        .addActionListener(new java.awt.event.ActionListener() {
198:                            public void actionPerformed(
199:                                    java.awt.event.ActionEvent evt) {
200:                                jButtonAddActionPerformed(evt);
201:                            }
202:                        });
203:
204:                gridBagConstraints = new java.awt.GridBagConstraints();
205:                gridBagConstraints.gridx = 0;
206:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
207:                gridBagConstraints.weightx = 1.0;
208:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
209:                jPanel2.add(jButtonAdd, gridBagConstraints);
210:
211:                jButtonModify.setText("Modify");
212:                jButtonModify.setEnabled(false);
213:                jButtonModify.setMargin(new java.awt.Insets(2, 8, 2, 8));
214:                jButtonModify
215:                        .addActionListener(new java.awt.event.ActionListener() {
216:                            public void actionPerformed(
217:                                    java.awt.event.ActionEvent evt) {
218:                                jButtonModifyActionPerformed(evt);
219:                            }
220:                        });
221:
222:                gridBagConstraints = new java.awt.GridBagConstraints();
223:                gridBagConstraints.gridx = 0;
224:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
225:                gridBagConstraints.weightx = 1.0;
226:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
227:                jPanel2.add(jButtonModify, gridBagConstraints);
228:
229:                jButtonDelete.setText("Delete");
230:                jButtonDelete.setEnabled(false);
231:                jButtonDelete.setMargin(new java.awt.Insets(2, 8, 2, 8));
232:                jButtonDelete
233:                        .addActionListener(new java.awt.event.ActionListener() {
234:                            public void actionPerformed(
235:                                    java.awt.event.ActionEvent evt) {
236:                                jButtonDeleteActionPerformed(evt);
237:                            }
238:                        });
239:
240:                gridBagConstraints = new java.awt.GridBagConstraints();
241:                gridBagConstraints.gridx = 0;
242:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
243:                gridBagConstraints.weightx = 1.0;
244:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
245:                jPanel2.add(jButtonDelete, gridBagConstraints);
246:
247:                jButtonMoveUp.setText("Move up");
248:                jButtonMoveUp.setEnabled(false);
249:                jButtonMoveUp.setMargin(new java.awt.Insets(2, 8, 2, 8));
250:                jButtonMoveUp
251:                        .addActionListener(new java.awt.event.ActionListener() {
252:                            public void actionPerformed(
253:                                    java.awt.event.ActionEvent evt) {
254:                                jButtonMoveUpActionPerformed(evt);
255:                            }
256:                        });
257:
258:                gridBagConstraints = new java.awt.GridBagConstraints();
259:                gridBagConstraints.gridx = 0;
260:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
261:                gridBagConstraints.weightx = 1.0;
262:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
263:                jPanel2.add(jButtonMoveUp, gridBagConstraints);
264:
265:                jButtonMoveDown.setText("Move down");
266:                jButtonMoveDown.setEnabled(false);
267:                jButtonMoveDown.setMargin(new java.awt.Insets(2, 8, 2, 8));
268:                jButtonMoveDown
269:                        .addActionListener(new java.awt.event.ActionListener() {
270:                            public void actionPerformed(
271:                                    java.awt.event.ActionEvent evt) {
272:                                jButtonMoveDownActionPerformed(evt);
273:                            }
274:                        });
275:
276:                gridBagConstraints = new java.awt.GridBagConstraints();
277:                gridBagConstraints.gridx = 0;
278:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
279:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
280:                gridBagConstraints.weightx = 1.0;
281:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 14, 4);
282:                jPanel2.add(jButtonMoveDown, gridBagConstraints);
283:
284:                jButtonCopyInterval.setText("Copy intervals");
285:                jButtonCopyInterval.setMargin(new java.awt.Insets(2, 8, 2, 8));
286:                jButtonCopyInterval
287:                        .addActionListener(new java.awt.event.ActionListener() {
288:                            public void actionPerformed(
289:                                    java.awt.event.ActionEvent evt) {
290:                                jButtonCopyIntervalActionPerformed(evt);
291:                            }
292:                        });
293:
294:                gridBagConstraints = new java.awt.GridBagConstraints();
295:                gridBagConstraints.gridx = 0;
296:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
297:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
298:                gridBagConstraints.weightx = 1.0;
299:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
300:                jPanel2.add(jButtonCopyInterval, gridBagConstraints);
301:
302:                jButtonPasteInterval.setText("Paste intervals");
303:                jButtonPasteInterval.setEnabled(false);
304:                jButtonPasteInterval.setMargin(new java.awt.Insets(2, 8, 2, 8));
305:                jButtonPasteInterval
306:                        .addActionListener(new java.awt.event.ActionListener() {
307:                            public void actionPerformed(
308:                                    java.awt.event.ActionEvent evt) {
309:                                jButtonPasteIntervalActionPerformed(evt);
310:                            }
311:                        });
312:
313:                gridBagConstraints = new java.awt.GridBagConstraints();
314:                gridBagConstraints.gridx = 0;
315:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
316:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
317:                gridBagConstraints.weightx = 1.0;
318:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
319:                jPanel2.add(jButtonPasteInterval, gridBagConstraints);
320:
321:                jButtonUseLast.setText("Use last");
322:                jButtonUseLast.setEnabled(false);
323:                jButtonUseLast.setMargin(new java.awt.Insets(2, 8, 2, 8));
324:                jButtonUseLast
325:                        .addActionListener(new java.awt.event.ActionListener() {
326:                            public void actionPerformed(
327:                                    java.awt.event.ActionEvent evt) {
328:                                jButtonPasteIntervalActionPerformed1(evt);
329:                            }
330:                        });
331:
332:                gridBagConstraints = new java.awt.GridBagConstraints();
333:                gridBagConstraints.gridx = 0;
334:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
335:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
336:                gridBagConstraints.weightx = 1.0;
337:                gridBagConstraints.weighty = 1.0;
338:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
339:                jPanel2.add(jButtonUseLast, gridBagConstraints);
340:
341:                gridBagConstraints = new java.awt.GridBagConstraints();
342:                gridBagConstraints.gridx = 1;
343:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
344:                gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4);
345:                getContentPane().add(jPanel2, gridBagConstraints);
346:
347:                jSeparator1.setMinimumSize(new java.awt.Dimension(0, 2));
348:                jSeparator1.setPreferredSize(new java.awt.Dimension(3, 2));
349:                gridBagConstraints = new java.awt.GridBagConstraints();
350:                gridBagConstraints.gridx = 0;
351:                gridBagConstraints.gridwidth = 2;
352:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
353:                getContentPane().add(jSeparator1, gridBagConstraints);
354:
355:                jPanel1.setLayout(new java.awt.GridBagLayout());
356:
357:                jPanel1.setPreferredSize(new java.awt.Dimension(320, 23));
358:                jButtonOk.setText("OK");
359:                jButtonOk
360:                        .addActionListener(new java.awt.event.ActionListener() {
361:                            public void actionPerformed(
362:                                    java.awt.event.ActionEvent evt) {
363:                                jButtonOkActionPerformed(evt);
364:                            }
365:                        });
366:
367:                gridBagConstraints = new java.awt.GridBagConstraints();
368:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
369:                gridBagConstraints.weightx = 1.0;
370:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 4);
371:                jPanel1.add(jButtonOk, gridBagConstraints);
372:
373:                jButtonCancel.setText("Cancel");
374:                jButtonCancel
375:                        .addActionListener(new java.awt.event.ActionListener() {
376:                            public void actionPerformed(
377:                                    java.awt.event.ActionEvent evt) {
378:                                jButtonCancelActionPerformed(evt);
379:                            }
380:                        });
381:
382:                jPanel1.add(jButtonCancel, new java.awt.GridBagConstraints());
383:
384:                gridBagConstraints = new java.awt.GridBagConstraints();
385:                gridBagConstraints.gridx = 0;
386:                gridBagConstraints.gridwidth = 2;
387:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
388:                gridBagConstraints.weightx = 1.0;
389:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
390:                getContentPane().add(jPanel1, gridBagConstraints);
391:
392:                pack();
393:            }// </editor-fold>//GEN-END:initComponents
394:
395:            private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
396:                openExtraWindows();
397:            }//GEN-LAST:event_formWindowOpened
398:
399:            private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
400:
401:                if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() == 2) {
402:                    jButtonModifyActionPerformed(null);
403:                }
404:
405:            }//GEN-LAST:event_jTable1MouseClicked
406:
407:            private void jButtonPasteIntervalActionPerformed1(
408:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPasteIntervalActionPerformed1
409:                if (lastIntervals.size() > 0) {
410:                    for (int i = 0; i < lastIntervals.size(); ++i) {
411:                        addRowValues(((MeterInterval) lastIntervals.get(i))
412:                                .cloneMe());
413:                    }
414:                }
415:            }//GEN-LAST:event_jButtonPasteIntervalActionPerformed1
416:
417:            private void jButtonPasteIntervalActionPerformed(
418:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPasteIntervalActionPerformed
419:
420:                if (clipboard.size() > 0) {
421:                    for (int i = 0; i < clipboard.size(); ++i) {
422:                        addRowValues(((MeterInterval) clipboard.get(i))
423:                                .cloneMe());
424:                    }
425:                }
426:
427:            }//GEN-LAST:event_jButtonPasteIntervalActionPerformed
428:
429:            private void jButtonCopyIntervalActionPerformed(
430:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCopyIntervalActionPerformed
431:
432:                if (jTable1.getRowCount() > 0) {
433:                    clipboard.clear();
434:                    for (int i = 0; i < jTable1.getRowCount(); ++i) {
435:                        clipboard
436:                                .add(((MeterInterval) jTable1.getValueAt(i, 0))
437:                                        .cloneMe());
438:                    }
439:                }
440:
441:                jButtonPasteInterval.setEnabled(true);
442:            }//GEN-LAST:event_jButtonCopyIntervalActionPerformed
443:
444:            private void jButtonCancelActionPerformed(
445:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
446:
447:                setDialogResult(JOptionPane.CANCEL_OPTION);
448:                setVisible(false);
449:                dispose();
450:
451:            }//GEN-LAST:event_jButtonCancelActionPerformed
452:
453:            private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOkActionPerformed
454:
455:                java.util.List temp_list = new java.util.ArrayList();
456:
457:                lastIntervals.clear();
458:
459:                for (int i = 0; i < jTable1.getRowCount(); ++i) {
460:                    temp_list.add(((MeterInterval) jTable1.getValueAt(i, 0))
461:                            .cloneMe());
462:                    lastIntervals
463:                            .add(((MeterInterval) jTable1.getValueAt(i, 0))
464:                                    .cloneMe());
465:                }
466:
467:                setMeterIntervals(temp_list);
468:                setDialogResult(JOptionPane.OK_OPTION);
469:                this .setVisible(false);
470:                this .dispose();
471:
472:            }//GEN-LAST:event_jButtonOkActionPerformed
473:
474:            private void jButtonMoveDownActionPerformed(
475:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveDownActionPerformed
476:                if (jTable1.getSelectedRowCount() > 0) {
477:                    DefaultTableModel dtm = (DefaultTableModel) jTable1
478:                            .getModel();
479:                    int[] indices = jTable1.getSelectedRows();
480:                    for (int i = indices.length - 1; i >= 0; --i) {
481:                        if (indices[i] >= (jTable1.getRowCount() - 1))
482:                            continue;
483:
484:                        Object val = jTable1.getValueAt(indices[i], 0);
485:                        dtm.removeRow(indices[i]);
486:                        dtm.insertRow(indices[i] + 1, new Object[5]);
487:                        setRowValues((MeterInterval) val, indices[i] + 1);
488:                        indices[i]++;
489:                    }
490:
491:                    DefaultListSelectionModel dlsm = (DefaultListSelectionModel) jTable1
492:                            .getSelectionModel();
493:                    dlsm.setValueIsAdjusting(true);
494:                    dlsm.clearSelection();
495:                    for (int i = 0; i < indices.length; ++i) {
496:                        dlsm.addSelectionInterval(indices[i], indices[i]);
497:                    }
498:                    dlsm.setValueIsAdjusting(false);
499:                }
500:            }//GEN-LAST:event_jButtonMoveDownActionPerformed
501:
502:            private void jButtonMoveUpActionPerformed(
503:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoveUpActionPerformed
504:
505:                if (jTable1.getSelectedRow() > 0) {
506:                    DefaultTableModel dtm = (DefaultTableModel) jTable1
507:                            .getModel();
508:                    int[] indices = jTable1.getSelectedRows();
509:                    for (int i = indices.length - 1; i >= 0; --i) {
510:                        if (indices[i] == 0)
511:                            continue;
512:
513:                        Object val = jTable1.getValueAt(indices[i], 0);
514:                        dtm.removeRow(indices[i]);
515:                        dtm.insertRow(indices[i] - 1, new Object[5]);
516:                        setRowValues((MeterInterval) val, indices[i] - 1);
517:                        indices[i]--;
518:                    }
519:
520:                    DefaultListSelectionModel dlsm = (DefaultListSelectionModel) jTable1
521:                            .getSelectionModel();
522:                    dlsm.setValueIsAdjusting(true);
523:                    dlsm.clearSelection();
524:                    for (int i = 0; i < indices.length; ++i) {
525:                        dlsm.addSelectionInterval(indices[i], indices[i]);
526:                    }
527:                    dlsm.setValueIsAdjusting(false);
528:                }
529:            }//GEN-LAST:event_jButtonMoveUpActionPerformed
530:
531:            private void jButtonDeleteActionPerformed(
532:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteActionPerformed
533:
534:                int[] indexes = jTable1.getSelectedRows();
535:
536:                for (int i = indexes.length - 1; i >= 0; --i) {
537:                    ((DefaultTableModel) jTable1.getModel())
538:                            .removeRow(indexes[i]);
539:                }
540:                jTable1.updateUI();
541:
542:            }//GEN-LAST:event_jButtonDeleteActionPerformed
543:
544:            private void jButtonModifyActionPerformed(
545:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyActionPerformed
546:
547:                int index = jTable1.getSelectedRow();
548:                if (index >= 0) {
549:                    MeterInterval c = (MeterInterval) jTable1.getValueAt(
550:                            jTable1.getSelectedRow(), 0);
551:                    MeterIntervalDialog cc = new MeterIntervalDialog(this , true);
552:                    cc.setMeterInterval(c);
553:                    if (newInfo != null) {
554:                        cc.setFocusedExpression(newInfo);
555:                    }
556:                    cc.setVisible(true);
557:
558:                    if (cc.getDialogResult() == JOptionPane.OK_OPTION) {
559:                        setRowValues(c, index);
560:                    }
561:                }
562:
563:            }//GEN-LAST:event_jButtonModifyActionPerformed
564:
565:            private void jButtonAddActionPerformed(
566:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddActionPerformed
567:
568:                MeterIntervalDialog cc = new MeterIntervalDialog(this , true);
569:                cc.setVisible(true);
570:
571:                if (cc.getDialogResult() == JOptionPane.OK_OPTION) {
572:                    addRowValues(cc.getMeterInterval());
573:                }
574:
575:            }//GEN-LAST:event_jButtonAddActionPerformed
576:
577:            /**
578:             * @param args the command line arguments
579:             */
580:            public static void main(String args[]) {
581:                java.awt.EventQueue.invokeLater(new Runnable() {
582:                    public void run() {
583:                        new SeriesColorsDialog(new javax.swing.JFrame(), true)
584:                                .setVisible(true);
585:                    }
586:                });
587:            }
588:
589:            public int getDialogResult() {
590:                return dialogResult;
591:            }
592:
593:            public void setDialogResult(int dialogResult) {
594:                this .dialogResult = dialogResult;
595:            }
596:
597:            public void setRowValues(MeterInterval mi, int row) {
598:                DecimalFormat dnf = new DecimalFormat("0.00");
599:                jTable1.setValueAt(mi, row, 0);
600:                jTable1.setValueAt(dnf.format(mi.getAlpha()), row, 1);
601:                jTable1
602:                        .setValueAt(mi.getDataRange().getLowExpression(), row,
603:                                2);
604:                jTable1.setValueAt(mi.getDataRange().getHighExpression(), row,
605:                        3);
606:                jTable1.updateUI();
607:            }
608:
609:            public void addRowValues(MeterInterval mi) {
610:                DecimalFormat dnf = new DecimalFormat("0.00");
611:                DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
612:                dtm.addRow(new Object[] { mi, dnf.format(mi.getAlpha()),
613:                        mi.getDataRange().getLowExpression(),
614:                        mi.getDataRange().getHighExpression() });
615:                jTable1.updateUI();
616:            }
617:
618:            public java.util.List getMeterIntervals() {
619:                return meterIntervals;
620:            }
621:
622:            public void setMeterIntervals(java.util.List meterIntervals) {
623:                this .meterIntervals = meterIntervals;
624:
625:                DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
626:                dtm.setRowCount(0);
627:
628:                for (int i = 0; i < meterIntervals.size(); ++i) {
629:                    addRowValues(((MeterInterval) meterIntervals.get(i))
630:                            .cloneMe());
631:                }
632:
633:                jTable1.updateUI();
634:            }
635:
636:            // Variables declaration - do not modify//GEN-BEGIN:variables
637:            private javax.swing.JButton jButtonAdd;
638:            private javax.swing.JButton jButtonCancel;
639:            private javax.swing.JButton jButtonCopyInterval;
640:            private javax.swing.JButton jButtonDelete;
641:            private javax.swing.JButton jButtonModify;
642:            private javax.swing.JButton jButtonMoveDown;
643:            private javax.swing.JButton jButtonMoveUp;
644:            private javax.swing.JButton jButtonOk;
645:            private javax.swing.JButton jButtonPasteInterval;
646:            private javax.swing.JButton jButtonUseLast;
647:            private javax.swing.JPanel jPanel1;
648:            private javax.swing.JPanel jPanel2;
649:            private javax.swing.JScrollPane jScrollPane1;
650:            private javax.swing.JSeparator jSeparator1;
651:            private javax.swing.JTable jTable1;
652:
653:            // End of variables declaration//GEN-END:variables
654:
655:            public void applyI18n() {
656:                // Start autogenerated code ----------------------
657:                jButtonAdd.setText(I18n.getString(
658:                        "meterIntervalsDialog.buttonAdd", "Add"));
659:                jButtonCancel.setText(I18n.getString(
660:                        "meterIntervalsDialog.buttonCancel", "Cancel"));
661:                jButtonCopyInterval.setText(I18n.getString(
662:                        "meterIntervalsDialog.buttonCopyInterval",
663:                        "Copy intervals"));
664:                jButtonDelete.setText(I18n.getString(
665:                        "meterIntervalsDialog.buttonDelete", "Delete"));
666:                jButtonModify.setText(I18n.getString(
667:                        "meterIntervalsDialog.buttonModify", "Modify"));
668:                jButtonMoveDown.setText(I18n.getString(
669:                        "meterIntervalsDialog.buttonMoveDown", "Move down"));
670:                jButtonMoveUp.setText(I18n.getString(
671:                        "meterIntervalsDialog.buttonMoveUp", "Move up"));
672:                jButtonOk.setText(I18n.getString(
673:                        "meterIntervalsDialog.buttonOk", "OK"));
674:                jButtonPasteInterval.setText(I18n.getString(
675:                        "meterIntervalsDialog.buttonPasteInterval",
676:                        "Paste intervals"));
677:                jButtonUseLast.setText(I18n.getString(
678:                        "meterIntervalsDialog.buttonUseLast", "Use last"));
679:                // End autogenerated code ----------------------
680:
681:                jTable1.getColumnModel().getColumn(0).setHeaderValue(
682:                        I18n.getString(
683:                                "meterIntervalsDialog.tablecolumn.label",
684:                                "Label"));
685:                jTable1.getColumnModel().getColumn(1).setHeaderValue(
686:                        I18n.getString(
687:                                "meterIntervalsDialog.tablecolumn.alpha",
688:                                "Alpha"));
689:                jTable1.getColumnModel().getColumn(2).setHeaderValue(
690:                        I18n.getString(
691:                                "meterIntervalsDialog.tablecolumn.lowExp",
692:                                "Low exp"));
693:                jTable1.getColumnModel().getColumn(3).setHeaderValue(
694:                        I18n.getString(
695:                                "meterIntervalsDialog.tablecolumn.highExp",
696:                                "High exp"));
697:
698:                jButtonCancel.setMnemonic(I18n.getString(
699:                        "meterIntervalsDialog.buttonCancelMnemonic", "c")
700:                        .charAt(0));
701:                jButtonOk
702:                        .setMnemonic(I18n.getString(
703:                                "meterIntervalsDialog.buttonOkMnemonic", "o")
704:                                .charAt(0));
705:            }
706:
707:            public static final int COMPONENT_NONE = 0;
708:            public static final int COMPONENT_INTERVALS_LIST = 1;
709:
710:            /**
711:             * This variable is checked by openExtraWindows() called when the component is shown.
712:             * If the value is != 0, the modify button will be action-performed.
713:             */
714:            public Object[] newInfo = null;
715:
716:            /**
717:             * This method set the focus on a specific component.
718:             * 
719:             * For this kind of datasource otherInfo must be:
720:             * [0] = Fixed to COMPONENT_PERIOD_SERIES_LIST (used for future extensions)
721:             * [1] = Integer, the category series to edit
722:             * [2] = The expression id in the category window to focus on 
723:             * [3] = The expression in the hyperlink...
724:             * [4] = The hyperlink parameter
725:             * [5] = The expression of the hyperlink parameter
726:             */
727:            public void setFocusedExpression(Object[] expressionInfo) {
728:                if (expressionInfo == null)
729:                    return;
730:                int expID = ((Integer) expressionInfo[0]).intValue();
731:                switch (expID) {
732:                case COMPONENT_INTERVALS_LIST:
733:                    int index = ((Integer) expressionInfo[1]).intValue();
734:
735:                    if (index >= 0 && jTable1.getRowCount() > index) {
736:                        jTable1.setRowSelectionInterval(index, index);
737:                        newInfo = new Object[expressionInfo.length - 2];
738:                        for (int i = 2; i < expressionInfo.length; ++i)
739:                            newInfo[i - 2] = expressionInfo[i];
740:                        break;
741:                    }
742:                }
743:            }
744:
745:            /**
746:             * This method checks for the variable subExpID. It is called when the component is shown.
747:             * If the value is >= 0, the modify button will be action-performed
748:             */
749:            private void openExtraWindows() {
750:                if (newInfo != null) {
751:                    jButtonModifyActionPerformed(new ActionEvent(jButtonModify,
752:                            0, ""));
753:                }
754:                newInfo = null;
755:            }
756:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.