Source Code Cross Referenced for SubDatasetsDialog.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » gui » subdataset » 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.subdataset 
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:         * SubDatasetsDialog.java
028:         * 
029:         * Created on 7 maggio 2003, 23.43
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.gui.subdataset;
034:
035:        import javax.swing.table.*;
036:        import javax.swing.*;
037:        import javax.swing.event.*;
038:        import it.businesslogic.ireport.*;
039:        import it.businesslogic.ireport.gui.ConnectionDialog;
040:        import it.businesslogic.ireport.gui.MainFrame;
041:        import it.businesslogic.ireport.gui.ValuesDialog;
042:        import it.businesslogic.ireport.util.Misc;
043:        import it.businesslogic.ireport.gui.event.ReportSubDatasetChangedEvent;
044:
045:        import java.util.*;
046:        import it.businesslogic.ireport.util.I18n;
047:
048:        /**
049:         *
050:         * @author  Administrator
051:         */
052:        public class SubDatasetsDialog extends javax.swing.JDialog {
053:
054:            /** Creates new form ValuesDialog */
055:            public SubDatasetsDialog(java.awt.Frame parent, boolean modal) {
056:                super (parent, modal);
057:                initComponents();
058:                applyI18n();
059:                this .setSize(490, 250);
060:                //DefaultTableColumnModel dtcm = (DefaultTableColumnModel)jTableParameters.getColumnModel();
061:                //DefaultTableCellRenderer tcr = (DefaultTableCellRenderer)dtcm.getColumn(0).getHeaderRenderer();
062:
063:                //new DefaultTableCellRenderer();
064:                //tcr.setFont(jTableParameters.getFont());
065:                //tcr.setBackground(this.getBackground());
066:                //tcr.setBorder( new javax.swing.border.BevelBorder( javax.swing.border.BevelBorder.RAISED));
067:                //dtcm.getColumn(0).setHeaderRenderer(tcr);
068:
069:                DefaultListSelectionModel dlsm = (DefaultListSelectionModel) this .jTableParameters
070:                        .getSelectionModel();
071:                dlsm
072:                        .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
073:                            public void valueChanged(ListSelectionEvent e) {
074:                                jTableParametersListSelectionValueChanged(e);
075:                            }
076:                        });
077:
078:                // Open in center...
079:                it.businesslogic.ireport.util.Misc.centerFrame(this );
080:
081:                DefaultTableModel dtm = (DefaultTableModel) jTableParameters
082:                        .getModel();
083:
084:                Enumeration e = it.businesslogic.ireport.gui.MainFrame
085:                        .getMainInstance().getActiveReportFrame().getReport()
086:                        .getSubDatasets().elements();
087:                while (e.hasMoreElements()) {
088:                    SubDataset dataset = (SubDataset) e.nextElement();
089:                    dtm.addRow(new Object[] { dataset });
090:                }
091:
092:                javax.swing.KeyStroke escape = javax.swing.KeyStroke
093:                        .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
094:                                false);
095:                javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
096:                    public void actionPerformed(java.awt.event.ActionEvent e) {
097:                        setVisible(false);
098:                    }
099:                };
100:
101:                getRootPane().getInputMap(
102:                        javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
103:                        escape, "ESCAPE");
104:                getRootPane().getActionMap().put("ESCAPE", escapeAction);
105:
106:            }
107:
108:            public void jTableParametersListSelectionValueChanged(
109:                    javax.swing.event.ListSelectionEvent e) {
110:                if (this .jTableParameters.getSelectedRowCount() > 0) {
111:                    this .jButtonModify.setEnabled(true);
112:                    this .jButtonDelete.setEnabled(true);
113:                } else {
114:                    this .jButtonModify.setEnabled(false);
115:                    this .jButtonDelete.setEnabled(false);
116:                }
117:            }
118:
119:            /** This method is called from within the constructor to
120:             * initialize the form.
121:             * WARNING: Do NOT modify this code. The content of this method is
122:             * always regenerated by the Form Editor.
123:             */
124:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
125:            private void initComponents() {
126:                java.awt.GridBagConstraints gridBagConstraints;
127:
128:                jPanelParameters = new javax.swing.JPanel();
129:                jScrollPane1 = new javax.swing.JScrollPane();
130:                jTableParameters = new javax.swing.JTable();
131:                jPanelButtons = new javax.swing.JPanel();
132:                jButtonNew = new javax.swing.JButton();
133:                jButtonModify = new javax.swing.JButton();
134:                jButtonDelete = new javax.swing.JButton();
135:
136:                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
137:                setTitle("SubDatasets");
138:                addWindowListener(new java.awt.event.WindowAdapter() {
139:                    public void windowClosing(java.awt.event.WindowEvent evt) {
140:                        closeDialog(evt);
141:                    }
142:                });
143:
144:                jPanelParameters.setLayout(new java.awt.BorderLayout(2, 2));
145:
146:                jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
147:                jTableParameters
148:                        .setModel(new javax.swing.table.DefaultTableModel(
149:                                new Object[][] {
150:
151:                                }, new String[] { "Name" }) {
152:                            boolean[] canEdit = new boolean[] { false };
153:
154:                            public boolean isCellEditable(int rowIndex,
155:                                    int columnIndex) {
156:                                return canEdit[columnIndex];
157:                            }
158:                        });
159:                jTableParameters
160:                        .addMouseListener(new java.awt.event.MouseAdapter() {
161:                            public void mouseClicked(
162:                                    java.awt.event.MouseEvent evt) {
163:                                jTableParametersMouseClicked(evt);
164:                            }
165:                        });
166:
167:                jScrollPane1.setViewportView(jTableParameters);
168:
169:                jPanelParameters
170:                        .add(jScrollPane1, java.awt.BorderLayout.CENTER);
171:
172:                jPanelButtons.setLayout(new java.awt.GridBagLayout());
173:
174:                jPanelButtons.setMinimumSize(new java.awt.Dimension(100, 10));
175:                jPanelButtons.setPreferredSize(new java.awt.Dimension(100, 10));
176:                jButtonNew.setText("New");
177:                jButtonNew
178:                        .addActionListener(new java.awt.event.ActionListener() {
179:                            public void actionPerformed(
180:                                    java.awt.event.ActionEvent evt) {
181:                                jButtonNewActionPerformed(evt);
182:                            }
183:                        });
184:
185:                gridBagConstraints = new java.awt.GridBagConstraints();
186:                gridBagConstraints.gridx = 0;
187:                gridBagConstraints.gridy = 0;
188:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
189:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
190:                gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
191:                jPanelButtons.add(jButtonNew, gridBagConstraints);
192:
193:                jButtonModify.setText("Modify");
194:                jButtonModify.setEnabled(false);
195:                jButtonModify
196:                        .addActionListener(new java.awt.event.ActionListener() {
197:                            public void actionPerformed(
198:                                    java.awt.event.ActionEvent evt) {
199:                                jButtonModifyActionPerformed(evt);
200:                            }
201:                        });
202:
203:                gridBagConstraints = new java.awt.GridBagConstraints();
204:                gridBagConstraints.gridx = 0;
205:                gridBagConstraints.gridy = 1;
206:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
207:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
208:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
209:                jPanelButtons.add(jButtonModify, gridBagConstraints);
210:
211:                jButtonDelete.setText("Delete");
212:                jButtonDelete.setEnabled(false);
213:                jButtonDelete
214:                        .addActionListener(new java.awt.event.ActionListener() {
215:                            public void actionPerformed(
216:                                    java.awt.event.ActionEvent evt) {
217:                                jButtonDeleteActionPerformed(evt);
218:                            }
219:                        });
220:
221:                gridBagConstraints = new java.awt.GridBagConstraints();
222:                gridBagConstraints.gridx = 0;
223:                gridBagConstraints.gridy = 2;
224:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
225:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
226:                gridBagConstraints.weightx = 1.0;
227:                gridBagConstraints.weighty = 1.0;
228:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
229:                jPanelButtons.add(jButtonDelete, gridBagConstraints);
230:
231:                jPanelParameters.add(jPanelButtons, java.awt.BorderLayout.EAST);
232:
233:                getContentPane().add(jPanelParameters,
234:                        java.awt.BorderLayout.CENTER);
235:
236:                pack();
237:            }// </editor-fold>//GEN-END:initComponents
238:
239:            private void jTableParametersMouseClicked(
240:                    java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableParametersMouseClicked
241:                if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1) {
242:                    jButtonModifyActionPerformed(null);
243:                }
244:            }//GEN-LAST:event_jTableParametersMouseClicked
245:
246:            private void jButtonDeleteActionPerformed(
247:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteActionPerformed
248:                // Get the selected connection...
249:                if (jTableParameters.getSelectedRowCount() > 0) {
250:                    SubDataset irc = null;
251:                    try {
252:                        irc = (SubDataset) jTableParameters.getModel()
253:                                .getValueAt(jTableParameters.getSelectedRow(),
254:                                        0);
255:                    } catch (Exception ex) {
256:                        return;
257:                    }
258:
259:                    if (javax.swing.JOptionPane
260:                            .showConfirmDialog(
261:                                    this ,
262:                                    I18n
263:                                            .getString(
264:                                                    "messages.subDatasetsDialog.removingSubDataset",
265:                                                    "Do you want really remove this subdataset?"),
266:                                    "",
267:                                    javax.swing.JOptionPane.YES_NO_CANCEL_OPTION,
268:                                    javax.swing.JOptionPane.QUESTION_MESSAGE) == javax.swing.JOptionPane.YES_OPTION) {
269:                        MainFrame.getMainInstance().getActiveReportFrame()
270:                                .getReport().removeSubDataset(irc);
271:
272:                        ((DefaultTableModel) jTableParameters.getModel())
273:                                .removeRow(jTableParameters.getSelectedRow());
274:                        jTableParameters.updateUI();
275:
276:                    }
277:                }
278:
279:            }//GEN-LAST:event_jButtonDeleteActionPerformed
280:
281:            private void jButtonModifyActionPerformed(
282:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyActionPerformed
283:                java.awt.Frame parent = Misc.frameFromComponent(this );
284:                SubDatasetDialog cd = new SubDatasetDialog(this , true);
285:
286:                // Take the selected connection from the table...
287:                if (jTableParameters.getSelectedRow() < 0)
288:                    return;
289:                SubDataset irc = null;
290:                try {
291:                    irc = (SubDataset) jTableParameters.getModel().getValueAt(
292:                            jTableParameters.getSelectedRow(), 0);
293:                } catch (Exception ex) {
294:                    return;
295:                }
296:
297:                if (irc == null)
298:                    return;
299:
300:                cd.setSubDataset(irc);
301:
302:                cd.setVisible(true);
303:
304:                if (cd.getDialogResult() == JOptionPane.OK_OPTION) {
305:                    SubDataset sub = cd.getSubDataset();
306:                    // Now we have an old and a new object.
307:                    // 1. Adjust table...
308:                    try {
309:                        jTableParameters.getModel().setValueAt(sub,
310:                                jTableParameters.getSelectedRow(), 0);
311:                    } catch (Exception ex) {
312:                        return;
313:                    }
314:                }
315:            }//GEN-LAST:event_jButtonModifyActionPerformed
316:
317:            private void jButtonNewActionPerformed(
318:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewActionPerformed
319:                java.awt.Frame parent = Misc.frameFromComponent(this );
320:                SubDatasetDialog cd = new SubDatasetDialog(this , true);
321:                cd.setVisible(true);
322:            }//GEN-LAST:event_jButtonNewActionPerformed
323:
324:            public void addSubDataset(SubDataset sub) {
325:                DefaultTableModel dtm = (DefaultTableModel) jTableParameters
326:                        .getModel();
327:                dtm.addRow(new Object[] { sub });
328:                // 
329:
330:            }
331:
332:            /** Closes the dialog */
333:            private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
334:                setVisible(false);
335:            }//GEN-LAST:event_closeDialog
336:
337:            // Variables declaration - do not modify//GEN-BEGIN:variables
338:            private javax.swing.JButton jButtonDelete;
339:            private javax.swing.JButton jButtonModify;
340:            private javax.swing.JButton jButtonNew;
341:            private javax.swing.JPanel jPanelButtons;
342:            private javax.swing.JPanel jPanelParameters;
343:            private javax.swing.JScrollPane jScrollPane1;
344:            private javax.swing.JTable jTableParameters;
345:
346:            // End of variables declaration//GEN-END:variables
347:
348:            public void applyI18n() {
349:                // Start autogenerated code ----------------------
350:                jButtonDelete.setText(I18n.getString(
351:                        "subDatasetsDialog.buttonDelete", "Delete"));
352:                jButtonModify.setText(I18n.getString(
353:                        "subDatasetsDialog.buttonModify", "Modify"));
354:                jButtonNew.setText(I18n.getString(
355:                        "subDatasetsDialog.buttonNew", "New"));
356:                // End autogenerated code ----------------------
357:
358:                jTableParameters.getColumnModel().getColumn(0).setHeaderValue(
359:                        I18n.getString("subDatasetsDialog.tablecolumn.name",
360:                                "Name"));
361:
362:                //
363:                this .setTitle(I18n.getString("subDatasetsDialog.title",
364:                        "SubDatasets"));
365:                //
366:            }
367:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.