private void createAndSaveSamplePackage(SampleContext sc, Integer[] indexes, String name, String notes, AudioFileFormat.Type format) throws CommandFailedException {
SamplePackage pkg = null;
try {
pkg = PackageFactory.createSamplePackage(sc, indexes, name, notes, null, format);
} catch (PackageGenerationException e) {
throw new CommandFailedException("Error saving sample package: " + e.getMessage());
}
File extFile = null;
synchronized (this.getClass()) {
assertChooser();
fc.setSelectedFile(new File(name));
int retval = fc.showSaveDialog(ZoeosFrame.getInstance());
if (retval == JFileChooser.APPROVE_OPTION) {
File f = fc.getSelectedFile();
//File extFile = new File(f.getAbsolutePath() + "." + SamplePackage.SAMPLE_PKG_EXT);
extFile = ZUtilities.replaceExtension(f, SamplePackage.SAMPLE_PKG_EXT);
if (extFile.exists() && JOptionPane.showConfirmDialog(ZoeosFrame.getInstance(), "Overwrite " + extFile.getName() + " ?", "File Already Exists", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == 1)
return;
ZPREF_lastDir.putValue(extFile.getAbsolutePath());
}
}
if (extFile != null) {
try {
PackageFactory.saveSamplePackage(pkg, extFile);
} catch (PackageGenerationException e) {
throw new CommandFailedException("Error saving sample package: " + e.getMessage());
} finally {
try {
sc.getDeviceContext().sampleMemoryDefrag(false);
} catch (ZDeviceNotRunningException e) {
} catch (RemoteUnreachableException e) {