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: * JRPropertyDialog.java
028: *
029: * Created on 9 maggio 2003, 17.25
030: *
031: */
032:
033: package it.businesslogic.ireport.gui;
034:
035: import it.businesslogic.ireport.util.*;
036: import it.businesslogic.ireport.*;
037: import javax.swing.DefaultListModel;
038: import javax.swing.SwingUtilities;
039:
040: /**
041: *
042: * @author Administrator
043: */
044: public class JRPropertyDialog extends javax.swing.JDialog {
045: /** Creates new form JRParameterDialog */
046: JRProperty tmpField = null;
047:
048: public JRPropertyDialog(java.awt.Frame parent, boolean modal) {
049: super (parent, modal);
050: initComponents();
051: applyI18n();
052:
053: javax.swing.KeyStroke escape = javax.swing.KeyStroke
054: .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
055: false);
056: javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
057: public void actionPerformed(java.awt.event.ActionEvent e) {
058: jButtonCancelActionPerformed(e);
059: }
060: };
061:
062: getRootPane().getInputMap(
063: javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
064: escape, "ESCAPE");
065: getRootPane().getActionMap().put("ESCAPE", escapeAction);
066:
067: jList1.setModel(new DefaultListModel());
068: jList1.setCellRenderer(new PropertyHintListCellRenderer());
069: addHints();
070:
071: //to make the default button ...
072: this .getRootPane().setDefaultButton(this .jButtonOK);
073: }
074:
075: private void addHints() {
076:
077: DefaultListModel dlm = (DefaultListModel) jList1.getModel();
078: dlm
079: .addElement(new PropertyHint(
080: "net.sf.jasperreports.text.truncate.at.char",
081: "Applied to text elements.<br>Setting this property to true, the text contents is truncated after the last character that fits the element area.<br>When the text element is rendered on multiple lines, line breaks still occur at word boundaries.<br>It defaults to false."));
082:
083: dlm
084: .addElement(new PropertyHint(
085: "net.sf.jasperreports.text.truncate.suffix",
086: "Applied to text elements.<br>Use this property to define a suffix to append to the text contents when it is truncated, after the last character that fits the element area.<br>When the text element is rendered on multiple lines, line breaks still occur at word boundaries.\nIt defaults to the empty string."));
087:
088: dlm
089: .addElement(new PropertyHint(
090: "net.sf.jasperreports.print.keep.full.text",
091: "Applied to text elements.<br>This property is used to preserve the entire content of a text element so that it's used in data-centric exporters.<br>It defaults to false."));
092:
093: dlm
094: .addElement(new PropertyHint(
095: "net.sf.jasperreports.text.measurer.factory",
096: "\nApplied to text elements.<br>This property can be set to use custom text measurer implementation for all or specific text elements.<br>It defaults to net.sf.jasperreports.engine.fill.TextMeasurerFactory."));
097:
098: }
099:
100: public void addExporterHints() {
101: DefaultListModel dlm = (DefaultListModel) jList1.getModel();
102: dlm.addElement(new PropertyHint(
103: "net.sf.jasperreports.export.character.encoding",
104: "Default: UTF-8"));
105:
106: dlm.addElement(new PropertyHint(
107: "net.sf.jasperreports.export.graphics2d.min.job.size",
108: "Used by the Graphics2D exporter<br>"
109: + "Default value: true"));
110:
111: dlm
112: .addElement(new PropertyHint(
113: "net.sf.jasperreports.export.html.frames.as.nested.tables",
114: "Used by the HTML exporter<br>"
115: + "Default value: true"));
116:
117: dlm
118: .addElement(new PropertyHint(
119: "net.sf.jasperreports.export.html.remove.empty.space.between.rows",
120: "Used by the HTML exporter<br>"
121: + "Default value: false"));
122:
123: dlm
124: .addElement(new PropertyHint(
125: "net.sf.jasperreports.export.html.white.page.background",
126: "Used by the HTML exporter<br>"
127: + "Default value: true"));
128:
129: dlm.addElement(new PropertyHint(
130: "net.sf.jasperreports.export.html.wrap.break.word",
131: "Used by the HTML exporter<br>"
132: + "Default value: false"));
133:
134: dlm.addElement(new PropertyHint(
135: "net.sf.jasperreports.export.html.size.unit",
136: "Used by the HTML exporter<br>" + "Default value: px"));
137:
138: dlm
139: .addElement(new PropertyHint(
140: "net.sf.jasperreports.export.html.using.images.to.align",
141: "Used by the HTML exporter<br>"
142: + "Default value: true"));
143:
144: dlm
145: .addElement(new PropertyHint(
146: "net.sf.jasperreports.export.pdf.force.svg.shapes",
147: "Used by the PDF exporter<br>"
148: + "Default value: true"));
149:
150: dlm
151: .addElement(new PropertyHint(
152: "net.sf.jasperreports.export.pdf.force.linebreak.policy",
153: "Used by the PDF exporter<br>"
154: + "Default value: false"));
155:
156: dlm
157: .addElement(new PropertyHint(
158: "net.sf.jasperreports.export.pdf.create.batch.mode.bookmarks",
159: "Used by the PDF exporter<br>"
160: + "Default value: false"));
161:
162: dlm
163: .addElement(new PropertyHint(
164: "net.sf.jasperreports.export.pdf.compressed",
165: "Used by the PDF exporter<br>"
166: + "Default value: false"));
167:
168: dlm
169: .addElement(new PropertyHint(
170: "net.sf.jasperreports.export.pdf.encrypted",
171: "Used by the PDF exporter<br>"
172: + "Default value: false"));
173:
174: dlm
175: .addElement(new PropertyHint(
176: "net.sf.jasperreports.export.pdf.128.bit.key",
177: "Used by the PDF exporter<br>"
178: + "Default value: false"));
179:
180: dlm
181: .addElement(new PropertyHint(
182: "net.sf.jasperreports.export.xls.create.custom.palette",
183: "Used by the XLS exporter<br>"
184: + "Default value: false"));
185:
186: dlm
187: .addElement(new PropertyHint(
188: "net.sf.jasperreports.export.xls.one.page.per.sheet",
189: "Used by the XLS exporter<br>"
190: + "Default value: false"));
191:
192: dlm
193: .addElement(new PropertyHint(
194: "net.sf.jasperreports.export.xls.remove.empty.space.between.rows",
195: "Used by the XLS exporter<br>"
196: + "Default value: false"));
197:
198: dlm
199: .addElement(new PropertyHint(
200: "net.sf.jasperreports.export.xls.remove.empty.space.between.columns",
201: "Used by the XLS exporter<br>"
202: + "Default value: false"));
203:
204: dlm
205: .addElement(new PropertyHint(
206: "net.sf.jasperreports.export.xls.white.page.background",
207: "Used by the XLS exporter<br>"
208: + "Default value: true"));
209:
210: dlm
211: .addElement(new PropertyHint(
212: "net.sf.jasperreports.export.xls.detect.cell.type",
213: "Used by the XLS exporter<br>"
214: + "Default value: false"));
215:
216: dlm
217: .addElement(new PropertyHint(
218: "net.sf.jasperreports.export.xls.size.fix.enabled",
219: "Used by the XLS exporter<br>"
220: + "Default value: false"));
221:
222: dlm
223: .addElement(new PropertyHint(
224: "net.sf.jasperreports.export.xls.ignore.graphics",
225: "Used by the XLS exporter<br>"
226: + "Default value: false"));
227:
228: dlm
229: .addElement(new PropertyHint(
230: "net.sf.jasperreports.export.xls.collapse.row.span",
231: "Used by the XLS exporter<br>"
232: + "Default value: false"));
233:
234: dlm
235: .addElement(new PropertyHint(
236: "net.sf.jasperreports.export.xls.ignore.cell.border",
237: "Used by the XLS exporter<br>"
238: + "Default value: false"));
239:
240: dlm.addElement(new PropertyHint(
241: "net.sf.jasperreports.export.xls.max.rows.per.sheet",
242: "Used by the XLS exporter<br>" + "Default value: 0"));
243:
244: dlm
245: .addElement(new PropertyHint(
246: "net.sf.jasperreports.export.xml.validation",
247: "Used by the XML exporter<br>"
248: + "Default value: true"));
249:
250: dlm.addElement(new PropertyHint(
251: "net.sf.jasperreports.export.csv.field.delimiter",
252: "Used by the CSV exporter<br>" + "Default value: ,"));
253:
254: dlm.addElement(new PropertyHint(
255: "net.sf.jasperreports.export.csv.record.delimiter",
256: "Used by the CSV exporter<br>"
257: + "Default value: \n (New line)"));
258: }
259:
260: /** This method is called from within the constructor to
261: * initialize the form.
262: * WARNING: Do NOT modify this code. The content of this method is
263: * always regenerated by the Form Editor.
264: */
265: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
266: private void initComponents() {
267: java.awt.GridBagConstraints gridBagConstraints;
268:
269: jLabel1 = new javax.swing.JLabel();
270: jTextFieldName = new javax.swing.JTextField();
271: jLabel4 = new javax.swing.JLabel();
272: jScrollPane1 = new javax.swing.JScrollPane();
273: jTextAreaDescription = new javax.swing.JTextArea();
274: jLabel5 = new javax.swing.JLabel();
275: jScrollPane2 = new javax.swing.JScrollPane();
276: jList1 = new javax.swing.JList();
277: jPanel1 = new javax.swing.JPanel();
278: jButtonOK = new javax.swing.JButton();
279: jButtonCancel = new javax.swing.JButton();
280:
281: setTitle("Add/modify property");
282: setModal(true);
283: addWindowListener(new java.awt.event.WindowAdapter() {
284: public void windowClosing(java.awt.event.WindowEvent evt) {
285: closeDialog(evt);
286: }
287: });
288: getContentPane().setLayout(new java.awt.GridBagLayout());
289:
290: jLabel1.setText("Property name");
291: jLabel1.setMaximumSize(new java.awt.Dimension(1000, 100));
292: jLabel1.setMinimumSize(new java.awt.Dimension(100, 15));
293: jLabel1.setPreferredSize(new java.awt.Dimension(100, 15));
294: gridBagConstraints = new java.awt.GridBagConstraints();
295: gridBagConstraints.gridx = 0;
296: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
297: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
298: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
299: getContentPane().add(jLabel1, gridBagConstraints);
300: gridBagConstraints = new java.awt.GridBagConstraints();
301: gridBagConstraints.gridx = 0;
302: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
303: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
304: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
305: getContentPane().add(jTextFieldName, gridBagConstraints);
306:
307: jLabel4.setText("Property value");
308: gridBagConstraints = new java.awt.GridBagConstraints();
309: gridBagConstraints.gridx = 0;
310: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
311: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
312: getContentPane().add(jLabel4, gridBagConstraints);
313:
314: jScrollPane1.setMinimumSize(new java.awt.Dimension(200, 40));
315: jScrollPane1.setPreferredSize(new java.awt.Dimension(200, 40));
316:
317: jTextAreaDescription.setMinimumSize(new java.awt.Dimension(0,
318: 64));
319: jTextAreaDescription.setPreferredSize(new java.awt.Dimension(0,
320: 64));
321: jScrollPane1.setViewportView(jTextAreaDescription);
322:
323: gridBagConstraints = new java.awt.GridBagConstraints();
324: gridBagConstraints.gridx = 0;
325: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
326: gridBagConstraints.ipadx = 1;
327: gridBagConstraints.ipady = 1;
328: gridBagConstraints.weightx = 1.0;
329: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
330: getContentPane().add(jScrollPane1, gridBagConstraints);
331:
332: jLabel5.setText("Special meaning properties");
333: gridBagConstraints = new java.awt.GridBagConstraints();
334: gridBagConstraints.gridx = 0;
335: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
336: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
337: getContentPane().add(jLabel5, gridBagConstraints);
338:
339: jScrollPane2.setPreferredSize(new java.awt.Dimension(200, 200));
340:
341: jList1.addMouseListener(new java.awt.event.MouseAdapter() {
342: public void mouseClicked(java.awt.event.MouseEvent evt) {
343: jList1MouseClicked(evt);
344: }
345: });
346: jScrollPane2.setViewportView(jList1);
347:
348: gridBagConstraints = new java.awt.GridBagConstraints();
349: gridBagConstraints.gridx = 0;
350: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
351: gridBagConstraints.weightx = 1.0;
352: gridBagConstraints.weighty = 1.0;
353: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
354: getContentPane().add(jScrollPane2, gridBagConstraints);
355:
356: jPanel1.setMinimumSize(new java.awt.Dimension(200, 35));
357: jPanel1.setPreferredSize(new java.awt.Dimension(250, 35));
358: jPanel1.setLayout(new java.awt.FlowLayout(
359: java.awt.FlowLayout.RIGHT));
360:
361: jButtonOK.setMnemonic('o');
362: jButtonOK.setText("OK");
363: jButtonOK
364: .addActionListener(new java.awt.event.ActionListener() {
365: public void actionPerformed(
366: java.awt.event.ActionEvent evt) {
367: jButtonOKActionPerformed(evt);
368: }
369: });
370: jPanel1.add(jButtonOK);
371:
372: jButtonCancel.setMnemonic('c');
373: jButtonCancel.setText("Cancel");
374: jButtonCancel
375: .addActionListener(new java.awt.event.ActionListener() {
376: public void actionPerformed(
377: java.awt.event.ActionEvent evt) {
378: jButtonCancelActionPerformed(evt);
379: }
380: });
381: jPanel1.add(jButtonCancel);
382:
383: gridBagConstraints = new java.awt.GridBagConstraints();
384: gridBagConstraints.gridx = 0;
385: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
386: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
387: getContentPane().add(jPanel1, gridBagConstraints);
388:
389: java.awt.Dimension screenSize = java.awt.Toolkit
390: .getDefaultToolkit().getScreenSize();
391: setBounds((screenSize.width - 515) / 2,
392: (screenSize.height - 358) / 2, 515, 358);
393: }// </editor-fold>//GEN-END:initComponents
394:
395: private void jButtonCancelActionPerformed(
396: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
397: setVisible(false);
398: this .setDialogResult(javax.swing.JOptionPane.CANCEL_OPTION);
399: dispose();
400: }//GEN-LAST:event_jButtonCancelActionPerformed
401:
402: private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
403:
404: if (this .jTextFieldName.getText().trim().length() <= 0) {
405: javax.swing.JOptionPane
406: .showMessageDialog(
407: this ,
408: I18n
409: .getString(
410: "messages.jRPropertyDialog.notValidName",
411: "Please insert a valid property name!"),
412: I18n
413: .getString(
414: "messages.jRPropertyDialog.notValidNameCaption",
415: "Invalid property!"),
416: javax.swing.JOptionPane.WARNING_MESSAGE);
417: return;
418: }
419:
420: tmpField = new JRProperty();
421: tmpField.setName(jTextFieldName.getText().trim());
422: tmpField.setValue(this .jTextAreaDescription.getText());
423:
424: setVisible(false);
425: this .setDialogResult(javax.swing.JOptionPane.OK_OPTION);
426: dispose();
427: }//GEN-LAST:event_jButtonOKActionPerformed
428:
429: /** Closes the dialog */
430: private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
431: setVisible(false);
432: this .setDialogResult(javax.swing.JOptionPane.CLOSED_OPTION);
433: dispose();
434: }//GEN-LAST:event_closeDialog
435:
436: private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
437:
438: if (evt.getClickCount() == 2
439: && SwingUtilities.isLeftMouseButton(evt)) {
440: if (jList1.getSelectedValue() != null
441: && jList1.getSelectedValue() instanceof PropertyHint) {
442: PropertyHint hint = (PropertyHint) jList1
443: .getSelectedValue();
444: jTextFieldName.setText(hint.getPropertyName());
445: }
446: }
447:
448: }//GEN-LAST:event_jList1MouseClicked
449:
450: /**
451: * @param args the command line arguments
452: */
453: public static void main(String args[]) {
454: new JRPropertyDialog(new javax.swing.JFrame(), true)
455: .setVisible(true);
456: }
457:
458: /** Getter for property tmpParameter.
459: * @return Value of property tmpParameter.
460: *
461: */
462: public it.businesslogic.ireport.JRProperty getProperty() {
463: return tmpField;
464: }
465:
466: /** Setter for property tmpParameter.
467: * @param tmpParameter New value of property tmpParameter.
468: *
469: */
470: public void setProperty(it.businesslogic.ireport.JRProperty tmpField) {
471: this .jTextFieldName.setText(new String(tmpField.getName()));
472: this .jTextAreaDescription.setText(new String(tmpField
473: .getValue()));
474: }
475:
476: /** Getter for property dialogResult.
477: * @return Value of property dialogResult.
478: *
479: */
480: public int getDialogResult() {
481: return dialogResult;
482: }
483:
484: /** Setter for property dialogResult.
485: * @param dialogResult New value of property dialogResult.
486: *
487: */
488: public void setDialogResult(int dialogResult) {
489: this .dialogResult = dialogResult;
490: }
491:
492: // Variables declaration - do not modify//GEN-BEGIN:variables
493: private javax.swing.JButton jButtonCancel;
494: private javax.swing.JButton jButtonOK;
495: private javax.swing.JLabel jLabel1;
496: private javax.swing.JLabel jLabel4;
497: private javax.swing.JLabel jLabel5;
498: private javax.swing.JList jList1;
499: private javax.swing.JPanel jPanel1;
500: private javax.swing.JScrollPane jScrollPane1;
501: private javax.swing.JScrollPane jScrollPane2;
502: private javax.swing.JTextArea jTextAreaDescription;
503: private javax.swing.JTextField jTextFieldName;
504: // End of variables declaration//GEN-END:variables
505:
506: private int dialogResult;
507:
508: public void applyI18n() {
509: // Start autogenerated code ----------------------
510: jButtonCancel.setText(I18n.getString(
511: "jRPropertyDialog.buttonCancel", "Cancel"));
512: jButtonOK.setText(I18n.getString("jRPropertyDialog.buttonOK",
513: "OK"));
514: jLabel1.setText(I18n.getString("jRPropertyDialog.label1",
515: "Property name"));
516: jLabel4.setText(I18n.getString("jRPropertyDialog.label4",
517: "Property value"));
518: // End autogenerated code ----------------------
519:
520: this .setTitle(I18n.getString("jRPropertyDialog.title",
521: "Add/modify property"));
522: jButtonCancel
523: .setMnemonic(I18n.getString(
524: "jRPropertyDialog.buttonCancelMnemonic", "c")
525: .charAt(0));
526: jButtonOK.setMnemonic(I18n.getString(
527: "jRPropertyDialog.buttonOKMnemonic", "o").charAt(0));
528: }
529: }
|