use of javax.swing.JFileChooser in project android_frameworks_base by crdroidandroid.
the class UI method showOpenDialog.
public File[] showOpenDialog(boolean multi) {
// Hide the wait dialog...
if (currentWaitDialog != null) {
currentWaitDialog.setVisible(false);
}
try {
if (jfc == null) {
jfc = new JFileChooser();
}
jfc.setMultiSelectionEnabled(multi);
int ret = jfc.showOpenDialog(this);
if (ret == JFileChooser.APPROVE_OPTION) {
return jfc.getSelectedFiles();
} else {
return null;
}
} finally {
// And reshow it afterwards...
if (currentWaitDialog != null) {
showWaitDialogLater();
}
}
}
use of javax.swing.JFileChooser in project processdash by dtuma.
the class TeamDataDirPanel method actionPerformed.
/**
* Actions-handling method.
*
* @param e The event.
*/
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == textField) {
parent.navigateNext();
} else {
// The user wants to browse its filesystem
// Prepares the file chooser
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(textField.getText()));
fc.setMultiSelectionEnabled(false);
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.addChoosableFileFilter(fc.getAcceptAllFileFilter());
// Shows it
if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
textField.setText(fc.getSelectedFile().getAbsolutePath());
}
}
use of javax.swing.JFileChooser 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;
}
use of javax.swing.JFileChooser in project processdash by dtuma.
the class WBSSaveAsAction method getDestinationFile.
private File getDestinationFile() {
// prompt the user to select a file to save to
JFileChooser fileChooser = makeFileChooser();
int userChoice = fileChooser.showSaveDialog(wbsEditor.frame);
openAction.lastDirectory = fileChooser.getCurrentDirectory();
if (userChoice != JFileChooser.APPROVE_OPTION)
return null;
// if they selected a file that did not end with the "zip" suffix,
// append it
File f = fileChooser.getSelectedFile();
if (f != null && !f.getName().toLowerCase().endsWith(".zip"))
f = new File(f.getParentFile(), f.getName() + ".zip");
if (f.isFile()) {
String title = resources.getString("Overwrite.Title");
String message = resources.format("Overwrite.Message_FMT", f.getPath());
userChoice = JOptionPane.showConfirmDialog(wbsEditor.frame, message, title, JOptionPane.OK_CANCEL_OPTION);
if (userChoice != JOptionPane.OK_OPTION)
f = null;
}
return f;
}
use of javax.swing.JFileChooser in project processdash by dtuma.
the class SaveAsExcelAction method getOutputFile.
private File getOutputFile() {
if (fileChooser == null) {
fileChooser = new JFileChooser();
fileChooser.setDialogTitle(resources.getString("Dialog_Title"));
fileChooser.setFileFilter(new ExcelFileFilter());
}
if (lastFileSelected != null)
fileChooser.setSelectedFile(lastFileSelected);
Component parent = SwingUtilities.getWindowAncestor(getWBSTabPanel());
int userOption = fileChooser.showSaveDialog(parent);
if (userOption != JFileChooser.APPROVE_OPTION)
return null;
File result = fileChooser.getSelectedFile();
if (result == null)
return null;
String filename = result.getName();
if (filename.indexOf('.') == -1) {
filename = filename + EXCEL_SUFFIX;
result = new File(result.getParentFile(), filename);
}
lastFileSelected = result;
return result;
}
Aggregations