if (SampleContextMacros.areSampleIndexesEmpty(sc, beginSample.getSampleNumber(), files.length)) {
SampleContextMacros.loadSamplesToContext(files, ZUtilities.fillIncrementally(new Integer[files.length], beginSample.getSampleNumber().intValue()), beginSample.getSampleContext(), true, stripIndex);
return;
}
} catch (NoSuchSampleException e) {
throw new CommandFailedException("No such sample");
} catch (NoSuchContextException e) {
throw new CommandFailedException("Problem with sample context");
}
if (files.length > 1) {
opt1 = "At locations " + df.format(beginSample.getSampleNumber()) + " - " + df.format(beginSample.getSampleNumber().intValue() + files.length - 1);
opt2 = "At first " + files.length + " empty locations searching from " + df.format(beginSample.getSampleNumber());
} else {
opt1 = "At location " + df.format(beginSample.getSampleNumber());
opt2 = "At first empty location searching from " + df.format(beginSample.getSampleNumber());
}
int res = JOptionPane.showOptionDialog(ZoeosFrame.getInstance(), (files.length == 1 ? "Load 1 sample" : "Load " + files.length + " samples "), "Load Samples", JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[]{opt1, opt2}, opt1);
if (res == 0) {
int si = beginSample.getSampleNumber().intValue();
Integer[] indexes = new Integer[files.length];
for (int i = 0; i < indexes.length; i++) {
indexes[i] = IntPool.get(si + i);
}
SampleContextMacros.loadSamplesToContext(files, indexes, beginSample.getSampleContext(), true, stripIndex);
} else if (res == 1) {
try {
List emptyList = sc.findEmptySamplesInContext(files.length, beginSample.getSampleNumber(), IntPool.get(DeviceContext.MAX_USER_SAMPLE));
if (emptyList.size() < files.length)
throw new CommandFailedException("Could not find " + files.length + " empty user sample locations.");
SampleContextMacros.loadSamplesToContext(files, (Integer[]) emptyList.toArray(new Integer[emptyList.size()]), beginSample.getSampleContext(), true, stripIndex);
} catch (NoSuchContextException e) {
throw new CommandFailedException("Problem with sample context");
}
}
}
}