Search in sources :

Example 1 with DiagramChange

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;
}
Also used : ChangesTrackerEvent(net.parostroj.timetable.model.changes.ChangesTrackerEvent) DiagramChangeDescription(net.parostroj.timetable.model.changes.DiagramChangeDescription) DiagramChange(net.parostroj.timetable.model.changes.DiagramChange) LinkedList(java.util.LinkedList) Pair(net.parostroj.timetable.utils.Pair)

Example 2 with DiagramChange

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);
}
Also used : DiagramChange(net.parostroj.timetable.model.changes.DiagramChange)

Example 3 with DiagramChange

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;
}
Also used : DiagramChangeDescription(net.parostroj.timetable.model.changes.DiagramChangeDescription) DiagramChange(net.parostroj.timetable.model.changes.DiagramChange) LinkedList(java.util.LinkedList)

Aggregations

DiagramChange (net.parostroj.timetable.model.changes.DiagramChange)3 LinkedList (java.util.LinkedList)2 DiagramChangeDescription (net.parostroj.timetable.model.changes.DiagramChangeDescription)2 ChangesTrackerEvent (net.parostroj.timetable.model.changes.ChangesTrackerEvent)1 Pair (net.parostroj.timetable.utils.Pair)1