Now update mode combo box displays `displayText` field values instead of enumeration value names
Closes #6936
This commit is contained in:
parent
a5dfc3fc37
commit
5fafa3b121
|
@ -16,25 +16,33 @@ public enum JobType {
|
|||
UPDATE_CALIBRATIONS("Update calibrations");
|
||||
|
||||
final String jobName;
|
||||
final String persistedValue;
|
||||
/***
|
||||
* Text to display in the corresponding combo box item
|
||||
*/
|
||||
final String displayText;
|
||||
|
||||
JobType(final String jobName, final String persistedValue) {
|
||||
JobType(final String jobName, final String displayText) {
|
||||
this.jobName = jobName;
|
||||
this.persistedValue = persistedValue;
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
JobType(final String jobName) {
|
||||
this.jobName = jobName;
|
||||
this.persistedValue = null;
|
||||
this.displayText = null;
|
||||
}
|
||||
|
||||
static Optional<JobType> parsePersistedValue(final String persistedValue) {
|
||||
for (final JobType value: values()) {
|
||||
final String valuePersistedValue = value.persistedValue;
|
||||
final String valuePersistedValue = value.displayText;
|
||||
if ((valuePersistedValue != null) && valuePersistedValue.equals(persistedValue)) {
|
||||
return Optional.of(value);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayText;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ProgramSelector {
|
|||
final JobType selectedMode = (JobType) updateModeComboBox.getSelectedItem();
|
||||
final PortResult selectedPort = ((PortResult) comboPorts.getSelectedItem());
|
||||
|
||||
final String persistedValue = (selectedMode != null ? selectedMode.persistedValue : null);
|
||||
final String persistedValue = (selectedMode != null ? selectedMode.displayText : null);
|
||||
getConfig().getRoot().setProperty(getClass().getSimpleName(), persistedValue);
|
||||
executeJob(comboPorts, selectedMode, selectedPort);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue