/* * PdfDialog.java * * Created on 8. August 2007, 16:34 */ package de.unisiegen.tpml.ui.netbeans; import java.io.File; import java.util.ResourceBundle; import java.util.prefs.Preferences; import javax.swing.filechooser.FileFilter; /** * * @author cfehling */ public class PdfDialog extends javax.swing.JDialog { private Preferences preferences; /** Creates new form PdfDialog */ public PdfDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); preferences = Preferences.userNodeForPackage ( PdfDialog.class ) ; filechooser.setCurrentDirectory(new File ( preferences.get ( "lastDir" , "." ) ) ) ; filechooser.setFileFilter ( new FileFilter ( ) { @ Override public boolean accept ( File pFile ) { return ( pFile.isDirectory ( ) ) || ( pFile.getName ( ).toLowerCase ( ).endsWith ( ".pdf" ) ) ; //$NON-NLS-1$ } @ Override public String getDescription ( ) { return ResourceBundle.getBundle ( "de/unisiegen/tpml/ui/ui" ) //$NON-NLS-1$ .getString ( "Pdf.FileFilter" ) ; //$NON-NLS-1$ } } ) ; } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jSeparator1 = new javax.swing.JSeparator(); jLabel1 = new javax.swing.JLabel(); portraitButton = new javax.swing.JRadioButton(); landscapeButton = new javax.swing.JRadioButton(); filechooser = new javax.swing.JFileChooser(); getContentPane().setLayout(new java.awt.GridBagLayout()); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("PDF Printing"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; getContentPane().add(jSeparator1, gridBagConstraints); jLabel1.setText("Pagelayout:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 0); getContentPane().add(jLabel1, gridBagConstraints); portraitButton.setSelected(true); portraitButton.setText("portrait"); portraitButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); portraitButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); portraitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { portraitButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 30, 0, 0); getContentPane().add(portraitButton, gridBagConstraints); landscapeButton.setText("landscape"); landscapeButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); landscapeButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); landscapeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { landscapeButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 30, 0, 0); getContentPane().add(landscapeButton, gridBagConstraints); filechooser.setDialogTitle("PDF Printing"); filechooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG); filechooser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { filechooserActionPerformed(evt); } }); filechooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { filechooserPropertyChange(evt); } }); filechooser.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { filechooserMouseClicked(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); getContentPane().add(filechooser, gridBagConstraints); pack(); }// </editor-fold>//GEN-END:initComponents private void portraitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_portraitButtonActionPerformed // TODO add your handling code here: landscapeButton.setSelected(false); portraitButton.setSelected(true); landscape = false; }//GEN-LAST:event_portraitButtonActionPerformed private void landscapeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_landscapeButtonActionPerformed // TODO add your handling code here: portraitButton.setSelected(false); landscape = true; }//GEN-LAST:event_landscapeButtonActionPerformed private void filechooserMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_filechooserMouseClicked // TODO add your handling code here: }//GEN-LAST:event_filechooserMouseClicked private void filechooserPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_filechooserPropertyChange // TODO add your handling code here: }//GEN-LAST:event_filechooserPropertyChange private void filechooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filechooserActionPerformed // TODO add your handling code here: if (evt.getActionCommand().equals("CancelSelection")){ this.cancelled = true; this.dispose(); } else if (evt.getActionCommand().equals("ApproveSelection")){ Preferences preferences = Preferences.userNodeForPackage ( PdfDialog.class ) ; preferences.put ( "lastDir" , filechooser.getSelectedFile().getAbsolutePath() ) ; this.dispose(); } }//GEN-LAST:event_filechooserActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables public javax.swing.JFileChooser filechooser; private javax.swing.JLabel jLabel1; private javax.swing.JSeparator jSeparator1; private javax.swing.JRadioButton landscapeButton; private javax.swing.JRadioButton portraitButton; // End of variables declaration//GEN-END:variables public boolean landscape; public boolean cancelled; }