use of net.parostroj.timetable.model.LineType in project grafikon by jub77.
the class TrainTypeDialog method updateValuesForTrainType.
private void updateValuesForTrainType(TrainType selected, TrainDiagram diagram) {
// update categories
brakeComboBox.removeAllItems();
brakeComboBox.addItem(NONE_CATEGORY);
for (TrainTypeCategory category : diagram.getTrainTypeCategories()) {
brakeComboBox.addItem(Wrapper.getWrapper(category));
}
if (selected != null) {
abbrTextField.getPresentationModel().init(selected.getAbbr(), diagram.getLocales());
descTextField.getPresentationModel().init(selected.getDesc(), diagram.getLocales());
colorLabel.setText(Conversions.convertColorToText(selected.getColor()));
colorLabel.setForeground(selected.getColor());
TrainTypeCategory category = selected.getCategory();
brakeComboBox.setSelectedItem(category != null ? Wrapper.getWrapper(category) : NONE_CATEGORY);
nameTemplateCheckBox.setSelected(selected.getTrainNameTemplate() != null);
nameTemplateEditBox.setEnabled(selected.getTrainNameTemplate() != null);
nameTemplateEditBox.setTemplate(selected.getTrainNameTemplate() == null ? selected.getDiagram().getTrainsData().getTrainNameTemplate() : selected.getTrainNameTemplate());
completeNameTemplateCheckBox.setSelected(selected.getTrainCompleteNameTemplate() != null);
cNameTemplateEditBox.setEnabled(selected.getTrainCompleteNameTemplate() != null);
cNameTemplateEditBox.setTemplate(selected.getTrainCompleteNameTemplate() == null ? selected.getDiagram().getTrainsData().getTrainCompleteNameTemplate() : selected.getTrainCompleteNameTemplate());
platformNeededCheckBox.setSelected(selected.isPlatform());
showWeightInfoCheckBox.setSelected(selected.getAttributes().getBool(TrainType.ATTR_SHOW_WEIGHT_INFO));
// line information
Integer lineTypeInt = selected.getAttributes().get(TrainType.ATTR_LINE_TYPE, Integer.class);
LineType lineType = LineType.valueOf(lineTypeInt);
lineTypeComboBox.setSelectedIndex(lineType.ordinal());
lineWidthTextField.setText(Integer.toString(this.convertDoubleValueToPercent(selected, TrainType.ATTR_LINE_WIDTH)));
lineLengthTextField.setText(Integer.toString(this.convertDoubleValueToPercent(selected, TrainType.ATTR_LINE_LENGTH)));
} else {
abbrTextField.getPresentationModel().init(LocalizedString.fromString(""), diagram.getLocales());
descTextField.getPresentationModel().init(LocalizedString.fromString(""), diagram.getLocales());
colorLabel.setText("0x000000");
colorLabel.setForeground(Color.BLACK);
brakeComboBox.setSelectedItem(NONE_CATEGORY);
nameTemplateCheckBox.setSelected(false);
nameTemplateEditBox.setTemplate(diagram.getTrainsData().getTrainNameTemplate());
nameTemplateEditBox.setEnabled(false);
completeNameTemplateCheckBox.setSelected(false);
cNameTemplateEditBox.setTemplate(diagram.getTrainsData().getTrainCompleteNameTemplate());
cNameTemplateEditBox.setEnabled(false);
platformNeededCheckBox.setSelected(false);
showWeightInfoCheckBox.setSelected(false);
lineTypeComboBox.setSelectedIndex(0);
lineWidthTextField.setText("100");
lineLengthTextField.setText("100");
}
}
use of net.parostroj.timetable.model.LineType in project grafikon by jub77.
the class TrainTypeDialog method extractLineType.
private Integer extractLineType() {
Wrapper<?> selectedType = (Wrapper<?>) lineTypeComboBox.getSelectedItem();
LineType type = (LineType) selectedType.getElement();
// solid is default value -> null
return type == LineType.SOLID ? null : type.getValue();
}
Aggregations