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;
}
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;
}
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);
}
}
}
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);
}
}
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();
}
Aggregations