auto-sync
This commit is contained in:
parent
b9eb97d485
commit
8facb8491a
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
|
@ -20,10 +20,11 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
|||
* 12/25/12
|
||||
* (c) Andrey Belomutskiy 2013-2015
|
||||
*
|
||||
* @see PortLookupFrame
|
||||
* @see WavePanel
|
||||
*/
|
||||
public class Launcher extends FrameHelper {
|
||||
public static final int CONSOLE_VERSION = 20150130;
|
||||
public static final int CONSOLE_VERSION = 20150203;
|
||||
public static final boolean SHOW_STIMULATOR = true;
|
||||
public static final String TAB_INDEX = "main_tab";
|
||||
private final String port;
|
||||
|
@ -67,6 +68,7 @@ public class Launcher extends FrameHelper {
|
|||
tabbedPane.setSelectedIndex(selectedIndex);
|
||||
}
|
||||
|
||||
PortLookupFrame.setAppIcon(frame);
|
||||
showFrame(tabbedPane);
|
||||
}
|
||||
|
||||
|
@ -124,7 +126,7 @@ public class Launcher extends FrameHelper {
|
|||
} else {
|
||||
for (String p : SerialPortList.getPortNames())
|
||||
MessagesCentral.getInstance().postMessage(Launcher.class, "Available port: " + p);
|
||||
PortLookupFrame.chooseSerialPort();
|
||||
new PortLookupFrame().chooseSerialPort();
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
|
|
|
@ -11,6 +11,9 @@ import javax.swing.*;
|
|||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -23,17 +26,38 @@ import java.util.List;
|
|||
* 2/14/14
|
||||
*/
|
||||
public class PortLookupFrame {
|
||||
// todo: figure out a better way to work with absolute path
|
||||
public static final String APPICON_PNG = "../../appicon.png";
|
||||
private static final String LINK_TEXT = "rusEfi (c) 2012-2015";
|
||||
private static final String URI = "http://rusefi.com/?java_console";
|
||||
|
||||
public static final String RUS_EFI_C_2012_2014 = "rusEfi (c) 2012-2015";
|
||||
public static final String URI = "http://rusefi.com/?java_console";
|
||||
private final JFrame frame;
|
||||
private boolean isProceeding;
|
||||
|
||||
public static void chooseSerialPort() {
|
||||
public PortLookupFrame() {
|
||||
frame = new JFrame(Launcher.CONSOLE_VERSION + ": Serial port selection");
|
||||
frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosed(WindowEvent ev) {
|
||||
if (!isProceeding)
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
setAppIcon(frame);
|
||||
}
|
||||
|
||||
public static void setAppIcon(JFrame frame) {
|
||||
ImageIcon icon = loadIcon(APPICON_PNG);
|
||||
if (icon != null)
|
||||
frame.setIconImage(icon.getImage());
|
||||
}
|
||||
|
||||
public void chooseSerialPort() {
|
||||
List<String> ports = new ArrayList<>();
|
||||
ports.addAll(Arrays.asList(SerialPortList.getPortNames()));
|
||||
ports.addAll(TcpConnector.getAvailablePorts());
|
||||
|
||||
final JFrame frame = new JFrame(Launcher.CONSOLE_VERSION + ": Serial port selection");
|
||||
|
||||
JPanel content = new JPanel(new BorderLayout());
|
||||
|
||||
final JPanel upperPanel = new JPanel(new FlowLayout());
|
||||
|
@ -46,7 +70,7 @@ public class PortLookupFrame {
|
|||
buttonLogViewer.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
frame.dispose();
|
||||
disposeFrameAndProceed();
|
||||
new Launcher(LinkManager.LOG_VIEWER);
|
||||
}
|
||||
});
|
||||
|
@ -54,11 +78,11 @@ public class PortLookupFrame {
|
|||
upperPanel.add(buttonLogViewer);
|
||||
|
||||
JPanel centerPanel = new JPanel(new FlowLayout());
|
||||
centerPanel.add(SimulatorHelper.createSimulatorComponent(frame));
|
||||
centerPanel.add(SimulatorHelper.createSimulatorComponent(this));
|
||||
|
||||
|
||||
JPanel lowerPanel = new JPanel(new FlowLayout());
|
||||
lowerPanel.add(new URLLabel(RUS_EFI_C_2012_2014, URI));
|
||||
lowerPanel.add(new URLLabel(LINK_TEXT, URI));
|
||||
content.add(upperPanel, BorderLayout.NORTH);
|
||||
content.add(centerPanel, BorderLayout.CENTER);
|
||||
content.add(lowerPanel, BorderLayout.SOUTH);
|
||||
|
@ -70,7 +94,12 @@ public class PortLookupFrame {
|
|||
UiUtils.centerWindow(frame);
|
||||
}
|
||||
|
||||
private static void addPortSelection(List<String> ports, final JFrame frame, JPanel panel) {
|
||||
public void disposeFrameAndProceed() {
|
||||
isProceeding = true;
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
private void addPortSelection(List<String> ports, final JFrame frame, JPanel panel) {
|
||||
final JComboBox<String> comboPorts = new JComboBox<>();
|
||||
for (final String port : ports)
|
||||
comboPorts.addItem(port);
|
||||
|
@ -81,9 +110,17 @@ public class PortLookupFrame {
|
|||
connect.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
frame.dispose();
|
||||
disposeFrameAndProceed();
|
||||
new Launcher(comboPorts.getSelectedItem().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static ImageIcon loadIcon(String strPath) {
|
||||
URL imgURL = PortLookupFrame.class.getResource(strPath);
|
||||
if (imgURL != null)
|
||||
return new ImageIcon(imgURL);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -43,24 +43,22 @@ public class SimulatorHelper {
|
|||
|
||||
}
|
||||
|
||||
public static JComponent createSimulatorComponent(final JFrame frame) {
|
||||
public static JComponent createSimulatorComponent(final PortLookupFrame portSelector) {
|
||||
if (!SimulatorHelper.isBinaryHere())
|
||||
return new JLabel(SimulatorHelper.BINARY + " not found");
|
||||
|
||||
if (TcpConnector.isTcpPortOpened())
|
||||
return new JLabel("Port " + TcpConnector.DEFAULT_PORT + " already busy. Simulator running?");
|
||||
|
||||
|
||||
JButton simulatorButton = new JButton("Start Simulator");
|
||||
simulatorButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
frame.dispose();
|
||||
portSelector.disposeFrameAndProceed();
|
||||
startSimulator();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return simulatorButton;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
|
|
Loading…
Reference in New Issue