use of net.parostroj.timetable.model.changes.ChangesTracker in project grafikon by jub77.
the class ModelUtils method saveModelData.
public static void saveModelData(final ApplicationModel model, File file) throws LSException {
// update author and date before save
TrainDiagram diagram = model.getDiagram();
boolean originalSkip = diagram.getAttributes().isSkipListeners();
diagram.getAttributes().setSkipListeners(true);
String user = model.getProgramSettings().getUserNameOrSystemUser();
diagram.setSaveUser(user);
final ChangesTracker tracker = diagram.getChangesTracker();
final DiagramChangeSet set = tracker.getCurrentChangeSet();
if (set != null && tracker.isTrackingEnabled()) {
try {
// do the update in event dispatch thread (because of events)
SwingUtilities.invokeAndWait(() -> {
tracker.updateCurrentChangeSet(set.getVersion(), user, Calendar.getInstance());
});
} catch (Exception e) {
log.warn("Error updating values for current diagram change set.", e);
}
}
log.info("Saving: {}", file);
LSFile ls = LSFileFactory.getInstance().createForSave();
ls.save(diagram, file);
diagram.getAttributes().setSkipListeners(originalSkip);
}
Aggregations