Search in sources :

Example 1 with ExampleFileFilter

use of net.sourceforge.processdash.ui.lib.ExampleFileFilter in project processdash by dtuma.

the class SaveBackupAction method getDestFile.

private File getDestFile(String defaultFilename) {
    JFileChooser fc = new JFileChooser();
    fc.setAcceptAllFileFilterUsed(false);
    fc.setSelectedFile(new File(getDefaultDirectory(fc), defaultFilename));
    fc.setDialogTitle(resources.getString("Save_Backup.Window_Title"));
    String defaultType = Settings.getVal(TYPE_PREF, ZIP);
    for (String type : BACKUP_FILE_TYPES) {
        ExampleFileFilter filter = makeFilter(type);
        fc.addChoosableFileFilter(filter);
        if (type.equalsIgnoreCase(defaultType))
            fc.setFileFilter(filter);
    }
    if (fc.showSaveDialog(null) != JFileChooser.APPROVE_OPTION)
        return null;
    File dest = fc.getSelectedFile();
    saveDefaultDirectory(dest);
    if (dest == null)
        return null;
    ExampleFileFilter ff = (ExampleFileFilter) fc.getFileFilter();
    File result = ff.maybeAppendExtension(dest);
    String resultType = ff.getExtension(result);
    if (StringUtils.hasValue(resultType))
        InternalSettings.set(TYPE_PREF, resultType);
    return result;
}
Also used : JFileChooser(javax.swing.JFileChooser) ExampleFileFilter(net.sourceforge.processdash.ui.lib.ExampleFileFilter) File(java.io.File)

Example 2 with ExampleFileFilter

use of net.sourceforge.processdash.ui.lib.ExampleFileFilter in project processdash by dtuma.

the class WBSOpenFileAction method makeFileChooser.

JFileChooser makeFileChooser() {
    JFileChooser fc = new JFileChooser();
    fc.setAcceptAllFileFilterUsed(false);
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fc.setFileFilter(new ExampleFileFilter("zip", resources.getString("File_Type_Description")));
    if (lastDirectory != null)
        fc.setCurrentDirectory(lastDirectory);
    return fc;
}
Also used : JFileChooser(javax.swing.JFileChooser) ExampleFileFilter(net.sourceforge.processdash.ui.lib.ExampleFileFilter)

Example 3 with ExampleFileFilter

use of net.sourceforge.processdash.ui.lib.ExampleFileFilter in project processdash by dtuma.

the class SaveBackupAction method selectBackupFile.

public File selectBackupFile(Component parent, String title) {
    JFileChooser fc = new JFileChooser();
    if (lastBackupDirectory != null)
        fc.setCurrentDirectory(lastBackupDirectory);
    fc.setDialogTitle(title);
    ExampleFileFilter ff = makeFilter(PDBK);
    for (String type : BACKUP_FILE_TYPES) ff.addExtension(type);
    ff.addFilename("state");
    fc.addChoosableFileFilter(ff);
    fc.setFileFilter(ff);
    if (fc.showOpenDialog(parent) != JFileChooser.APPROVE_OPTION)
        return null;
    File result = fc.getSelectedFile();
    saveDefaultDirectory(result);
    return result;
}
Also used : JFileChooser(javax.swing.JFileChooser) ExampleFileFilter(net.sourceforge.processdash.ui.lib.ExampleFileFilter) File(java.io.File)

Aggregations

JFileChooser (javax.swing.JFileChooser)3 ExampleFileFilter (net.sourceforge.processdash.ui.lib.ExampleFileFilter)3 File (java.io.File)2