mirror of https://github.com/rusefi/rusefi-1.git
refactoring: better dependency control
This commit is contained in:
parent
1a12d0cdeb
commit
9c3ea2f17b
|
@ -31,7 +31,7 @@ public class CommandQueue {
|
|||
*/
|
||||
private Set<String> pendingConfirmations = Collections.synchronizedSet(new HashSet<String>());
|
||||
|
||||
private static final CommandQueue instance = new CommandQueue();
|
||||
public static final CommandQueue instance = new CommandQueue();
|
||||
private final BlockingQueue<IMethodInvocation> pendingCommands = new LinkedBlockingQueue<>();
|
||||
private final List<CommandQueueListener> commandListeners = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -99,7 +99,8 @@ public class ECUEditorToolBar extends JToolBar {
|
|||
burnImage.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
CommandQueue.getInstance().write(Fields.CMD_WRITECONFIG);
|
||||
throw new UnsupportedOperationException("Disabled");
|
||||
//CommandQueue.getInstance().write(Fields.CMD_WRITECONFIG);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,10 +17,12 @@ public class PresetsPane {
|
|||
private static final int TEST_V_12 = 49;
|
||||
private static final int ETB_BENCH = 58;
|
||||
private static final int MINIMAL_PINS = 99;
|
||||
private final UIContext uiContext;
|
||||
|
||||
private JPanel content = new JPanel(new GridLayout(2, 4));
|
||||
|
||||
public PresetsPane(UIContext uiContext) {
|
||||
this.uiContext = uiContext;
|
||||
content.add(new SetEngineTypeCommandControl("Frankenso Miata NA6 Stage 0", "/engines/miata_na.png", Fields.ET_FRANKENSO_MIATA_NA6_VAF).getContent());
|
||||
content.add(new SetEngineTypeCommandControl("Frankenso Miata NA6 Stage 1", "/engines/miata_na.png", Fields.ET_FRANKENSO_MIATA_NA6).getContent());
|
||||
content.add(new SetEngineTypeCommandControl("Frankenso Miata NB2", "/engines/miata_nb.png", Fields.ET_FRANKENSO_MIATA_NB2).getContent());
|
||||
|
@ -53,7 +55,7 @@ public class PresetsPane {
|
|||
if (dialogResult != JOptionPane.YES_OPTION)
|
||||
return;
|
||||
|
||||
CommandQueue.getInstance().write(getCommand());
|
||||
uiContext.getCommandQueue().write(getCommand());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package com.rusefi;
|
|||
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.opensr5.Logger;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.ui.RecentCommands;
|
||||
import com.rusefi.ui.StatusWindow;
|
||||
import com.rusefi.ui.UIContext;
|
||||
|
||||
|
@ -13,28 +10,26 @@ import java.awt.*;
|
|||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
* 3/7/2015
|
||||
*/
|
||||
public class UploadChanges {
|
||||
private static final StatusWindow wnd = new StatusWindow();
|
||||
//public static final Logger logger = createUiLogger();
|
||||
|
||||
public static void main(String[] args) throws InvocationTargetException, InterruptedException {
|
||||
|
||||
StatusWindow wnd = new StatusWindow();
|
||||
|
||||
static {
|
||||
wnd.getFrame().setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
|
||||
wnd.getFrame().setTitle("rusEfi bin upload");
|
||||
wnd.getFrameHelper().initFrame(wnd.getContent(), false);
|
||||
|
||||
JPanel bottomPanel = new JPanel(new FlowLayout());
|
||||
bottomPanel.add(RecentCommands.createButton(new AtomicBoolean(), Fields.CMD_WRITECONFIG));
|
||||
// bottomPanel.add(RecentCommands.createButton(new AtomicBoolean(), Fields.CMD_WRITECONFIG));
|
||||
wnd.getContent().add(bottomPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
public static final Logger logger = createUiLogger();
|
||||
|
||||
public static void main(String[] args) throws InvocationTargetException, InterruptedException {
|
||||
if (args.length != 1) {
|
||||
System.out.println("Exactly one parameter expected");
|
||||
return;
|
||||
|
@ -77,12 +72,16 @@ public class UploadChanges {
|
|||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
public static void scheduleUpload(UIContext uiContext, final ConfigurationImage newVersion) {
|
||||
scheduleUpload(uiContext, newVersion, null);
|
||||
}
|
||||
|
||||
*/
|
||||
public static void scheduleUpload(UIContext uiContext, final ConfigurationImage newVersion, final Runnable afterUpload) {
|
||||
JFrame frame = wnd.getFrame();
|
||||
if (1 == 1)
|
||||
throw new UnsupportedOperationException("disabled");
|
||||
Logger logger = null;
|
||||
JFrame frame = null;//wnd.getFrame();
|
||||
frame.setVisible(true);
|
||||
uiContext.getLinkManager().execute(new Runnable() {
|
||||
@Override
|
||||
|
@ -104,6 +103,7 @@ public class UploadChanges {
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
private static Logger createUiLogger() {
|
||||
return new Logger() {
|
||||
@Override
|
||||
|
@ -140,5 +140,5 @@ public class UploadChanges {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class RecentCommands {
|
|||
|
||||
public RecentCommands(UIContext uiContext) {
|
||||
this.uiContext = uiContext;
|
||||
CommandQueue.getInstance().addListener(new CommandQueue.CommandQueueListener() {
|
||||
uiContext.getCommandQueue().addListener(new CommandQueue.CommandQueueListener() {
|
||||
@Override
|
||||
public void onCommand(String command) {
|
||||
if (!reentrant.get())
|
||||
|
@ -168,7 +168,7 @@ public class RecentCommands {
|
|||
content.removeAll();
|
||||
|
||||
if (uiContext.getLinkManager().isLogViewer())
|
||||
content.add(createButton());
|
||||
content.add(createButton(uiContext));
|
||||
|
||||
JButton reset = new JButton(AutoupdateUtil.loadIcon("/undo.jpg"));
|
||||
reset.setContentAreaFilled(false);
|
||||
|
@ -188,7 +188,7 @@ public class RecentCommands {
|
|||
sorted.addAll(entries.keySet());
|
||||
|
||||
for (Entry entry : sorted) {
|
||||
content.add(createButton(reentrant, entry.command));
|
||||
content.add(createButton(uiContext, reentrant, entry.command));
|
||||
}
|
||||
}
|
||||
UiUtils.trueLayout(content.getParent());
|
||||
|
@ -197,7 +197,7 @@ public class RecentCommands {
|
|||
getConfig().getRoot().setProperty(KEY, pack());
|
||||
}
|
||||
|
||||
public static JComponent createButton(final AtomicBoolean reentrant, final String command) {
|
||||
public static JComponent createButton(UIContext uiContext, final AtomicBoolean reentrant, final String command) {
|
||||
JButton button = new JButton(command);
|
||||
Icon icon = COMMAND_ICONS.get(command);
|
||||
if (icon != null)
|
||||
|
@ -209,7 +209,7 @@ public class RecentCommands {
|
|||
public void actionPerformed(ActionEvent e) {
|
||||
reentrant.set(true);
|
||||
int timeout = CommandQueue.getTimeout(command);
|
||||
CommandQueue.getInstance().write(command, timeout);
|
||||
uiContext.getCommandQueue().write(command, timeout);
|
||||
reentrant.set(false);
|
||||
}
|
||||
});
|
||||
|
@ -279,7 +279,7 @@ public class RecentCommands {
|
|||
}
|
||||
|
||||
|
||||
public static JButton createButton() {
|
||||
public static JButton createButton(UIContext uiContext) {
|
||||
JButton button = new JButton("Read trigger log");
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.sensor_logs.SensorLogger;
|
||||
|
||||
|
@ -11,4 +12,8 @@ public class UIContext {
|
|||
public LinkManager getLinkManager() {
|
||||
return linkManager;
|
||||
}
|
||||
|
||||
public CommandQueue getCommandQueue() {
|
||||
return CommandQueue.instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class SettingsTab {
|
|||
|
||||
panel.add(dialogBody);
|
||||
|
||||
panel.add(UiUtils.wrap(RecentCommands.createButton(new AtomicBoolean(), Fields.CMD_WRITECONFIG)));
|
||||
panel.add(UiUtils.wrap(RecentCommands.createButton(uiContext, new AtomicBoolean(), Fields.CMD_WRITECONFIG)));
|
||||
|
||||
JLabel unusable = new JLabel("This is painfully unusable, TunerStudio works way better for settings!");
|
||||
unusable.setForeground(Color.red);
|
||||
|
|
Loading…
Reference in New Issue