KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > gui > ValuesPanel


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * ValuesPanel.java
28  *
29  * Created on 28 settembre 2005, 15.52
30  *
31  */

32
33 package it.businesslogic.ireport.gui;
34 import it.businesslogic.ireport.*;
35 import it.businesslogic.ireport.util.LanguageChangedEvent;
36 import it.businesslogic.ireport.util.Misc;
37 import java.util.Enumeration JavaDoc;
38 import java.util.Vector JavaDoc;
39 import javax.swing.DefaultListSelectionModel JavaDoc;
40 import javax.swing.JOptionPane JavaDoc;
41 import javax.swing.event.ListSelectionEvent JavaDoc;
42 import javax.swing.table.DefaultTableModel JavaDoc;
43 import it.businesslogic.ireport.util.I18n;
44 import it.businesslogic.ireport.util.LanguageChangedListener;
45 /**
46  *
47  * @author Administrator
48  */

49 public class ValuesPanel extends javax.swing.JPanel JavaDoc {
50     
51     private Vector JavaDoc clipboardFields = null;
52     private Vector JavaDoc clipboardVariables = null;
53     private Vector JavaDoc clipboardParameters = null;
54     
55     /**
56      * Dataset with wich the dialog deals
57      */

58     private SubDataset subDataset;
59     
60     /** Creates new form ValuesPanel */
61     public ValuesPanel() {
62         initComponents();
63         
64         setClipboardFields(new Vector JavaDoc());
65         setClipboardVariables(new Vector JavaDoc());
66         setClipboardParameters(new Vector JavaDoc());
67
68         //DefaultTableColumnModel dtcm = (DefaultTableColumnModel)jTableParameters.getColumnModel();
69
//DefaultTableCellRenderer tcr = (DefaultTableCellRenderer)dtcm.getColumn(0).getHeaderRenderer();
70

71         //new DefaultTableCellRenderer();
72
//tcr.setFont(jTableParameters.getFont());
73
//tcr.setBackground(this.getBackground());
74
//tcr.setBorder( new javax.swing.border.BevelBorder( javax.swing.border.BevelBorder.RAISED));
75
//dtcm.getColumn(0).setHeaderRenderer(tcr);
76
DefaultListSelectionModel JavaDoc dlsm = (DefaultListSelectionModel JavaDoc) this.jTableParameters.getSelectionModel();
77         dlsm.addListSelectionListener(new javax.swing.event.ListSelectionListener JavaDoc() {
78             public void valueChanged(ListSelectionEvent JavaDoc e)
79             {
80                 jTableParametersListSelectionValueChanged(e);
81             }
82         });
83
84         dlsm = (DefaultListSelectionModel JavaDoc) this.jTableVariables.getSelectionModel();
85         dlsm.addListSelectionListener(new javax.swing.event.ListSelectionListener JavaDoc() {
86             public void valueChanged(ListSelectionEvent JavaDoc e)
87             {
88                 jTableVariablesListSelectionValueChanged(e);
89             }
90         });
91
92         dlsm = (DefaultListSelectionModel JavaDoc) this.jTableFields.getSelectionModel();
93         dlsm.addListSelectionListener(new javax.swing.event.ListSelectionListener JavaDoc() {
94             public void valueChanged(ListSelectionEvent JavaDoc e)
95             {
96                 jTableFieldsListSelectionValueChanged(e);
97             }
98         });
99
100         applyI18n();
101         
102         I18n.addOnLanguageChangedListener( new LanguageChangedListener() {
103             public void languageChanged(LanguageChangedEvent evt) {
104                 applyI18n();
105             }
106         } );
107     }
108     
109     /**
110      * DOCUMENT ME!
111      *
112      * @param e DOCUMENT ME!
113      */

114     public void jTableParametersListSelectionValueChanged(javax.swing.event.ListSelectionEvent JavaDoc e)
115     {
116
117         if (this.jTableParameters.getSelectedRowCount() > 0)
118         {
119             this.jButtonModifyParameter.setEnabled(true);
120             this.jButtonDeleteParameter.setEnabled(true);
121
122             // if more than one row is selected and one of them is a built-in parameter then
123
// the buttons must be disabled
124
int[] rows = jTableParameters.getSelectedRows();
125
126             for (int i = rows.length - 1; i >= 0; --i)
127             {
128
129                 if (((JRParameter) jTableParameters.getValueAt(rows[ i ], 0)).isBuiltin())
130                 {
131                     this.jButtonModifyParameter.setEnabled(false);
132                     this.jButtonDeleteParameter.setEnabled(false);
133                 }
134             }
135
136         }
137         else
138         {
139             this.jButtonModifyParameter.setEnabled(false);
140             this.jButtonDeleteParameter.setEnabled(false);
141         }
142
143     }
144
145     /**
146      * DOCUMENT ME!
147      *
148      * @param e DOCUMENT ME!
149      */

150     public void jTableVariablesListSelectionValueChanged(javax.swing.event.ListSelectionEvent JavaDoc e)
151     {
152
153         if (this.jTableVariables.getSelectedRowCount() > 0)
154         {
155             this.jButtonModifyVariable.setEnabled(true);
156             this.jButtonDeleteVariable.setEnabled(true);
157
158             // if more than one row is selected and one of them is a built-in variable then
159
// the buttons must be disabled
160
int[] rows = jTableVariables.getSelectedRows();
161
162             for (int i = rows.length - 1; i >= 0; --i)
163             {
164
165                 if (((JRVariable) jTableVariables.getValueAt(rows[ i ], 0)).isBuiltin())
166                 {
167                     this.jButtonModifyVariable.setEnabled(false);
168                     this.jButtonDeleteVariable.setEnabled(false);
169                 }
170             }
171
172         }
173         else
174         {
175             this.jButtonModifyVariable.setEnabled(false);
176             this.jButtonDeleteVariable.setEnabled(false);
177         }
178     }
179
180     /**
181      * DOCUMENT ME!
182      *
183      * @param e DOCUMENT ME!
184      */

185     public void jTableFieldsListSelectionValueChanged(javax.swing.event.ListSelectionEvent JavaDoc e)
186     {
187
188         if (this.jTableFields.getSelectedRowCount() > 0)
189         {
190             this.jButtonModifyField.setEnabled(true);
191             this.jButtonDeleteField.setEnabled(true);
192         }
193         else
194         {
195             this.jButtonModifyField.setEnabled(false);
196             this.jButtonDeleteField.setEnabled(false);
197         }
198     }
199
200     public SubDataset getSubDataset() {
201         return subDataset;
202     }
203
204     public void setSubDataset(SubDataset subDataset) {
205         this.subDataset = subDataset;
206         
207         // Update all...
208
if (subDataset != null)
209         {
210             updateParameters();
211             updateFields();
212             updateVariables();
213         }
214     }
215     
216     /** This method is called from within the constructor to
217      * initialize the form.
218      * WARNING: Do NOT modify this code. The content of this method is
219      * always regenerated by the Form Editor.
220      */

221     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
222
private void initComponents() {
223         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
224
225         jPopupMenuFields = new javax.swing.JPopupMenu JavaDoc();
226         jMenuItemCut = new javax.swing.JMenuItem JavaDoc();
227         jMenuItemCopy = new javax.swing.JMenuItem JavaDoc();
228         jMenuItemPaste = new javax.swing.JMenuItem JavaDoc();
229         jMenuItemDelete = new javax.swing.JMenuItem JavaDoc();
230         jMenuItemDuplicate = new javax.swing.JMenuItem JavaDoc();
231         jPopupMenuVariables = new javax.swing.JPopupMenu JavaDoc();
232         jMenuItemCut1 = new javax.swing.JMenuItem JavaDoc();
233         jMenuItemCopy1 = new javax.swing.JMenuItem JavaDoc();
234         jMenuItemPaste1 = new javax.swing.JMenuItem JavaDoc();
235         jMenuItemDelete1 = new javax.swing.JMenuItem JavaDoc();
236         jMenuItemDuplicate1 = new javax.swing.JMenuItem JavaDoc();
237         jPopupMenuParameters = new javax.swing.JPopupMenu JavaDoc();
238         jMenuItemCut2 = new javax.swing.JMenuItem JavaDoc();
239         jMenuItemCopy2 = new javax.swing.JMenuItem JavaDoc();
240         jMenuItemPaste2 = new javax.swing.JMenuItem JavaDoc();
241         jMenuItemDelete2 = new javax.swing.JMenuItem JavaDoc();
242         jMenuItemDuplicate2 = new javax.swing.JMenuItem JavaDoc();
243         jTabbedPane = new javax.swing.JTabbedPane JavaDoc();
244         jPanelFields = new javax.swing.JPanel JavaDoc();
245         jScrollPane3 = new javax.swing.JScrollPane JavaDoc();
246         jTableFields = new it.businesslogic.ireport.gui.JDragTable();
247         jPanelButtons2 = new javax.swing.JPanel JavaDoc();
248         jButtonNewField = new javax.swing.JButton JavaDoc();
249         jButtonModifyField = new javax.swing.JButton JavaDoc();
250         jButtonDeleteField = new javax.swing.JButton JavaDoc();
251         jPanelVariables = new javax.swing.JPanel JavaDoc();
252         jScrollPane2 = new javax.swing.JScrollPane JavaDoc();
253         jTableVariables = new it.businesslogic.ireport.gui.JDragTable();
254         jPanelButtons1 = new javax.swing.JPanel JavaDoc();
255         jButtonNewVariable = new javax.swing.JButton JavaDoc();
256         jButtonModifyVariable = new javax.swing.JButton JavaDoc();
257         jButtonDeleteVariable = new javax.swing.JButton JavaDoc();
258         jPanelParameters = new javax.swing.JPanel JavaDoc();
259         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
260         jTableParameters = new it.businesslogic.ireport.gui.JDragTable();
261         jPanelButtons = new javax.swing.JPanel JavaDoc();
262         jButtonNewParameter = new javax.swing.JButton JavaDoc();
263         jButtonModifyParameter = new javax.swing.JButton JavaDoc();
264         jButtonDeleteParameter = new javax.swing.JButton JavaDoc();
265
266         jPopupMenuFields.addPopupMenuListener(new javax.swing.event.PopupMenuListener JavaDoc() {
267             public void popupMenuCanceled(javax.swing.event.PopupMenuEvent JavaDoc evt) {
268             }
269             public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent JavaDoc evt) {
270             }
271             public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent JavaDoc evt) {
272                 jPopupMenuFieldsPopupMenuWillBecomeVisible(evt);
273             }
274         });
275
276         jMenuItemCut.setText("Item");
277         jMenuItemCut.setActionCommand("Item");
278         jMenuItemCut.addActionListener(new java.awt.event.ActionListener JavaDoc() {
279             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
280                 jMenuItemCutActionPerformed(evt);
281             }
282         });
283
284         jPopupMenuFields.add(jMenuItemCut);
285
286         jMenuItemCopy.setText("Item");
287         jMenuItemCopy.addActionListener(new java.awt.event.ActionListener JavaDoc() {
288             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
289                 jMenuItemCopyActionPerformed(evt);
290             }
291         });
292
293         jPopupMenuFields.add(jMenuItemCopy);
294
295         jMenuItemPaste.setText("Item");
296         jMenuItemPaste.addActionListener(new java.awt.event.ActionListener JavaDoc() {
297             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
298                 jMenuItemPasteActionPerformed(evt);
299             }
300         });
301
302         jPopupMenuFields.add(jMenuItemPaste);
303
304         jMenuItemDelete.setText("Item");
305         jMenuItemDelete.addActionListener(new java.awt.event.ActionListener JavaDoc() {
306             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
307                 jMenuItemDeleteActionPerformed(evt);
308             }
309         });
310
311         jPopupMenuFields.add(jMenuItemDelete);
312
313         jMenuItemDuplicate.setText("Item");
314         jMenuItemDuplicate.addActionListener(new java.awt.event.ActionListener JavaDoc() {
315             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
316                 jMenuItemDuplicateActionPerformed(evt);
317             }
318         });
319
320         jPopupMenuFields.add(jMenuItemDuplicate);
321
322         jPopupMenuVariables.addPopupMenuListener(new javax.swing.event.PopupMenuListener JavaDoc() {
323             public void popupMenuCanceled(javax.swing.event.PopupMenuEvent JavaDoc evt) {
324             }
325             public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent JavaDoc evt) {
326             }
327             public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent JavaDoc evt) {
328                 jPopupMenuVariablesPopupMenuWillBecomeVisible(evt);
329             }
330         });
331
332         jMenuItemCut1.setText("Item");
333         jMenuItemCut1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
334             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
335                 jMenuItemCut1ActionPerformed(evt);
336             }
337         });
338
339         jPopupMenuVariables.add(jMenuItemCut1);
340
341         jMenuItemCopy1.setText("Item");
342         jMenuItemCopy1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
343             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
344                 jMenuItemCopy1ActionPerformed(evt);
345             }
346         });
347
348         jPopupMenuVariables.add(jMenuItemCopy1);
349
350         jMenuItemPaste1.setText("Item");
351         jMenuItemPaste1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
352             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
353                 jMenuItemPaste1ActionPerformed(evt);
354             }
355         });
356
357         jPopupMenuVariables.add(jMenuItemPaste1);
358
359         jMenuItemDelete1.setText("Item");
360         jMenuItemDelete1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
361             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
362                 jMenuItemDelete1ActionPerformed(evt);
363             }
364         });
365
366         jPopupMenuVariables.add(jMenuItemDelete1);
367
368         jMenuItemDuplicate1.setText("Item");
369         jMenuItemDuplicate1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
370             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
371                 jMenuItemDuplicate1ActionPerformed(evt);
372             }
373         });
374
375         jPopupMenuVariables.add(jMenuItemDuplicate1);
376
377         jPopupMenuParameters.addPopupMenuListener(new javax.swing.event.PopupMenuListener JavaDoc() {
378             public void popupMenuCanceled(javax.swing.event.PopupMenuEvent JavaDoc evt) {
379             }
380             public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent JavaDoc evt) {
381             }
382             public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent JavaDoc evt) {
383                 jPopupMenuParametersPopupMenuWillBecomeVisible(evt);
384             }
385         });
386
387         jMenuItemCut2.setText("Item");
388         jMenuItemCut2.addActionListener(new java.awt.event.ActionListener JavaDoc() {
389             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
390                 jMenuItemCut2ActionPerformed(evt);
391             }
392         });
393
394         jPopupMenuParameters.add(jMenuItemCut2);
395
396         jMenuItemCopy2.setText("Item");
397         jMenuItemCopy2.addActionListener(new java.awt.event.ActionListener JavaDoc() {
398             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
399                 jMenuItemCopy2ActionPerformed(evt);
400             }
401         });
402
403         jPopupMenuParameters.add(jMenuItemCopy2);
404
405         jMenuItemPaste2.setText("Item");
406         jMenuItemPaste2.addActionListener(new java.awt.event.ActionListener JavaDoc() {
407             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
408                 jMenuItemPaste2ActionPerformed(evt);
409             }
410         });
411
412         jPopupMenuParameters.add(jMenuItemPaste2);
413
414         jMenuItemDelete2.setText("Item");
415         jMenuItemDelete2.addActionListener(new java.awt.event.ActionListener JavaDoc() {
416             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
417                 jMenuItemDelete2ActionPerformed(evt);
418             }
419         });
420
421         jPopupMenuParameters.add(jMenuItemDelete2);
422
423         jMenuItemDuplicate2.setText("Item");
424         jMenuItemDuplicate2.addActionListener(new java.awt.event.ActionListener JavaDoc() {
425             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
426                 jMenuItemDuplicate2ActionPerformed(evt);
427             }
428         });
429
430         jPopupMenuParameters.add(jMenuItemDuplicate2);
431
432         setLayout(new java.awt.BorderLayout JavaDoc());
433
434         jTabbedPane.setName("");
435         jPanelFields.setLayout(new java.awt.GridBagLayout JavaDoc());
436
437         jScrollPane3.setBackground(new java.awt.Color JavaDoc(255, 255, 255));
438         jScrollPane3.addMouseListener(new java.awt.event.MouseAdapter JavaDoc() {
439             public void mouseClicked(java.awt.event.MouseEvent JavaDoc evt) {
440                 jScrollPane3MouseClicked(evt);
441             }
442         });
443
444         jTableFields.setModel(new javax.swing.table.DefaultTableModel JavaDoc(
445             new Object JavaDoc [][] {
446
447             },
448             new String JavaDoc [] {
449                 "Field name", "Class type"
450             }
451         ) {
452             boolean[] canEdit = new boolean [] {
453                 false, false
454             };
455
456             public boolean isCellEditable(int rowIndex, int columnIndex) {
457                 return canEdit [columnIndex];
458             }
459         });
460         jTableFields.addMouseListener(new java.awt.event.MouseAdapter JavaDoc() {
461             public void mouseClicked(java.awt.event.MouseEvent JavaDoc evt) {
462                 jTableFieldsMouseClicked(evt);
463             }
464         });
465
466         jScrollPane3.setViewportView(jTableFields);
467
468         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
469         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
470         gridBagConstraints.weightx = 1.0;
471         gridBagConstraints.weighty = 1.0;
472         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 2, 2, 2);
473         jPanelFields.add(jScrollPane3, gridBagConstraints);
474
475         jPanelButtons2.setLayout(null);
476
477         jPanelButtons2.setMinimumSize(new java.awt.Dimension JavaDoc(100, 100));
478         jPanelButtons2.setOpaque(false);
479         jPanelButtons2.setPreferredSize(new java.awt.Dimension JavaDoc(100, 100));
480         jButtonNewField.setText("New");
481         jButtonNewField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
482             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
483                 jButtonNewFieldActionPerformed(evt);
484             }
485         });
486
487         jPanelButtons2.add(jButtonNewField);
488         jButtonNewField.setBounds(4, 5, 92, 22);
489
490         jButtonModifyField.setText("Modify");
491         jButtonModifyField.setEnabled(false);
492         jButtonModifyField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
493             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
494                 jButtonModifyFieldActionPerformed(evt);
495             }
496         });
497
498         jPanelButtons2.add(jButtonModifyField);
499         jButtonModifyField.setBounds(4, 30, 92, 22);
500
501         jButtonDeleteField.setText("Delete");
502         jButtonDeleteField.setEnabled(false);
503         jButtonDeleteField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
504             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
505                 jButtonDeleteFieldActionPerformed(evt);
506             }
507         });
508
509         jPanelButtons2.add(jButtonDeleteField);
510         jButtonDeleteField.setBounds(4, 56, 92, 22);
511
512         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
513         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
514         gridBagConstraints.weighty = 1.0;
515         jPanelFields.add(jPanelButtons2, gridBagConstraints);
516
517         jTabbedPane.addTab("Fields", jPanelFields);
518
519         jPanelVariables.setLayout(new java.awt.GridBagLayout JavaDoc());
520
521         jScrollPane2.setBackground(new java.awt.Color JavaDoc(255, 255, 255));
522         jScrollPane2.addMouseListener(new java.awt.event.MouseAdapter JavaDoc() {
523             public void mouseClicked(java.awt.event.MouseEvent JavaDoc evt) {
524                 jScrollPane2MouseClicked(evt);
525             }
526         });
527
528         jTableVariables.setModel(new javax.swing.table.DefaultTableModel JavaDoc(
529             new Object JavaDoc [][] {
530
531             },
532             new String JavaDoc [] {
533                 "Variable name", "Builtin"
534             }
535         ) {
536             boolean[] canEdit = new boolean [] {
537                 false, false
538             };
539
540             public boolean isCellEditable(int rowIndex, int columnIndex) {
541                 return canEdit [columnIndex];
542             }
543         });
544         jTableVariables.addMouseListener(new java.awt.event.MouseAdapter JavaDoc() {
545             public void mouseClicked(java.awt.event.MouseEvent JavaDoc evt) {
546                 jTableVariablesMouseClicked(evt);
547             }
548         });
549
550         jScrollPane2.setViewportView(jTableVariables);
551
552         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
553         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
554         gridBagConstraints.weightx = 1.0;
555         gridBagConstraints.weighty = 1.0;
556         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 2, 2, 2);
557         jPanelVariables.add(jScrollPane2, gridBagConstraints);
558
559         jPanelButtons1.setLayout(null);
560
561         jPanelButtons1.setMinimumSize(new java.awt.Dimension JavaDoc(100, 100));
562         jPanelButtons1.setPreferredSize(new java.awt.Dimension JavaDoc(100, 100));
563         jButtonNewVariable.setText("New");
564         jButtonNewVariable.addActionListener(new java.awt.event.ActionListener JavaDoc() {
565             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
566                 jButtonNewVariableActionPerformed(evt);
567             }
568         });
569
570         jPanelButtons1.add(jButtonNewVariable);
571         jButtonNewVariable.setBounds(4, 5, 92, 22);
572
573         jButtonModifyVariable.setText("Modify");
574         jButtonModifyVariable.setEnabled(false);
575         jButtonModifyVariable.addActionListener(new java.awt.event.ActionListener JavaDoc() {
576             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
577                 jButtonModifyVariableActionPerformed(evt);
578             }
579         });
580
581         jPanelButtons1.add(jButtonModifyVariable);
582         jButtonModifyVariable.setBounds(4, 30, 92, 22);
583
584         jButtonDeleteVariable.setText("Delete");
585         jButtonDeleteVariable.setEnabled(false);
586         jButtonDeleteVariable.addActionListener(new java.awt.event.ActionListener JavaDoc() {
587             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
588                 jButtonDeleteVariableActionPerformed(evt);
589             }
590         });
591
592         jPanelButtons1.add(jButtonDeleteVariable);
593         jButtonDeleteVariable.setBounds(4, 56, 92, 22);
594
595         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
596         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
597         gridBagConstraints.weighty = 1.0;
598         jPanelVariables.add(jPanelButtons1, gridBagConstraints);
599
600         jTabbedPane.addTab("Variables", jPanelVariables);
601
602         jPanelParameters.setLayout(new java.awt.GridBagLayout JavaDoc());
603
604         jScrollPane1.setBackground(new java.awt.Color JavaDoc(255, 255, 255));
605         jScrollPane1.addMouseListener(new java.awt.event.MouseAdapter JavaDoc() {
606             public void mouseClicked(java.awt.event.MouseEvent JavaDoc evt) {
607                 jScrollPane1MouseClicked(evt);
608             }
609         });
610
611         jTableParameters.setModel(new javax.swing.table.DefaultTableModel JavaDoc(
612             new Object JavaDoc [][] {
613
614             },
615             new String JavaDoc [] {
616                 "Parameter name", "Class type", "Is for prompting", "Built-in"
617             }
618         ) {
619             boolean[] canEdit = new boolean [] {
620                 false, false, false, false
621             };
622
623             public boolean isCellEditable(int rowIndex, int columnIndex) {
624                 return canEdit [columnIndex];
625             }
626         });
627         jTableParameters.addMouseListener(new java.awt.event.MouseAdapter JavaDoc() {
628             public void mouseClicked(java.awt.event.MouseEvent JavaDoc evt) {
629                 jTableParametersMouseClicked(evt);
630             }
631         });
632
633         jScrollPane1.setViewportView(jTableParameters);
634
635         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
636         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
637         gridBagConstraints.weightx = 1.0;
638         gridBagConstraints.weighty = 1.0;
639         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 2, 2, 2);
640         jPanelParameters.add(jScrollPane1, gridBagConstraints);
641
642         jPanelButtons.setLayout(null);
643
644         jPanelButtons.setMinimumSize(new java.awt.Dimension JavaDoc(100, 100));
645         jPanelButtons.setPreferredSize(new java.awt.Dimension JavaDoc(100, 100));
646         jButtonNewParameter.setText("New");
647         jButtonNewParameter.addActionListener(new java.awt.event.ActionListener JavaDoc() {
648             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
649                 jButtonNewParameterActionPerformed(evt);
650             }
651         });
652
653         jPanelButtons.add(jButtonNewParameter);
654         jButtonNewParameter.setBounds(4, 5, 92, 22);
655
656         jButtonModifyParameter.setText("Modify");
657         jButtonModifyParameter.setEnabled(false);
658         jButtonModifyParameter.addActionListener(new java.awt.event.ActionListener JavaDoc() {
659             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
660                 jButtonModifyParameterActionPerformed(evt);
661             }
662         });
663
664         jPanelButtons.add(jButtonModifyParameter);
665         jButtonModifyParameter.setBounds(4, 30, 92, 22);
666
667         jButtonDeleteParameter.setText("Delete");
668         jButtonDeleteParameter.setEnabled(false);
669         jButtonDeleteParameter.addActionListener(new java.awt.event.ActionListener JavaDoc() {
670             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
671                 jButtonDeleteParameterActionPerformed(evt);
672             }
673         });
674
675         jPanelButtons.add(jButtonDeleteParameter);
676         jButtonDeleteParameter.setBounds(4, 56, 92, 22);
677
678         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
679         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
680         gridBagConstraints.weighty = 1.0;
681         jPanelParameters.add(jPanelButtons, gridBagConstraints);
682
683         jTabbedPane.addTab("Parameters", jPanelParameters);
684
685         add(jTabbedPane, java.awt.BorderLayout.CENTER);
686
687     }// </editor-fold>//GEN-END:initComponents
688

689     private void jButtonDeleteFieldActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonDeleteFieldActionPerformed
690
jTableFields.getSelectedRows();
691
692         int[] rows = jTableFields.getSelectedRows();
693
694         for (int i = rows.length - 1; i >= 0; --i)
695         {
696             getSubDataset().removeField(
697                     (JRField) jTableFields.getValueAt(rows[ i ], 0));
698         }
699
700     }//GEN-LAST:event_jButtonDeleteFieldActionPerformed
701

702     private void jPopupMenuParametersPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent JavaDoc evt) {//GEN-FIRST:event_jPopupMenuParametersPopupMenuWillBecomeVisible
703
if (getClipboardParameters().size() > 0)
704         {
705             jMenuItemPaste2.setEnabled(true);
706         }
707         else
708         {
709             jMenuItemPaste2.setEnabled(false);
710         }
711
712         if (jTableParameters.getSelectedRowCount() > 0)
713         {
714             jMenuItemCut2.setEnabled(true);
715             jMenuItemCopy2.setEnabled(true);
716             jMenuItemDelete2.setEnabled(true);
717             jMenuItemDuplicate2.setEnabled(true);
718         }
719         else
720         {
721             jMenuItemCut2.setEnabled(false);
722             jMenuItemCopy2.setEnabled(false);
723             jMenuItemDelete2.setEnabled(false);
724             jMenuItemDuplicate2.setEnabled(false);
725         }
726     }//GEN-LAST:event_jPopupMenuParametersPopupMenuWillBecomeVisible
727

728     private void jPopupMenuVariablesPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent JavaDoc evt) {//GEN-FIRST:event_jPopupMenuVariablesPopupMenuWillBecomeVisible
729

730         if (getClipboardVariables().size() > 0)
731         {
732             jMenuItemPaste1.setEnabled(true);
733         }
734         else
735         {
736             jMenuItemPaste1.setEnabled(false);
737         }
738
739         if (jTableVariables.getSelectedRowCount() > 0)
740         {
741             jMenuItemCut1.setEnabled(true);
742             jMenuItemCopy1.setEnabled(true);
743             jMenuItemDelete1.setEnabled(true);
744             jMenuItemDuplicate1.setEnabled(true);
745         }
746         else
747         {
748             jMenuItemCut1.setEnabled(false);
749             jMenuItemCopy1.setEnabled(false);
750             jMenuItemDelete1.setEnabled(false);
751             jMenuItemDuplicate1.setEnabled(false);
752         }
753     }//GEN-LAST:event_jPopupMenuVariablesPopupMenuWillBecomeVisible
754

755     private void jPopupMenuFieldsPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent JavaDoc evt) {//GEN-FIRST:event_jPopupMenuFieldsPopupMenuWillBecomeVisible
756
if (getClipboardFields().size() > 0)
757         {
758             jMenuItemPaste.setEnabled(true);
759         }
760         else
761         {
762             jMenuItemPaste.setEnabled(false);
763         }
764
765         if (jTableFields.getSelectedRowCount() > 0)
766         {
767             jMenuItemCut.setEnabled(true);
768             jMenuItemCopy.setEnabled(true);
769             jMenuItemDelete.setEnabled(true);
770             jMenuItemDuplicate.setEnabled(true);
771         }
772         else
773         {
774             jMenuItemCut.setEnabled(false);
775             jMenuItemCopy.setEnabled(false);
776             jMenuItemDelete.setEnabled(false);
777             jMenuItemDuplicate.setEnabled(false);
778         }
779     }//GEN-LAST:event_jPopupMenuFieldsPopupMenuWillBecomeVisible
780

781     private void jMenuItemDuplicate2ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemDuplicate2ActionPerformed
782
Vector JavaDoc selectedParameters = new Vector JavaDoc();
783         jTableParameters.getSelectedRows();
784
785         int[] rows = jTableParameters.getSelectedRows();
786
787         for (int i = rows.length - 1; i >= 0; --i)
788         {
789             selectedParameters.add(((JRParameter) jTableParameters.getValueAt(
790                                             rows[ i ], 0)).cloneMe());
791         }
792
793         duplicateParameters(selectedParameters);
794     }//GEN-LAST:event_jMenuItemDuplicate2ActionPerformed
795

796     private void jMenuItemDelete2ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemDelete2ActionPerformed
797
jButtonDeleteParameterActionPerformed(evt);
798     }//GEN-LAST:event_jMenuItemDelete2ActionPerformed
799

800     private void jMenuItemPaste2ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemPaste2ActionPerformed
801
duplicateParameters(getClipboardParameters());
802     }//GEN-LAST:event_jMenuItemPaste2ActionPerformed
803

804     private void jMenuItemCopy2ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemCopy2ActionPerformed
805
jTableParameters.getSelectedRows();
806
807         int[] rows = jTableParameters.getSelectedRows();
808         getClipboardParameters().removeAllElements();
809
810         for (int i = rows.length - 1; i >= 0; --i)
811         {
812
813             JRParameter parameter = ((JRParameter) jTableParameters.getValueAt(
814                                              rows[ i ], 0)).cloneMe();
815
816             if (!parameter.isBuiltin())
817             {
818                 getClipboardParameters().add(parameter);
819             }
820         }
821     }//GEN-LAST:event_jMenuItemCopy2ActionPerformed
822

823     private void jMenuItemCut2ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemCut2ActionPerformed
824
// Put selected elements in clipboard and call delete...
825
jTableParameters.getSelectedRows();
826
827         int[] rows = jTableParameters.getSelectedRows();
828         getClipboardParameters().removeAllElements();
829
830         for (int i = rows.length - 1; i >= 0; --i)
831         {
832
833             JRParameter parameter = ((JRParameter) jTableParameters.getValueAt(
834                                              rows[ i ], 0)).cloneMe();
835
836             if (!parameter.isBuiltin())
837             {
838                 getClipboardParameters().add(parameter);
839             }
840         }
841
842         jButtonDeleteParameterActionPerformed(evt);
843     }//GEN-LAST:event_jMenuItemCut2ActionPerformed
844

845     private void jMenuItemDuplicate1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemDuplicate1ActionPerformed
846
Vector JavaDoc selectedVariables = new Vector JavaDoc();
847         jTableVariables.getSelectedRows();
848
849         int[] rows = jTableVariables.getSelectedRows();
850
851         for (int i = rows.length - 1; i >= 0; --i)
852         {
853             selectedVariables.add(((JRVariable) jTableVariables.getValueAt(
854                                            rows[ i ], 0)).cloneMe());
855         }
856
857         duplicateVariables(selectedVariables);
858     }//GEN-LAST:event_jMenuItemDuplicate1ActionPerformed
859

860     private void jMenuItemDelete1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemDelete1ActionPerformed
861
jButtonDeleteVariableActionPerformed(evt);
862     }//GEN-LAST:event_jMenuItemDelete1ActionPerformed
863

864     private void jMenuItemPaste1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemPaste1ActionPerformed
865
duplicateVariables(getClipboardVariables());
866     }//GEN-LAST:event_jMenuItemPaste1ActionPerformed
867

868     private void jMenuItemCopy1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemCopy1ActionPerformed
869
jTableVariables.getSelectedRows();
870
871         int[] rows = jTableVariables.getSelectedRows();
872         getClipboardVariables().removeAllElements();
873
874         for (int i = rows.length - 1; i >= 0; --i)
875         {
876
877             JRVariable variable = ((JRVariable) jTableVariables.getValueAt(
878                                            rows[ i ], 0)).cloneMe();
879
880             if (!variable.isBuiltin())
881             {
882                 getClipboardVariables().add(variable);
883             }
884         }
885     }//GEN-LAST:event_jMenuItemCopy1ActionPerformed
886

887     private void jMenuItemCut1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemCut1ActionPerformed
888
// Put selected elements in clipboard and call delete...
889
jTableVariables.getSelectedRows();
890
891         int[] rows = jTableVariables.getSelectedRows();
892         getClipboardVariables().removeAllElements();
893
894         for (int i = rows.length - 1; i >= 0; --i)
895         {
896
897             JRVariable variable = ((JRVariable) jTableVariables.getValueAt(
898                                            rows[ i ], 0)).cloneMe();
899
900             if (!variable.isBuiltin())
901             {
902                 getClipboardVariables().add(variable);
903             }
904         }
905
906         jButtonDeleteVariableActionPerformed(evt);
907     }//GEN-LAST:event_jMenuItemCut1ActionPerformed
908

909     private void jMenuItemDuplicateActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemDuplicateActionPerformed
910
Vector JavaDoc selectedFields = new Vector JavaDoc();
911         jTableFields.getSelectedRows();
912
913         int[] rows = jTableFields.getSelectedRows();
914
915         for (int i = rows.length - 1; i >= 0; --i)
916         {
917             selectedFields.add(((JRField) jTableFields.getValueAt(rows[ i ], 0)).cloneMe());
918         }
919
920         duplicateFields(selectedFields);
921     }//GEN-LAST:event_jMenuItemDuplicateActionPerformed
922

923     private void jMenuItemDeleteActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemDeleteActionPerformed
924
jButtonDeleteFieldActionPerformed(evt);
925     }//GEN-LAST:event_jMenuItemDeleteActionPerformed
926

927     private void jMenuItemPasteActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemPasteActionPerformed
928
duplicateFields(getClipboardFields());
929     }//GEN-LAST:event_jMenuItemPasteActionPerformed
930

931     private void jMenuItemCopyActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemCopyActionPerformed
932
jTableFields.getSelectedRows();
933
934         int[] rows = jTableFields.getSelectedRows();
935         getClipboardFields().removeAllElements();
936
937         for (int i = rows.length - 1; i >= 0; --i)
938         {
939             getClipboardFields().add(((JRField) jTableFields.getValueAt(
940                                               rows[ i ], 0)).cloneMe());
941         }
942     }//GEN-LAST:event_jMenuItemCopyActionPerformed
943

944     private void jMenuItemCutActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jMenuItemCutActionPerformed
945
// Put selected elements in clipboard and call delete...
946
jTableFields.getSelectedRows();
947
948         int[] rows = jTableFields.getSelectedRows();
949         getClipboardFields().removeAllElements();
950
951         for (int i = rows.length - 1; i >= 0; --i)
952         {
953             getClipboardFields().add(((JRField) jTableFields.getValueAt(
954                                               rows[ i ], 0)).cloneMe());
955         }
956
957         jButtonDeleteFieldActionPerformed(evt);
958     }//GEN-LAST:event_jMenuItemCutActionPerformed
959

960     private void jTableParametersMouseClicked(java.awt.event.MouseEvent JavaDoc evt) {//GEN-FIRST:event_jTableParametersMouseClicked
961
if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1 &&
962             jTableParameters.getSelectedRow() >= 0)
963         {
964             jButtonModifyParameterActionPerformed(new java.awt.event.ActionEvent JavaDoc(
965                                                           jButtonModifyParameter,
966                                                           0, ""));
967         }
968
969         if (evt.getClickCount() == 1 && evt.getButton() == evt.BUTTON3)
970         {
971             jPopupMenuParameters.show(jTableParameters, evt.getPoint().x,
972                                       evt.getPoint().y);
973         }
974     }//GEN-LAST:event_jTableParametersMouseClicked
975

976     private void jTableVariablesMouseClicked(java.awt.event.MouseEvent JavaDoc evt) {//GEN-FIRST:event_jTableVariablesMouseClicked
977
if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1 &&
978             jTableVariables.getSelectedRow() >= 0)
979         {
980             jButtonModifyVariableActionPerformed(new java.awt.event.ActionEvent JavaDoc(
981                                                          jButtonModifyVariable,
982                                                          0, ""));
983         }
984
985         if (evt.getClickCount() == 1 && evt.getButton() == evt.BUTTON3)
986         {
987             jPopupMenuVariables.show(jTableVariables, evt.getPoint().x,
988                                      evt.getPoint().y);
989         }
990     }//GEN-LAST:event_jTableVariablesMouseClicked
991

992     private void jTableFieldsMouseClicked(java.awt.event.MouseEvent JavaDoc evt) {//GEN-FIRST:event_jTableFieldsMouseClicked
993
if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1 &&
994             jTableFields.getSelectedRow() >= 0)
995         {
996             jButtonModifyFieldActionPerformed(new java.awt.event.ActionEvent JavaDoc(
997                                                       jButtonModifyField, 0,
998                                                       ""));
999         }
1000
1001        if (evt.getClickCount() == 1 && evt.getButton() == evt.BUTTON3)
1002        {
1003            jPopupMenuFields.show(jTableFields, evt.getPoint().x,
1004                                  evt.getPoint().y);
1005        }
1006    }//GEN-LAST:event_jTableFieldsMouseClicked
1007

1008    private void jScrollPane1MouseClicked(java.awt.event.MouseEvent JavaDoc evt) {//GEN-FIRST:event_jScrollPane1MouseClicked
1009

1010    }//GEN-LAST:event_jScrollPane1MouseClicked
1011

1012    private void jScrollPane2MouseClicked(java.awt.event.MouseEvent JavaDoc evt) {//GEN-FIRST:event_jScrollPane2MouseClicked
1013

1014    }//GEN-LAST:event_jScrollPane2MouseClicked
1015

1016    private void jScrollPane3MouseClicked(java.awt.event.MouseEvent JavaDoc evt) {//GEN-FIRST:event_jScrollPane3MouseClicked
1017

1018    }//GEN-LAST:event_jScrollPane3MouseClicked
1019

1020    private void jButtonDeleteParameterActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonDeleteParameterActionPerformed
1021
jTableParameters.getSelectedRows();
1022
1023        int[] rows = jTableParameters.getSelectedRows();
1024
1025        for (int i = rows.length - 1; i >= 0; --i)
1026        {
1027
1028            JRParameter parameter = (JRParameter) jTableParameters.getValueAt(
1029                                            rows[ i ], 0);
1030
1031            if (!parameter.isBuiltin())
1032            {
1033                getSubDataset().removeParameter(parameter);
1034            }
1035            else
1036            {
1037                javax.swing.JOptionPane.showMessageDialog(this,
1038                        I18n.getString( "messages.valuesPanel.cantModifyBuiltInParameters","You can't modify or delete builtin parameters!"),
1039                        I18n.getString( "messages.valuesPanel.cantModifyBuiltInParametersCaption","Invalid operation!"),
1040                        javax.swing.JOptionPane.WARNING_MESSAGE);
1041
1042                return;
1043            }
1044        }
1045    }//GEN-LAST:event_jButtonDeleteParameterActionPerformed
1046

1047    private void jButtonModifyParameterActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonModifyParameterActionPerformed
1048
JRParameter parameter = (JRParameter) jTableParameters.getValueAt(jTableParameters.getSelectedRow(),
1049                                                                          0);
1050
1051        modifyParameter(parameter);
1052    }//GEN-LAST:event_jButtonModifyParameterActionPerformed
1053

1054    private void jButtonNewParameterActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonNewParameterActionPerformed
1055
// create a new parameter....
1056
newParameter();
1057    }//GEN-LAST:event_jButtonNewParameterActionPerformed
1058

1059    private void jButtonDeleteVariableActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonDeleteVariableActionPerformed
1060
jTableVariables.getSelectedRows();
1061
1062        int[] rows = jTableVariables.getSelectedRows();
1063
1064        for (int i = rows.length - 1; i >= 0; --i)
1065        {
1066
1067            if (!((JRVariable) jTableVariables.getValueAt(rows[ i ], 0)).isBuiltin())
1068            {
1069                getSubDataset().removeVariable(
1070                        (JRVariable) jTableVariables.getValueAt(rows[ i ], 0));
1071            }
1072
1073            //this.jTableParameters.removeRowSelectionInterval( rows[i],rows[i]);
1074
}
1075    }//GEN-LAST:event_jButtonDeleteVariableActionPerformed
1076

1077    private void jButtonModifyVariableActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonModifyVariableActionPerformed
1078
JRVariable variable = (JRVariable) jTableVariables.getValueAt(jTableVariables.getSelectedRow(), 0);
1079        modifyVariable(variable);
1080    }//GEN-LAST:event_jButtonModifyVariableActionPerformed
1081

1082    private void jButtonNewVariableActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonNewVariableActionPerformed
1083
newVariable();
1084    }//GEN-LAST:event_jButtonNewVariableActionPerformed
1085

1086    private void jButtonModifyFieldActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonModifyFieldActionPerformed
1087
JRField field = (JRField) jTableFields.getValueAt(jTableFields.getSelectedRow(), 0);
1088                                                          
1089        modifyField(field);
1090    }//GEN-LAST:event_jButtonModifyFieldActionPerformed
1091

1092    private void jButtonNewFieldActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonNewFieldActionPerformed
1093

1094        newField();
1095    }//GEN-LAST:event_jButtonNewFieldActionPerformed
1096

1097    
1098    
1099    // Variables declaration - do not modify//GEN-BEGIN:variables
1100
private javax.swing.JButton JavaDoc jButtonDeleteField;
1101    private javax.swing.JButton JavaDoc jButtonDeleteParameter;
1102    private javax.swing.JButton JavaDoc jButtonDeleteVariable;
1103    private javax.swing.JButton JavaDoc jButtonModifyField;
1104    private javax.swing.JButton JavaDoc jButtonModifyParameter;
1105    private javax.swing.JButton JavaDoc jButtonModifyVariable;
1106    private javax.swing.JButton JavaDoc jButtonNewField;
1107    private javax.swing.JButton JavaDoc jButtonNewParameter;
1108    private javax.swing.JButton JavaDoc jButtonNewVariable;
1109    private javax.swing.JMenuItem JavaDoc jMenuItemCopy;
1110    private javax.swing.JMenuItem JavaDoc jMenuItemCopy1;
1111    private javax.swing.JMenuItem JavaDoc jMenuItemCopy2;
1112    private javax.swing.JMenuItem JavaDoc jMenuItemCut;
1113    private javax.swing.JMenuItem JavaDoc jMenuItemCut1;
1114    private javax.swing.JMenuItem JavaDoc jMenuItemCut2;
1115    private javax.swing.JMenuItem JavaDoc jMenuItemDelete;
1116    private javax.swing.JMenuItem JavaDoc jMenuItemDelete1;
1117    private javax.swing.JMenuItem JavaDoc jMenuItemDelete2;
1118    private javax.swing.JMenuItem JavaDoc jMenuItemDuplicate;
1119    private javax.swing.JMenuItem JavaDoc jMenuItemDuplicate1;
1120    private javax.swing.JMenuItem JavaDoc jMenuItemDuplicate2;
1121    private javax.swing.JMenuItem JavaDoc jMenuItemPaste;
1122    private javax.swing.JMenuItem JavaDoc jMenuItemPaste1;
1123    private javax.swing.JMenuItem JavaDoc jMenuItemPaste2;
1124    private javax.swing.JPanel JavaDoc jPanelButtons;
1125    private javax.swing.JPanel JavaDoc jPanelButtons1;
1126    private javax.swing.JPanel JavaDoc jPanelButtons2;
1127    private javax.swing.JPanel JavaDoc jPanelFields;
1128    private javax.swing.JPanel JavaDoc jPanelParameters;
1129    private javax.swing.JPanel JavaDoc jPanelVariables;
1130    private javax.swing.JPopupMenu JavaDoc jPopupMenuFields;
1131    private javax.swing.JPopupMenu JavaDoc jPopupMenuParameters;
1132    private javax.swing.JPopupMenu JavaDoc jPopupMenuVariables;
1133    private javax.swing.JScrollPane JavaDoc jScrollPane1;
1134    private javax.swing.JScrollPane JavaDoc jScrollPane2;
1135    private javax.swing.JScrollPane JavaDoc jScrollPane3;
1136    private javax.swing.JTabbedPane JavaDoc jTabbedPane;
1137    private it.businesslogic.ireport.gui.JDragTable jTableFields;
1138    private it.businesslogic.ireport.gui.JDragTable jTableParameters;
1139    private it.businesslogic.ireport.gui.JDragTable jTableVariables;
1140    // End of variables declaration//GEN-END:variables
1141

1142    
1143    /**
1144     * DOCUMENT ME!
1145     */

1146    public void updateFields()
1147    {
1148
1149        DefaultTableModel JavaDoc dtm = (DefaultTableModel JavaDoc) jTableFields.getModel();
1150        dtm.setRowCount(0);
1151        
1152        if (getSubDataset() == null) return;
1153
1154        Enumeration JavaDoc e = sortFieldsByName(getSubDataset().getFields()).elements();
1155
1156        while (e.hasMoreElements())
1157        {
1158
1159            it.businesslogic.ireport.JRField field = (it.businesslogic.ireport.JRField) e.nextElement();
1160            Vector JavaDoc row = new Vector JavaDoc();
1161            row.addElement(field);
1162            row.addElement(field.getClassType());
1163
1164            dtm.addRow(row);
1165        }
1166
1167    }
1168
1169    /**
1170     * DOCUMENT ME!
1171     */

1172    public void updateVariables()
1173    {
1174
1175        DefaultTableModel JavaDoc dtm = (DefaultTableModel JavaDoc) jTableVariables.getModel();
1176        dtm.setRowCount(0);
1177        
1178        if (getSubDataset() == null) return;
1179
1180        Enumeration JavaDoc e = sortVariablesByName(getSubDataset().getVariables())
1181            .elements();
1182
1183        while (e.hasMoreElements())
1184        {
1185
1186            it.businesslogic.ireport.JRVariable variable = (it.businesslogic.ireport.JRVariable) e.nextElement();
1187            Vector JavaDoc row = new Vector JavaDoc();
1188            row.addElement(variable);
1189            row.addElement((variable.isBuiltin()
1190                                ? "yes"
1191                                : "no"));
1192
1193            dtm.addRow(row);
1194        }
1195    }
1196
1197    /**
1198     * DOCUMENT ME!
1199     */

1200    public void updateParameters()
1201    {
1202
1203        DefaultTableModel JavaDoc dtm = (DefaultTableModel JavaDoc) jTableParameters.getModel();
1204        dtm.setRowCount(0);
1205        
1206        if (getSubDataset() == null) return;
1207
1208        //Enumeration e = sortParametersByName( getSubDataset().getParameters().elements() );
1209
Enumeration JavaDoc e = sortParametersByName(getSubDataset().getParameters()).elements();
1210
1211        while (e.hasMoreElements())
1212        {
1213
1214            it.businesslogic.ireport.JRParameter parameter =
1215                    (it.businesslogic.ireport.JRParameter) e.nextElement();
1216            Vector JavaDoc row = new Vector JavaDoc();
1217            row.addElement(parameter);
1218            row.addElement(parameter.getClassType());
1219            row.addElement(
1220                    (parameter.isIsForPrompting()
1221                         ? "yes"
1222                         : "no"));
1223            row.addElement((parameter.isBuiltin()
1224                                ? "yes"
1225                                : "no"));
1226
1227            dtm.addRow(row);
1228        }
1229    }
1230
1231    /**
1232     * DOCUMENT ME!
1233     */

1234    public void applyI18n()
1235    {
1236                // Start autogenerated code ----------------------
1237
// End autogenerated code ----------------------
1238
// Start autogenerated code ----------------------
1239
// End autogenerated code ----------------------
1240
jButtonNewField.setText(it.businesslogic.ireport.util.I18n.getString(
1241                                        "new", "New"));
1242        jButtonModifyField.setText(it.businesslogic.ireport.util.I18n.getString(
1243                                           "modify", "Modify"));
1244        jButtonDeleteField.setText(it.businesslogic.ireport.util.I18n.getString(
1245                                           "delete", "Delete"));
1246        jButtonNewVariable.setText(it.businesslogic.ireport.util.I18n.getString(
1247                                           "new", "New"));
1248        jButtonModifyVariable.setText(it.businesslogic.ireport.util.I18n.getString(
1249                                              "modify", "Modify"));
1250        jButtonDeleteVariable.setText(it.businesslogic.ireport.util.I18n.getString(
1251                                              "delete", "Delete"));
1252        jButtonNewParameter.setText(it.businesslogic.ireport.util.I18n.getString(
1253                                            "new", "New"));
1254        jButtonModifyParameter.setText(it.businesslogic.ireport.util.I18n.getString(
1255                                               "modify", "Modify"));
1256        jButtonDeleteParameter.setText(it.businesslogic.ireport.util.I18n.getString(
1257                                               "delete", "Delete"));
1258
1259        jMenuItemCut.setText(it.businesslogic.ireport.util.I18n.getString(
1260                                     "cut", "Cut"));
1261        jMenuItemCopy.setText(it.businesslogic.ireport.util.I18n.getString(
1262                                      "copy", "Copy"));
1263        jMenuItemPaste.setText(it.businesslogic.ireport.util.I18n.getString(
1264                                       "paste", "Paste"));
1265        jMenuItemDelete.setText(it.businesslogic.ireport.util.I18n.getString(
1266                                        "delete", "Delete"));
1267        jMenuItemDuplicate.setText(it.businesslogic.ireport.util.I18n.getString(
1268                                           "duplicate", "Duplicate"));
1269
1270        jMenuItemCut1.setText(it.businesslogic.ireport.util.I18n.getString(
1271                                      "cut", "Cut"));
1272        jMenuItemCopy1.setText(it.businesslogic.ireport.util.I18n.getString(
1273                                       "copy", "Copy"));
1274        jMenuItemPaste1.setText(it.businesslogic.ireport.util.I18n.getString(
1275                                        "paste", "Paste"));
1276        jMenuItemDelete1.setText(it.businesslogic.ireport.util.I18n.getString(
1277                                         "delete", "Delete"));
1278        jMenuItemDuplicate1.setText(it.businesslogic.ireport.util.I18n.getString(
1279                                            "duplicate", "Duplicate"));
1280
1281        jMenuItemCut2.setText(it.businesslogic.ireport.util.I18n.getString(
1282                                      "cut", "Cut"));
1283        jMenuItemCopy2.setText(it.businesslogic.ireport.util.I18n.getString(
1284                                       "copy", "Copy"));
1285        jMenuItemPaste2.setText(it.businesslogic.ireport.util.I18n.getString(
1286                                        "paste", "Paste"));
1287        jMenuItemDelete2.setText(it.businesslogic.ireport.util.I18n.getString(
1288                                         "delete", "Delete"));
1289        jMenuItemDuplicate2.setText(it.businesslogic.ireport.util.I18n.getString(
1290                                            "duplicate", "Duplicate"));
1291        
1292        
1293        jTableFields.getColumnModel().getColumn(0).setHeaderValue( I18n.getString("valuesPanel.tableFields.fieldName","Field name") );
1294        jTableFields.getColumnModel().getColumn(1).setHeaderValue( I18n.getString("valuesPanel.tableFields.classType","Class type") );
1295        
1296        jTableVariables.getColumnModel().getColumn(0).setHeaderValue( I18n.getString("valuesPanel.tableVariables.variableName","Variable name") );
1297        jTableVariables.getColumnModel().getColumn(1).setHeaderValue( I18n.getString("valuesPanel.tableVariables.builtin","Builtin") );
1298        
1299        jTableParameters.getColumnModel().getColumn(0).setHeaderValue( I18n.getString("valuesPanel.tableParameters.parameterName","Parameter name") );
1300        jTableParameters.getColumnModel().getColumn(1).setHeaderValue( I18n.getString("valuesPanel.tableParameters.classType","Class type") );
1301        jTableParameters.getColumnModel().getColumn(2).setHeaderValue( I18n.getString("valuesPanel.tableParameters.isForPrompting","Is for prompting") );
1302        jTableParameters.getColumnModel().getColumn(3).setHeaderValue( I18n.getString("valuesPanel.tableParameters.builtin","Builtin") );
1303        
1304        jTabbedPane.setTitleAt(0,I18n.getString("valuesPanel.tab.Fields", "Fields"));
1305        jTabbedPane.setTitleAt(1,I18n.getString("valuesPanel.tab.Variables", "Variables"));
1306        jTabbedPane.setTitleAt(2,I18n.getString("valuesPanel.tab.Parameters", "Parameters"));
1307    }
1308
1309    /**
1310     * DOCUMENT ME!
1311     *
1312     * @param evt DOCUMENT ME!
1313     */

1314    public void languageChanged(LanguageChangedEvent evt)
1315    {
1316        this.applyI18n();
1317    }
1318    
1319        private Vector JavaDoc sortFieldsByName(Vector JavaDoc vector)
1320    {
1321
1322        Vector JavaDoc myElements = new Vector JavaDoc();
1323        boolean inserted;
1324
1325        Enumeration JavaDoc enum2 = vector.elements();
1326
1327        while (enum2.hasMoreElements())
1328        {
1329
1330            JRField elem = (JRField) enum2.nextElement();
1331
1332            // insert this element in the right position...
1333
if (myElements.size() == 0)
1334            {
1335                myElements.add(elem);
1336            }
1337            else
1338            {
1339                inserted = false;
1340
1341                for (int i = 0; i < myElements.size(); ++i)
1342                {
1343
1344                    JRField elem2 = (JRField) myElements.elementAt(i);
1345
1346                    if (elem.getName().compareTo(elem2.getName()) < 0)
1347                    {
1348                        myElements.insertElementAt(elem, i);
1349                        inserted = true;
1350
1351                        break;
1352                    }
1353
1354                }
1355
1356                if (!inserted)
1357                {
1358                    myElements.addElement(elem);
1359                }
1360            }
1361        }
1362
1363        return myElements;
1364    }
1365
1366    private Vector JavaDoc sortVariablesByName(Vector JavaDoc vector)
1367    {
1368
1369        Vector JavaDoc myElements = new Vector JavaDoc();
1370        boolean inserted;
1371        JRVariable elem2;
1372
1373        Enumeration JavaDoc enum2 = vector.elements();
1374
1375        while (enum2.hasMoreElements())
1376        {
1377
1378            JRVariable elem = (JRVariable) enum2.nextElement();
1379
1380            // insert this element in the right position...
1381
if (myElements.size() == 0)
1382            {
1383                myElements.add(elem);
1384            }
1385            else
1386            {
1387                inserted = false;
1388
1389                for (int i = 0; i < myElements.size(); ++i)
1390                {
1391                    elem2 = (JRVariable) myElements.elementAt(i);
1392
1393                    // list builtin parameters first and then the others
1394
if (elem.isBuiltin())
1395                    {
1396
1397                        if (elem.isBuiltin() == elem2.isBuiltin())
1398                        {
1399
1400                            if (elem.getName().compareTo(elem2.getName()) < 0)
1401                            {
1402                                myElements.insertElementAt(elem, i);
1403                                inserted = true;
1404
1405                                break;
1406                            }
1407
1408                        }
1409
1410                    }
1411                    else
1412                    {
1413
1414                        if (elem.isBuiltin() == elem2.isBuiltin())
1415                        {
1416
1417                            if (elem.getName().compareTo(elem2.getName()) < 0)
1418                            {
1419                                myElements.insertElementAt(elem, i);
1420                                inserted = true;
1421
1422                                break;
1423                            }
1424
1425                        }
1426
1427                    }
1428                }
1429
1430                if (!inserted)
1431                {
1432                    myElements.addElement(elem);
1433                }
1434
1435            }
1436        }
1437
1438        return myElements;
1439    }
1440
1441    private Vector JavaDoc sortParametersByName(Vector JavaDoc vector)
1442    {
1443
1444        Vector JavaDoc myElements = new Vector JavaDoc();
1445        boolean inserted;
1446        JRParameter elem2;
1447        Enumeration JavaDoc enum2 = vector.elements();
1448
1449        while (enum2.hasMoreElements())
1450        {
1451
1452            JRParameter elem = (JRParameter) enum2.nextElement();
1453
1454            // insert this element in the right position...
1455
if (myElements.size() == 0)
1456            {
1457                myElements.add(elem);
1458            }
1459            else
1460            {
1461                inserted = false;
1462
1463                for (int i = 0; i < myElements.size(); ++i)
1464                {
1465                    elem2 = (JRParameter) myElements.elementAt(i);
1466
1467                    // list builtin parameters first and then the others
1468
if (elem.isBuiltin())
1469                    {
1470
1471                        if (elem.isBuiltin() == elem2.isBuiltin())
1472                        {
1473
1474                            if (elem.getName().compareTo(elem2.getName()) < 0)
1475                            {
1476                                myElements.insertElementAt(elem, i);
1477                                inserted = true;
1478
1479                                break;
1480                            }
1481
1482                        }
1483
1484                    }
1485                    else
1486                    {
1487
1488                        if (elem.isBuiltin() == elem2.isBuiltin())
1489                        {
1490
1491                            if (elem.getName().compareTo(elem2.getName()) < 0)
1492                            {
1493                                myElements.insertElementAt(elem, i);
1494                                inserted = true;
1495
1496                                break;
1497                            }
1498
1499                        }
1500
1501                    }
1502                }
1503
1504                if (!inserted)
1505                {
1506                    myElements.addElement(elem);
1507                }
1508            }
1509        }
1510
1511        return myElements;
1512    }
1513    
1514    
1515    
1516    
1517        /**
1518     * DOCUMENT ME!
1519     *
1520     * @param p DOCUMENT ME!
1521     */

1522    public void modifyErrorParameter(it.businesslogic.ireport.JRParameter p)
1523    {
1524
1525        // 1. Switch to parameters panel.
1526
this.jTabbedPane.setSelectedComponent(jPanelParameters);
1527
1528        // 2. Fine the parameter and select it
1529
DefaultTableModel JavaDoc dtm = (DefaultTableModel JavaDoc) jTableParameters.getModel();
1530
1531        for (int i = 0; i < dtm.getRowCount(); ++i)
1532        {
1533
1534            if (dtm.getValueAt(i, 0) == p)
1535            {
1536                jTableParameters.setRowSelectionInterval(i, i);
1537                this.jButtonModifyParameterActionPerformed(new java.awt.event.ActionEvent JavaDoc(
1538                                                                   jButtonModifyParameter,
1539                                                                   0,
1540                                                                   jButtonModifyParameter.getName()));
1541
1542                return;
1543            }
1544        }
1545    }
1546
1547    /**
1548     * DOCUMENT ME!
1549     *
1550     * @param tab DOCUMENT ME!
1551     */

1552    public void gotoTab(String JavaDoc tab)
1553    {
1554
1555        if (tab.equals("Parameters"))
1556        {
1557            this.jTabbedPane.setSelectedIndex(2);
1558        }
1559        else if (tab.equals("Fields"))
1560        {
1561            this.jTabbedPane.setSelectedIndex(0);
1562        }
1563        else if (tab.equals("Variables"))
1564        {
1565            this.jTabbedPane.setSelectedIndex(1);
1566        }
1567    }
1568
1569    /**
1570     * DOCUMENT ME!
1571     *
1572     * @return DOCUMENT ME!
1573     */

1574    public Vector JavaDoc getClipboardFields()
1575    {
1576
1577        return clipboardFields;
1578    }
1579
1580    /**
1581     * DOCUMENT ME!
1582     *
1583     * @param clipboardFields DOCUMENT ME!
1584     */

1585    public void setClipboardFields(Vector JavaDoc clipboardFields)
1586    {
1587        this.clipboardFields = clipboardFields;
1588    }
1589
1590    /**
1591     * DOCUMENT ME!
1592     *
1593     * @return DOCUMENT ME!
1594     */

1595    public Vector JavaDoc getClipboardVariables()
1596    {
1597
1598        return clipboardVariables;
1599    }
1600
1601    /**
1602     * DOCUMENT ME!
1603     *
1604     * @param clipboardVariables DOCUMENT ME!
1605     */

1606    public void setClipboardVariables(Vector JavaDoc clipboardVariables)
1607    {
1608        this.clipboardVariables = clipboardVariables;
1609    }
1610
1611    /**
1612     * DOCUMENT ME!
1613     *
1614     * @return DOCUMENT ME!
1615     */

1616    public Vector JavaDoc getClipboardParameters()
1617    {
1618
1619        return clipboardParameters;
1620    }
1621
1622    /**
1623     * DOCUMENT ME!
1624     *
1625     * @param clipboardParameters DOCUMENT ME!
1626     */

1627    public void setClipboardParameters(Vector JavaDoc clipboardParameters)
1628    {
1629        this.clipboardParameters = clipboardParameters;
1630    }
1631
1632    /**
1633     * DOCUMENT ME!
1634     *
1635     * @param fieldsToDuplicate DOCUMENT ME!
1636     */

1637    public void duplicateFields(Vector JavaDoc fieldsToDuplicate)
1638    {
1639         duplicateFields(fieldsToDuplicate, getSubDataset());
1640    }
1641     
1642    public void duplicateFields(Vector JavaDoc fieldsToDuplicate, SubDataset dataset)
1643    {
1644
1645        for (int i = 0; i < fieldsToDuplicate.size(); ++i)
1646        {
1647
1648            JRField field = ((JRField) fieldsToDuplicate.elementAt(i)).cloneMe();
1649            String JavaDoc base_name = field.getName();
1650            Vector JavaDoc fields = dataset.getFields();
1651
1652            for (int j = 0;; ++j)
1653            {
1654
1655                boolean found = false;
1656
1657                for (int k = 0; k < fields.size(); ++k)
1658                {
1659
1660                    JRField field1 = (JRField) fields.elementAt(k);
1661
1662                    if (j == 0)
1663                    {
1664
1665                        if (field1.getName().equals(base_name))
1666                        {
1667                            found = true;
1668
1669                            break;
1670                        }
1671                    }
1672                    else
1673                    {
1674
1675                        if (field1.getName().equals(base_name + "_" + j))
1676                        {
1677                            found = true;
1678
1679                            break;
1680                        }
1681                    }
1682                }
1683
1684                if (!found)
1685                {
1686                    field.setName(base_name +
1687                                  ((j == 0)
1688                                       ? ""
1689                                       : "_" + j));
1690
1691                    break;
1692                }
1693            }
1694
1695            dataset.addField(field);
1696        }
1697    }
1698
1699    /**
1700     * DOCUMENT ME!
1701     *
1702     * @param variablesToDuplicate DOCUMENT ME!
1703     */

1704    public void duplicateVariables(Vector JavaDoc variablesToDuplicate)
1705    {
1706        duplicateVariables(variablesToDuplicate, getSubDataset() );
1707    }
1708    
1709    public void duplicateVariables(Vector JavaDoc variablesToDuplicate, SubDataset dataset)
1710    {
1711
1712        for (int i = 0; i < variablesToDuplicate.size(); ++i)
1713        {
1714
1715            JRVariable variable = ((JRVariable) variablesToDuplicate.elementAt(
1716                                           i)).cloneMe();
1717            String JavaDoc base_name = variable.getName();
1718            Vector JavaDoc variables = dataset.getVariables();
1719
1720            for (int j = 0;; ++j)
1721            {
1722
1723                boolean found = false;
1724
1725                for (int k = 0; k < variables.size(); ++k)
1726                {
1727
1728                    JRVariable variable1 = (JRVariable) variables.elementAt(k);
1729
1730                    if (j == 0)
1731                    {
1732
1733                        if (variable1.getName().equals(base_name))
1734                        {
1735                            found = true;
1736
1737                            break;
1738                        }
1739                    }
1740                    else
1741                    {
1742
1743                        if (variable1.getName().equals(base_name + "_" + j))
1744                        {
1745                            found = true;
1746
1747                            break;
1748                        }
1749                    }
1750                }
1751
1752                if (!found)
1753                {
1754                    variable.setName(base_name +
1755                                     ((j == 0)
1756                                          ? ""
1757                                          : "_" + j));
1758
1759                    break;
1760                }
1761            }
1762
1763            if (variable.isBuiltin())
1764            {
1765                JOptionPane.showMessageDialog(this,
1766                        I18n.getString( "messages.valuesPanel.duplicatingBuiltinVariable","It's not possible duplicate built-in variables!"));
1767            }
1768            else
1769            {
1770                dataset.addVariable(variable);
1771            }
1772        }
1773    }
1774
1775    /**
1776     * DOCUMENT ME!
1777     *
1778     * @param parametersToDuplicate DOCUMENT ME!
1779     */

1780    public void duplicateParameters(Vector JavaDoc parametersToDuplicate)
1781    {
1782         duplicateParameters(parametersToDuplicate, getSubDataset());
1783    }
1784     
1785    public void duplicateParameters(Vector JavaDoc parametersToDuplicate, SubDataset dataset)
1786    {
1787
1788        boolean msg_disp = false;
1789
1790        for (int i = 0; i < parametersToDuplicate.size(); ++i)
1791        {
1792
1793            JRParameter parameter = ((JRParameter) parametersToDuplicate.elementAt(
1794                                             i)).cloneMe();
1795            String JavaDoc base_name = parameter.getName();
1796            Vector JavaDoc parameters = dataset.getParameters();
1797
1798            for (int j = 0;; ++j)
1799            {
1800
1801                boolean found = false;
1802
1803                for (int k = 0; k < parameters.size(); ++k)
1804                {
1805
1806                    JRParameter parameter1 = (JRParameter) parameters.elementAt(
1807                                                     k);
1808
1809                    if (j == 0)
1810                    {
1811
1812                        if (parameter1.getName().equals(base_name))
1813                        {
1814                            found = true;
1815
1816                            break;
1817                        }
1818                    }
1819                    else
1820                    {
1821
1822                        if (parameter1.getName().equals(base_name + "_" + j))
1823                        {
1824                            found = true;
1825
1826                            break;
1827                        }
1828                    }
1829                }
1830
1831                if (!found)
1832                {
1833                    parameter.setName(base_name +
1834                                      ((j == 0)
1835                                           ? ""
1836                                           : "_" + j));
1837
1838                    break;
1839                }
1840            }
1841
1842            if (parameter.isBuiltin())
1843            {
1844
1845                if (!msg_disp)
1846                {
1847                    JOptionPane.showMessageDialog(this,
1848                            I18n.getString( "messages.valuesPanel.duplicatingBuiltinParameters","It's not possible duplicate built-in parameters!"));
1849                                                  
1850                    msg_disp = true;
1851                }
1852            }
1853            else
1854            {
1855                dataset.addParameter(parameter);
1856            }
1857        }
1858    }
1859    
1860        /**
1861     * DOCUMENT ME!
1862     *
1863     * @param field DOCUMENT ME!
1864     */

1865    public void modifyField(JRField field)
1866    {
1867        java.awt.Frame JavaDoc parent = Misc.frameFromComponent(this);
1868        JRFieldDialog jrpd = new JRFieldDialog(parent, true);
1869        jrpd.setSubDataset( this.getSubDataset() );
1870        jrpd.setField(field);
1871        jrpd.setVisible(true);
1872
1873        if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION)
1874        {
1875            JRField oldFile = field.cloneMe();
1876            field.setName(jrpd.getField().getName());
1877            field.setClassType(jrpd.getField().getClassType());
1878
1879            field.setDescription(jrpd.getField().getDescription());
1880
1881            getSubDataset().fireSubDatasetObjectChangedListenerSubDatasetObjectChanged(new it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent(getSubDataset(),
1882                                                                                                                                       it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.FIELD,
1883                                                                                                                                       it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.MODIFIED,
1884                                                                                                                                       oldFile,
1885                                                                                                                                       field));
1886        }
1887    }
1888    
1889        /**
1890     * DOCUMENT ME!
1891     */

1892    public void newField()
1893    {
1894        newField(getSubDataset());
1895    }
1896    
1897    
1898    public void newField(SubDataset sd)
1899    {
1900
1901        java.awt.Frame JavaDoc parent = Misc.frameFromComponent(this);
1902        JRFieldDialog jrpd = new JRFieldDialog(parent, true);
1903        jrpd.setSubDataset( this.getSubDataset() );
1904        jrpd.setVisible(true);
1905
1906        if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION)
1907        {
1908
1909            JRField field = jrpd.getField();
1910            sd.addField(field);
1911        }
1912    }
1913    
1914    
1915        /**
1916     * DOCUMENT ME!
1917     *
1918     * @param variable DOCUMENT ME!
1919     */

1920    public void modifyVariable(JRVariable variable)
1921    {
1922
1923        if (variable.isBuiltin())
1924        {
1925            javax.swing.JOptionPane.showMessageDialog(this,
1926                    I18n.getString( "messages.valuesPanel.cantModifyBuiltInVariables","You can't modify or delete builtin variables!"),
1927                    I18n.getString( "messages.valuesPanel.cantModifyBuiltInVariablesCaption","Invalid operation!"),
1928                    javax.swing.JOptionPane.WARNING_MESSAGE);
1929
1930            return;
1931        }
1932
1933        java.awt.Frame JavaDoc parent = Misc.frameFromComponent(this);
1934        JRVariableDialog jrpd = new JRVariableDialog(getSubDataset(), parent, true);
1935        jrpd.setVariable(variable);
1936        jrpd.setVisible(true);
1937
1938        if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION)
1939        {
1940            JRVariable oldVar = variable.cloneMe();
1941            getSubDataset().getKeywordLookup().removeKeyword(
1942                    "$V{" + variable.getName() + "}");
1943            variable.setName(jrpd.getVariable().getName());
1944            getSubDataset().getKeywordLookup().addKeyword(
1945                    "$V{" + variable.getName() + "}");
1946            variable.setClassType(jrpd.getVariable().getClassType());
1947            variable.setCalculation(jrpd.getVariable().getCalculation());
1948            variable.setResetType(jrpd.getVariable().getResetType());
1949            variable.setResetGroup(jrpd.getVariable().getResetGroup());
1950            variable.setExpression(jrpd.getVariable().getExpression());
1951            variable.setInitialValueExpression(jrpd.getVariable().getInitialValueExpression());
1952            variable.setIncrementerFactoryClass(jrpd.getVariable().getIncrementerFactoryClass());
1953            variable.setIncrementType(jrpd.getVariable().getIncrementType());
1954            variable.setIncrementGroup(jrpd.getVariable().getIncrementGroup());
1955
1956            getSubDataset().fireSubDatasetObjectChangedListenerSubDatasetObjectChanged(new it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent(getSubDataset(),
1957                                                                                                                                                           it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.VARIABLE,
1958                                                                                                                                                           it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.MODIFIED,
1959                                                                                                                                                           oldVar,
1960                                                                                                                                                           variable));
1961        }
1962    }
1963
1964    
1965    /**
1966     * DOCUMENT ME!
1967     */

1968    public void newVariable()
1969    {
1970        newVariable(getSubDataset());
1971    }
1972    
1973    
1974    public void newVariable(SubDataset sd)
1975    {
1976        java.awt.Frame JavaDoc parent = Misc.frameFromComponent(this);
1977        JRVariableDialog jrpd = new JRVariableDialog(sd, parent, true);
1978        jrpd.setVisible(true);
1979
1980        if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION)
1981        {
1982
1983            JRVariable variable = jrpd.getVariable();
1984            sd.addVariable(variable);
1985        }
1986    }
1987    
1988    
1989    /**
1990     * DOCUMENT ME!
1991     *
1992     * @param parameter DOCUMENT ME!
1993     */

1994    public void modifyParameter(JRParameter parameter)
1995    {
1996
1997        if (parameter.isBuiltin())
1998        {
1999            javax.swing.JOptionPane.showMessageDialog(this,
2000                    I18n.getString( "messages.valuesPanel.cantModifyBuiltInParameters","You can't modify or delete builtin parameters!"),
2001                    I18n.getString( "messages.valuesPanel.cantModifyBuiltInParametersCaption","Invalid operation!"),
2002                    javax.swing.JOptionPane.WARNING_MESSAGE);
2003
2004            return;
2005        }
2006
2007        java.awt.Frame JavaDoc parent = Misc.frameFromComponent(this);
2008        JRParameterDialog jrpd = new JRParameterDialog(parent, true);
2009        jrpd.setSubDataset( this.getSubDataset() );
2010        jrpd.setParameter(parameter);
2011
2012        jrpd.setVisible(true);
2013
2014        if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION)
2015        {
2016            JRParameter oldParam = parameter.cloneMe();
2017            getSubDataset().getKeywordLookup().removeKeyword(
2018                    "$P{" + parameter.getName() + "}");
2019            parameter.setName(jrpd.getParameter().getName());
2020            getSubDataset().getKeywordLookup().addKeyword(
2021                    "$P{" + parameter.getName() + "}");
2022            parameter.setClassType(jrpd.getParameter().getClassType());
2023            parameter.setDescription(jrpd.getParameter().getDescription());
2024            parameter.setDefaultValueExpression(jrpd.getParameter().getDefaultValueExpression());
2025            parameter.setIsForPrompting(jrpd.getParameter().isIsForPrompting());
2026
2027            getSubDataset().fireSubDatasetObjectChangedListenerSubDatasetObjectChanged(new it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent(getSubDataset(),
2028                                                                                       it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.PARAMETER,
2029                                                                                       it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent.MODIFIED,
2030                                                                                       oldParam,
2031                                                                                       parameter));
2032        }
2033    }
2034    
2035    /**
2036     * DOCUMENT ME!
2037     */

2038    public void newParameter()
2039    {
2040        newParameter(getSubDataset());
2041    }
2042    
2043    
2044    public void newParameter(SubDataset sd)
2045    {
2046
2047        java.awt.Frame JavaDoc parent = Misc.frameFromComponent(this);
2048        JRParameterDialog jrpd = new JRParameterDialog(parent, true);
2049        jrpd.setSubDataset( this.getSubDataset() );
2050        jrpd.setVisible(true);
2051
2052        if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION)
2053        {
2054
2055            JRParameter parameter = jrpd.getParameter();
2056            sd.addParameter(parameter);
2057        }
2058    }
2059    
2060    
2061}
2062
Popular Tags