only:refactoring: move job name from `JobType` enumeration to corresponding job class
This commit is contained in:
parent
88150d651b
commit
6315c6dc47
|
@ -3,34 +3,26 @@ package com.rusefi.maintenance;
|
|||
import java.util.Optional;
|
||||
|
||||
public enum JobType {
|
||||
DFU_AUTO("DFU update", "Auto DFU Update"),
|
||||
DFU_MANUAL("DFU update", "Manual DFU Update"),
|
||||
INSTALL_OPENBLT("OpenBLT Initial Programming", "Install OpenBLT"),
|
||||
ST_LINK("", "ST-LINK Update"),
|
||||
DFU_SWITCH("DFU switch", "Switch to DFU Mode"),
|
||||
OPENBLT_SWITCH("OpenBLT switch", "Switch to OpenBLT Mode"),
|
||||
OPENBLT_CAN("OpenBLT via CAN", "OpenBLT via CAN"),
|
||||
OPENBLT_MANUAL("OpenBLT via Serial", "Manual OpenBLT Update"),
|
||||
OPENBLT_AUTO("OpenBLT via Serial", "Auto OpenBLT Update"),
|
||||
DFU_ERASE("DFU erase", "Full DFU Erase"),
|
||||
UPDATE_CALIBRATIONS("Update calibrations");
|
||||
DFU_AUTO("Auto DFU Update"),
|
||||
DFU_MANUAL("Manual DFU Update"),
|
||||
INSTALL_OPENBLT("Install OpenBLT"),
|
||||
ST_LINK("ST-LINK Update"),
|
||||
DFU_SWITCH("Switch to DFU Mode"),
|
||||
OPENBLT_SWITCH("Switch to OpenBLT Mode"),
|
||||
OPENBLT_CAN("OpenBLT via CAN"),
|
||||
OPENBLT_MANUAL("Manual OpenBLT Update"),
|
||||
OPENBLT_AUTO("Auto OpenBLT Update"),
|
||||
DFU_ERASE("Full DFU Erase");
|
||||
|
||||
public final String jobName;
|
||||
/***
|
||||
* Text to display in the corresponding combo box item
|
||||
*/
|
||||
final String displayText;
|
||||
|
||||
JobType(final String jobName, final String displayText) {
|
||||
this.jobName = jobName;
|
||||
JobType(final String displayText) {
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
JobType(final String jobName) {
|
||||
this.jobName = jobName;
|
||||
this.displayText = null;
|
||||
}
|
||||
|
||||
static Optional<JobType> parsePersistedValue(final String persistedValue) {
|
||||
for (final JobType value: values()) {
|
||||
final String valuePersistedValue = value.displayText;
|
||||
|
|
|
@ -108,9 +108,6 @@ public class ProgramSelector {
|
|||
case DFU_ERASE:
|
||||
job = new DfuEraseJob();
|
||||
break;
|
||||
case UPDATE_CALIBRATIONS:
|
||||
job = new UpdateCalibrationsJob(selectedPort);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("How did you " + selectedMode);
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ import com.rusefi.maintenance.DfuFlasher;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.DFU_AUTO;
|
||||
|
||||
public class DfuAutoJob extends AsyncJobWithContext<SerialPortWithParentComponentJobContext> {
|
||||
public DfuAutoJob(final SerialPortScanner.PortResult port, final JComponent parent) {
|
||||
super(DFU_AUTO.jobName, new SerialPortWithParentComponentJobContext(port, parent));
|
||||
super("DFU update", new SerialPortWithParentComponentJobContext(port, parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,11 +3,9 @@ package com.rusefi.maintenance.jobs;
|
|||
import com.rusefi.io.UpdateOperationCallbacks;
|
||||
import com.rusefi.maintenance.DfuFlasher;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.DFU_ERASE;
|
||||
|
||||
public class DfuEraseJob extends AsyncJob {
|
||||
public DfuEraseJob() {
|
||||
super(DFU_ERASE.jobName);
|
||||
super("DFU erase");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,11 +3,9 @@ package com.rusefi.maintenance.jobs;
|
|||
import com.rusefi.io.UpdateOperationCallbacks;
|
||||
import com.rusefi.maintenance.DfuFlasher;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.DFU_MANUAL;
|
||||
|
||||
public class DfuManualJob extends AsyncJob {
|
||||
public DfuManualJob() {
|
||||
super(DFU_MANUAL.jobName);
|
||||
super("DFU update");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,11 +6,9 @@ import com.rusefi.maintenance.ProgramSelector;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.DFU_SWITCH;
|
||||
|
||||
public class DfuSwitchJob extends AsyncJobWithContext<SerialPortWithParentComponentJobContext> {
|
||||
public DfuSwitchJob(final SerialPortScanner.PortResult port, final JComponent parent) {
|
||||
super(DFU_SWITCH.jobName, new SerialPortWithParentComponentJobContext(port, parent));
|
||||
super("DFU switch", new SerialPortWithParentComponentJobContext(port, parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,11 +3,9 @@ package com.rusefi.maintenance.jobs;
|
|||
import com.rusefi.io.UpdateOperationCallbacks;
|
||||
import com.rusefi.maintenance.DfuFlasher;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.INSTALL_OPENBLT;
|
||||
|
||||
public class InstallOpenBltJob extends AsyncJob {
|
||||
public InstallOpenBltJob() {
|
||||
super(INSTALL_OPENBLT.jobName);
|
||||
super("OpenBLT Initial Programming");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,11 +6,9 @@ import com.rusefi.maintenance.ProgramSelector;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.OPENBLT_AUTO;
|
||||
|
||||
public class OpenBltAutoJob extends AsyncJobWithContext<SerialPortWithParentComponentJobContext> {
|
||||
public OpenBltAutoJob(final SerialPortScanner.PortResult port, final JComponent parent) {
|
||||
super(OPENBLT_AUTO.jobName, new SerialPortWithParentComponentJobContext(port, parent));
|
||||
super("OpenBLT via Serial", new SerialPortWithParentComponentJobContext(port, parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,11 +5,9 @@ import com.rusefi.maintenance.ProgramSelector;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.OPENBLT_CAN;
|
||||
|
||||
public class OpenBltCanJob extends AsyncJobWithContext<ParentComponentContext> {
|
||||
public OpenBltCanJob(final JComponent parent) {
|
||||
super(OPENBLT_CAN.jobName, new ParentComponentContext(parent));
|
||||
super("OpenBLT via CAN", new ParentComponentContext(parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,11 +6,9 @@ import com.rusefi.maintenance.ProgramSelector;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.OPENBLT_MANUAL;
|
||||
|
||||
public class OpenBltManualJob extends AsyncJobWithContext<SerialPortWithParentComponentJobContext> {
|
||||
public OpenBltManualJob(final SerialPortScanner.PortResult port, final JComponent parent) {
|
||||
super(OPENBLT_MANUAL.jobName, new SerialPortWithParentComponentJobContext(port, parent));
|
||||
super("OpenBLT via Serial", new SerialPortWithParentComponentJobContext(port, parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,11 +6,9 @@ import com.rusefi.maintenance.ProgramSelector;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.OPENBLT_SWITCH;
|
||||
|
||||
public class OpenBltSwitchJob extends AsyncJobWithContext<SerialPortWithParentComponentJobContext> {
|
||||
public OpenBltSwitchJob(final SerialPortScanner.PortResult port, final JComponent parent) {
|
||||
super(OPENBLT_SWITCH.jobName, new SerialPortWithParentComponentJobContext(port, parent));
|
||||
super("OpenBLT switch", new SerialPortWithParentComponentJobContext(port, parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,12 +6,10 @@ import com.rusefi.maintenance.StLinkFlasher;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.ST_LINK;
|
||||
|
||||
public class StLinkJob extends AsyncJobWithContext<ParentComponentContext> {
|
||||
|
||||
public StLinkJob(final JComponent parent) {
|
||||
super(ST_LINK.jobName, new ParentComponentContext(parent));
|
||||
super("", new ParentComponentContext(parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,11 +4,9 @@ import com.rusefi.SerialPortScanner;
|
|||
import com.rusefi.io.UpdateOperationCallbacks;
|
||||
import com.rusefi.maintenance.CalibrationsUpdater;
|
||||
|
||||
import static com.rusefi.maintenance.JobType.UPDATE_CALIBRATIONS;
|
||||
|
||||
public class UpdateCalibrationsJob extends AsyncJobWithContext<SerialPortJobContext> {
|
||||
public UpdateCalibrationsJob(final SerialPortScanner.PortResult port) {
|
||||
super(UPDATE_CALIBRATIONS.jobName, new SerialPortJobContext(port));
|
||||
super("Update calibrations", new SerialPortJobContext(port));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
import static com.rusefi.maintenance.JobType.UPDATE_CALIBRATIONS;
|
||||
|
||||
public class UpdateCalibrations {
|
||||
private static final Logging log = getLogging(UpdateCalibrations.class);
|
||||
|
|
Loading…
Reference in New Issue