}
}
if (f != null) {
int errors = 0;
Zoeos z = Zoeos.getInstance();
z.beginProgressElement(this, ZUtilities.makeExactLengthString(prefix + " Samples", 80), samples.length);
int overwriteMode = sap.getOverwriteMode();
try {
String name = "";
String nameMode;
int im = sap.getIndexMode();
switch (im) {
case SaveAccessoryPanel.MODE_PREFIXED_INDEX:
nameMode = AudioUtilities.SAMPLE_NAMING_MODE_IN;
break;
case SaveAccessoryPanel.MODE_POSTFIXED_INDEX:
nameMode = AudioUtilities.SAMPLE_NAMING_MODE_NI;
break;
case SaveAccessoryPanel.MODE_NO_INDEX:
nameMode = AudioUtilities.SAMPLE_NAMING_MODE_N;
break;
default:
throw new IllegalArgumentException("illegal index mode");
}
for (int i = 0; i < samples.length; i++) {
try {
name = samples[i].getSampleDisplayName();
z.setProgressElementIndeterminate(this, true);
File sf;
SampleRetrievalInfo sri = new Impl_SampleRetrievalInfo(samples[i].getSample(), samples[i].getSampleName(), f, afap.getActiveType(), nameMode, true, (overwriteMode == SaveAccessoryPanel.MODE_ALWAYS_OVERWRITE ? true : false));
z.updateProgressElementTitle(this, prefix + " " + name + " to \"" + sri.getFile().getName() + "\"");
try {
sf = samples[i].retrieveCustomLocalCopy(sri);
if (sf == null && (overwriteMode == SaveAccessoryPanel.MODE_ASK_OVERWRITE)) {
//int r = UserMessaging.askYesNoYesAll("File for " + "\"" + name + "\"" + " already exists, overwrite?", "File Already Exists");
int r = UserMessaging.askYesNoYesAllNoAll("File \"" + sri.getFile().getName() + "\" already exists, overwrite?", "File Already Exists");
if (r == 2)
overwriteMode = SaveAccessoryPanel.MODE_ALWAYS_OVERWRITE;
if (r == 3)
overwriteMode = SaveAccessoryPanel.MODE_NEVER_OVERWRITE;
if (r == 0 && r == 2)
samples[i].retrieveCustomLocalCopy(new Impl_SampleRetrievalInfo(samples[i].getSample(), samples[i].getSampleName(), f, afap.getActiveType(), nameMode, true, true));
}
} finally {
z.setProgressElementIndeterminate(this, false);
z.updateProgressElement(this, "Finished " + name);
}
} catch (NoSuchSampleException e) {
errors++;
} catch (SampleEmptyException e) {
errors++;
} catch (SampleRetrievalException e) {
errors++;
} finally {
}
}
} finally {
try {
if (samples.length > 0)
samples[0].getDeviceContext().sampleMemoryDefrag(false);
} catch (ZDeviceNotRunningException e) {
} catch (RemoteUnreachableException e) {
}
z.updateProgressElement(this, ProgressMultiBox.PROGRESS_DONE_TITLE);
z.endProgressElement(this);
}
if (errors == samples.length)
JOptionPane.showMessageDialog(ZoeosFrame.getInstance(), (samples.length > 1 ? "None of the source samples could be retrieved" : "The source sample could not be retrieved"), "Problem", JOptionPane.ERROR_MESSAGE);
else if (errors > 0)
JOptionPane.showMessageDialog(ZoeosFrame.getInstance(), errors + " of " + samples.length + " source samples could not be retrieved", "Problem", JOptionPane.ERROR_MESSAGE);