001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * HtmlStreamExportDialog.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.gui.html;
030:
031: import java.awt.BorderLayout;
032: import java.awt.Dialog;
033: import java.awt.Frame;
034: import java.awt.GridBagConstraints;
035: import java.awt.GridBagLayout;
036: import java.awt.Insets;
037: import java.awt.event.ActionEvent;
038: import java.io.File;
039: import java.text.MessageFormat;
040: import java.util.Locale;
041: import java.util.ResourceBundle;
042: import javax.swing.AbstractAction;
043: import javax.swing.Action;
044: import javax.swing.JCheckBox;
045: import javax.swing.JComboBox;
046: import javax.swing.JFileChooser;
047: import javax.swing.JLabel;
048: import javax.swing.JOptionPane;
049: import javax.swing.JPanel;
050: import javax.swing.JTabbedPane;
051: import javax.swing.JTextField;
052:
053: import org.jfree.fonts.encoding.EncodingRegistry;
054: import org.jfree.report.JFreeReportBoot;
055: import org.jfree.report.modules.gui.commonswing.AbstractExportDialog;
056: import org.jfree.report.modules.gui.commonswing.EncodingComboBoxModel;
057: import org.jfree.report.modules.gui.commonswing.JStatusBar;
058: import org.jfree.report.modules.gui.commonswing.StatusType;
059: import org.jfree.ui.FilesystemFilter;
060: import org.jfree.ui.action.ActionButton;
061: import org.jfree.util.Configuration;
062: import org.jfree.util.DefaultConfiguration;
063: import org.jfree.util.StringUtils;
064:
065: /**
066: * A dialog that is used to perform the printing of a report into an HTML file.
067: *
068: * @author Heiko Evermann
069: */
070: public class HtmlStreamExportDialog extends AbstractExportDialog {
071: /**
072: * The 'HTML encoding' property key.
073: */
074: public static final String HTML_OUTPUT_ENCODING = "org.jfree.report.modules.output.table.html.Encoding"; //$NON-NLS-1$
075: /**
076: * A default value of the 'HTML encoding' property key.
077: */
078: public static final String HTML_OUTPUT_ENCODING_DEFAULT = "UTF-16"; //$NON-NLS-1$
079:
080: /**
081: * An action to select the export target file.
082: */
083: private class ActionSelectDirFile extends AbstractAction {
084: /**
085: * Default constructor.
086: */
087: protected ActionSelectDirFile(final ResourceBundle resources) {
088: putValue(Action.NAME, resources
089: .getString("htmlexportdialog.selectFile")); //$NON-NLS-1$
090: }
091:
092: /**
093: * Receives notification that the action has occurred.
094: *
095: * @param e the action event.
096: */
097: public void actionPerformed(final ActionEvent e) {
098: performSelectFile();
099: }
100: }
101:
102: /**
103: * Filename text field.
104: */
105: private JTextField txFilename;
106:
107: /**
108: * Title text field.
109: */
110: private JTextField txTitle;
111:
112: /**
113: * Author text field.
114: */
115: private JTextField txAuthor;
116:
117: /**
118: * A combo-box for selecting the encoding.
119: */
120: private JComboBox cbEncoding;
121:
122: /**
123: * The encoding data model.
124: */
125: private EncodingComboBoxModel encodingModel;
126:
127: /**
128: * A check-box for selecting 'strict layout'.
129: */
130: private JCheckBox cbxStrictLayout;
131:
132: /**
133: * A check-box for...
134: */
135: private JCheckBox cbxCopyExternalReferences;
136:
137: /**
138: * A file chooser for directory and stream export.
139: */
140: private JFileChooser fileChooserHtml;
141:
142: public static final int EXPORT_STREAM = 0;
143: public static final int EXPORT_DIR = 1;
144: public static final int EXPORT_ZIP = 2;
145: private static final String HTML_FILE_EXTENSION = ".html"; //$NON-NLS-1$
146: private static final String HTM_FILE_EXTENSION = ".htm"; //$NON-NLS-1$
147: private JStatusBar statusBar;
148: private JTextField txDescription;
149: private JTextField txKeywords;
150:
151: /**
152: * Creates a new HTML save dialog.
153: *
154: * @param owner the dialog owner.
155: */
156: public HtmlStreamExportDialog(final Frame owner) {
157: super (owner);
158: initConstructor();
159: }
160:
161: /**
162: * Creates a new HTML export dialog.
163: *
164: * @param owner the dialog owner.
165: */
166: public HtmlStreamExportDialog(final Dialog owner) {
167: super (owner);
168: initConstructor();
169: }
170:
171: /**
172: * Creates a new HTML save dialog. The created dialog is modal.
173: */
174: public HtmlStreamExportDialog() {
175: initConstructor();
176: }
177:
178: /**
179: * Initialisation.
180: */
181: private void initConstructor() {
182: statusBar = new JStatusBar();
183:
184: setTitle(getResources().getString(
185: "htmlexportdialog.dialogtitle")); //$NON-NLS-1$
186: initialize();
187: clear();
188: }
189:
190: public JStatusBar getStatusBar() {
191: return statusBar;
192: }
193:
194: private JPanel createExportPanel() {
195: final JLabel lblDirFileName = new JLabel(getResources()
196: .getString("htmlexportdialog.filename")); //$NON-NLS-1$
197:
198: final JPanel contentPane = new JPanel();
199: contentPane.setLayout(new GridBagLayout());
200:
201: GridBagConstraints gbc = new GridBagConstraints();
202: gbc.fill = GridBagConstraints.NONE;
203: gbc.anchor = GridBagConstraints.WEST;
204: gbc.gridx = 0;
205: gbc.gridy = 1;
206: gbc.insets = new Insets(1, 1, 1, 5);
207: contentPane.add(lblDirFileName, gbc);
208:
209: gbc = new GridBagConstraints();
210: gbc.anchor = GridBagConstraints.WEST;
211: gbc.fill = GridBagConstraints.HORIZONTAL;
212: gbc.gridx = 1;
213: gbc.gridy = 1;
214: gbc.gridwidth = 1;
215: gbc.weightx = 1;
216: gbc.insets = new Insets(1, 1, 1, 1);
217: contentPane.add(txFilename, gbc);
218:
219: gbc = new GridBagConstraints();
220: gbc.anchor = GridBagConstraints.WEST;
221: gbc.fill = GridBagConstraints.HORIZONTAL;
222: gbc.gridx = 2;
223: gbc.gridy = 1;
224: contentPane.add(new ActionButton(new ActionSelectDirFile(
225: getResources())), gbc);
226:
227: final JPanel advancedOptionsPane = new JPanel();
228: advancedOptionsPane.setLayout(new BorderLayout());
229: advancedOptionsPane.add(contentPane, BorderLayout.NORTH);
230: return advancedOptionsPane;
231:
232: }
233:
234: private JPanel createExportOptionsPanel() {
235: final JLabel lblEncoding = new JLabel(getResources().getString(
236: "htmlexportdialog.encoding")); //$NON-NLS-1$
237: final JPanel contentPane = new JPanel();
238: contentPane.setLayout(new GridBagLayout());
239:
240: GridBagConstraints gbc = new GridBagConstraints();
241: gbc.anchor = GridBagConstraints.WEST;
242: gbc.fill = GridBagConstraints.NONE;
243: gbc.gridx = 1;
244: gbc.gridy = 2;
245: gbc.gridwidth = 1;
246: gbc.weightx = 1;
247: gbc.insets = new Insets(1, 1, 1, 1);
248: contentPane.add(cbxCopyExternalReferences, gbc);
249:
250: gbc = new GridBagConstraints();
251: gbc.anchor = GridBagConstraints.WEST;
252: gbc.gridx = 0;
253: gbc.gridy = 0;
254: gbc.insets = new Insets(1, 1, 1, 1);
255: contentPane.add(lblEncoding, gbc);
256:
257: gbc = new GridBagConstraints();
258: gbc.fill = GridBagConstraints.HORIZONTAL;
259: gbc.weightx = 1;
260: gbc.gridx = 1;
261: gbc.gridy = 0;
262: gbc.gridwidth = 2;
263: gbc.insets = new Insets(1, 1, 1, 1);
264: contentPane.add(cbEncoding, gbc);
265:
266: gbc = new GridBagConstraints();
267: gbc.anchor = GridBagConstraints.WEST;
268: gbc.fill = GridBagConstraints.HORIZONTAL;
269: gbc.gridx = 1;
270: gbc.gridy = 1;
271: gbc.gridwidth = 2;
272: gbc.insets = new Insets(1, 1, 1, 1);
273: contentPane.add(cbxStrictLayout, gbc);
274:
275: final JPanel advancedOptionsPane = new JPanel();
276: advancedOptionsPane.setLayout(new BorderLayout());
277: advancedOptionsPane.add(contentPane, BorderLayout.NORTH);
278: return advancedOptionsPane;
279: }
280:
281: private JPanel createMetaDataPanel() {
282: final JPanel contentPane = new JPanel();
283: contentPane.setLayout(new GridBagLayout());
284:
285: final JLabel lblAuthor = new JLabel(getResources().getString(
286: "htmlexportdialog.author")); //$NON-NLS-1$
287: final JLabel lblTitel = new JLabel(getResources().getString(
288: "htmlexportdialog.title")); //$NON-NLS-1$
289: final JLabel lblKeywords = new JLabel(getResources().getString(
290: "htmlexportdialog.keywords")); //$NON-NLS-1$
291: final JLabel lblDescription = new JLabel(getResources()
292: .getString("htmlexportdialog.description")); //$NON-NLS-1$
293:
294: GridBagConstraints gbc = new GridBagConstraints();
295: gbc.gridx = 0;
296: gbc.gridy = 0;
297: gbc.anchor = GridBagConstraints.WEST;
298: gbc.insets = new Insets(3, 1, 1, 1);
299: contentPane.add(lblTitel, gbc);
300:
301: gbc = new GridBagConstraints();
302: gbc.anchor = GridBagConstraints.WEST;
303: gbc.gridx = 0;
304: gbc.gridy = 1;
305: gbc.insets = new Insets(1, 1, 1, 1);
306: contentPane.add(lblAuthor, gbc);
307:
308: gbc = new GridBagConstraints();
309: gbc.anchor = GridBagConstraints.WEST;
310: gbc.gridx = 0;
311: gbc.gridy = 2;
312: gbc.insets = new Insets(1, 1, 1, 1);
313: contentPane.add(lblKeywords, gbc);
314:
315: gbc = new GridBagConstraints();
316: gbc.anchor = GridBagConstraints.WEST;
317: gbc.gridx = 0;
318: gbc.gridy = 3;
319: gbc.insets = new Insets(1, 1, 1, 1);
320: contentPane.add(lblDescription, gbc);
321:
322: gbc = new GridBagConstraints();
323: gbc.fill = GridBagConstraints.HORIZONTAL;
324: gbc.weightx = 1;
325: gbc.gridx = 1;
326: gbc.gridy = 0;
327: gbc.gridwidth = 2;
328: gbc.insets = new Insets(3, 1, 1, 1);
329: contentPane.add(txTitle, gbc);
330:
331: gbc = new GridBagConstraints();
332: gbc.fill = GridBagConstraints.HORIZONTAL;
333: gbc.weightx = 1;
334: gbc.gridx = 1;
335: gbc.gridy = 1;
336: gbc.gridwidth = 2;
337: gbc.insets = new Insets(1, 1, 1, 1);
338: contentPane.add(txAuthor, gbc);
339:
340: gbc = new GridBagConstraints();
341: gbc.fill = GridBagConstraints.HORIZONTAL;
342: gbc.weightx = 1;
343: gbc.gridx = 1;
344: gbc.gridy = 2;
345: gbc.gridwidth = 2;
346: gbc.insets = new Insets(1, 1, 1, 1);
347: contentPane.add(txKeywords, gbc);
348:
349: gbc = new GridBagConstraints();
350: gbc.fill = GridBagConstraints.HORIZONTAL;
351: gbc.weightx = 1;
352: gbc.gridx = 1;
353: gbc.gridy = 3;
354: gbc.gridwidth = 2;
355: gbc.insets = new Insets(1, 1, 1, 1);
356: contentPane.add(txDescription, gbc);
357:
358: final JPanel advancedOptionsPane = new JPanel();
359: advancedOptionsPane.setLayout(new BorderLayout());
360: advancedOptionsPane.add(contentPane, BorderLayout.NORTH);
361: return advancedOptionsPane;
362: }
363:
364: /**
365: * Initializes the Swing components of this dialog.
366: */
367: private void initialize() {
368: txAuthor = new JTextField();
369: txAuthor.setColumns(40);
370: txTitle = new JTextField();
371: txTitle.setColumns(40);
372: txKeywords = new JTextField();
373: txKeywords.setColumns(40);
374: txDescription = new JTextField();
375: txDescription.setColumns(40);
376: txFilename = new JTextField();
377: txFilename.setColumns(40);
378:
379: encodingModel = EncodingComboBoxModel.createDefaultModel(Locale
380: .getDefault());
381: encodingModel.sort();
382:
383: cbEncoding = new JComboBox(encodingModel);
384: cbxStrictLayout = new JCheckBox(getResources().getString(
385: "htmlexportdialog.strict-layout")); //$NON-NLS-1$
386: cbxCopyExternalReferences = new JCheckBox(getResources()
387: .getString("htmlexportdialog.copy-external-references")); //$NON-NLS-1$
388:
389: getFormValidator().registerButton(cbxStrictLayout);
390: getFormValidator().registerTextField(txFilename);
391: getFormValidator().registerComboBox(cbEncoding);
392:
393: final JPanel exportPane = createExportPanel();
394:
395: final Configuration config = JFreeReportBoot.getInstance()
396: .getGlobalConfig();
397: final boolean advancedSettingsTabAvail = "true"
398: .equals(config
399: .getConfigProperty("org.jfree.report.modules.gui.html.stream.AdvancedSettingsAvailable"));
400: final boolean metaDataSettingsTabAvail = "true"
401: .equals(config
402: .getConfigProperty("org.jfree.report.modules.gui.html.stream.MetaDataSettingsAvailable"));
403: if (advancedSettingsTabAvail || metaDataSettingsTabAvail) {
404: final JTabbedPane tabbedPane = new JTabbedPane();
405: tabbedPane.add(getResources().getString(
406: "htmlexportdialog.export-settings"), exportPane); //$NON-NLS-1$
407: if (metaDataSettingsTabAvail) {
408: tabbedPane
409: .add(
410: getResources()
411: .getString(
412: "htmlexportdialog.metadata-settings"), createMetaDataPanel()); //$NON-NLS-1$
413: }
414: if (advancedSettingsTabAvail) {
415: tabbedPane
416: .add(
417: getResources()
418: .getString(
419: "htmlexportdialog.advanced-settings"), createExportOptionsPanel()); //$NON-NLS-1$
420: }
421:
422: setContentPane(createContentPane(tabbedPane));
423: } else {
424: setContentPane(createContentPane(exportPane));
425: }
426:
427: }
428:
429: /**
430: * Returns the title of the HTML file.
431: *
432: * @return the title
433: */
434: public String getHTMLTitle() {
435: return txTitle.getText();
436: }
437:
438: /**
439: * Defines the title of the HTML file.
440: *
441: * @param title the title
442: */
443: public void setHTMLTitle(final String title) {
444: this .txTitle.setText(title);
445: }
446:
447: /**
448: * Gets the author of the dialog. This is not yet implemented in the HTML-Target.
449: *
450: * @return the name of the author of this report.
451: */
452: public String getAuthor() {
453: return txAuthor.getText();
454: }
455:
456: /**
457: * Defines the Author of the report. Any freeform text is valid. This defaults to the
458: * value of the systemProperty "user.name".
459: *
460: * @param author the name of the author.
461: */
462: public void setAuthor(final String author) {
463: this .txAuthor.setText(author);
464: }
465:
466: public void setKeywords(final String keywords) {
467: this .txKeywords.setText(keywords);
468: }
469:
470: public String getKeywords() {
471: return this .txKeywords.getText();
472: }
473:
474: public void setDescription(final String description) {
475: this .txDescription.setText(description);
476: }
477:
478: public String getDescription() {
479: return this .txDescription.getText();
480: }
481:
482: /**
483: * Clears all selections and input fields.
484: */
485: public void clear() {
486: txAuthor.setText(JFreeReportBoot.getInstance()
487: .getGlobalConfig().getConfigProperty("user.name", "")); //$NON-NLS-1$ //$NON-NLS-2$
488: txFilename.setText(""); //$NON-NLS-1$
489: txTitle.setText(""); //$NON-NLS-1$
490: txDescription.setText(""); //$NON-NLS-1$
491: txKeywords.setText(""); //$NON-NLS-1$
492: cbEncoding
493: .setSelectedIndex(encodingModel
494: .indexOf(EncodingRegistry
495: .getPlatformDefaultEncoding()));
496: cbxCopyExternalReferences.setSelected(false);
497: cbxStrictLayout.setSelected(false);
498: }
499:
500: /**
501: * Returns a new (and not connected to the default config from the job)
502: * configuration containing all properties from the dialog.
503: *
504: * @param full
505: * @return
506: */
507: protected Configuration grabDialogContents(final boolean full) {
508: final DefaultConfiguration p = new DefaultConfiguration();
509: if (full) {
510: p
511: .setProperty(
512: "org.jfree.report.modules.gui.html.stream.TargetFileName", getFilename()); //$NON-NLS-1$
513: }
514:
515: p
516: .setConfigProperty(
517: "org.jfree.report.modules.output.table.html.Keywords", getKeywords()); //$NON-NLS-1$
518: p
519: .setConfigProperty(
520: "org.jfree.report.modules.output.table.html.Description", getDescription()); //$NON-NLS-1$
521: p
522: .setConfigProperty(
523: "org.jfree.report.modules.output.table.html.Author", getAuthor()); //$NON-NLS-1$
524: p
525: .setConfigProperty(
526: "org.jfree.report.modules.output.table.html.Encoding", getEncoding()); //$NON-NLS-1$
527: p
528: .setConfigProperty(
529: "org.jfree.report.modules.output.table.html.Title", getHTMLTitle()); //$NON-NLS-1$
530: p
531: .setConfigProperty(
532: "org.jfree.report.modules.output.table.html.StrictLayout", String.valueOf(isStrictLayout())); //$NON-NLS-1$
533: return p;
534: }
535:
536: protected void setDialogContents(final Configuration p) {
537: setHTMLTitle(p.getConfigProperty(
538: "org.jfree.report.modules.output.table.html.Title", //$NON-NLS-1$
539: p.getConfigProperty("org.jfree.report.metadata.Title"))); //$NON-NLS-1$
540: setAuthor(p
541: .getConfigProperty(
542: "org.jfree.report.modules.output.table.html.Author", //$NON-NLS-1$
543: p
544: .getConfigProperty("org.jfree.report.metadata.Author"))); //$NON-NLS-1$
545: setKeywords(p
546: .getConfigProperty(
547: "org.jfree.report.modules.output.table.html.Keywords", //$NON-NLS-1$
548: p
549: .getConfigProperty("org.jfree.report.metadata.Keywords"))); //$NON-NLS-1$
550: setDescription(p
551: .getConfigProperty(
552: "org.jfree.report.modules.output.table.html.Description", //$NON-NLS-1$
553: p
554: .getConfigProperty("org.jfree.report.metadata.Description"))); //$NON-NLS-1$
555:
556: setStrictLayout("true".equals(p.getConfigProperty //$NON-NLS-1$
557: ("org.jfree.report.modules.output.table.html.StrictLayout"))); //$NON-NLS-1$
558:
559: final String encoding = p.getConfigProperty(
560: "org.jfree.report.modules.output.table.html.Encoding", //$NON-NLS-1$
561: EncodingRegistry.getPlatformDefaultEncoding());
562: encodingModel.ensureEncodingAvailable(encoding);
563: setEncoding(encoding);
564:
565: setFilename(p
566: .getConfigProperty(
567: "org.jfree.report.modules.gui.html.stream.TargetFileName", "")); //$NON-NLS-1$ //$NON-NLS-2$
568:
569: }
570:
571: /**
572: * Returns the directory file name.
573: *
574: * @return The directory file name.
575: */
576: public String getFilename() {
577: return txFilename.getText();
578: }
579:
580: /**
581: * Sets the directory file name.
582: *
583: * @param dirFilename the file name.
584: */
585: public void setFilename(final String dirFilename) {
586: this .txFilename.setText(dirFilename);
587: }
588:
589: /**
590: * Returns the setting of the 'strict layout' check-box.
591: *
592: * @return A boolean.
593: */
594: public boolean isStrictLayout() {
595: return cbxStrictLayout.isSelected();
596: }
597:
598: /**
599: * Sets the 'strict layout' check-box.
600: *
601: * @param s boolean.
602: */
603: public void setStrictLayout(final boolean s) {
604: cbxStrictLayout.setSelected(s);
605: }
606:
607: /**
608: * Returns the selected encoding.
609: *
610: * @return The encoding name.
611: */
612: public String getEncoding() {
613: if (cbEncoding.getSelectedIndex() == -1) {
614: return EncodingRegistry.getPlatformDefaultEncoding();
615: } else {
616: return encodingModel.getEncoding(cbEncoding
617: .getSelectedIndex());
618: }
619: }
620:
621: /**
622: * Sets the encoding.
623: *
624: * @param encoding the encoding name.
625: */
626: public void setEncoding(final String encoding) {
627: cbEncoding.setSelectedIndex(encodingModel.indexOf(encoding));
628: }
629:
630: /**
631: * Selects a file to use as target for the report processing.
632: */
633: protected void performSelectFile() {
634: final File file = new File(getFilename());
635:
636: if (fileChooserHtml == null) {
637: fileChooserHtml = new JFileChooser();
638: fileChooserHtml
639: .addChoosableFileFilter(new FilesystemFilter(
640: new String[] {
641: HtmlStreamExportDialog.HTML_FILE_EXTENSION,
642: HtmlStreamExportDialog.HTM_FILE_EXTENSION },
643: getResources().getString(
644: "htmlexportdialog.html-documents"), true)); //$NON-NLS-1$
645: fileChooserHtml.setMultiSelectionEnabled(false);
646: }
647:
648: fileChooserHtml.setCurrentDirectory(file);
649: fileChooserHtml.setSelectedFile(file);
650: final int option = fileChooserHtml.showSaveDialog(this );
651: if (option == JFileChooser.APPROVE_OPTION) {
652: final File selFile = fileChooserHtml.getSelectedFile();
653: String selFileName = selFile.getAbsolutePath();
654:
655: // Test if ends on html
656: if ((StringUtils.endsWithIgnoreCase(selFileName,
657: HtmlStreamExportDialog.HTML_FILE_EXTENSION) == false)
658: && (StringUtils.endsWithIgnoreCase(selFileName,
659: HtmlStreamExportDialog.HTM_FILE_EXTENSION) == false)) {
660: selFileName = selFileName
661: + HtmlStreamExportDialog.HTML_FILE_EXTENSION;
662: }
663: setFilename(selFileName);
664: }
665: }
666:
667: /**
668: * Validates the contents of the dialog's input fields. If the selected file exists, it
669: * is also checked for validity.
670: *
671: * @return true, if the input is valid, false otherwise
672: */
673: public boolean performValidate() {
674: getStatusBar().clear();
675:
676: final String filename = getFilename();
677: if (filename.trim().length() == 0) {
678: getStatusBar().setStatus(
679: StatusType.ERROR,
680: getResources().getString(
681: "htmlexportdialog.targetIsEmpty")); //$NON-NLS-1$
682: return false;
683: }
684: final File f = new File(filename);
685: if (f.exists()) {
686: if (f.isFile() == false) {
687: getStatusBar().setStatus(
688: StatusType.ERROR,
689: getResources().getString(
690: "htmlexportdialog.targetIsNoFile")); //$NON-NLS-1$
691: return false;
692: }
693: if (f.canWrite() == false) {
694: getStatusBar()
695: .setStatus(
696: StatusType.ERROR,
697: getResources()
698: .getString(
699: "htmlexportdialog.targetIsNotWritable")); //$NON-NLS-1$
700: return false;
701: }
702:
703: final String message = MessageFormat.format(getResources()
704: .getString("htmlexportdialog.targetExistsWarning"), //$NON-NLS-1$
705: new Object[] { filename });
706: getStatusBar().setStatus(StatusType.WARNING, message);
707: }
708:
709: return true;
710: }
711:
712: protected boolean performConfirm() {
713: final String filename = getFilename();
714: final File f = new File(filename).getAbsoluteFile();
715: if (f.exists()) {
716: final String key1 = "htmlexportdialog.targetOverwriteConfirmation"; //$NON-NLS-1$
717: final String key2 = "htmlexportdialog.targetOverwriteTitle"; //$NON-NLS-1$
718: if (JOptionPane.showConfirmDialog(this , MessageFormat
719: .format(getResources().getString(key1),
720: new Object[] { getFilename() }),
721: getResources().getString(key2),
722: JOptionPane.YES_NO_OPTION,
723: JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
724: return false;
725: }
726: }
727: return true;
728: }
729:
730: protected String getConfigurationSuffix() {
731: return "_html-stream-export"; //$NON-NLS-1$
732: }
733:
734: protected String getResourceBaseName() {
735: return HtmlZipExportPlugin.BASE_RESOURCE_CLASS;
736: }
737:
738: protected String getConfigurationPrefix() {
739: return "org.jfree.report.modules.gui.html.stream."; //$NON-NLS-1$
740: }
741: }
|