use of net.parostroj.timetable.model.changes.DiagramChange in project grafikon by jub77.
the class DiagramChangeSetImpl method addChange.
List<Pair<DiagramChange, ChangesTrackerEvent.Type>> addChange(DiagramChange change) {
// add change
// look for existing changes
List<DiagramChange> existing = getChangesForId(change.getObjectId());
List<Pair<DiagramChange, ChangesTrackerEvent.Type>> returning = new LinkedList<>();
boolean shouldAdd = true;
DiagramChange addTo = null;
if (existing != null) {
for (DiagramChange ex : existing) {
// logic
boolean add = shouldAdd(change, ex);
if (add && ex.getAction() == Action.MODIFIED && change.getAction() == Action.MODIFIED) {
addTo = ex;
}
shouldAdd &= add;
if (shouldRemove(change, ex)) {
changes.remove(ex);
returning.add(new Pair<>(ex, ChangesTrackerEvent.Type.CHANGE_REMOVED));
}
}
}
if (shouldAdd) {
if (addTo == null) {
changes.add(change);
returning.add(new Pair<>(change, ChangesTrackerEvent.Type.CHANGE_ADDED));
} else {
addTo.setObject(change.getObject());
if (change.getDescriptions() != null) {
for (DiagramChangeDescription d : change.getDescriptions()) {
addTo.addDescriptionUnique(d);
}
returning.add(new Pair<>(addTo, ChangesTrackerEvent.Type.CHANGE_MODIFIED));
}
}
}
return returning;
}
use of net.parostroj.timetable.model.changes.DiagramChange in project grafikon by jub77.
the class ChangesTrackerPanel method fillChanges.
private void fillChanges(DiagramChangeSet set) {
ChangesTrackerListModel model = new ChangesTrackerListModel();
if (set != null) {
for (DiagramChange change : set.getChanges()) {
model.addElement(new ChangeWrapper(change));
}
}
changesList.setModel(model);
}
use of net.parostroj.timetable.model.changes.DiagramChange in project grafikon by jub77.
the class LSDiagramChange method createDiagramChange.
public DiagramChange createDiagramChange() {
DiagramChange change = new DiagramChange();
change.setType(DiagramChange.Type.valueOf(type));
if (action != null)
change.setAction(DiagramChange.Action.valueOf(action));
change.setObjectId(objectId);
change.setObject(object);
if (this.descs != null) {
List<DiagramChangeDescription> ds = new LinkedList<DiagramChangeDescription>();
for (LSDiagramChangeDescription d : this.descs) {
ds.add(d.createDiagramChangeDescription());
}
change.setDescriptions(ds);
}
return change;
}
Aggregations