use of net.parostroj.timetable.model.changes.DiagramChangeDescription 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.DiagramChangeDescription in project grafikon by jub77.
the class ChangesTrackerPanel method transformChange.
private String transformChange(DiagramChange change) {
StringBuilder b = new StringBuilder();
b.append(change.getType()).append(": ");
b.append(change.getObject() != null ? change.getObject() : change.getType()).append('\n');
if (change.getAction() != null)
b.append(ResourceLoader.getString("tracker.action")).append(": ").append(change.getAction()).append('\n');
if (change.getDescriptions() != null) {
boolean endl = false;
for (DiagramChangeDescription d : change.getDescriptions()) {
if (endl)
b.append('\n');
else
endl = true;
b.append(d.getFormattedDescription());
}
}
return b.toString();
}
use of net.parostroj.timetable.model.changes.DiagramChangeDescription 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;
}
use of net.parostroj.timetable.model.changes.DiagramChangeDescription in project grafikon by jub77.
the class LSDiagramChangeDescription method createDiagramChangeDescription.
public DiagramChangeDescription createDiagramChangeDescription() {
DiagramChangeDescription result = new DiagramChangeDescription(desc);
if (this.params != null) {
Parameter[] created = new Parameter[this.params.length];
for (int i = 0; i < this.params.length; i++) {
created[i] = this.params[i].createParameter();
}
result.setParams(created);
}
return result;
}
Aggregations