KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > gui > export > ExportPreferencesDialog


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  * ExportPreferencesDialog.java
28  *
29  * Created on 5 maggio 2005, 18.26
30  *
31  */

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

43 public class ExportPreferencesDialog extends javax.swing.JDialog JavaDoc {
44
45     private CategorySheetPanel categorySheetPanel = null;
46     private java.util.Properties JavaDoc defaultValues = null;
47     /** Creates new form ExportPreferencesDialog */
48     public ExportPreferencesDialog(java.awt.Frame JavaDoc parent, boolean modal) {
49         super(parent, modal);
50         initComponents();
51         applyI18n();
52         categorySheetPanel = new CategorySheetPanel();
53         defaultValues = new java.util.Properties JavaDoc();
54
55         // Adding all properties...
56
categorySheetPanel.addSheetProperty("PDF Exporter", new SheetProperty("PDF_IS_ENCRYPTED",it.businesslogic.ireport.util.I18n.getString("isEncrypted","Is Encrypted"), SheetProperty.BOOLEAN));
57         defaultValues.setProperty("PDF_IS_ENCRYPTED", "false");
58         categorySheetPanel.addSheetProperty("PDF Exporter", new SheetProperty("PDF_IS_128_BIT_KEY",it.businesslogic.ireport.util.I18n.getString("is128BitKey", "Is 128 Bit Key"), SheetProperty.BOOLEAN));
59         defaultValues.setProperty("PDF_IS_128_BIT_KEY", "false");
60         categorySheetPanel.addSheetProperty("PDF Exporter", new SheetProperty("PDF_USER_PASSWORD",it.businesslogic.ireport.util.I18n.getString("userPassword", "User Password"), SheetProperty.PASSWORD));
61         defaultValues.setProperty("PDF_USER_PASSWORD", "");
62         categorySheetPanel.addSheetProperty("PDF Exporter", new SheetProperty("PDF_OWNER_PASSWORD",it.businesslogic.ireport.util.I18n.getString("ownerPassword", "Owner Password"), SheetProperty.PASSWORD));
63         defaultValues.setProperty("PDF_OWNER_PASSWORD", "");
64         categorySheetPanel.addSheetProperty("PDF Exporter", new SheetProperty("PDF_PERMISSIONS",it.businesslogic.ireport.util.I18n.getString("permissions", "Permissions"), SheetProperty.INTEGER));
65         defaultValues.setProperty("PDF_PERMISSIONS", "0");
66
67         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_IMAGES_MAP","Images Map Object", SheetProperty.STRING));
68         defaultValues.setProperty("HTML_IMAGES_MAP", "");
69         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_IMAGES_DIR","Images Directory", SheetProperty.STRING));
70         defaultValues.setProperty("HTML_IMAGES_DIR", "");
71         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_IMAGES_DIR_NAME","Images Directory Name", SheetProperty.STRING));
72         defaultValues.setProperty("HTML_IMAGES_DIR_NAME", "");
73         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_IS_OUTPUT_IMAGES_TO_DIR","Is Output Images to Directory Flag", SheetProperty.BOOLEAN));
74         defaultValues.setProperty("HTML_IS_OUTPUT_IMAGES_TO_DIR", "false");
75         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_IMAGES_URI","Images URI", SheetProperty.STRING));
76         defaultValues.setProperty("HTML_IMAGES_URI", "");
77         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_HTML_HEADER","HTML Header", SheetProperty.STRING));
78         defaultValues.setProperty("HTML_HTML_HEADER", "");
79         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_BETWEEN_PAGES_HTML","Between Pages HTML", SheetProperty.STRING));
80         defaultValues.setProperty("HTML_BETWEEN_PAGES_HTML", "");
81         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_HTML_FOOTER","HTML Footer", SheetProperty.STRING));
82         defaultValues.setProperty("HTML_HTML_FOOTER", "");
83         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS","Is Remove Empty Space Between Rows", SheetProperty.BOOLEAN));
84         defaultValues.setProperty("HTML_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS", "false");
85         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_IS_WHITE_PAGE_BACKGROUND","Is White Page Background", SheetProperty.BOOLEAN));
86         defaultValues.setProperty("HTML_IS_WHITE_PAGE_BACKGROUND", "ture");
87         categorySheetPanel.addSheetProperty("HTML Exporter", new SheetProperty("HTML_IS_USING_IMAGES_TO_ALIGN","Is Using Images To Align", SheetProperty.BOOLEAN));
88         defaultValues.setProperty("HTML_IS_USING_IMAGES_TO_ALIGN", "true");
89
90         categorySheetPanel.addSheetProperty("XLS Exporter", new SheetProperty("XLS_IS_ONE_PAGE_PER_SHEET","Is One Page per Sheet", SheetProperty.BOOLEAN));
91         defaultValues.setProperty("XLS_IS_ONE_PAGE_PER_SHEET", "false");
92         categorySheetPanel.addSheetProperty("XLS Exporter", new SheetProperty("XLS_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS","Is Remove Empty Space Between Rows", SheetProperty.BOOLEAN));
93         defaultValues.setProperty("XLS_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS", "false");
94         categorySheetPanel.addSheetProperty("XLS Exporter", new SheetProperty("XLS_IS_WHITE_PAGE_BACKGROUND","Is White Page Background", SheetProperty.BOOLEAN));
95         defaultValues.setProperty("XLS_IS_WHITE_PAGE_BACKGROUND", "true");
96         categorySheetPanel.addSheetProperty("XLS Exporter", new SheetProperty("XLS_IS_AUTO_DETECT_CELL_TYPE","Is Detect Cell Type", SheetProperty.BOOLEAN));
97         defaultValues.setProperty("XLS_IS_DETECT_CELL_TYPE", "true");
98
99         categorySheetPanel.addSheetProperty("XML Exporter (using POI)", new SheetProperty("XML_IS_EMBEDDING_IMAGES","Is Embedding Images Flag", SheetProperty.BOOLEAN));
100         defaultValues.setProperty("XML_IS_EMBEDDING_IMAGES", "true");
101         categorySheetPanel.addSheetProperty("XML Exporter (using POI)", new SheetProperty("XML_DTD_LOCATION","DTD Location", SheetProperty.STRING));
102         defaultValues.setProperty("XML_DTD_LOCATION", "");
103
104         categorySheetPanel.addSheetProperty("XML Exporter (using JExcelApi)", new SheetProperty("XML2_IS_FONT_SIZE_FIX_ENABLED","Is Font Size Fix Enabled", SheetProperty.BOOLEAN));
105         defaultValues.setProperty("XML2_IS_FONT_SIZE_FIX_ENABLED", "true");
106
107         categorySheetPanel.addSheetProperty("Text Exporter", new SheetProperty("TXT_PAGE_ROWS","Rows per page", SheetProperty.INTEGER));
108         defaultValues.setProperty("TXT_PAGE_ROWS", "61");
109         categorySheetPanel.addSheetProperty("Text Exporter", new SheetProperty("TXT_PAGE_COLUMNS","Columns per page", SheetProperty.INTEGER));
110         defaultValues.setProperty("TXT_PAGE_COLUMNS", "255");
111         categorySheetPanel.addSheetProperty("Text Exporter", new SheetProperty("TXT_ADD_FORM_FEED","Add FORM FEED", SheetProperty.BOOLEAN));
112         defaultValues.setProperty("TXT_ADD_FORM_FEED", "true");
113
114         categorySheetPanel.addSheetProperty("CSV Exporter", new SheetProperty("CSV_FIELD_DELIMITER","Field Delimiter", SheetProperty.STRING));
115         defaultValues.setProperty("CSV_RECORD_DELIMITER", ",");
116
117         categorySheetPanel.addSheetProperty("JR Text Exporter", new SheetProperty("JRTXT_CHARACTER_WIDTH","Character Width", SheetProperty.INTEGER));
118         defaultValues.setProperty("JRTXT_CHARACTER_WIDTH", "10");
119         categorySheetPanel.addSheetProperty("JR Text Exporter", new SheetProperty("JRTXT_CHARACTER_HEIGHT","Character Height", SheetProperty.INTEGER));
120         defaultValues.setProperty("JRTXT_CHARACTER_HEIGHT", "20");
121         categorySheetPanel.addSheetProperty("JR Text Exporter", new SheetProperty("JRTXT_PAGE_WIDTH","Page Width", SheetProperty.INTEGER));
122         defaultValues.setProperty("JRTXT_PAGE_WIDTH", "225");
123         categorySheetPanel.addSheetProperty("JR Text Exporter", new SheetProperty("JRTXT_CHARACTER_HEIGHT","Page Height", SheetProperty.INTEGER));
124         defaultValues.setProperty("JRTXT_PAGE_HEIGHT", "61");
125         categorySheetPanel.addSheetProperty("JR Text Exporter", new SheetProperty("JRTXT_BETWEEN_PAGES_TEXT","Between Pages Text", SheetProperty.STRING));
126         defaultValues.setProperty("JRTXT_BETWEEN_PAGES_TEXT", "\n\n");
127
128         jPanel1.add("Center", categorySheetPanel);
129         categorySheetPanel.setShowResetButton(false);
130         categorySheetPanel.recreateSheet();
131         
132         loadConfiguration();
133
134         it.businesslogic.ireport.util.Misc.centerFrame( this );
135
136         javax.swing.KeyStroke JavaDoc escape = javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
137         javax.swing.Action JavaDoc escapeAction = new javax.swing.AbstractAction JavaDoc() {
138             public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
139                 jButtonCancelActionPerformed(e);
140             }
141         };
142
143         getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
144         getRootPane().getActionMap().put("ESCAPE", escapeAction);
145
146
147         //to make the default button ...
148
this.getRootPane().setDefaultButton(this.jButtonSave);
149     }
150
151     public void loadConfiguration()
152     {
153         java.util.Properties JavaDoc props = it.businesslogic.ireport.gui.MainFrame.getMainInstance().getProperties();
154
155         Enumeration p_props = categorySheetPanel.getProperties().elements();
156
157         while (p_props.hasMoreElements())
158         {
159             SheetProperty sp = (SheetProperty)p_props.nextElement();
160             String JavaDoc property_name = sp.getKeyName();
161
162             if (props.getProperty(property_name) != null)
163             {
164                 sp.setValue( props.getProperty(property_name) );
165             }
166             else if (defaultValues.getProperty(property_name) != null)
167             {
168                 sp.setValue( defaultValues.getProperty(property_name) );
169             }
170         }
171     }
172
173     public void saveConfiguration()
174     {
175         java.util.Properties JavaDoc props = it.businesslogic.ireport.gui.MainFrame.getMainInstance().getProperties();
176
177         Enumeration p_props = categorySheetPanel.getProperties().elements();
178
179         while (p_props.hasMoreElements())
180         {
181             SheetProperty sp = (SheetProperty)p_props.nextElement();
182             String JavaDoc property_name = sp.getKeyName();
183             if (sp.getValue() != null) props.setProperty(property_name, sp.getValue()+"");
184         }
185
186         it.businesslogic.ireport.gui.MainFrame.getMainInstance().saveiReportConfiguration();
187     }
188
189     /** This method is called from within the constructor to
190      * initialize the form.
191      * WARNING: Do NOT modify this code. The content of this method is
192      * always regenerated by the Form Editor.
193      */

194     private void initComponents() {//GEN-BEGIN:initComponents
195
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
196
197         jPanel1 = new javax.swing.JPanel JavaDoc();
198         jPanel2 = new javax.swing.JPanel JavaDoc();
199         jPanel3 = new javax.swing.JPanel JavaDoc();
200         jButtonSave = new javax.swing.JButton JavaDoc();
201         jButtonCancel = new javax.swing.JButton JavaDoc();
202
203         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
204         jPanel1.setLayout(new java.awt.BorderLayout JavaDoc());
205
206         jPanel1.setMinimumSize(new java.awt.Dimension JavaDoc(100, 100));
207         jPanel1.setPreferredSize(new java.awt.Dimension JavaDoc(400, 400));
208         getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
209
210         jPanel2.setLayout(new java.awt.GridBagLayout JavaDoc());
211
212         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
213         gridBagConstraints.weightx = 1.0;
214         jPanel2.add(jPanel3, gridBagConstraints);
215
216         jButtonSave.setText("Save");
217         jButtonSave.addActionListener(new java.awt.event.ActionListener JavaDoc() {
218             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
219                 jButtonSaveActionPerformed(evt);
220             }
221         });
222
223         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
224         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 4, 0);
225         jPanel2.add(jButtonSave, gridBagConstraints);
226
227         jButtonCancel.setText("Cancel");
228         jButtonCancel.addActionListener(new java.awt.event.ActionListener JavaDoc() {
229             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
230                 jButtonCancelActionPerformed(evt);
231             }
232         });
233
234         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
235         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 4, 4);
236         jPanel2.add(jButtonCancel, gridBagConstraints);
237
238         getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
239
240         pack();
241     }//GEN-END:initComponents
242

243     private void jButtonCancelActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
244
this.setVisible(false);
245         this.dispose();
246     }//GEN-LAST:event_jButtonCancelActionPerformed
247

248     private void jButtonSaveActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonSaveActionPerformed
249
this.saveConfiguration();
250         this.setVisible(false);
251         this.dispose();
252     }//GEN-LAST:event_jButtonSaveActionPerformed
253

254     /**
255      * @param args the command line arguments
256      */

257     public static void main(String JavaDoc args[]) {
258         java.awt.EventQueue.invokeLater(new Runnable JavaDoc() {
259             public void run() {
260                 new ExportPreferencesDialog(new javax.swing.JFrame JavaDoc(), true).setVisible(true);
261             }
262         });
263     }
264
265     public CategorySheetPanel getCategorySheetPanel() {
266         return categorySheetPanel;
267     }
268
269     public void setCategorySheetPanel(CategorySheetPanel categorySheetPanel) {
270         this.categorySheetPanel = categorySheetPanel;
271     }
272
273     public javax.swing.JButton JavaDoc getJButtonCancel() {
274         return jButtonCancel;
275     }
276
277     public void setJButtonCancel(javax.swing.JButton JavaDoc jButtonCancel) {
278         this.jButtonCancel = jButtonCancel;
279     }
280
281     public javax.swing.JButton JavaDoc getJButtonSave() {
282         return jButtonSave;
283     }
284
285     public void setJButtonSave(javax.swing.JButton JavaDoc jButtonSave) {
286         this.jButtonSave = jButtonSave;
287     }
288
289     public javax.swing.JPanel JavaDoc getJPanel1() {
290         return jPanel1;
291     }
292
293     public void setJPanel1(javax.swing.JPanel JavaDoc jPanel1) {
294         this.jPanel1 = jPanel1;
295     }
296
297     public javax.swing.JPanel JavaDoc getJPanel2() {
298         return jPanel2;
299     }
300
301     public void setJPanel2(javax.swing.JPanel JavaDoc jPanel2) {
302         this.jPanel2 = jPanel2;
303     }
304
305     public javax.swing.JPanel JavaDoc getJPanel3() {
306         return jPanel3;
307     }
308
309     public void setJPanel3(javax.swing.JPanel JavaDoc jPanel3) {
310         this.jPanel3 = jPanel3;
311     }
312
313     // Variables declaration - do not modify//GEN-BEGIN:variables
314
private javax.swing.JButton JavaDoc jButtonCancel;
315     private javax.swing.JButton JavaDoc jButtonSave;
316     private javax.swing.JPanel JavaDoc jPanel1;
317     private javax.swing.JPanel JavaDoc jPanel2;
318     private javax.swing.JPanel JavaDoc jPanel3;
319     // End of variables declaration//GEN-END:variables
320

321     public void applyI18n(){
322                 // Start autogenerated code ----------------------
323
jButtonCancel.setText(I18n.getString("exportPreferencesDialog.buttonCancel","Cancel"));
324                 jButtonSave.setText(I18n.getString("exportPreferencesDialog.buttonSave","Save"));
325                 // End autogenerated code ----------------------
326
}
327 }
328
Popular Tags