KickJava   Java API By Example, From Geeks To Geeks.

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


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  * PluginConfigurationDialog.java
28  *
29  * Created on 21 maggio 2004, 7.52
30  *
31  */

32
33 package it.businesslogic.ireport.gui;
34
35 import java.util.*;
36 import it.businesslogic.ireport.*;
37 import it.businesslogic.ireport.util.I18n;
38 /**
39  *
40  * @author Administrator
41  */

42 public class PluginConfigurationDialog extends javax.swing.JDialog JavaDoc {
43     
44     /** Creates new form PluginConfigurationFrame */
45     public PluginConfigurationDialog(javax.swing.JFrame JavaDoc owner ) {
46         super(owner,false);
47         initComponents();
48         applyI18n();
49         this.setSize(450, 250);
50         it.businesslogic.ireport.util.Misc.centerFrame(this);
51         jListPlugins.setModel(new javax.swing.DefaultListModel JavaDoc());
52         
53         
54         javax.swing.KeyStroke JavaDoc escape = javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
55         javax.swing.Action JavaDoc escapeAction = new javax.swing.AbstractAction JavaDoc() {
56             public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
57                 jButtonCloseActionPerformed(e);
58             }
59         };
60        
61         getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
62         getRootPane().getActionMap().put("ESCAPE", escapeAction);
63
64
65         //to make the default button ...
66
this.getRootPane().setDefaultButton(this.jButtonClose);
67         
68     }
69     
70     /** This method is called from within the constructor to
71      * initialize the form.
72      * WARNING: Do NOT modify this code. The content of this method is
73      * always regenerated by the Form Editor.
74      */

75     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
76
private void initComponents() {
77         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
78
79         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
80         jListPlugins = new javax.swing.JList JavaDoc();
81         jPanel1 = new javax.swing.JPanel JavaDoc();
82         jButtonConfig = new javax.swing.JButton JavaDoc();
83         jButtonClose = new javax.swing.JButton JavaDoc();
84         jPanel2 = new javax.swing.JPanel JavaDoc();
85
86         getContentPane().setLayout(new java.awt.GridBagLayout JavaDoc());
87
88         setTitle("Plugins configuration");
89         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
90             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
91                 exitForm(evt);
92             }
93         });
94
95         jListPlugins.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
96         jListPlugins.addListSelectionListener(new javax.swing.event.ListSelectionListener JavaDoc() {
97             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {
98                 jListPluginsValueChanged(evt);
99             }
100         });
101         jListPlugins.addMouseListener(new java.awt.event.MouseAdapter JavaDoc() {
102             public void mouseClicked(java.awt.event.MouseEvent JavaDoc evt) {
103                 jListPluginsMouseClicked(evt);
104             }
105         });
106
107         jScrollPane1.setViewportView(jListPlugins);
108
109         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
110         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
111         gridBagConstraints.weightx = 1.0;
112         gridBagConstraints.weighty = 1.0;
113         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 4, 4);
114         getContentPane().add(jScrollPane1, gridBagConstraints);
115
116         jPanel1.setLayout(new java.awt.GridBagLayout JavaDoc());
117
118         jPanel1.setMinimumSize(new java.awt.Dimension JavaDoc(120, 150));
119         jPanel1.setPreferredSize(new java.awt.Dimension JavaDoc(120, 150));
120         jButtonConfig.setText("Configure");
121         jButtonConfig.setEnabled(false);
122         jButtonConfig.addActionListener(new java.awt.event.ActionListener JavaDoc() {
123             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
124                 jButtonConfigActionPerformed(evt);
125             }
126         });
127
128         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
129         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
130         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
131         gridBagConstraints.weightx = 1.0;
132         jPanel1.add(jButtonConfig, gridBagConstraints);
133
134         jButtonClose.setText("Close");
135         jButtonClose.addActionListener(new java.awt.event.ActionListener JavaDoc() {
136             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
137                 jButtonCloseActionPerformed(evt);
138             }
139         });
140
141         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
142         gridBagConstraints.gridx = 0;
143         gridBagConstraints.gridy = 1;
144         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
145         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
146         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 0, 0, 0);
147         jPanel1.add(jButtonClose, gridBagConstraints);
148
149         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
150         gridBagConstraints.gridx = 0;
151         gridBagConstraints.gridy = 3;
152         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
153         gridBagConstraints.weighty = 1.0;
154         jPanel1.add(jPanel2, gridBagConstraints);
155
156         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
157         gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
158         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 0, 4, 4);
159         getContentPane().add(jPanel1, gridBagConstraints);
160
161         pack();
162     }// </editor-fold>//GEN-END:initComponents
163

164     private void jListPluginsMouseClicked(java.awt.event.MouseEvent JavaDoc evt) {//GEN-FIRST:event_jListPluginsMouseClicked
165
if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() == 2)
166         {
167             jButtonConfigActionPerformed( new java.awt.event.ActionEvent JavaDoc(this,0,""));
168         }
169     }//GEN-LAST:event_jListPluginsMouseClicked
170

171     private void jButtonConfigActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonConfigActionPerformed
172

173         if (jListPlugins.getSelectedValue() == null) return;
174         
175         PluginEntry pe = (PluginEntry)jListPlugins.getSelectedValue();
176         pe.getPlugin().configure();
177         
178     }//GEN-LAST:event_jButtonConfigActionPerformed
179

180     private void jListPluginsValueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {//GEN-FIRST:event_jListPluginsValueChanged
181

182         if (this.jListPlugins.getSelectedValue() != null)
183         {
184             PluginEntry pe = (PluginEntry)jListPlugins.getSelectedValue();
185             if (pe.isConfigurable())
186             {
187                 jButtonConfig.setEnabled(true);
188             }
189             else
190             {
191                 jButtonConfig.setEnabled(false);
192             }
193         }
194         else
195         {
196             jButtonConfig.setEnabled(false);
197         }
198     }//GEN-LAST:event_jListPluginsValueChanged
199

200     private void jButtonCloseActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonCloseActionPerformed
201
this.setVisible(false);
202     }//GEN-LAST:event_jButtonCloseActionPerformed
203

204     /** Exit the Application */
205     private void exitForm(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_exitForm
206
this.setVisible(false);
207     }//GEN-LAST:event_exitForm
208

209     public void setPlugins(Collection plugins)
210     {
211         Iterator iter = plugins.iterator();
212         while (iter.hasNext())
213         {
214             PluginEntry pe = (PluginEntry)iter.next();
215             ((javax.swing.DefaultListModel JavaDoc)(jListPlugins.getModel())).addElement(pe);
216         }
217         
218         
219         //jListPlugins.setCellRenderer(this);
220
}
221     
222     /*
223     public java.awt.Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
224         
225         if (value instanceof PluginEntry)
226         {
227             PluginEntry pe = (PluginEntry)value;
228             javax.swing.JLabel label = new javax.swing.JLabel(pe.getName(),pe.getIcon(),javax.swing.JLabel.LEFT);
229             if (isSelected)
230             {
231                 
232             }
233             return label;
234         }
235         return new javax.swing.JLabel(""+value);
236     }
237      */

238     
239     // Variables declaration - do not modify//GEN-BEGIN:variables
240
private javax.swing.JButton JavaDoc jButtonClose;
241     private javax.swing.JButton JavaDoc jButtonConfig;
242     private javax.swing.JList JavaDoc jListPlugins;
243     private javax.swing.JPanel JavaDoc jPanel1;
244     private javax.swing.JPanel JavaDoc jPanel2;
245     private javax.swing.JScrollPane JavaDoc jScrollPane1;
246     // End of variables declaration//GEN-END:variables
247

248     public void applyI18n(){
249                 // Start autogenerated code ----------------------
250
jButtonClose.setText(I18n.getString("pluginConfigurationDialog.buttonClose","Close"));
251                 jButtonConfig.setText(I18n.getString("pluginConfigurationDialog.buttonConfig","Configure"));
252                 // End autogenerated code ----------------------
253
}
254 }
255
Popular Tags