Search in sources :

Example 1 with Attributes

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

the class AttributesPanel method stopEditing.

public Attributes stopEditing() {
    if (attributesTableModel != null) {
        TableCellEditor editor = attributesTable.getCellEditor();
        if (editor != null) {
            editor.stopCellEditing();
        }
        Attributes attributes = attributesTableModel.stopEditing();
        attributesTableModel = null;
        attributesTable.setModel(new DefaultTableModel());
        return attributes;
    } else {
        return null;
    }
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) Attributes(net.parostroj.timetable.model.Attributes) TableCellEditor(javax.swing.table.TableCellEditor)

Example 2 with Attributes

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

the class ModelAttributesPM method init.

public void init(Attributes attributes, String category, Function<String, String> nameTranslation) {
    Attributes oldValue = this.attributes;
    this.attributes = attributes;
    this.category = category;
    this.nameTranslation = nameTranslation;
    this.getPropertyChangeSupport().firePropertyChange("attributes", oldValue, this.attributes);
}
Also used : Attributes(net.parostroj.timetable.model.Attributes)

Example 3 with Attributes

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

the class LoadFilter4d21 method checkDiagram.

@Override
public void checkDiagram(TrainDiagram diagram, ModelVersion version) {
    if (version.compareTo(new ModelVersion(4, 21, 0)) <= 0) {
        // convert route unit...
        Attributes attributes = diagram.getAttributes();
        if (attributes.containsKey(TrainDiagram.ATTR_ROUTE_LENGTH_UNIT)) {
            // try to convert to length unit
            String lUnitStr = attributes.get(TrainDiagram.ATTR_ROUTE_LENGTH_UNIT, String.class);
            LengthUnit lUnit = LengthUnit.getByKey(lUnitStr);
            attributes.setRemove(TrainDiagram.ATTR_ROUTE_LENGTH_UNIT, lUnit);
        }
    }
    if (version.compareTo(new ModelVersion(4, 21, 1)) <= 0) {
        // convert train name templates (common)
        diagram.getTrainsData().setTrainNameTemplate(convertForAbbreviation(diagram.getTrainsData().getTrainNameTemplate()));
        diagram.getTrainsData().setTrainCompleteNameTemplate(convertForAbbreviation(diagram.getTrainsData().getTrainCompleteNameTemplate()));
        // in train types
        for (TrainType type : diagram.getTrainTypes()) {
            type.setTrainNameTemplate(convertForAbbreviation(type.getTrainNameTemplate()));
            type.setTrainCompleteNameTemplate(convertForAbbreviation(type.getTrainCompleteNameTemplate()));
        }
    }
}
Also used : Attributes(net.parostroj.timetable.model.Attributes) ModelVersion(net.parostroj.timetable.model.ls.ModelVersion) TrainType(net.parostroj.timetable.model.TrainType) LengthUnit(net.parostroj.timetable.model.units.LengthUnit)

Aggregations

Attributes (net.parostroj.timetable.model.Attributes)3 DefaultTableModel (javax.swing.table.DefaultTableModel)1 TableCellEditor (javax.swing.table.TableCellEditor)1 TrainType (net.parostroj.timetable.model.TrainType)1 ModelVersion (net.parostroj.timetable.model.ls.ModelVersion)1 LengthUnit (net.parostroj.timetable.model.units.LengthUnit)1