static Boolean saveProduct(Product product) {
Assert.notNull(product.getFileLocation());
final File file = product.getFileLocation();
if (file.isFile() && !file.canWrite()) {
Dialogs.showWarning(Bundle.CTL_SaveProductActionName(),
MessageFormat.format("The product\n" +
"''{0}''\n" +
"exists and cannot be overwritten, because it is read only.\n" +
"Please choose another file or remove the write protection.",
file.getPath()),
null);
return false;
}
SnapApp.getDefault().setStatusBarMessage(MessageFormat.format("Writing product ''{0}'' to {1}...", product.getDisplayName(), file));
boolean incremental = true;
WriteProductOperation operation = new WriteProductOperation(product, incremental);
BaseProgressUtils.runOffEventThreadWithProgressDialog(operation,
Bundle.CTL_SaveProductActionName(),
operation.getProgressHandle(),
true,
50,
1000);
SnapApp.getDefault().setStatusBarMessage("");
return operation.getStatus();
}