Source Code Cross Referenced for PdfExportDialog.java in  » Report » pentaho-report » org » jfree » report » modules » gui » pdf » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » pentaho report » org.jfree.report.modules.gui.pdf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * ===========================================
0003:         * JFreeReport : a free Java reporting library
0004:         * ===========================================
0005:         *
0006:         * Project Info:  http://reporting.pentaho.org/
0007:         *
0008:         * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
0009:         *
0010:         * This library is free software; you can redistribute it and/or modify it under the terms
0011:         * of the GNU Lesser General Public License as published by the Free Software Foundation;
0012:         * either version 2.1 of the License, or (at your option) any later version.
0013:         *
0014:         * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
0015:         * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0016:         * See the GNU Lesser General Public License for more details.
0017:         *
0018:         * You should have received a copy of the GNU Lesser General Public License along with this
0019:         * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
0020:         * Boston, MA 02111-1307, USA.
0021:         *
0022:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
0023:         * in the United States and other countries.]
0024:         *
0025:         * ------------
0026:         * PdfExportDialog.java
0027:         * ------------
0028:         * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
0029:         */package org.jfree.report.modules.gui.pdf;
0030:
0031:        import java.awt.BorderLayout;
0032:        import java.awt.Dialog;
0033:        import java.awt.Frame;
0034:        import java.awt.GridBagConstraints;
0035:        import java.awt.GridBagLayout;
0036:        import java.awt.GridLayout;
0037:        import java.awt.Insets;
0038:        import java.awt.event.ActionEvent;
0039:        import java.io.File;
0040:        import java.text.MessageFormat;
0041:        import java.util.Locale;
0042:        import java.util.ResourceBundle;
0043:        import javax.swing.AbstractAction;
0044:        import javax.swing.Action;
0045:        import javax.swing.BorderFactory;
0046:        import javax.swing.ButtonGroup;
0047:        import javax.swing.DefaultComboBoxModel;
0048:        import javax.swing.JButton;
0049:        import javax.swing.JCheckBox;
0050:        import javax.swing.JComboBox;
0051:        import javax.swing.JFileChooser;
0052:        import javax.swing.JLabel;
0053:        import javax.swing.JOptionPane;
0054:        import javax.swing.JPanel;
0055:        import javax.swing.JPasswordField;
0056:        import javax.swing.JRadioButton;
0057:        import javax.swing.JTabbedPane;
0058:        import javax.swing.JTextField;
0059:
0060:        import org.jfree.fonts.encoding.EncodingRegistry;
0061:        import org.jfree.report.JFreeReport;
0062:        import org.jfree.report.JFreeReportBoot;
0063:        import org.jfree.report.modules.gui.common.GuiContext;
0064:        import org.jfree.report.modules.gui.commonswing.AbstractExportDialog;
0065:        import org.jfree.report.modules.gui.commonswing.EncodingComboBoxModel;
0066:        import org.jfree.report.modules.gui.commonswing.JStatusBar;
0067:        import org.jfree.report.modules.gui.commonswing.StatusType;
0068:        import org.jfree.ui.FilesystemFilter;
0069:        import org.jfree.ui.action.ActionButton;
0070:        import org.jfree.util.Configuration;
0071:        import org.jfree.util.DefaultConfiguration;
0072:        import org.jfree.util.Log;
0073:
0074:        /**
0075:         * Creation-Date: 02.12.2006, 15:27:30
0076:         *
0077:         * @author Thomas Morgner
0078:         */
0079:        public class PdfExportDialog extends AbstractExportDialog {
0080:            /** Useful constant. */
0081:            private static final int CBMODEL_NOPRINTING = 0;
0082:
0083:            /** Useful constant. */
0084:            private static final int CBMODEL_DEGRADED = 1;
0085:
0086:            /** Useful constant. */
0087:            private static final int CBMODEL_FULL = 2;
0088:
0089:            /**
0090:             * Internal action class to enable/disable the Security-Settings panel.
0091:             * Without encryption a pdf file cannot have any security settings enabled.
0092:             */
0093:            private class ActionSecuritySelection extends AbstractAction {
0094:                /** Default constructor. */
0095:                protected ActionSecuritySelection() {
0096:                }
0097:
0098:                /**
0099:                 * Receives notification that the action has occurred.
0100:                 *
0101:                 * @param e the action event.
0102:                 */
0103:                public void actionPerformed(final ActionEvent e) {
0104:                    updateSecurityPanelEnabled();
0105:                }
0106:            }
0107:
0108:            /** Internal action class to select a target file. */
0109:            private class ActionSelectFile extends AbstractAction {
0110:                /** Default constructor. */
0111:                protected ActionSelectFile(final ResourceBundle resources) {
0112:                    putValue(Action.NAME, resources
0113:                            .getString("pdfsavedialog.selectFile")); //$NON-NLS-1$
0114:                }
0115:
0116:                /**
0117:                 * Receives notification that the action has occurred.
0118:                 *
0119:                 * @param e the action event.
0120:                 */
0121:                public void actionPerformed(final ActionEvent e) {
0122:                    performSelectFile();
0123:                }
0124:            }
0125:
0126:            /** Security (none) radio button. */
0127:            private JRadioButton rbSecurityNone;
0128:
0129:            /** Security (40 bit) radio button. */
0130:            private JRadioButton rbSecurity40Bit;
0131:
0132:            /** Security (128 bit) radio button. */
0133:            private JRadioButton rbSecurity128Bit;
0134:
0135:            /** User password text field. */
0136:            private JTextField txUserPassword;
0137:
0138:            /** Owner password text field. */
0139:            private JTextField txOwnerPassword;
0140:
0141:            /** Confirm user password text field. */
0142:            private JTextField txConfUserPassword;
0143:
0144:            /** Confirm ownder password text field. */
0145:            private JTextField txConfOwnerPassword;
0146:
0147:            /** Allow copy check box. */
0148:            private JCheckBox cxAllowCopy;
0149:
0150:            /** Allow screen readers check box. */
0151:            private JCheckBox cxAllowScreenReaders;
0152:
0153:            /** Allow printing check box. */
0154:            private JComboBox cbAllowPrinting;
0155:
0156:            /** Allow assembly check box. */
0157:            private JCheckBox cxAllowAssembly;
0158:
0159:            /** Allow modify contents check box. */
0160:            private JCheckBox cxAllowModifyContents;
0161:
0162:            /** Allow modify annotations check box. */
0163:            private JCheckBox cxAllowModifyAnnotations;
0164:
0165:            /** Allow fill in check box. */
0166:            private JCheckBox cxAllowFillIn;
0167:
0168:            /** A model for the available encodings. */
0169:            private EncodingComboBoxModel encodingModel;
0170:
0171:            /** A file chooser. */
0172:            private JFileChooser fileChooser;
0173:
0174:            /**
0175:             * Title text field.
0176:             */
0177:            private JTextField txTitle;
0178:
0179:            /**
0180:             * Author text field.
0181:             */
0182:            private JTextField txAuthor;
0183:
0184:            private static final String PDF_FILE_EXTENSION = ".pdf"; //$NON-NLS-1$
0185:            private JStatusBar statusBar;
0186:            private JTextField txFilename;
0187:            private DefaultComboBoxModel printingModel;
0188:            private JComboBox cbEncoding;
0189:            private JCheckBox cxEmbedded;
0190:            private JTextField txKeywords;
0191:            private JTextField txDescription;
0192:
0193:            /**
0194:             * Creates a non-modal dialog without a title and without a specified
0195:             * <code>Frame</code> owner.  A shared, hidden frame will be set as the owner
0196:             * of the dialog.
0197:             */
0198:            public PdfExportDialog() {
0199:                initializeComponents();
0200:            }
0201:
0202:            /**
0203:             * Creates a non-modal dialog without a title with the specified
0204:             * <code>Frame</code> as its owner.  If <code>owner</code> is
0205:             * <code>null</code>, a shared, hidden frame will be set as the owner of the
0206:             * dialog.
0207:             *
0208:             * @param owner the <code>Frame</code> from which the dialog is displayed
0209:             */
0210:            public PdfExportDialog(final Frame owner) {
0211:                super (owner);
0212:                initializeComponents();
0213:            }
0214:
0215:            /**
0216:             * Creates a non-modal dialog without a title with the specified
0217:             * <code>Dialog</code> as its owner.
0218:             *
0219:             * @param owner the non-null <code>Dialog</code> from which the dialog is
0220:             *              displayed
0221:             */
0222:            public PdfExportDialog(final Dialog owner) {
0223:                super (owner);
0224:                initializeComponents();
0225:            }
0226:
0227:            private JPanel createMetaDataPanel() {
0228:                final JPanel contentPane = new JPanel();
0229:                contentPane.setLayout(new GridBagLayout());
0230:
0231:                final JLabel lblAuthor = new JLabel(getResources().getString(
0232:                        "pdfsavedialog.author")); //$NON-NLS-1$
0233:                final JLabel lblTitel = new JLabel(getResources().getString(
0234:                        "pdfsavedialog.title")); //$NON-NLS-1$
0235:                final JLabel lblKeywords = new JLabel(getResources().getString(
0236:                        "pdfsavedialog.keywords")); //$NON-NLS-1$
0237:                final JLabel lblDescription = new JLabel(getResources()
0238:                        .getString("pdfsavedialog.description")); //$NON-NLS-1$
0239:
0240:                GridBagConstraints gbc = new GridBagConstraints();
0241:                gbc.gridx = 0;
0242:                gbc.gridy = 0;
0243:                gbc.anchor = GridBagConstraints.WEST;
0244:                gbc.insets = new Insets(3, 1, 1, 1);
0245:                contentPane.add(lblTitel, gbc);
0246:
0247:                gbc = new GridBagConstraints();
0248:                gbc.anchor = GridBagConstraints.WEST;
0249:                gbc.gridx = 0;
0250:                gbc.gridy = 1;
0251:                gbc.insets = new Insets(1, 1, 1, 1);
0252:                contentPane.add(lblAuthor, gbc);
0253:
0254:                gbc = new GridBagConstraints();
0255:                gbc.anchor = GridBagConstraints.WEST;
0256:                gbc.gridx = 0;
0257:                gbc.gridy = 2;
0258:                gbc.insets = new Insets(1, 1, 1, 1);
0259:                contentPane.add(lblKeywords, gbc);
0260:
0261:                gbc = new GridBagConstraints();
0262:                gbc.anchor = GridBagConstraints.WEST;
0263:                gbc.gridx = 0;
0264:                gbc.gridy = 3;
0265:                gbc.insets = new Insets(1, 1, 1, 1);
0266:                contentPane.add(lblDescription, gbc);
0267:
0268:                gbc = new GridBagConstraints();
0269:                gbc.fill = GridBagConstraints.HORIZONTAL;
0270:                gbc.weightx = 1;
0271:                gbc.gridx = 1;
0272:                gbc.gridy = 0;
0273:                gbc.gridwidth = 2;
0274:                gbc.insets = new Insets(3, 1, 1, 1);
0275:                contentPane.add(txTitle, gbc);
0276:
0277:                gbc = new GridBagConstraints();
0278:                gbc.fill = GridBagConstraints.HORIZONTAL;
0279:                gbc.weightx = 1;
0280:                gbc.gridx = 1;
0281:                gbc.gridy = 1;
0282:                gbc.gridwidth = 2;
0283:                gbc.insets = new Insets(1, 1, 1, 1);
0284:                contentPane.add(txAuthor, gbc);
0285:
0286:                gbc = new GridBagConstraints();
0287:                gbc.fill = GridBagConstraints.HORIZONTAL;
0288:                gbc.weightx = 1;
0289:                gbc.gridx = 1;
0290:                gbc.gridy = 2;
0291:                gbc.gridwidth = 2;
0292:                gbc.insets = new Insets(1, 1, 1, 1);
0293:                contentPane.add(txKeywords, gbc);
0294:
0295:                gbc = new GridBagConstraints();
0296:                gbc.fill = GridBagConstraints.HORIZONTAL;
0297:                gbc.weightx = 1;
0298:                gbc.gridx = 1;
0299:                gbc.gridy = 3;
0300:                gbc.gridwidth = 2;
0301:                gbc.insets = new Insets(1, 1, 1, 1);
0302:                contentPane.add(txDescription, gbc);
0303:
0304:                final JPanel advancedOptionsPane = new JPanel();
0305:                advancedOptionsPane.setLayout(new BorderLayout());
0306:                advancedOptionsPane.add(contentPane, BorderLayout.NORTH);
0307:                return advancedOptionsPane;
0308:            }
0309:
0310:            private void initializeComponents() {
0311:                setTitle(getResources().getString("pdfsavedialog.dialogtitle")); //$NON-NLS-1$
0312:
0313:                txAuthor = new JTextField();
0314:                txAuthor.setColumns(40);
0315:                txTitle = new JTextField();
0316:                txTitle.setColumns(40);
0317:                txKeywords = new JTextField();
0318:                txKeywords.setColumns(40);
0319:                txDescription = new JTextField();
0320:                txDescription.setColumns(40);
0321:
0322:                rbSecurityNone = new JRadioButton(getResources().getString(
0323:                        "pdfsavedialog.securityNone")); //$NON-NLS-1$
0324:                rbSecurity40Bit = new JRadioButton(getResources().getString(
0325:                        "pdfsavedialog.security40bit")); //$NON-NLS-1$
0326:                rbSecurity128Bit = new JRadioButton(getResources().getString(
0327:                        "pdfsavedialog.security128bit")); //$NON-NLS-1$
0328:
0329:                final Action securitySelectAction = new ActionSecuritySelection();
0330:                rbSecurityNone.addActionListener(securitySelectAction);
0331:                rbSecurity40Bit.addActionListener(securitySelectAction);
0332:                rbSecurity128Bit.addActionListener(securitySelectAction);
0333:
0334:                rbSecurity128Bit.setSelected(true);
0335:
0336:                txUserPassword = new JPasswordField();
0337:                txConfUserPassword = new JPasswordField();
0338:                txOwnerPassword = new JPasswordField();
0339:                txConfOwnerPassword = new JPasswordField();
0340:
0341:                cxAllowCopy = new JCheckBox(getResources().getString(
0342:                        "pdfsavedialog.allowCopy")); //$NON-NLS-1$
0343:                cbAllowPrinting = new JComboBox(getPrintingComboBoxModel());
0344:                cxAllowScreenReaders = new JCheckBox(getResources().getString(
0345:                        "pdfsavedialog.allowScreenreader")); //$NON-NLS-1$
0346:
0347:                cxAllowAssembly = new JCheckBox(getResources().getString(
0348:                        "pdfsavedialog.allowAssembly")); //$NON-NLS-1$
0349:                cxAllowModifyContents = new JCheckBox(getResources().getString(
0350:                        "pdfsavedialog.allowModifyContents")); //$NON-NLS-1$
0351:                cxAllowModifyAnnotations = new JCheckBox(getResources()
0352:                        .getString("pdfsavedialog.allowModifyAnnotations")); //$NON-NLS-1$
0353:                cxAllowFillIn = new JCheckBox(getResources().getString(
0354:                        "pdfsavedialog.allowFillIn")); //$NON-NLS-1$
0355:
0356:                txFilename = new JTextField();
0357:                txFilename.setColumns(40);
0358:                statusBar = new JStatusBar();
0359:
0360:                encodingModel = EncodingComboBoxModel.createDefaultModel(Locale
0361:                        .getDefault());
0362:                encodingModel.sort();
0363:
0364:                cbEncoding = new JComboBox(encodingModel);
0365:                cxEmbedded = new JCheckBox(getResources().getString(
0366:                        "pdfsavedialog.embedfonts"));
0367:
0368:                getFormValidator().registerTextField(txFilename);
0369:                getFormValidator().registerTextField(txConfOwnerPassword);
0370:                getFormValidator().registerTextField(txConfUserPassword);
0371:                getFormValidator().registerTextField(txUserPassword);
0372:                getFormValidator().registerTextField(txOwnerPassword);
0373:
0374:                final JPanel exportPane = createExportPanel();
0375:                final Configuration config = JFreeReportBoot.getInstance()
0376:                        .getGlobalConfig();
0377:                final boolean advancedSettingsTabAvail = "true"
0378:                        .equals(config
0379:                                .getConfigProperty("org.jfree.report.modules.gui.pdf.AdvancedSettingsAvailable"));
0380:                final boolean metaDataSettingsTabAvail = "true"
0381:                        .equals(config
0382:                                .getConfigProperty("org.jfree.report.modules.gui.pdf.MetaDataSettingsAvailable"));
0383:                if (advancedSettingsTabAvail || metaDataSettingsTabAvail) {
0384:                    final JTabbedPane tabbedPane = new JTabbedPane();
0385:                    tabbedPane.add(getResources().getString(
0386:                            "pdfsavedialog.export-settings"), exportPane); //$NON-NLS-1$
0387:                    if (metaDataSettingsTabAvail) {
0388:                        tabbedPane
0389:                                .add(
0390:                                        getResources()
0391:                                                .getString(
0392:                                                        "pdfsavedialog.metadata-settings"), createMetaDataPanel()); //$NON-NLS-1$
0393:                    }
0394:                    if (advancedSettingsTabAvail) {
0395:                        tabbedPane
0396:                                .add(
0397:                                        getResources()
0398:                                                .getString(
0399:                                                        "pdfsavedialog.advanced-settings"), createAdvancedPanel()); //$NON-NLS-1$
0400:                    }
0401:
0402:                    setContentPane(createContentPane(tabbedPane));
0403:                } else {
0404:                    setContentPane(createContentPane(exportPane));
0405:                }
0406:
0407:            }
0408:
0409:            private JPanel createExportPanel() {
0410:                final JButton btnSelect = new ActionButton(
0411:                        new ActionSelectFile(getResources()));
0412:                final JLabel lblFileName = new JLabel(getResources().getString(
0413:                        "pdfsavedialog.filename")); //$NON-NLS-1$
0414:                final JPanel mainPanel = new JPanel();
0415:                mainPanel.setLayout(new GridBagLayout());
0416:                mainPanel
0417:                        .setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
0418:                GridBagConstraints gbc = new GridBagConstraints();
0419:                gbc.gridx = 0;
0420:                gbc.gridy = 0;
0421:                gbc.anchor = GridBagConstraints.WEST;
0422:                gbc.insets = new Insets(3, 3, 1, 1);
0423:                mainPanel.add(lblFileName, gbc);
0424:
0425:                gbc = new GridBagConstraints();
0426:                gbc.fill = GridBagConstraints.HORIZONTAL;
0427:                gbc.weightx = 1;
0428:                gbc.gridx = 1;
0429:                gbc.gridy = 0;
0430:                gbc.ipadx = 120;
0431:                gbc.insets = new Insets(3, 1, 1, 1);
0432:                mainPanel.add(txFilename, gbc);
0433:
0434:                gbc = new GridBagConstraints();
0435:                gbc.anchor = GridBagConstraints.NORTHWEST;
0436:                gbc.gridx = 2;
0437:                gbc.gridy = 0;
0438:                mainPanel.add(btnSelect, gbc);
0439:
0440:                final JPanel advancedPaneCarrier = new JPanel();
0441:                advancedPaneCarrier.setBorder(BorderFactory.createEmptyBorder(
0442:                        4, 4, 4, 4));
0443:                advancedPaneCarrier.setLayout(new BorderLayout());
0444:                advancedPaneCarrier.add(mainPanel, BorderLayout.NORTH);
0445:                return advancedPaneCarrier;
0446:            }
0447:
0448:            public JStatusBar getStatusBar() {
0449:                return statusBar;
0450:            }
0451:
0452:            protected boolean performConfirm() {
0453:                final String filename = txFilename.getText();
0454:                final File f = new File(filename);
0455:                if (f.exists()) {
0456:                    final String key1 = "pdfsavedialog.targetOverwriteConfirmation"; //$NON-NLS-1$
0457:                    final String key2 = "pdfsavedialog.targetOverwriteTitle"; //$NON-NLS-1$
0458:                    if (JOptionPane.showConfirmDialog(this , MessageFormat
0459:                            .format(getResources().getString(key1),
0460:                                    new Object[] { txFilename.getText() }),
0461:                            getResources().getString(key2),
0462:                            JOptionPane.YES_NO_OPTION,
0463:                            JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
0464:                        return false;
0465:                    }
0466:                }
0467:
0468:                if (getEncryptionValue().equals(
0469:                        PdfExportGUIModule.SECURITY_ENCRYPTION_128BIT)
0470:                        || getEncryptionValue().equals(
0471:                                PdfExportGUIModule.SECURITY_ENCRYPTION_40BIT)) {
0472:                    if (txOwnerPassword.getText().trim().length() == 0) {
0473:                        if (JOptionPane.showConfirmDialog(this ,
0474:                                getResources().getString(
0475:                                        "pdfsavedialog.ownerpasswordEmpty"), //$NON-NLS-1$
0476:                                getResources().getString(
0477:                                        "pdfsavedialog.warningTitle"), //$NON-NLS-1$
0478:                                JOptionPane.YES_NO_OPTION,
0479:                                JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) {
0480:                            return false;
0481:                        }
0482:                    }
0483:                }
0484:                return true;
0485:            }
0486:
0487:            protected boolean performValidate() {
0488:                getStatusBar().clear();
0489:
0490:                final String filename = txFilename.getText();
0491:                if (filename.trim().length() == 0) {
0492:                    getStatusBar().setStatus(
0493:                            StatusType.ERROR,
0494:                            getResources().getString(
0495:                                    "pdfsavedialog.targetIsEmpty")); //$NON-NLS-1$
0496:                    return false;
0497:                }
0498:                final File f = new File(filename);
0499:                if (f.exists()) {
0500:                    if (f.isFile() == false) {
0501:                        getStatusBar().setStatus(
0502:                                StatusType.ERROR,
0503:                                getResources().getString(
0504:                                        "pdfsavedialog.targetIsNoFile")); //$NON-NLS-1$
0505:                        return false;
0506:                    }
0507:                    if (f.canWrite() == false) {
0508:                        getStatusBar().setStatus(
0509:                                StatusType.ERROR,
0510:                                getResources().getString(
0511:                                        "pdfsavedialog.targetIsNotWritable")); //$NON-NLS-1$
0512:                        return false;
0513:                    }
0514:
0515:                    final String message = MessageFormat.format(getResources()
0516:                            .getString("pdfsavedialog.targetOverwriteWarning"), //$NON-NLS-1$
0517:                            new Object[] { filename });
0518:                    getStatusBar().setStatus(StatusType.WARNING, message);
0519:                }
0520:
0521:                if (getEncryptionValue().equals(
0522:                        PdfExportGUIModule.SECURITY_ENCRYPTION_128BIT)
0523:                        || getEncryptionValue().equals(
0524:                                PdfExportGUIModule.SECURITY_ENCRYPTION_40BIT)) {
0525:                    if (txUserPassword.getText().equals(
0526:                            txConfUserPassword.getText()) == false) {
0527:                        getStatusBar().setStatus(
0528:                                StatusType.ERROR,
0529:                                getResources().getString(
0530:                                        "pdfsavedialog.userpasswordNoMatch")); //$NON-NLS-1$
0531:                        return false;
0532:                    }
0533:                    if (txOwnerPassword.getText().equals(
0534:                            txConfOwnerPassword.getText()) == false) {
0535:                        getStatusBar().setStatus(
0536:                                StatusType.ERROR,
0537:                                getResources().getString(
0538:                                        "pdfsavedialog.ownerpasswordNoMatch")); //$NON-NLS-1$
0539:                        return false;
0540:                    }
0541:                }
0542:
0543:                return true;
0544:            }
0545:
0546:            protected void initializeFromJob(final JFreeReport job,
0547:                    final GuiContext guiContext) {
0548:                statusBar.setIconTheme(guiContext.getIconTheme());
0549:
0550:                encodingModel = EncodingComboBoxModel.createDefaultModel(Locale
0551:                        .getDefault());
0552:                encodingModel.sort();
0553:                cbEncoding.setModel(encodingModel);
0554:            }
0555:
0556:            protected String getConfigurationPrefix() {
0557:                return "org.jfree.report.modules.gui.pdf."; //$NON-NLS-1$
0558:            }
0559:
0560:            /**
0561:             * Returns a new (and not connected to the default config from the job)
0562:             * configuration containing all properties from the dialog.
0563:             *
0564:             * @param full
0565:             */
0566:            protected Configuration grabDialogContents(final boolean full) {
0567:                final DefaultConfiguration config = new DefaultConfiguration();
0568:
0569:                config
0570:                        .setConfigProperty(
0571:                                "org.jfree.report.modules.output.pageable.pdf.Keywords", //$NON-NLS-1$
0572:                                txKeywords.getText());
0573:                config
0574:                        .setConfigProperty(
0575:                                "org.jfree.report.modules.output.pageable.pdf.Description", //$NON-NLS-1$
0576:                                txDescription.getText());
0577:                config.setConfigProperty(
0578:                        "org.jfree.report.modules.output.pageable.pdf.Author", //$NON-NLS-1$
0579:                        txAuthor.getText());
0580:                config.setConfigProperty(
0581:                        "org.jfree.report.modules.output.pageable.pdf.Title", //$NON-NLS-1$
0582:                        txTitle.getText());
0583:
0584:                config.setConfigProperty(
0585:                        "org.jfree.report.modules.gui.pdf.TargetFileName", //$NON-NLS-1$
0586:                        txFilename.getText());
0587:                config
0588:                        .setConfigProperty(
0589:                                "org.jfree.report.modules.output.pageable.pdf.Encoding", //$NON-NLS-1$
0590:                                encodingModel.getSelectedEncoding());
0591:
0592:                config
0593:                        .getConfigProperty(
0594:                                "org.jfree.report.modules.output.pageable.pdf.PrintLevel", //$NON-NLS-1$
0595:                                getPrintLevel());
0596:                config
0597:                        .getConfigProperty(
0598:                                "org.jfree.report.modules.output.pageable.pdf.Encryption", //$NON-NLS-1$
0599:                                getEncryptionValue());
0600:                config
0601:                        .getConfigProperty(
0602:                                "org.jfree.report.modules.output.pageable.pdf.UserPassword", //$NON-NLS-1$
0603:                                txUserPassword.getText());
0604:                config
0605:                        .getConfigProperty(
0606:                                "org.jfree.report.modules.output.pageable.pdf.OwnerPassword", //$NON-NLS-1$
0607:                                txOwnerPassword.getText());
0608:                config
0609:                        .setConfigProperty(
0610:                                "org.jfree.report.modules.output.pageable.pdf.AllowAssembly", //$NON-NLS-1$
0611:                                String.valueOf(cxAllowAssembly.isSelected()));
0612:                config
0613:                        .setConfigProperty(
0614:                                "org.jfree.report.modules.output.pageable.pdf.AllowCopy", //$NON-NLS-1$
0615:                                String.valueOf(cxAllowCopy.isSelected()));
0616:                config
0617:                        .setConfigProperty(
0618:                                "org.jfree.report.modules.output.pageable.pdf.AllowFillIn", //$NON-NLS-1$
0619:                                String.valueOf(cxAllowFillIn.isSelected()));
0620:                config
0621:                        .setConfigProperty(
0622:                                "org.jfree.report.modules.output.pageable.pdf.AllowModifyAnnotations", //$NON-NLS-1$
0623:                                String.valueOf(cxAllowModifyAnnotations
0624:                                        .isSelected()));
0625:                config
0626:                        .setConfigProperty(
0627:                                "org.jfree.report.modules.output.pageable.pdf.AllowModifyContents", //$NON-NLS-1$
0628:                                String.valueOf(cxAllowModifyContents
0629:                                        .isSelected()));
0630:                config
0631:                        .setConfigProperty(
0632:                                "org.jfree.report.modules.output.pageable.pdf.AllowScreenReaders", //$NON-NLS-1$
0633:                                String.valueOf(cxAllowScreenReaders
0634:                                        .isSelected()));
0635:                config
0636:                        .setConfigProperty(
0637:                                "org.jfree.report.modules.output.pageable.pdf.EmbedFonts", //$NON-NLS-1$
0638:                                String.valueOf(cxEmbedded.isSelected()));
0639:                return config;
0640:            }
0641:
0642:            protected void setDialogContents(final Configuration config) {
0643:                txFilename
0644:                        .setText(config
0645:                                .getConfigProperty("org.jfree.report.modules.gui.pdf.TargetFileName")); //$NON-NLS-1$
0646:                final String encoding = config
0647:                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.Encoding"); //$NON-NLS-1$
0648:                if (encoding != null && encoding.length() > 0) {
0649:                    encodingModel.setSelectedEncoding(encoding);
0650:                }
0651:                setPrintLevel(config
0652:                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.security.PrintLevel")); //$NON-NLS-1$
0653:                setEncryptionValue(config
0654:                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.security.Encryption")); //$NON-NLS-1$
0655:
0656:                txUserPassword
0657:                        .setText(config
0658:                                .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.UserPassword")); //$NON-NLS-1$
0659:                txOwnerPassword
0660:                        .setText(config
0661:                                .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.OwnerPassword")); //$NON-NLS-1$
0662:                txConfUserPassword
0663:                        .setText(config
0664:                                .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.UserPassword")); //$NON-NLS-1$
0665:                txConfOwnerPassword
0666:                        .setText(config
0667:                                .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.OwnerPassword")); //$NON-NLS-1$
0668:
0669:                cxAllowAssembly
0670:                        .setSelected("true".equals //$NON-NLS-1$
0671:                                (config
0672:                                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.AllowAssembly"))); //$NON-NLS-1$
0673:                cxAllowCopy
0674:                        .setSelected("true".equals //$NON-NLS-1$
0675:                                (config
0676:                                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.AllowCopy"))); //$NON-NLS-1$
0677:                cxAllowFillIn
0678:                        .setSelected("true".equals //$NON-NLS-1$
0679:                                (config
0680:                                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.AllowFillIn"))); //$NON-NLS-1$
0681:                cxAllowModifyAnnotations
0682:                        .setSelected("true".equals //$NON-NLS-1$
0683:                                (config
0684:                                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.AllowModifyAnnotations"))); //$NON-NLS-1$
0685:                cxAllowModifyContents
0686:                        .setSelected("true".equals //$NON-NLS-1$
0687:                                (config
0688:                                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.AllowModifyContents"))); //$NON-NLS-1$
0689:                cxAllowScreenReaders
0690:                        .setSelected("true".equals //$NON-NLS-1$
0691:                                (config
0692:                                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.AllowScreenReaders"))); //$NON-NLS-1$
0693:                cxEmbedded
0694:                        .setSelected("true".equals //$NON-NLS-1$
0695:                                (config
0696:                                        .getConfigProperty("org.jfree.report.modules.output.pageable.pdf.EmbedFonts"))); //$NON-NLS-1$
0697:
0698:                txTitle
0699:                        .setText(config
0700:                                .getConfigProperty(
0701:                                        "org.jfree.report.modules.output.pageable.pdf.Title", //$NON-NLS-1$
0702:                                        config
0703:                                                .getConfigProperty("org.jfree.report.metadata.Title"))); //$NON-NLS-1$
0704:                txAuthor
0705:                        .setText(config
0706:                                .getConfigProperty(
0707:                                        "org.jfree.report.modules.output.pageable.pdf.Author", //$NON-NLS-1$
0708:                                        config
0709:                                                .getConfigProperty("org.jfree.report.metadata.Author"))); //$NON-NLS-1$
0710:                txKeywords
0711:                        .setText(config
0712:                                .getConfigProperty(
0713:                                        "org.jfree.report.modules.output.pageable.pdf.Keywords", //$NON-NLS-1$
0714:                                        config
0715:                                                .getConfigProperty("org.jfree.report.metadata.Keywords"))); //$NON-NLS-1$
0716:                txDescription
0717:                        .setText(config
0718:                                .getConfigProperty(
0719:                                        "org.jfree.report.modules.output.pageable.pdf.Description", //$NON-NLS-1$
0720:                                        config
0721:                                                .getConfigProperty("org.jfree.report.metadata.Description"))); //$NON-NLS-1$
0722:            }
0723:
0724:            protected String getConfigurationSuffix() {
0725:                return "_pdf_export"; //$NON-NLS-1$
0726:            }
0727:
0728:            public void clear() {
0729:                txConfOwnerPassword.setText(""); //$NON-NLS-1$
0730:                txConfUserPassword.setText(""); //$NON-NLS-1$
0731:                txFilename.setText(""); //$NON-NLS-1$
0732:                txOwnerPassword.setText(""); //$NON-NLS-1$
0733:                txUserPassword.setText(""); //$NON-NLS-1$
0734:
0735:                cxAllowAssembly.setSelected(false);
0736:                cxAllowCopy.setSelected(false);
0737:                cbAllowPrinting.setSelectedIndex(CBMODEL_NOPRINTING);
0738:                cxAllowFillIn.setSelected(false);
0739:                cxAllowModifyAnnotations.setSelected(false);
0740:                cxAllowModifyContents.setSelected(false);
0741:                cxAllowScreenReaders.setSelected(false);
0742:                cxEmbedded.setSelected(false);
0743:                rbSecurityNone.setSelected(true);
0744:                updateSecurityPanelEnabled();
0745:
0746:                final String plattformDefaultEncoding = EncodingRegistry
0747:                        .getPlatformDefaultEncoding();
0748:                encodingModel.setSelectedEncoding(plattformDefaultEncoding);
0749:
0750:                txAuthor.setText(JFreeReportBoot.getInstance()
0751:                        .getGlobalConfig().getConfigProperty("user.name", "")); //$NON-NLS-1$ //$NON-NLS-2$
0752:                txFilename.setText(""); //$NON-NLS-1$
0753:                txTitle.setText(""); //$NON-NLS-1$
0754:                txDescription.setText(""); //$NON-NLS-1$
0755:                txKeywords.setText(""); //$NON-NLS-1$
0756:            }
0757:
0758:            protected String getResourceBaseName() {
0759:                return PdfExportPlugin.BASE_RESOURCE_CLASS;
0760:            }
0761:
0762:            /**
0763:             * Updates the security panel state. If no encryption is selected, all
0764:             * security setting components will be disabled.
0765:             */
0766:            protected void updateSecurityPanelEnabled() {
0767:                final boolean b = (rbSecurityNone.isSelected() == false);
0768:                txUserPassword.setEnabled(b);
0769:                txOwnerPassword.setEnabled(b);
0770:                txConfOwnerPassword.setEnabled(b);
0771:                txConfUserPassword.setEnabled(b);
0772:                cxAllowAssembly.setEnabled(b);
0773:                cxAllowCopy.setEnabled(b);
0774:                cbAllowPrinting.setEnabled(b);
0775:                cxAllowFillIn.setEnabled(b);
0776:                cxAllowModifyAnnotations.setEnabled(b);
0777:                cxAllowModifyContents.setEnabled(b);
0778:                cxAllowScreenReaders.setEnabled(b);
0779:            }
0780:
0781:            /**
0782:             * Creates a panel for the security settings.
0783:             *
0784:             * @return The panel.
0785:             */
0786:            private JPanel createAdvancedPanel() {
0787:                final JLabel lblEncoding = new JLabel(getResources().getString(
0788:                        "pdfsavedialog.encoding")); //$NON-NLS-1$
0789:                final JPanel encodingPanel = new JPanel();
0790:                encodingPanel.setBorder(BorderFactory
0791:                        .createTitledBorder(getResources().getString(
0792:                                "pdfsavedialog.export-options")));
0793:                encodingPanel.setLayout(new GridBagLayout());
0794:                GridBagConstraints gbc = new GridBagConstraints();
0795:                gbc.anchor = GridBagConstraints.WEST;
0796:                gbc.gridx = 0;
0797:                gbc.gridy = 0;
0798:                gbc.insets = new Insets(1, 1, 1, 1);
0799:                encodingPanel.add(lblEncoding, gbc);
0800:
0801:                gbc = new GridBagConstraints();
0802:                gbc.fill = GridBagConstraints.HORIZONTAL;
0803:                gbc.weightx = 1;
0804:                gbc.gridx = 1;
0805:                gbc.gridy = 0;
0806:                gbc.ipadx = 80;
0807:                gbc.insets = new Insets(1, 1, 1, 1);
0808:                encodingPanel.add(cbEncoding, gbc);
0809:
0810:                gbc = new GridBagConstraints();
0811:                gbc.fill = GridBagConstraints.HORIZONTAL;
0812:                gbc.weightx = 1;
0813:                gbc.gridx = 1;
0814:                gbc.gridy = 1;
0815:                gbc.ipadx = 80;
0816:                gbc.insets = new Insets(1, 1, 1, 1);
0817:                encodingPanel.add(cxEmbedded, gbc);
0818:
0819:                final JPanel securityPanel = new JPanel();
0820:                securityPanel.setLayout(new GridBagLayout());
0821:                securityPanel.setBorder(BorderFactory
0822:                        .createTitledBorder(getResources().getString(
0823:                                "pdfsavedialog.security")));
0824:
0825:                final JLabel lblUserPass = new JLabel(getResources().getString(
0826:                        "pdfsavedialog.userpassword")); //$NON-NLS-1$
0827:                final JLabel lblUserPassConfirm = new JLabel(getResources()
0828:                        .getString("pdfsavedialog.userpasswordconfirm")); //$NON-NLS-1$
0829:                final JLabel lblOwnerPass = new JLabel(getResources()
0830:                        .getString("pdfsavedialog.ownerpassword")); //$NON-NLS-1$
0831:                final JLabel lblOwnerPassConfirm = new JLabel(getResources()
0832:                        .getString("pdfsavedialog.ownerpasswordconfirm")); //$NON-NLS-1$
0833:                final JLabel lbAllowPrinting = new JLabel(getResources()
0834:                        .getString("pdfsavedialog.allowPrinting")); //$NON-NLS-1$
0835:
0836:                gbc = new GridBagConstraints();
0837:                gbc.fill = GridBagConstraints.HORIZONTAL;
0838:                gbc.weightx = 1;
0839:                gbc.gridx = 0;
0840:                gbc.gridwidth = 4;
0841:                gbc.gridy = 1;
0842:                gbc.insets = new Insets(5, 5, 5, 5);
0843:                securityPanel.add(createSecurityConfigPanel(), gbc);
0844:
0845:                gbc = new GridBagConstraints();
0846:                gbc.anchor = GridBagConstraints.WEST;
0847:                gbc.gridx = 0;
0848:                gbc.gridy = 2;
0849:                gbc.insets = new Insets(5, 5, 5, 5);
0850:                securityPanel.add(lblUserPass, gbc);
0851:
0852:                gbc = new GridBagConstraints();
0853:                gbc.fill = GridBagConstraints.HORIZONTAL;
0854:                gbc.weightx = 1;
0855:                gbc.gridx = 1;
0856:                gbc.gridy = 2;
0857:                gbc.ipadx = 120;
0858:                gbc.insets = new Insets(5, 5, 5, 5);
0859:                securityPanel.add(txUserPassword, gbc);
0860:
0861:                gbc = new GridBagConstraints();
0862:                gbc.anchor = GridBagConstraints.WEST;
0863:                gbc.gridx = 0;
0864:                gbc.gridy = 3;
0865:                gbc.insets = new Insets(5, 5, 5, 5);
0866:                securityPanel.add(lblOwnerPass, gbc);
0867:
0868:                gbc = new GridBagConstraints();
0869:                gbc.fill = GridBagConstraints.HORIZONTAL;
0870:                gbc.weightx = 1;
0871:                gbc.gridx = 1;
0872:                gbc.gridy = 3;
0873:                gbc.ipadx = 80;
0874:                gbc.insets = new Insets(5, 5, 5, 5);
0875:                securityPanel.add(txOwnerPassword, gbc);
0876:
0877:                gbc = new GridBagConstraints();
0878:                gbc.anchor = GridBagConstraints.WEST;
0879:                gbc.gridx = 2;
0880:                gbc.gridy = 2;
0881:                gbc.insets = new Insets(5, 5, 5, 5);
0882:                securityPanel.add(lblUserPassConfirm, gbc);
0883:
0884:                gbc = new GridBagConstraints();
0885:                gbc.fill = GridBagConstraints.HORIZONTAL;
0886:                gbc.weightx = 1;
0887:                gbc.gridx = 3;
0888:                gbc.gridy = 2;
0889:                gbc.ipadx = 80;
0890:                gbc.insets = new Insets(5, 5, 5, 5);
0891:                securityPanel.add(txConfUserPassword, gbc);
0892:
0893:                gbc = new GridBagConstraints();
0894:                gbc.anchor = GridBagConstraints.WEST;
0895:                gbc.gridx = 2;
0896:                gbc.gridy = 3;
0897:                gbc.insets = new Insets(5, 5, 5, 5);
0898:                securityPanel.add(lblOwnerPassConfirm, gbc);
0899:
0900:                gbc = new GridBagConstraints();
0901:                gbc.fill = GridBagConstraints.HORIZONTAL;
0902:                gbc.weightx = 1;
0903:                gbc.gridx = 3;
0904:                gbc.gridy = 3;
0905:                gbc.ipadx = 80;
0906:                gbc.insets = new Insets(5, 5, 5, 5);
0907:                securityPanel.add(txConfOwnerPassword, gbc);
0908:
0909:                gbc = new GridBagConstraints();
0910:                gbc.gridx = 0;
0911:                gbc.gridwidth = 2;
0912:                gbc.gridy = 4;
0913:                gbc.anchor = GridBagConstraints.WEST;
0914:                securityPanel.add(cxAllowCopy, gbc);
0915:
0916:                gbc = new GridBagConstraints();
0917:                gbc.gridx = 0;
0918:                gbc.gridwidth = 2;
0919:                gbc.gridy = 5;
0920:                gbc.anchor = GridBagConstraints.WEST;
0921:                securityPanel.add(cxAllowScreenReaders, gbc);
0922:
0923:                gbc = new GridBagConstraints();
0924:                gbc.gridx = 0;
0925:                gbc.gridwidth = 2;
0926:                gbc.gridy = 6;
0927:                gbc.anchor = GridBagConstraints.WEST;
0928:                securityPanel.add(cxAllowFillIn, gbc);
0929:
0930:                gbc = new GridBagConstraints();
0931:                gbc.gridx = 2;
0932:                gbc.gridwidth = 2;
0933:                gbc.gridy = 4;
0934:                gbc.anchor = GridBagConstraints.WEST;
0935:                securityPanel.add(cxAllowAssembly, gbc);
0936:
0937:                gbc = new GridBagConstraints();
0938:                gbc.gridx = 2;
0939:                gbc.gridwidth = 2;
0940:                gbc.gridy = 5;
0941:                gbc.anchor = GridBagConstraints.WEST;
0942:                securityPanel.add(cxAllowModifyContents, gbc);
0943:
0944:                gbc = new GridBagConstraints();
0945:                gbc.gridx = 2;
0946:                gbc.gridwidth = 2;
0947:                gbc.gridy = 6;
0948:                gbc.anchor = GridBagConstraints.WEST;
0949:                securityPanel.add(cxAllowModifyAnnotations, gbc);
0950:
0951:                gbc = new GridBagConstraints();
0952:                gbc.gridx = 0;
0953:                gbc.gridwidth = 1;
0954:                gbc.gridy = 7;
0955:                gbc.anchor = GridBagConstraints.WEST;
0956:                securityPanel.add(lbAllowPrinting, gbc);
0957:
0958:                gbc = new GridBagConstraints();
0959:                gbc.gridx = 1;
0960:                gbc.gridwidth = 3;
0961:                gbc.gridy = 7;
0962:                gbc.anchor = GridBagConstraints.WEST;
0963:                securityPanel.add(cbAllowPrinting, gbc);
0964:
0965:                final JPanel advancedCarrier2 = new JPanel();
0966:                advancedCarrier2.setLayout(new GridBagLayout());
0967:
0968:                gbc = new GridBagConstraints();
0969:                gbc.gridx = 0;
0970:                gbc.fill = GridBagConstraints.HORIZONTAL;
0971:                gbc.gridwidth = 1;
0972:                gbc.gridy = 0;
0973:                gbc.anchor = GridBagConstraints.WEST;
0974:                gbc.insets = new Insets(1, 1, 5, 1);
0975:                advancedCarrier2.add(encodingPanel, gbc);
0976:
0977:                gbc = new GridBagConstraints();
0978:                gbc.gridx = 0;
0979:                gbc.fill = GridBagConstraints.HORIZONTAL;
0980:                gbc.gridwidth = 1;
0981:                gbc.gridy = 1;
0982:                gbc.anchor = GridBagConstraints.WEST;
0983:                gbc.insets = new Insets(1, 1, 1, 1);
0984:                advancedCarrier2.add(securityPanel, gbc);
0985:
0986:                final JPanel advancedPaneCarrier = new JPanel();
0987:                advancedPaneCarrier.setBorder(BorderFactory.createEmptyBorder(
0988:                        4, 4, 4, 4));
0989:                advancedPaneCarrier.setLayout(new BorderLayout());
0990:                advancedPaneCarrier.add(advancedCarrier2, BorderLayout.NORTH);
0991:                return advancedPaneCarrier;
0992:            }
0993:
0994:            /**
0995:             * Creates the security config panel. This panel is used to select the level
0996:             * of the PDF security.
0997:             *
0998:             * @return the created security config panel.
0999:             */
1000:            private JPanel createSecurityConfigPanel() {
1001:                final JPanel pnlSecurityConfig = new JPanel();
1002:                pnlSecurityConfig.setLayout(new GridLayout());
1003:                pnlSecurityConfig.add(rbSecurityNone);
1004:                pnlSecurityConfig.add(rbSecurity40Bit);
1005:                pnlSecurityConfig.add(rbSecurity128Bit);
1006:
1007:                final ButtonGroup btGrpSecurity = new ButtonGroup();
1008:                btGrpSecurity.add(rbSecurity128Bit);
1009:                btGrpSecurity.add(rbSecurity40Bit);
1010:                btGrpSecurity.add(rbSecurityNone);
1011:
1012:                return pnlSecurityConfig;
1013:            }
1014:
1015:            /**
1016:             * Gets and initializes the the combobox model for the security setting
1017:             * "allowPrinting".
1018:             *
1019:             * @return the combobox model containing the different values for the
1020:             *         allowPrinting option.
1021:             */
1022:            private DefaultComboBoxModel getPrintingComboBoxModel() {
1023:                if (printingModel == null) {
1024:                    final Object[] data = {
1025:                            getResources().getString(
1026:                                    "pdfsavedialog.option.noprinting"), //$NON-NLS-1$
1027:                            getResources().getString(
1028:                                    "pdfsavedialog.option.degradedprinting"), //$NON-NLS-1$
1029:                            getResources().getString(
1030:                                    "pdfsavedialog.option.fullprinting") //$NON-NLS-1$
1031:                    };
1032:                    printingModel = new DefaultComboBoxModel(data);
1033:                }
1034:                return printingModel;
1035:            }
1036:
1037:            /** selects a file to use as target for the report processing. */
1038:            protected void performSelectFile() {
1039:                // lazy initialize ... the file chooser is one of the hot spots here ...
1040:                if (fileChooser == null) {
1041:                    fileChooser = new JFileChooser();
1042:                    final FilesystemFilter filter = new FilesystemFilter(
1043:                            PDF_FILE_EXTENSION, getResources().getString(
1044:                                    "file.save.pdfdescription")); //$NON-NLS-1$
1045:                    fileChooser.addChoosableFileFilter(filter);
1046:                    fileChooser.setMultiSelectionEnabled(false);
1047:                }
1048:
1049:                final File file = new File(txFilename.getText());
1050:                fileChooser.setCurrentDirectory(file);
1051:                fileChooser.setSelectedFile(file);
1052:                final int option = fileChooser.showSaveDialog(this );
1053:                if (option == JFileChooser.APPROVE_OPTION) {
1054:                    final File selFile = fileChooser.getSelectedFile();
1055:                    String selFileName = selFile.getAbsolutePath();
1056:
1057:                    // Test if ends of pdf
1058:                    if (selFileName.toLowerCase().endsWith(PDF_FILE_EXTENSION) == false) {
1059:                        selFileName = selFileName + PDF_FILE_EXTENSION;
1060:                    }
1061:                    txFilename.setText(selFileName);
1062:                }
1063:            }
1064:
1065:            /**
1066:             * Defines whether the user is allowed to print the file.  If this right is
1067:             * granted, the user is also able to print a degraded version of the file,
1068:             * regardless of the <code>allowDegradedPrinting</code< property. If you
1069:             * disabled printing but enabled degraded printing, then the user is able to
1070:             * print a low-quality version of the document.
1071:             *
1072:             */
1073:            public void setPrintLevel(final String printLevel) {
1074:                if ("full".equals(printLevel)) //$NON-NLS-1$
1075:                {
1076:                    this .cbAllowPrinting.setSelectedIndex(CBMODEL_FULL);
1077:                } else if ("degraded".equals(printLevel)) //$NON-NLS-1$
1078:                {
1079:                    this .cbAllowPrinting.setSelectedIndex(CBMODEL_DEGRADED);
1080:                } else {
1081:                    this .cbAllowPrinting.setSelectedIndex(CBMODEL_NOPRINTING);
1082:                }
1083:            }
1084:
1085:            public String getPrintLevel() {
1086:                if (cbAllowPrinting.getSelectedIndex() == CBMODEL_FULL) {
1087:                    return "full"; //$NON-NLS-1$
1088:                }
1089:                if (cbAllowPrinting.getSelectedIndex() == CBMODEL_DEGRADED) {
1090:                    return "degraded"; //$NON-NLS-1$
1091:                }
1092:                return "none"; //$NON-NLS-1$
1093:            }
1094:
1095:            /**
1096:             * Queries the currently selected encryption. If an encryption is selected
1097:             * this method returns either Boolean.TRUE or Boolean.FALSE, when no
1098:             * encryption is set, <code>null</code> is returned. If no encryption is set,
1099:             * the security properties have no defined state.
1100:             *
1101:             * @return the selection state for the encryption. If no encryption is set,
1102:             *         this method returns null, if 40-bit encryption is set, the method
1103:             *         returns Boolean.FALSE and on 128-Bit-encryption, Boolean.TRUE is
1104:             *         returned.
1105:             */
1106:            public String getEncryptionValue() {
1107:                if (rbSecurity40Bit.isSelected()) {
1108:                    return PdfExportGUIModule.SECURITY_ENCRYPTION_40BIT;
1109:                }
1110:                if (rbSecurity128Bit.isSelected()) {
1111:                    return PdfExportGUIModule.SECURITY_ENCRYPTION_128BIT;
1112:                }
1113:                return PdfExportGUIModule.SECURITY_ENCRYPTION_NONE;
1114:            }
1115:
1116:            /**
1117:             * Defines the currently selected encryption.
1118:             *
1119:             * @param b the new encryption state, one of null, Boolean.TRUE or
1120:             *          Boolean.FALSE
1121:             */
1122:            public void setEncryptionValue(final String b) {
1123:                if (b != null) {
1124:                    if (b.equals(PdfExportGUIModule.SECURITY_ENCRYPTION_128BIT)) {
1125:                        rbSecurity128Bit.setSelected(true);
1126:                        updateSecurityPanelEnabled();
1127:                        return;
1128:                    } else if (b
1129:                            .equals(PdfExportGUIModule.SECURITY_ENCRYPTION_40BIT)) {
1130:                        rbSecurity40Bit.setSelected(true);
1131:                        updateSecurityPanelEnabled();
1132:                        return;
1133:                    } else if (b
1134:                            .equals(PdfExportGUIModule.SECURITY_ENCRYPTION_NONE) == false) {
1135:                        Log.warn("Invalid encryption value entered. " + b); //$NON-NLS-1$
1136:                    }
1137:                }
1138:                rbSecurityNone.setSelected(true);
1139:                updateSecurityPanelEnabled();
1140:            }
1141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.