Search in sources :

Example 1 with ExtensionFileFilter

use of org.apache.pdfbox.debugger.ui.ExtensionFileFilter in project pdfbox by apache.

the class PDFDebugger method openMenuItemActionPerformed.

private void openMenuItemActionPerformed(ActionEvent evt) {
    try {
        if (IS_MAC_OS) {
            FileDialog openDialog = new FileDialog(this, "Open");
            openDialog.setFilenameFilter(new FilenameFilter() {

                @Override
                public boolean accept(File dir, String name) {
                    return name.toLowerCase().endsWith(".pdf");
                }
            });
            openDialog.setVisible(true);
            if (openDialog.getFile() != null) {
                readPDFFile(openDialog.getFile(), "");
            }
        } else {
            String[] extensions = new String[] { "pdf", "PDF" };
            FileFilter pdfFilter = new ExtensionFileFilter(extensions, "PDF Files (*.pdf)");
            FileOpenSaveDialog openDialog = new FileOpenSaveDialog(this, pdfFilter);
            File file = openDialog.openFile();
            if (file != null) {
                readPDFFile(file, "");
            }
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) COSString(org.apache.pdfbox.cos.COSString) IOException(java.io.IOException) ExtensionFileFilter(org.apache.pdfbox.debugger.ui.ExtensionFileFilter) FileFilter(javax.swing.filechooser.FileFilter) FileDialog(java.awt.FileDialog) File(java.io.File) ExtensionFileFilter(org.apache.pdfbox.debugger.ui.ExtensionFileFilter) FileOpenSaveDialog(org.apache.pdfbox.debugger.ui.FileOpenSaveDialog)

Aggregations

FileDialog (java.awt.FileDialog)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 FileFilter (javax.swing.filechooser.FileFilter)1 COSString (org.apache.pdfbox.cos.COSString)1 ExtensionFileFilter (org.apache.pdfbox.debugger.ui.ExtensionFileFilter)1 FileOpenSaveDialog (org.apache.pdfbox.debugger.ui.FileOpenSaveDialog)1