Search in sources :

Example 1 with DiagramChangeDescription

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;
}
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 DiagramChangeDescription

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

Example 3 with DiagramChangeDescription

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

Example 4 with DiagramChangeDescription

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

Aggregations

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