private boolean isSupportedFormat( final URL sourceURL ) { final String file = sourceURL.getFile(); if ( StringUtils.endsWithIgnoreCase( file, ".png" ) ) { return true; } if ( StringUtils.endsWithIgnoreCase( file, ".jpg" ) || StringUtils.endsWithIgnoreCase( file, ".jpeg" ) ) { return true; } if ( StringUtils.endsWithIgnoreCase( file, ".bmp" ) || StringUtils.endsWithIgnoreCase( file, ".ico" ) ) { return true; } return false; }
private int getImageFormat( final ResourceKey key ) { final URL url = resourceManager.toURL( key ); if ( url == null ) { return -1; } final String file = url.getFile(); if ( StringUtils.endsWithIgnoreCase( file, ".png" ) ) { // NON-NLS return Workbook.PICTURE_TYPE_PNG; } if ( StringUtils.endsWithIgnoreCase( file, ".jpg" ) || // NON-NLS StringUtils.endsWithIgnoreCase( file, ".jpeg" ) ) { // NON-NLS return Workbook.PICTURE_TYPE_JPEG; } if ( StringUtils.endsWithIgnoreCase( file, ".bmp" ) || // NON-NLS StringUtils.endsWithIgnoreCase( file, ".ico" ) ) { // NON-NLS return Workbook.PICTURE_TYPE_DIB; } return -1; }
/** * Tests whether or not the specified abstract pathname should be included in a pathname list. * * @param pathname The abstract pathname to be tested * @return <code>true</code> if and only if <code>pathname</code> should be included */ public boolean accept( final File pathname ) { if ( pathname.canRead() == false ) { return false; } if ( pathname.isDirectory() ) { return true; } final String name = pathname.getName(); if ( StringUtils.endsWithIgnoreCase( name, ".ttf" ) ) { return true; } if ( StringUtils.endsWithIgnoreCase( name, ".ttc" ) ) { return true; } if ( StringUtils.endsWithIgnoreCase( name, ".otf" ) ) { return true; } return false; }
/** * Tests whether or not the specified abstract pathname should be included in a pathname list. * * @param pathname The abstract pathname to be tested * @return <code>true</code> if and only if <code>pathname</code> should be included */ public boolean accept( final File pathname ) { if ( pathname.canRead() == false ) { return false; } if ( pathname.isDirectory() ) { return true; } final String name = pathname.getName(); return StringUtils.endsWithIgnoreCase( name, ".afm" ); }
/** * Tests whether or not the specified abstract pathname should be included in a pathname list. * * @param pathname The abstract pathname to be tested * @return <code>true</code> if and only if <code>pathname</code> should be included */ public boolean accept( final File pathname ) { if ( pathname.canRead() == false ) { return false; } if ( pathname.isDirectory() ) { return true; } final String name = pathname.getName(); return StringUtils.endsWithIgnoreCase( name, ".pfm" ); }
protected boolean canHandleResourceByName( final String name ) { final String[] fexts = getFileExtensions(); for ( int i = 0; i < fexts.length; i++ ) { if ( StringUtils.endsWithIgnoreCase( name, fexts[ i ] ) ) { return true; } } return false; }
/** * Returns an AWT Font which can be used to represent the given BaseFont * * @param font the font to be converted * @param size the desired point size of the resulting font * @return a Font which has similar properties to the provided BaseFont */ public Font pdfToAwt( final BaseFont font, final int size ) { final String logicalName = getFontName( font ); boolean bold = false; boolean italic = false; if ( StringUtils.endsWithIgnoreCase( logicalName, "bolditalic" ) ) { bold = true; italic = true; } else if ( StringUtils.endsWithIgnoreCase( logicalName, "bold" ) ) { bold = true; } else if ( StringUtils.endsWithIgnoreCase( logicalName, "italic" ) ) { italic = true; } int style = Font.PLAIN; if ( bold ) { style |= Font.BOLD; } if ( italic ) { style |= Font.ITALIC; } return new Font( logicalName, style, size ); }
if ( StringUtils.endsWithIgnoreCase( file, ".jpg" ) ) { return true; if ( StringUtils.endsWithIgnoreCase( file, ".jpeg" ) ) { return true; if ( StringUtils.endsWithIgnoreCase( file, ".png" ) ) { return true; if ( StringUtils.endsWithIgnoreCase( file, ".gif" ) ) { return true;
/** * Selects a file to use as target for the report processing. */ protected void performSelectFile() { final File file = new File( getFilename() ); if ( fileChooserHtml == null ) { fileChooserHtml = new JFileChooser(); fileChooserHtml.addChoosableFileFilter( new FilesystemFilter( new String[] { HtmlDirExportDialog.HTML_FILE_EXTENSION, HtmlDirExportDialog.HTM_FILE_EXTENSION }, getResources().getString( "htmlexportdialog.html-documents" ), true ) ); //$NON-NLS-1$ fileChooserHtml.setMultiSelectionEnabled( false ); } fileChooserHtml.setCurrentDirectory( file ); fileChooserHtml.setSelectedFile( file ); final int option = fileChooserHtml.showSaveDialog( this ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = fileChooserHtml.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on html if ( ( StringUtils.endsWithIgnoreCase( selFileName, HtmlDirExportDialog.HTML_FILE_EXTENSION ) == false ) && ( StringUtils.endsWithIgnoreCase( selFileName, HtmlDirExportDialog.HTM_FILE_EXTENSION ) == false ) ) { selFileName = selFileName + HtmlDirExportDialog.HTML_FILE_EXTENSION; } setFilename( selFileName ); } }
/** * Selects a file to use as target for the report processing. */ protected void performSelectFile() { final File file = new File( getFilename() ); if ( fileChooserHtml == null ) { fileChooserHtml = new JFileChooser(); fileChooserHtml.addChoosableFileFilter( new FilesystemFilter( new String[] { HtmlStreamExportDialog.HTML_FILE_EXTENSION, HtmlStreamExportDialog.HTM_FILE_EXTENSION }, getResources() .getString( "htmlexportdialog.html-documents" ), true ) ); //$NON-NLS-1$ fileChooserHtml.setMultiSelectionEnabled( false ); } fileChooserHtml.setCurrentDirectory( file ); fileChooserHtml.setSelectedFile( file ); final int option = fileChooserHtml.showSaveDialog( this ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = fileChooserHtml.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on html if ( ( StringUtils.endsWithIgnoreCase( selFileName, HtmlStreamExportDialog.HTML_FILE_EXTENSION ) == false ) && ( StringUtils.endsWithIgnoreCase( selFileName, HtmlStreamExportDialog.HTM_FILE_EXTENSION ) == false ) ) { selFileName = selFileName + HtmlStreamExportDialog.HTML_FILE_EXTENSION; } setFilename( selFileName ); } }
/** * Selects a file to use as target for the report processing. */ protected void performSelectFile() { if ( fileChooser == null ) { fileChooser = new JFileChooser(); final FilesystemFilter filter = new FilesystemFilter( CSVTableExportDialog.CSV_FILE_EXTENSION, getResources().getString( "csvexportdialog.csv-file-description" ) ); //$NON-NLS-1$ fileChooser.addChoosableFileFilter( filter ); fileChooser.setMultiSelectionEnabled( false ); } fileChooser.setSelectedFile( new File( getFilename() ) ); final int option = fileChooser.showSaveDialog( this ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on csv if ( StringUtils.endsWithIgnoreCase( selFileName, CSVTableExportDialog.CSV_FILE_EXTENSION ) == false ) { selFileName = selFileName + CSVTableExportDialog.CSV_FILE_EXTENSION; } setFilename( selFileName ); } }
/** * Selects a file to use as target for the report processing. */ protected void performSelectFileZip() { final File file = new File( getFilename() ); if ( fileChooserZip == null ) { fileChooserZip = new JFileChooser(); fileChooserZip.addChoosableFileFilter( new FilesystemFilter( new String[] { HtmlZipExportDialog.ZIP_FILE_EXTENSION, HtmlZipExportDialog.JAR_FILE_EXTENSION }, getResources().getString( "htmlexportdialog.zip-archives" ), true ) ); //$NON-NLS-1$ fileChooserZip.setMultiSelectionEnabled( false ); } fileChooserZip.setCurrentDirectory( file ); fileChooserZip.setSelectedFile( file ); final int option = fileChooserZip.showSaveDialog( this ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = fileChooserZip.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on xls if ( StringUtils.endsWithIgnoreCase( selFileName, HtmlZipExportDialog.ZIP_FILE_EXTENSION ) == false ) { selFileName = selFileName + HtmlZipExportDialog.ZIP_FILE_EXTENSION; } setFilename( selFileName ); } }
/** * Selects a file to use as target for the report processing. */ protected void performSelectFile() { if ( fileChooser == null ) { fileChooser = new JFileChooser(); final FilesystemFilter filter = new FilesystemFilter( CSVDataExportDialog.CSV_FILE_EXTENSION, getResources().getString( "csvexportdialog.csv-file-description" ) ); //$NON-NLS-1$ fileChooser.addChoosableFileFilter( filter ); fileChooser.setMultiSelectionEnabled( false ); } fileChooser.setSelectedFile( new File( getFilename() ) ); final int option = fileChooser.showSaveDialog( this ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on csv if ( StringUtils.endsWithIgnoreCase( selFileName, CSVDataExportDialog.CSV_FILE_EXTENSION ) == false ) { selFileName = selFileName + CSVDataExportDialog.CSV_FILE_EXTENSION; } setFilename( selFileName ); } }
/** * Selects a file to use as target for the report processing. */ protected void performSelectFile() { if ( fileChooser == null ) { fileChooser = new JFileChooser(); final FilesystemFilter filter = new FilesystemFilter( ExcelExportDialog.XLS_FILE_EXTENSION, getResources().getString( "excelexportdialog.excel-file-description" ) ); //$NON-NLS-1$ fileChooser.addChoosableFileFilter( filter ); fileChooser.setMultiSelectionEnabled( false ); } final File file = new File( getFilename() ); fileChooser.setCurrentDirectory( file ); fileChooser.setSelectedFile( file ); final int option = fileChooser.showSaveDialog( this ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on xls if ( StringUtils.endsWithIgnoreCase( selFileName, ExcelExportDialog.XLS_FILE_EXTENSION ) == false ) { selFileName = selFileName + ExcelExportDialog.XLS_FILE_EXTENSION; } setFilename( selFileName ); } }
/** * Selects a file to use as target for the report processing. */ protected void performSelectFile() { if ( fileChooser == null ) { fileChooser = new JFileChooser(); final FilesystemFilter filter = new FilesystemFilter( RTFExportDialog.RTF_FILE_EXTENSION, getResources().getString( "rtf-exportdialog.rtf-file-description" ) ); //$NON-NLS-1$ fileChooser.addChoosableFileFilter( filter ); fileChooser.setMultiSelectionEnabled( false ); } final File file = new File( getFilename() ); fileChooser.setCurrentDirectory( file ); fileChooser.setSelectedFile( file ); final int option = fileChooser.showSaveDialog( this ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on xls if ( StringUtils.endsWithIgnoreCase( selFileName, RTFExportDialog.RTF_FILE_EXTENSION ) == false ) { selFileName = selFileName + RTFExportDialog.RTF_FILE_EXTENSION; } setFilename( selFileName ); } }
/** * Selects a file to use as target for the report processing. */ protected void performSelectFile() { if ( fileChooser == null ) { fileChooser = new JFileChooser(); final FilesystemFilter filter = new FilesystemFilter( XSSFExcelExportDialog.XLS_FILE_EXTENSION, getResources().getString( "excelexportdialog.excel-file-description" ) ); //$NON-NLS-1$ fileChooser.addChoosableFileFilter( filter ); fileChooser.setMultiSelectionEnabled( false ); } final File file = new File( getFilename() ); fileChooser.setCurrentDirectory( file ); fileChooser.setSelectedFile( file ); final int option = fileChooser.showSaveDialog( this ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on xls if ( StringUtils.endsWithIgnoreCase( selFileName, XSSFExcelExportDialog.XLS_FILE_EXTENSION ) == false ) { selFileName = selFileName + XSSFExcelExportDialog.XLS_FILE_EXTENSION; } setFilename( selFileName ); } }
/** * Saves the report configuration to a user selectable report properties file. */ protected void save() { setStatusText( resources.getString( "ConfigEditor.USER_SAVING" ) ); //$NON-NLS-1$ editorPane.commit(); if ( fileChooser == null ) { fileChooser = new JFileChooser(); final FilesystemFilter filter = new FilesystemFilter ( ConfigEditor.PROPERTIES_FILE_EXTENSION, resources.getString( "config-editor.file-description.properties" ) ); //$NON-NLS-1$ fileChooser.addChoosableFileFilter( filter ); fileChooser.setMultiSelectionEnabled( false ); } final int option = fileChooser.showSaveDialog( this ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); // Test if ends on xls if ( StringUtils.endsWithIgnoreCase( selFileName, ConfigEditor.PROPERTIES_FILE_EXTENSION ) == false ) { selFileName = selFileName + ConfigEditor.PROPERTIES_FILE_EXTENSION; } write( selFileName ); } }
/** * Selects a file to use as target for the operation. * * @param selectedFile * the selected file. * @param dialogType * the dialog type. * @param appendExtension * true, if the file extension should be added if necessary, false if the unmodified filename should be used. * @return the selected and approved file or null, if the user canceled the operation */ protected File performSelectFile( final File selectedFile, final int dialogType, final boolean appendExtension ) { if ( this.fileChooser == null ) { this.fileChooser = createFileChooser(); } this.fileChooser.setSelectedFile( selectedFile ); this.fileChooser.setDialogType( dialogType ); final int option = this.fileChooser.showDialog( this.parent, null ); if ( option == JFileChooser.APPROVE_OPTION ) { final File selFile = this.fileChooser.getSelectedFile(); String selFileName = selFile.getAbsolutePath(); if ( StringUtils.endsWithIgnoreCase( selFileName, getFileExtension() ) == false ) { selFileName = selFileName + getFileExtension(); } return new File( selFileName ); } return null; }
if ( StringUtils.endsWithIgnoreCase( selFileName, ConfigEditor.PROPERTIES_FILE_EXTENSION ) == false ) { selFileName = selFileName + ConfigEditor.PROPERTIES_FILE_EXTENSION;
protected boolean addFont( final File file, final String encoding ) throws IOException { try { if ( StringUtils.endsWithIgnoreCase( file.getName(), ".ttc" ) ) { final TrueTypeCollection ttc = new TrueTypeCollection( file ); for ( int i = 0; i < ttc.getNumFonts(); i++ ) {