use of net.parostroj.timetable.gui.actions.execution.EventDispatchAfterModelAction in project grafikon by jub77.
the class ExportAction method getSaveModelAction.
public static ModelAction getSaveModelAction(ActionContext context, final File file, final Component parent, final Library library) {
ModelAction action = new EventDispatchAfterModelAction(context) {
private String errorMessage;
@Override
protected void backgroundAction() {
setWaitMessage(ResourceLoader.getString("wait.message.savelibrary"));
setWaitDialogVisible(true);
long time = System.currentTimeMillis();
try {
ModelUtils.saveLibraryData(library, file);
} catch (LSException e) {
log.warn("Error saving library.", e);
errorMessage = ResourceLoader.getString("dialog.error.saving");
} catch (Exception e) {
log.warn("Error saving library.", e);
errorMessage = ResourceLoader.getString("dialog.error.saving");
} finally {
log.debug("Saved in {}ms", System.currentTimeMillis() - time);
setWaitDialogVisible(false);
}
}
@Override
protected void eventDispatchActionAfter() {
if (errorMessage != null) {
GuiComponentUtils.showError(errorMessage + " " + file.getName(), parent);
}
}
};
return action;
}
Aggregations