1 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 43 public class ExportPreferencesDialog extends javax.swing.JDialog { 44 45 private CategorySheetPanel categorySheetPanel = null; 46 private java.util.Properties defaultValues = null; 47 48 public ExportPreferencesDialog(java.awt.Frame parent, boolean modal) { 49 super(parent, modal); 50 initComponents(); 51 applyI18n(); 52 categorySheetPanel = new CategorySheetPanel(); 53 defaultValues = new java.util.Properties (); 54 55 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 escape = javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false); 137 javax.swing.Action escapeAction = new javax.swing.AbstractAction () { 138 public void actionPerformed(java.awt.event.ActionEvent 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 this.getRootPane().setDefaultButton(this.jButtonSave); 149 } 150 151 public void loadConfiguration() 152 { 153 java.util.Properties 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 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 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 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 194 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 196 197 jPanel1 = new javax.swing.JPanel (); 198 jPanel2 = new javax.swing.JPanel (); 199 jPanel3 = new javax.swing.JPanel (); 200 jButtonSave = new javax.swing.JButton (); 201 jButtonCancel = new javax.swing.JButton (); 202 203 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 204 jPanel1.setLayout(new java.awt.BorderLayout ()); 205 206 jPanel1.setMinimumSize(new java.awt.Dimension (100, 100)); 207 jPanel1.setPreferredSize(new java.awt.Dimension (400, 400)); 208 getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); 209 210 jPanel2.setLayout(new java.awt.GridBagLayout ()); 211 212 gridBagConstraints = new java.awt.GridBagConstraints (); 213 gridBagConstraints.weightx = 1.0; 214 jPanel2.add(jPanel3, gridBagConstraints); 215 216 jButtonSave.setText("Save"); 217 jButtonSave.addActionListener(new java.awt.event.ActionListener () { 218 public void actionPerformed(java.awt.event.ActionEvent evt) { 219 jButtonSaveActionPerformed(evt); 220 } 221 }); 222 223 gridBagConstraints = new java.awt.GridBagConstraints (); 224 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 0); 225 jPanel2.add(jButtonSave, gridBagConstraints); 226 227 jButtonCancel.setText("Cancel"); 228 jButtonCancel.addActionListener(new java.awt.event.ActionListener () { 229 public void actionPerformed(java.awt.event.ActionEvent evt) { 230 jButtonCancelActionPerformed(evt); 231 } 232 }); 233 234 gridBagConstraints = new java.awt.GridBagConstraints (); 235 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 4); 236 jPanel2.add(jButtonCancel, gridBagConstraints); 237 238 getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); 239 240 pack(); 241 } 243 private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) { this.setVisible(false); 245 this.dispose(); 246 } 248 private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) { this.saveConfiguration(); 250 this.setVisible(false); 251 this.dispose(); 252 } 254 257 public static void main(String args[]) { 258 java.awt.EventQueue.invokeLater(new Runnable () { 259 public void run() { 260 new ExportPreferencesDialog(new javax.swing.JFrame (), 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 getJButtonCancel() { 274 return jButtonCancel; 275 } 276 277 public void setJButtonCancel(javax.swing.JButton jButtonCancel) { 278 this.jButtonCancel = jButtonCancel; 279 } 280 281 public javax.swing.JButton getJButtonSave() { 282 return jButtonSave; 283 } 284 285 public void setJButtonSave(javax.swing.JButton jButtonSave) { 286 this.jButtonSave = jButtonSave; 287 } 288 289 public javax.swing.JPanel getJPanel1() { 290 return jPanel1; 291 } 292 293 public void setJPanel1(javax.swing.JPanel jPanel1) { 294 this.jPanel1 = jPanel1; 295 } 296 297 public javax.swing.JPanel getJPanel2() { 298 return jPanel2; 299 } 300 301 public void setJPanel2(javax.swing.JPanel jPanel2) { 302 this.jPanel2 = jPanel2; 303 } 304 305 public javax.swing.JPanel getJPanel3() { 306 return jPanel3; 307 } 308 309 public void setJPanel3(javax.swing.JPanel jPanel3) { 310 this.jPanel3 = jPanel3; 311 } 312 313 private javax.swing.JButton jButtonCancel; 315 private javax.swing.JButton jButtonSave; 316 private javax.swing.JPanel jPanel1; 317 private javax.swing.JPanel jPanel2; 318 private javax.swing.JPanel jPanel3; 319 321 public void applyI18n(){ 322 jButtonCancel.setText(I18n.getString("exportPreferencesDialog.buttonCancel","Cancel")); 324 jButtonSave.setText(I18n.getString("exportPreferencesDialog.buttonSave","Save")); 325 } 327 } 328 | Popular Tags |