Search in sources :

Example 1 with TrainsCycle

use of net.parostroj.timetable.model.TrainsCycle in project grafikon by jub77.

the class TrainCycleTypeRemoveValidator method validate.

@Override
public boolean validate(Event event) {
    if (event.getSource() instanceof TrainDiagram && event.getType() == Type.REMOVED && event.getObject() instanceof TrainsCycleType) {
        // remove all cycles ...
        TrainsCycleType cycleType = (TrainsCycleType) event.getObject();
        List<TrainsCycle> copy = ImmutableList.copyOf(cycleType.getCycles());
        for (TrainsCycle cycle : copy) {
            cycleType.getCycles().remove(cycle);
        }
        return true;
    }
    return false;
}
Also used : TrainsCycle(net.parostroj.timetable.model.TrainsCycle) TrainDiagram(net.parostroj.timetable.model.TrainDiagram) TrainsCycleType(net.parostroj.timetable.model.TrainsCycleType)

Example 2 with TrainsCycle

use of net.parostroj.timetable.model.TrainsCycle in project grafikon by jub77.

the class TrainsCycleValidator method handleTrainsCycleEvent.

private boolean handleTrainsCycleEvent(Event event) {
    boolean validated = false;
    TrainsCycle circulation = (TrainsCycle) event.getSource();
    boolean attribute = event.getType() == Event.Type.ATTRIBUTE;
    if (attribute && circulation.isPartOfSequence() && event.getAttributeChange().checkName(CHECKED_ATTRIBUTES)) {
        distributeAttributesInSequence(circulation, event.getAttributeChange());
        validated = true;
    }
    if (attribute && event.getAttributeChange().checkName(TrainsCycle.ATTR_ENGINE_CLASS)) {
        recalculateEngineClassChange(circulation);
        validated = true;
    }
    return validated;
}
Also used : TrainsCycle(net.parostroj.timetable.model.TrainsCycle)

Example 3 with TrainsCycle

use of net.parostroj.timetable.model.TrainsCycle in project grafikon by jub77.

the class TrainDiagramBuilder method addCirculationToSequence.

private void addCirculationToSequence(String fromId) {
    String toId = circulationSequenceMap.remove(fromId);
    if (toId != null) {
        TrainsCycle from = diagram.getCycleById(fromId);
        TrainsCycle to = diagram.getCycleById(toId);
        // do not add if already part of sequence (circular - last one)
        if (!to.isPartOfSequence()) {
            from.connectToSequenceAsNext(to);
            addCirculationToSequence(toId);
        }
    }
}
Also used : TrainsCycle(net.parostroj.timetable.model.TrainsCycle)

Example 4 with TrainsCycle

use of net.parostroj.timetable.model.TrainsCycle in project grafikon by jub77.

the class TCListView method createButtonActionPerformed.

private void createButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // get name from text field (ignore shorter than one character
    if (newNameTextField.getText().length() > 0 && delegate.getType() != null) {
        TrainDiagram trainDiagram = delegate.getTrainDiagram();
        TrainsCycle cycle = new TrainsCycle(IdGenerator.getInstance().getId(), trainDiagram, newNameTextField.getText(), null, delegate.getType());
        cycle.getType().getCycles().add(cycle);
        // clear field
        newNameTextField.setText("");
        // fire event
        delegate.fireEvent(TCDelegate.Action.NEW_CYCLE, cycle);
        // set selected
        int index = cycles.getIndexOfObject(cycle);
        cyclesList.setSelectedIndex(index);
        cyclesList.ensureIndexIsVisible(index);
        delegate.fireEvent(TCDelegate.Action.SELECTED_CHANGED, cycle);
    }
}
Also used : TrainsCycle(net.parostroj.timetable.model.TrainsCycle) TrainDiagram(net.parostroj.timetable.model.TrainDiagram)

Example 5 with TrainsCycle

use of net.parostroj.timetable.model.TrainsCycle in project grafikon by jub77.

the class TCListView method updateView.

private void updateView() {
    cycles.clear();
    cyclesList.clearSelection();
    if (delegate.getTrainDiagram() != null && delegate.getType() != null) {
        // set list
        for (TrainsCycle cycle : delegate.getType().getCycles()) {
            cycles.addWrapper(Wrapper.getWrapper(cycle));
        }
    }
    this.updateButtonStatus();
}
Also used : TrainsCycle(net.parostroj.timetable.model.TrainsCycle)

Aggregations

TrainsCycle (net.parostroj.timetable.model.TrainsCycle)18 TrainsCycleItem (net.parostroj.timetable.model.TrainsCycleItem)6 Train (net.parostroj.timetable.model.Train)5 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)3 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)3 TrainsCycleType (net.parostroj.timetable.model.TrainsCycleType)3 Route (net.parostroj.timetable.model.Route)2 TimeInterval (net.parostroj.timetable.model.TimeInterval)2 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 ZipEntry (java.util.zip.ZipEntry)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 ModelPredicates (net.parostroj.timetable.filters.ModelPredicates)1 Wrapper (net.parostroj.timetable.gui.wrappers.Wrapper)1