001: /*
002: * JRXMLDataSourceConnectionEditor.java
003: *
004: * Created on March 27, 2007, 11:57 AM
005: */
006:
007: package it.businesslogic.ireport.connection.gui;
008:
009: import it.businesslogic.ireport.IReportConnection;
010: import it.businesslogic.ireport.IReportConnectionEditor;
011: import it.businesslogic.ireport.connection.JRXMLDataSourceConnection;
012: import it.businesslogic.ireport.gui.FieldPatternDialog;
013: import it.businesslogic.ireport.gui.MainFrame;
014: import it.businesslogic.ireport.gui.locale.LocaleSelectorDialog;
015: import it.businesslogic.ireport.gui.locale.TimeZoneDialog;
016: import it.businesslogic.ireport.util.I18n;
017: import it.businesslogic.ireport.util.Misc;
018: import java.util.Locale;
019: import java.util.TimeZone;
020: import javax.swing.JDialog;
021: import javax.swing.JOptionPane;
022: import javax.swing.SwingUtilities;
023:
024: /**
025: *
026: * @author gtoffoli
027: */
028: public class JRXMLDataSourceConnectionEditor extends javax.swing.JPanel
029: implements IReportConnectionEditor {
030:
031: private IReportConnection iReportConnection = null;
032: private boolean init = false;
033: private Locale tmpXMLLocale = null;
034: private TimeZone tmpXMLTimeZone = null;
035:
036: /** Creates new form JRXMLDataSourceConnectionEditor */
037: public JRXMLDataSourceConnectionEditor() {
038: initComponents();
039: applyI18n();
040: }
041:
042: /** This method is called from within the constructor to
043: * initialize the form.
044: * WARNING: Do NOT modify this code. The content of this method is
045: * always regenerated by the Form Editor.
046: */
047: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
048: private void initComponents() {
049: java.awt.GridBagConstraints gridBagConstraints;
050:
051: buttonGroup1 = new javax.swing.ButtonGroup();
052: jPanelXML = new javax.swing.JPanel();
053: jLabel9 = new javax.swing.JLabel();
054: jTextFieldXMLFile = new javax.swing.JTextField();
055: jButton2 = new javax.swing.JButton();
056: jRadioButtonXML_connection = new javax.swing.JRadioButton();
057: jRadioButtonXML_datasource = new javax.swing.JRadioButton();
058: jPanel13 = new javax.swing.JPanel();
059: jLabelXMLRecordPath = new javax.swing.JLabel();
060: jTextFieldRecordPath = new javax.swing.JTextField();
061: jSeparator9 = new javax.swing.JSeparator();
062: jLabelXMLDatePattern = new javax.swing.JLabel();
063: jTextFieldXMLDatePattern = new javax.swing.JTextField();
064: jButtonXMLDatePattern = new javax.swing.JButton();
065: jLabelXMLNumberPattern = new javax.swing.JLabel();
066: jTextFieldXMLNumberPattern = new javax.swing.JTextField();
067: jButtonXMLNumberPattern = new javax.swing.JButton();
068: jPanel3 = new javax.swing.JPanel();
069: jLabelXMLLocale = new javax.swing.JLabel();
070: jTextFieldXMLLocaleValue = new javax.swing.JTextField();
071: jLabelXMLTimeZone = new javax.swing.JLabel();
072: jButtonXMLLocale = new javax.swing.JButton();
073: jTextFieldXMLTimeZoneValue = new javax.swing.JTextField();
074: jButtonXMLTimeZone = new javax.swing.JButton();
075:
076: setLayout(new java.awt.BorderLayout());
077:
078: jPanelXML.setLayout(new java.awt.GridBagLayout());
079:
080: jPanelXML.setPreferredSize(new java.awt.Dimension(1, 30));
081: jLabel9.setText("XML file");
082: jLabel9.setMinimumSize(new java.awt.Dimension(20, 14));
083: jLabel9.setPreferredSize(new java.awt.Dimension(20, 14));
084: gridBagConstraints = new java.awt.GridBagConstraints();
085: gridBagConstraints.gridx = 0;
086: gridBagConstraints.gridy = 0;
087: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
088: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
089: jPanelXML.add(jLabel9, gridBagConstraints);
090:
091: gridBagConstraints = new java.awt.GridBagConstraints();
092: gridBagConstraints.gridx = 1;
093: gridBagConstraints.gridy = 0;
094: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
095: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
096: gridBagConstraints.weightx = 1.0;
097: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
098: jPanelXML.add(jTextFieldXMLFile, gridBagConstraints);
099:
100: jButton2.setText("Browse");
101: jButton2.setMargin(new java.awt.Insets(2, 4, 2, 4));
102: jButton2.setMaximumSize(new java.awt.Dimension(100, 25));
103: jButton2.setMinimumSize(new java.awt.Dimension(70, 25));
104: jButton2.setPreferredSize(new java.awt.Dimension(70, 25));
105: jButton2.addActionListener(new java.awt.event.ActionListener() {
106: public void actionPerformed(java.awt.event.ActionEvent evt) {
107: jButton2ActionPerformed(evt);
108: }
109: });
110:
111: gridBagConstraints = new java.awt.GridBagConstraints();
112: gridBagConstraints.gridx = 2;
113: gridBagConstraints.gridy = 0;
114: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
115: gridBagConstraints.ipadx = 21;
116: gridBagConstraints.ipady = -3;
117: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 7);
118: jPanelXML.add(jButton2, gridBagConstraints);
119:
120: buttonGroup1.add(jRadioButtonXML_connection);
121: jRadioButtonXML_connection
122: .setText("Use the report XPath expression when filling the report");
123: jRadioButtonXML_connection.setBorder(javax.swing.BorderFactory
124: .createEmptyBorder(0, 0, 0, 0));
125: jRadioButtonXML_connection.setMargin(new java.awt.Insets(0, 0,
126: 0, 0));
127: jRadioButtonXML_connection
128: .addActionListener(new java.awt.event.ActionListener() {
129: public void actionPerformed(
130: java.awt.event.ActionEvent evt) {
131: jRadioButtonXML_connectionActionPerformed(evt);
132: }
133: });
134:
135: gridBagConstraints = new java.awt.GridBagConstraints();
136: gridBagConstraints.gridx = 0;
137: gridBagConstraints.gridwidth = 3;
138: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
139: gridBagConstraints.weightx = 1.0;
140: gridBagConstraints.insets = new java.awt.Insets(8, 4, 0, 4);
141: jPanelXML.add(jRadioButtonXML_connection, gridBagConstraints);
142:
143: buttonGroup1.add(jRadioButtonXML_datasource);
144: jRadioButtonXML_datasource.setSelected(true);
145: jRadioButtonXML_datasource
146: .setText("Create a datasource using this expression");
147: jRadioButtonXML_datasource
148: .setActionCommand("Create a datasource using the following expression");
149: jRadioButtonXML_datasource.setBorder(javax.swing.BorderFactory
150: .createEmptyBorder(0, 0, 0, 0));
151: jRadioButtonXML_datasource.setMargin(new java.awt.Insets(0, 0,
152: 0, 0));
153: jRadioButtonXML_datasource
154: .addActionListener(new java.awt.event.ActionListener() {
155: public void actionPerformed(
156: java.awt.event.ActionEvent evt) {
157: jRadioButtonXML_datasourceActionPerformed(evt);
158: }
159: });
160:
161: gridBagConstraints = new java.awt.GridBagConstraints();
162: gridBagConstraints.gridx = 0;
163: gridBagConstraints.gridwidth = 3;
164: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
165: gridBagConstraints.weightx = 1.0;
166: gridBagConstraints.insets = new java.awt.Insets(8, 4, 0, 4);
167: jPanelXML.add(jRadioButtonXML_datasource, gridBagConstraints);
168:
169: jPanel13.setLayout(new java.awt.GridBagLayout());
170:
171: jLabelXMLRecordPath.setText("Select Expression");
172: jLabelXMLRecordPath.setMaximumSize(new java.awt.Dimension(2000,
173: 14));
174: jLabelXMLRecordPath
175: .setMinimumSize(new java.awt.Dimension(2, 14));
176: jLabelXMLRecordPath.setPreferredSize(new java.awt.Dimension(60,
177: 14));
178: gridBagConstraints = new java.awt.GridBagConstraints();
179: gridBagConstraints.gridx = 0;
180: gridBagConstraints.gridy = 4;
181: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
182: gridBagConstraints.ipadx = 24;
183: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
184: jPanel13.add(jLabelXMLRecordPath, gridBagConstraints);
185:
186: gridBagConstraints = new java.awt.GridBagConstraints();
187: gridBagConstraints.gridx = 1;
188: gridBagConstraints.gridy = 4;
189: gridBagConstraints.gridwidth = 2;
190: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
191: gridBagConstraints.ipadx = 232;
192: gridBagConstraints.ipady = 1;
193: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
194: gridBagConstraints.weightx = 1.0;
195: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 7);
196: jPanel13.add(jTextFieldRecordPath, gridBagConstraints);
197:
198: gridBagConstraints = new java.awt.GridBagConstraints();
199: gridBagConstraints.gridx = 0;
200: gridBagConstraints.gridwidth = 3;
201: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
202: gridBagConstraints.weightx = 1.0;
203: gridBagConstraints.insets = new java.awt.Insets(0, 40, 0, 0);
204: jPanelXML.add(jPanel13, gridBagConstraints);
205:
206: jSeparator9.setPreferredSize(new java.awt.Dimension(2, 2));
207: gridBagConstraints = new java.awt.GridBagConstraints();
208: gridBagConstraints.gridx = 0;
209: gridBagConstraints.gridwidth = 4;
210: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
211: gridBagConstraints.insets = new java.awt.Insets(8, 4, 8, 4);
212: jPanelXML.add(jSeparator9, gridBagConstraints);
213:
214: jLabelXMLDatePattern.setText("Date pattern");
215: gridBagConstraints = new java.awt.GridBagConstraints();
216: gridBagConstraints.gridx = 0;
217: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
218: gridBagConstraints.ipadx = 24;
219: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
220: jPanelXML.add(jLabelXMLDatePattern, gridBagConstraints);
221:
222: gridBagConstraints = new java.awt.GridBagConstraints();
223: gridBagConstraints.gridx = 1;
224: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
225: gridBagConstraints.ipadx = 232;
226: gridBagConstraints.ipady = 1;
227: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
228: gridBagConstraints.weightx = 1.0;
229: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
230: jPanelXML.add(jTextFieldXMLDatePattern, gridBagConstraints);
231:
232: jButtonXMLDatePattern.setText("Create");
233: jButtonXMLDatePattern
234: .setMargin(new java.awt.Insets(2, 4, 2, 4));
235: jButtonXMLDatePattern.setMaximumSize(new java.awt.Dimension(
236: 100, 25));
237: jButtonXMLDatePattern.setMinimumSize(new java.awt.Dimension(70,
238: 25));
239: jButtonXMLDatePattern.setPreferredSize(new java.awt.Dimension(
240: 70, 25));
241: jButtonXMLDatePattern
242: .addActionListener(new java.awt.event.ActionListener() {
243: public void actionPerformed(
244: java.awt.event.ActionEvent evt) {
245: jButton2ActionPerformed1(evt);
246: }
247: });
248:
249: gridBagConstraints = new java.awt.GridBagConstraints();
250: gridBagConstraints.gridx = 2;
251: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
252: gridBagConstraints.ipadx = 21;
253: gridBagConstraints.ipady = -3;
254: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 7);
255: jPanelXML.add(jButtonXMLDatePattern, gridBagConstraints);
256:
257: jLabelXMLNumberPattern.setText("Number pattern");
258: gridBagConstraints = new java.awt.GridBagConstraints();
259: gridBagConstraints.gridx = 0;
260: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
261: gridBagConstraints.ipadx = 24;
262: gridBagConstraints.insets = new java.awt.Insets(1, 3, 3, 3);
263: jPanelXML.add(jLabelXMLNumberPattern, gridBagConstraints);
264:
265: gridBagConstraints = new java.awt.GridBagConstraints();
266: gridBagConstraints.gridx = 1;
267: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
268: gridBagConstraints.ipadx = 232;
269: gridBagConstraints.ipady = 1;
270: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
271: gridBagConstraints.weightx = 1.0;
272: gridBagConstraints.insets = new java.awt.Insets(1, 3, 3, 3);
273: jPanelXML.add(jTextFieldXMLNumberPattern, gridBagConstraints);
274:
275: jButtonXMLNumberPattern.setText("Create");
276: jButtonXMLNumberPattern.setMargin(new java.awt.Insets(2, 4, 2,
277: 4));
278: jButtonXMLNumberPattern.setMaximumSize(new java.awt.Dimension(
279: 100, 25));
280: jButtonXMLNumberPattern.setMinimumSize(new java.awt.Dimension(
281: 70, 25));
282: jButtonXMLNumberPattern
283: .setPreferredSize(new java.awt.Dimension(70, 25));
284: jButtonXMLNumberPattern
285: .addActionListener(new java.awt.event.ActionListener() {
286: public void actionPerformed(
287: java.awt.event.ActionEvent evt) {
288: jButtonXMLDatePatternjButton2ActionPerformed1(evt);
289: }
290: });
291:
292: gridBagConstraints = new java.awt.GridBagConstraints();
293: gridBagConstraints.gridx = 2;
294: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
295: gridBagConstraints.ipadx = 21;
296: gridBagConstraints.ipady = -3;
297: gridBagConstraints.insets = new java.awt.Insets(1, 3, 3, 7);
298: jPanelXML.add(jButtonXMLNumberPattern, gridBagConstraints);
299:
300: jPanel3.setLayout(new java.awt.GridBagLayout());
301:
302: jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
303: javax.swing.BorderFactory.createEtchedBorder(),
304: "Locale / Time zone"));
305: jLabelXMLLocale.setText("Locale");
306: gridBagConstraints = new java.awt.GridBagConstraints();
307: gridBagConstraints.gridx = 0;
308: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
309: gridBagConstraints.ipadx = 24;
310: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
311: jPanel3.add(jLabelXMLLocale, gridBagConstraints);
312:
313: jTextFieldXMLLocaleValue.setEditable(false);
314: jTextFieldXMLLocaleValue.setText("Default");
315: gridBagConstraints = new java.awt.GridBagConstraints();
316: gridBagConstraints.gridx = 1;
317: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
318: gridBagConstraints.ipadx = 232;
319: gridBagConstraints.ipady = 1;
320: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
321: gridBagConstraints.weightx = 1.0;
322: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4);
323: jPanel3.add(jTextFieldXMLLocaleValue, gridBagConstraints);
324:
325: jLabelXMLTimeZone.setText("Time zone");
326: gridBagConstraints = new java.awt.GridBagConstraints();
327: gridBagConstraints.gridx = 0;
328: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
329: gridBagConstraints.ipadx = 24;
330: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
331: jPanel3.add(jLabelXMLTimeZone, gridBagConstraints);
332:
333: jButtonXMLLocale.setText("Select...");
334: jButtonXMLLocale.setMargin(new java.awt.Insets(2, 4, 2, 4));
335: jButtonXMLLocale
336: .setMaximumSize(new java.awt.Dimension(100, 25));
337: jButtonXMLLocale.setMinimumSize(new java.awt.Dimension(70, 25));
338: jButtonXMLLocale
339: .setPreferredSize(new java.awt.Dimension(70, 25));
340: jButtonXMLLocale
341: .addActionListener(new java.awt.event.ActionListener() {
342: public void actionPerformed(
343: java.awt.event.ActionEvent evt) {
344: jButtonXMLDatePatternjButton2ActionPerformed11(evt);
345: }
346: });
347:
348: gridBagConstraints = new java.awt.GridBagConstraints();
349: gridBagConstraints.gridx = 2;
350: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
351: gridBagConstraints.ipadx = 21;
352: gridBagConstraints.ipady = -3;
353: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 8);
354: jPanel3.add(jButtonXMLLocale, gridBagConstraints);
355:
356: jTextFieldXMLTimeZoneValue.setEditable(false);
357: jTextFieldXMLTimeZoneValue.setText("Default");
358: gridBagConstraints = new java.awt.GridBagConstraints();
359: gridBagConstraints.gridx = 1;
360: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
361: gridBagConstraints.ipadx = 232;
362: gridBagConstraints.ipady = 1;
363: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
364: gridBagConstraints.weightx = 1.0;
365: gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 4);
366: jPanel3.add(jTextFieldXMLTimeZoneValue, gridBagConstraints);
367:
368: jButtonXMLTimeZone.setText("Select...");
369: jButtonXMLTimeZone.setMargin(new java.awt.Insets(2, 4, 2, 4));
370: jButtonXMLTimeZone.setMaximumSize(new java.awt.Dimension(100,
371: 25));
372: jButtonXMLTimeZone
373: .setMinimumSize(new java.awt.Dimension(70, 25));
374: jButtonXMLTimeZone.setPreferredSize(new java.awt.Dimension(70,
375: 25));
376: jButtonXMLTimeZone
377: .addActionListener(new java.awt.event.ActionListener() {
378: public void actionPerformed(
379: java.awt.event.ActionEvent evt) {
380: jButtonXMLDatePattern1jButtonXMLDatePatternjButton2ActionPerformed11(evt);
381: }
382: });
383:
384: gridBagConstraints = new java.awt.GridBagConstraints();
385: gridBagConstraints.gridx = 2;
386: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
387: gridBagConstraints.ipadx = 21;
388: gridBagConstraints.ipady = -3;
389: gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 8);
390: jPanel3.add(jButtonXMLTimeZone, gridBagConstraints);
391:
392: gridBagConstraints = new java.awt.GridBagConstraints();
393: gridBagConstraints.gridx = 0;
394: gridBagConstraints.gridwidth = 3;
395: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
396: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
397: gridBagConstraints.weightx = 1.0;
398: gridBagConstraints.weighty = 1.0;
399: gridBagConstraints.insets = new java.awt.Insets(4, 3, 0, 4);
400: jPanelXML.add(jPanel3, gridBagConstraints);
401:
402: add(jPanelXML, java.awt.BorderLayout.CENTER);
403:
404: }// </editor-fold>//GEN-END:initComponents
405:
406: private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
407: String fileName = "";
408: javax.swing.JFileChooser jfc = new javax.swing.JFileChooser(
409: MainFrame.getMainInstance().getCurrentDirectory());
410:
411: jfc.setDialogTitle("Select XML file....");
412:
413: jfc
414: .addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {
415: public boolean accept(java.io.File file) {
416: String filename = file.getName();
417: return (filename.toLowerCase().endsWith(".xml") || file
418: .isDirectory());
419: }
420:
421: public String getDescription() {
422: return "XML *.xml";
423: }
424: });
425:
426: jfc.setMultiSelectionEnabled(false);
427: jfc.setDialogType(javax.swing.JFileChooser.OPEN_DIALOG);
428: if (jfc.showOpenDialog(this ) == javax.swing.JOptionPane.OK_OPTION) {
429: java.io.File file = jfc.getSelectedFile();
430: try {
431: jTextFieldXMLFile.setText(file.getAbsolutePath());
432: } catch (Exception ex) {
433: }
434: }
435:
436: }
437:
438: private void jRadioButtonXML_connectionActionPerformed(
439: java.awt.event.ActionEvent evt) {
440:
441: XMLDataSourceCheckBoxesChanged();
442:
443: }
444:
445: private void jRadioButtonXML_datasourceActionPerformed(
446: java.awt.event.ActionEvent evt) {
447: XMLDataSourceCheckBoxesChanged();
448: }
449:
450: public void XMLDataSourceCheckBoxesChanged() {
451: jTextFieldRecordPath.setEnabled(jRadioButtonXML_datasource
452: .isSelected());
453: jLabelXMLRecordPath.setEnabled(jRadioButtonXML_datasource
454: .isSelected());
455: }
456:
457: private void jButtonXMLDatePattern1jButtonXMLDatePatternjButton2ActionPerformed11(
458: java.awt.event.ActionEvent evt) {
459:
460: TimeZoneDialog lsd = new TimeZoneDialog(
461: (JDialog) SwingUtilities.getWindowAncestor(this ), true);
462: if (this .tmpXMLTimeZone != null) {
463: lsd.setReportTimeZoneId(tmpXMLTimeZone.getID());
464: }
465:
466: lsd.setVisible(true);
467:
468: if (lsd.getDialogResult() == JOptionPane.OK_OPTION) {
469: if (lsd.getReportTimeZoneId() == null) {
470: tmpXMLTimeZone = null;
471: jTextFieldXMLTimeZoneValue.setText(I18n.getString(
472: "timezone.default", "Default"));
473: } else {
474: tmpXMLTimeZone = TimeZone.getTimeZone(lsd
475: .getReportTimeZoneId());
476: jTextFieldXMLTimeZoneValue.setText(tmpXMLTimeZone
477: .getDisplayName(I18n.getCurrentLocale()));
478: }
479: }
480: }
481:
482: private void jButtonXMLDatePatternjButton2ActionPerformed11(
483: java.awt.event.ActionEvent evt) {
484:
485: LocaleSelectorDialog lsd = new LocaleSelectorDialog(
486: (JDialog) SwingUtilities.getWindowAncestor(this ), true);
487: if (this .tmpXMLLocale != null) {
488: lsd.setSelectedLocale(this .tmpXMLLocale);
489: }
490:
491: lsd.setVisible(true);
492:
493: if (lsd.getDialogResult() == JOptionPane.OK_OPTION) {
494: tmpXMLLocale = lsd.getSelectedLocale();
495: jTextFieldXMLLocaleValue
496: .setText((tmpXMLLocale == null) ? I18n.getString(
497: "timezone.default", "Default")
498: : tmpXMLLocale.getDisplayName(I18n
499: .getCurrentLocale()));
500: }
501:
502: }
503:
504: private void jButtonXMLDatePatternjButton2ActionPerformed1(
505: java.awt.event.ActionEvent evt) {
506:
507: FieldPatternDialog fpd = new FieldPatternDialog(
508: (JDialog) SwingUtilities.getWindowAncestor(this ), true);
509: fpd.setOnlyNumbers(true);
510: if (jTextFieldXMLNumberPattern.getText().length() > 0) {
511: fpd.setPattern(jTextFieldXMLNumberPattern.getText());
512: }
513:
514: fpd.setVisible(true);
515:
516: if (fpd.getDialogResult() == JOptionPane.OK_OPTION) {
517: jTextFieldXMLNumberPattern.setText(fpd.getPattern());
518: }
519:
520: }
521:
522: private void jButton2ActionPerformed1(java.awt.event.ActionEvent evt) {
523:
524: FieldPatternDialog fpd = new FieldPatternDialog(
525: (JDialog) SwingUtilities.getWindowAncestor(this ), true);
526: fpd.setOnlyDate(true);
527: if (jTextFieldXMLDatePattern.getText().length() > 0) {
528: fpd.setPattern(jTextFieldXMLDatePattern.getText());
529: }
530:
531: fpd.setVisible(true);
532:
533: if (fpd.getDialogResult() == JOptionPane.OK_OPTION) {
534: jTextFieldXMLDatePattern.setText(fpd.getPattern());
535: }
536: }
537:
538: public void setIReportConnection(IReportConnection c) {
539:
540: this .iReportConnection = c;
541: if (iReportConnection instanceof JRXMLDataSourceConnection) {
542: JRXMLDataSourceConnection con = (JRXMLDataSourceConnection) iReportConnection;
543: this .jTextFieldXMLFile.setText(con.getFilename());
544: this .jTextFieldRecordPath
545: .setText(con.getSelectExpression());
546: this .jRadioButtonXML_connection.setSelected(con
547: .isUseConnection());
548: this .jRadioButtonXML_datasource.setSelected(!con
549: .isUseConnection());
550:
551: this .jTextFieldXMLDatePattern.setText(Misc.nvl(con
552: .getDatePattern(), ""));
553: this .jTextFieldXMLNumberPattern.setText(Misc.nvl(con
554: .getNumberPattern(), ""));
555:
556: this .tmpXMLLocale = con.getLocale();
557: if (this .tmpXMLLocale != null) {
558: jTextFieldXMLLocaleValue.setText(this .tmpXMLLocale
559: .getDisplayName(I18n.getCurrentLocale()));
560: } else {
561: jTextFieldXMLLocaleValue.setText(I18n.getString(
562: "timezone.default", "Default"));
563: }
564:
565: this .tmpXMLTimeZone = con.getTimeZone();
566: if (this .tmpXMLLocale != null) {
567: jTextFieldXMLTimeZoneValue.setText(tmpXMLTimeZone
568: .getDisplayName(I18n.getCurrentLocale()));
569: } else {
570: jTextFieldXMLTimeZoneValue.setText(I18n.getString(
571: "timezone.default", "Default"));
572: }
573:
574: XMLDataSourceCheckBoxesChanged();
575: }
576: }
577:
578: public IReportConnection getIReportConnection() {
579:
580: IReportConnection irConn = new JRXMLDataSourceConnection();
581: ((JRXMLDataSourceConnection) irConn)
582: .setFilename(this .jTextFieldXMLFile.getText().trim());
583: ((JRXMLDataSourceConnection) irConn)
584: .setSelectExpression(this .jTextFieldRecordPath
585: .getText().trim());
586: ((JRXMLDataSourceConnection) irConn)
587: .setUseConnection(jRadioButtonXML_connection
588: .isSelected());
589:
590: ((JRXMLDataSourceConnection) irConn)
591: .setDatePattern(jTextFieldXMLDatePattern.getText());
592: ((JRXMLDataSourceConnection) irConn)
593: .setNumberPattern(jTextFieldXMLNumberPattern.getText());
594: ((JRXMLDataSourceConnection) irConn)
595: .setLocale(this .tmpXMLLocale);
596: ((JRXMLDataSourceConnection) irConn)
597: .setTimeZone(this .tmpXMLTimeZone);
598:
599: iReportConnection = irConn;
600: return iReportConnection;
601: }
602:
603: public void applyI18n() {
604: // Start autogenerated code ----------------------
605: jRadioButtonXML_connection
606: .setText(I18n
607: .getString(
608: "connectionDialog.radioButtonXML_connection",
609: "Use the report XPath expression when filling the report"));
610: jRadioButtonXML_datasource.setText(I18n.getString(
611: "connectionDialog.radioButtonXML_datasource",
612: "Create a datasource using this expression"));
613: // End autogenerated code ----------------------
614: // Start autogenerated code ----------------------
615: jButton2.setText(I18n.getString("connectionDialog.button2",
616: "Browse"));
617: jLabel9.setText(I18n.getString("connectionDialog.label9",
618: "XML file"));
619: jLabelXMLRecordPath.setText(I18n.getString(
620: "connectionDialog.labelXMLRecordPath",
621: "Select Expression"));
622: // End autogenerated code ----------------------
623:
624: jTextFieldXMLTimeZoneValue.setText(I18n.getString(
625: "timezone.default", "Default"));
626: jTextFieldXMLLocaleValue.setText(I18n.getString(
627: "timezone.default", "Default"));
628:
629: ((javax.swing.border.TitledBorder) jPanel3.getBorder())
630: .setTitle(it.businesslogic.ireport.util.I18n.getString(
631: "connectionDialog.borderXMLLocaleTimeZone",
632: "Locale / Time zone"));
633:
634: jLabelXMLLocale.setText(I18n.getString(
635: "connectionDialog.labelXMLLocale", "Locale"));
636: jLabelXMLTimeZone.setText(I18n.getString(
637: "connectionDialog.labelXMLTimeZone", "Time zone"));
638: jLabelXMLDatePattern
639: .setText(I18n.getString(
640: "connectionDialog.labelXMLDatePattern",
641: "Date pattern"));
642: jLabelXMLNumberPattern.setText(I18n.getString(
643: "connectionDialog.labelXMLNumberPattern",
644: "Number pattern"));
645: jButtonXMLDatePattern.setText(I18n.getString(
646: "connectionDialog.buttonXMLDatePattern", "Create..."));
647: jButtonXMLNumberPattern
648: .setText(I18n.getString(
649: "connectionDialog.buttonXMLNumberPattern",
650: "Create..."));
651: jButtonXMLLocale.setText(I18n.getString(
652: "connectionDialog.buttonXMLLocale", "Select..."));
653: jButtonXMLTimeZone.setText(I18n.getString(
654: "connectionDialog.buttonXMLTimeZone", "Select..."));
655: }
656:
657: // Variables declaration - do not modify//GEN-BEGIN:variables
658: private javax.swing.ButtonGroup buttonGroup1;
659: private javax.swing.JButton jButton2;
660: private javax.swing.JButton jButtonXMLDatePattern;
661: private javax.swing.JButton jButtonXMLLocale;
662: private javax.swing.JButton jButtonXMLNumberPattern;
663: private javax.swing.JButton jButtonXMLTimeZone;
664: private javax.swing.JLabel jLabel9;
665: private javax.swing.JLabel jLabelXMLDatePattern;
666: private javax.swing.JLabel jLabelXMLLocale;
667: private javax.swing.JLabel jLabelXMLNumberPattern;
668: private javax.swing.JLabel jLabelXMLRecordPath;
669: private javax.swing.JLabel jLabelXMLTimeZone;
670: private javax.swing.JPanel jPanel13;
671: private javax.swing.JPanel jPanel3;
672: private javax.swing.JPanel jPanelXML;
673: private javax.swing.JRadioButton jRadioButtonXML_connection;
674: private javax.swing.JRadioButton jRadioButtonXML_datasource;
675: private javax.swing.JSeparator jSeparator9;
676: private javax.swing.JTextField jTextFieldRecordPath;
677: private javax.swing.JTextField jTextFieldXMLDatePattern;
678: private javax.swing.JTextField jTextFieldXMLFile;
679: private javax.swing.JTextField jTextFieldXMLLocaleValue;
680: private javax.swing.JTextField jTextFieldXMLNumberPattern;
681: private javax.swing.JTextField jTextFieldXMLTimeZoneValue;
682: // End of variables declaration//GEN-END:variables
683:
684: }
|