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: * PluginConfigurationDialog.java
028: *
029: * Created on 21 maggio 2004, 7.52
030: *
031: */
032:
033: package it.businesslogic.ireport.gui;
034:
035: import java.util.*;
036: import it.businesslogic.ireport.*;
037: import it.businesslogic.ireport.util.I18n;
038:
039: /**
040: *
041: * @author Administrator
042: */
043: public class PluginConfigurationDialog extends javax.swing.JDialog {
044:
045: /** Creates new form PluginConfigurationFrame */
046: public PluginConfigurationDialog(javax.swing.JFrame owner) {
047: super (owner, false);
048: initComponents();
049: applyI18n();
050: this .setSize(450, 250);
051: it.businesslogic.ireport.util.Misc.centerFrame(this );
052: jListPlugins.setModel(new javax.swing.DefaultListModel());
053:
054: javax.swing.KeyStroke escape = javax.swing.KeyStroke
055: .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
056: false);
057: javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
058: public void actionPerformed(java.awt.event.ActionEvent e) {
059: jButtonCloseActionPerformed(e);
060: }
061: };
062:
063: getRootPane().getInputMap(
064: javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
065: escape, "ESCAPE");
066: getRootPane().getActionMap().put("ESCAPE", escapeAction);
067:
068: //to make the default button ...
069: this .getRootPane().setDefaultButton(this .jButtonClose);
070:
071: }
072:
073: /** This method is called from within the constructor to
074: * initialize the form.
075: * WARNING: Do NOT modify this code. The content of this method is
076: * always regenerated by the Form Editor.
077: */
078: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
079: private void initComponents() {
080: java.awt.GridBagConstraints gridBagConstraints;
081:
082: jScrollPane1 = new javax.swing.JScrollPane();
083: jListPlugins = new javax.swing.JList();
084: jPanel1 = new javax.swing.JPanel();
085: jButtonConfig = new javax.swing.JButton();
086: jButtonClose = new javax.swing.JButton();
087: jPanel2 = new javax.swing.JPanel();
088:
089: getContentPane().setLayout(new java.awt.GridBagLayout());
090:
091: setTitle("Plugins configuration");
092: addWindowListener(new java.awt.event.WindowAdapter() {
093: public void windowClosing(java.awt.event.WindowEvent evt) {
094: exitForm(evt);
095: }
096: });
097:
098: jListPlugins
099: .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
100: jListPlugins
101: .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
102: public void valueChanged(
103: javax.swing.event.ListSelectionEvent evt) {
104: jListPluginsValueChanged(evt);
105: }
106: });
107: jListPlugins
108: .addMouseListener(new java.awt.event.MouseAdapter() {
109: public void mouseClicked(
110: java.awt.event.MouseEvent evt) {
111: jListPluginsMouseClicked(evt);
112: }
113: });
114:
115: jScrollPane1.setViewportView(jListPlugins);
116:
117: gridBagConstraints = new java.awt.GridBagConstraints();
118: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
119: gridBagConstraints.weightx = 1.0;
120: gridBagConstraints.weighty = 1.0;
121: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
122: getContentPane().add(jScrollPane1, gridBagConstraints);
123:
124: jPanel1.setLayout(new java.awt.GridBagLayout());
125:
126: jPanel1.setMinimumSize(new java.awt.Dimension(120, 150));
127: jPanel1.setPreferredSize(new java.awt.Dimension(120, 150));
128: jButtonConfig.setText("Configure");
129: jButtonConfig.setEnabled(false);
130: jButtonConfig
131: .addActionListener(new java.awt.event.ActionListener() {
132: public void actionPerformed(
133: java.awt.event.ActionEvent evt) {
134: jButtonConfigActionPerformed(evt);
135: }
136: });
137:
138: gridBagConstraints = new java.awt.GridBagConstraints();
139: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
140: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
141: gridBagConstraints.weightx = 1.0;
142: jPanel1.add(jButtonConfig, gridBagConstraints);
143:
144: jButtonClose.setText("Close");
145: jButtonClose
146: .addActionListener(new java.awt.event.ActionListener() {
147: public void actionPerformed(
148: java.awt.event.ActionEvent evt) {
149: jButtonCloseActionPerformed(evt);
150: }
151: });
152:
153: gridBagConstraints = new java.awt.GridBagConstraints();
154: gridBagConstraints.gridx = 0;
155: gridBagConstraints.gridy = 1;
156: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
157: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
158: gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0);
159: jPanel1.add(jButtonClose, gridBagConstraints);
160:
161: gridBagConstraints = new java.awt.GridBagConstraints();
162: gridBagConstraints.gridx = 0;
163: gridBagConstraints.gridy = 3;
164: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
165: gridBagConstraints.weighty = 1.0;
166: jPanel1.add(jPanel2, gridBagConstraints);
167:
168: gridBagConstraints = new java.awt.GridBagConstraints();
169: gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
170: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4);
171: getContentPane().add(jPanel1, gridBagConstraints);
172:
173: pack();
174: }// </editor-fold>//GEN-END:initComponents
175:
176: private void jListPluginsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListPluginsMouseClicked
177: if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() == 2) {
178: jButtonConfigActionPerformed(new java.awt.event.ActionEvent(
179: this , 0, ""));
180: }
181: }//GEN-LAST:event_jListPluginsMouseClicked
182:
183: private void jButtonConfigActionPerformed(
184: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfigActionPerformed
185:
186: if (jListPlugins.getSelectedValue() == null)
187: return;
188:
189: PluginEntry pe = (PluginEntry) jListPlugins.getSelectedValue();
190: pe.getPlugin().configure();
191:
192: }//GEN-LAST:event_jButtonConfigActionPerformed
193:
194: private void jListPluginsValueChanged(
195: javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListPluginsValueChanged
196:
197: if (this .jListPlugins.getSelectedValue() != null) {
198: PluginEntry pe = (PluginEntry) jListPlugins
199: .getSelectedValue();
200: if (pe.isConfigurable()) {
201: jButtonConfig.setEnabled(true);
202: } else {
203: jButtonConfig.setEnabled(false);
204: }
205: } else {
206: jButtonConfig.setEnabled(false);
207: }
208: }//GEN-LAST:event_jListPluginsValueChanged
209:
210: private void jButtonCloseActionPerformed(
211: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCloseActionPerformed
212: this .setVisible(false);
213: }//GEN-LAST:event_jButtonCloseActionPerformed
214:
215: /** Exit the Application */
216: private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
217: this .setVisible(false);
218: }//GEN-LAST:event_exitForm
219:
220: public void setPlugins(Collection plugins) {
221: Iterator iter = plugins.iterator();
222: while (iter.hasNext()) {
223: PluginEntry pe = (PluginEntry) iter.next();
224: ((javax.swing.DefaultListModel) (jListPlugins.getModel()))
225: .addElement(pe);
226: }
227:
228: //jListPlugins.setCellRenderer(this);
229: }
230:
231: /*
232: public java.awt.Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
233:
234: if (value instanceof PluginEntry)
235: {
236: PluginEntry pe = (PluginEntry)value;
237: javax.swing.JLabel label = new javax.swing.JLabel(pe.getName(),pe.getIcon(),javax.swing.JLabel.LEFT);
238: if (isSelected)
239: {
240:
241: }
242: return label;
243: }
244: return new javax.swing.JLabel(""+value);
245: }
246: */
247:
248: // Variables declaration - do not modify//GEN-BEGIN:variables
249: private javax.swing.JButton jButtonClose;
250: private javax.swing.JButton jButtonConfig;
251: private javax.swing.JList jListPlugins;
252: private javax.swing.JPanel jPanel1;
253: private javax.swing.JPanel jPanel2;
254: private javax.swing.JScrollPane jScrollPane1;
255:
256: // End of variables declaration//GEN-END:variables
257:
258: public void applyI18n() {
259: // Start autogenerated code ----------------------
260: jButtonClose.setText(I18n.getString(
261: "pluginConfigurationDialog.buttonClose", "Close"));
262: jButtonConfig.setText(I18n.getString(
263: "pluginConfigurationDialog.buttonConfig", "Configure"));
264: // End autogenerated code ----------------------
265: this .setTitle(I18n.getString("pluginConfigurationDialog.title",
266: "Plugins configuration"));
267: }
268: }
|