TS plugin
This commit is contained in:
parent
cfd6f06ae5
commit
c27dfae2bb
|
@ -94,6 +94,15 @@ public class AutoupdateUtil {
|
|||
return file.length() == completeFileSize && file.lastModified() == lastModified;
|
||||
}
|
||||
|
||||
public static ImageIcon loadIcon(String strPath) {
|
||||
URL imgURL = AutoupdateUtil.class.getResource(strPath);
|
||||
if (imgURL != null) {
|
||||
return new ImageIcon(imgURL);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConnectionAndMeta {
|
||||
private String zipFileName;
|
||||
private HttpURLConnection httpConnection;
|
||||
|
|
|
@ -3,6 +3,6 @@ package com.rusefi;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20200614;
|
||||
public static final int CONSOLE_VERSION = 20200617;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -19,7 +20,7 @@ abstract class CommandControl {
|
|||
final JButton test;
|
||||
|
||||
public CommandControl(String labelText, String iconFileName, String buttonText, JComponent... components) {
|
||||
ImageIcon icon = UiUtils.loadIcon(iconFileName);
|
||||
ImageIcon icon = AutoupdateUtil.loadIcon(iconFileName);
|
||||
JPanel rightVerticalPanel = new JPanel(new VerticalFlowLayout());
|
||||
rightVerticalPanel.add(new JLabel(labelText));
|
||||
for (JComponent component : components)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi;
|
||||
|
||||
import com.rusefi.autodetect.PortDetector;
|
||||
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.io.serial.BaudRateHolder;
|
||||
import com.rusefi.maintenance.*;
|
||||
|
@ -37,7 +38,7 @@ import static javax.swing.JOptionPane.YES_NO_OPTION;
|
|||
public class StartupFrame {
|
||||
// todo: figure out a better way to work with absolute path
|
||||
private static final String APPICON = "appicon.png";
|
||||
private static final String LOGO = "logo.gif";
|
||||
private static final String LOGO = "/com/rusefi/logo.gif";
|
||||
public static final String LINK_TEXT = "rusEFI (c) 2012-2020";
|
||||
private static final String URI = "http://rusefi.com/?java_console";
|
||||
// private static final int RUSEFI_ORANGE = 0xff7d03;
|
||||
|
@ -84,7 +85,7 @@ public class StartupFrame {
|
|||
}
|
||||
|
||||
public static void setAppIcon(JFrame frame) {
|
||||
ImageIcon icon = UiUtils.loadIcon(APPICON);
|
||||
ImageIcon icon = AutoupdateUtil.loadIcon(APPICON);
|
||||
if (icon != null)
|
||||
frame.setIconImage(icon.getImage());
|
||||
}
|
||||
|
@ -217,7 +218,7 @@ public class StartupFrame {
|
|||
}
|
||||
|
||||
public static JLabel createLogoLabel() {
|
||||
ImageIcon logoIcon = UiUtils.loadIcon(LOGO);
|
||||
ImageIcon logoIcon = AutoupdateUtil.loadIcon(LOGO);
|
||||
if (logoIcon == null)
|
||||
return null;
|
||||
JLabel logo = new JLabel(logoIcon);
|
||||
|
@ -272,7 +273,7 @@ public class StartupFrame {
|
|||
}
|
||||
|
||||
private Component createShowDeviceManagerButton() {
|
||||
JButton showDeviceManager = new JButton(UiUtils.loadIcon("DeviceManager.png"));
|
||||
JButton showDeviceManager = new JButton(AutoupdateUtil.loadIcon("DeviceManager.png"));
|
||||
showDeviceManager.setMargin(new Insets(0, 0, 0, 0));
|
||||
showDeviceManager.setToolTipText("Show Device Manager");
|
||||
showDeviceManager.addActionListener(event -> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.maintenance;
|
||||
|
||||
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||
import com.rusefi.ui.StatusWindow;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -16,7 +16,7 @@ public class EraseChip {
|
|||
private static final String FLASH_SIZE = "0x0100000";
|
||||
private static final String ERASE_COMMAND_SUFFIX = " -c init -c targets -c \"halt\" -c \"flash erase_address 0x08000000 " + FLASH_SIZE + "\" -c shutdown";
|
||||
|
||||
private final JButton button = new JButton("ST-LINK Erase Chip", UiUtils.loadIcon("/com/rusefi/erase.png"));
|
||||
private final JButton button = new JButton("ST-LINK Erase Chip", AutoupdateUtil.loadIcon("/com/rusefi/erase.png"));
|
||||
private StatusWindow wnd = new StatusWindow();
|
||||
|
||||
public EraseChip() {
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.rusefi.maintenance;
|
||||
|
||||
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||
import com.rusefi.ui.util.URLLabel;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||
|
@ -38,7 +37,7 @@ public class ProgramSelector {
|
|||
mode.setSelectedItem(persistedMode);
|
||||
|
||||
JButton updateFirmware = new JButton("Update Firmware",
|
||||
UiUtils.loadIcon("/com/rusefi/upload48.jpg"));
|
||||
AutoupdateUtil.loadIcon("/com/rusefi/upload48.jpg"));
|
||||
controls.add(updateFirmware);
|
||||
JButton updateHelp = new JButton("?");
|
||||
updateHelp.addActionListener(e -> URLLabel.open(HELP));
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.ui;
|
|||
|
||||
import com.rusefi.AverageAnglesUtil;
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
|
@ -54,28 +55,28 @@ public class RecentCommands {
|
|||
private final static Map<String, Icon> COMMAND_ICONS = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
static {
|
||||
COMMAND_ICONS.put(STOPENGINE, UiUtils.loadIcon("stop.jpg"));
|
||||
ImageIcon infoIcon = UiUtils.loadIcon("info.png");
|
||||
COMMAND_ICONS.put(STOPENGINE, AutoupdateUtil.loadIcon("stop.jpg"));
|
||||
ImageIcon infoIcon = AutoupdateUtil.loadIcon("info.png");
|
||||
COMMAND_ICONS.put(SHOWCONFIG, infoIcon);
|
||||
COMMAND_ICONS.put(HELP, UiUtils.loadIcon("help.jpg"));
|
||||
COMMAND_ICONS.put(HELP, AutoupdateUtil.loadIcon("help.jpg"));
|
||||
COMMAND_ICONS.put(ANALOGINFO, infoIcon);
|
||||
COMMAND_ICONS.put(CMD_TRIGGERINFO, UiUtils.loadIcon("trigger.jpg"));
|
||||
COMMAND_ICONS.put(CMD_TRIGGERINFO, AutoupdateUtil.loadIcon("trigger.jpg"));
|
||||
COMMAND_ICONS.put(IDLEINFO, infoIcon);
|
||||
COMMAND_ICONS.put(ALTINFO, UiUtils.loadIcon("alternator.jpg"));
|
||||
COMMAND_ICONS.put(ALTINFO, AutoupdateUtil.loadIcon("alternator.jpg"));
|
||||
COMMAND_ICONS.put(ACCELINFO, infoIcon);
|
||||
COMMAND_ICONS.put(TSINFO, infoIcon);
|
||||
COMMAND_ICONS.put(TPSINFO, infoIcon);
|
||||
COMMAND_ICONS.put(MAPINFO, infoIcon);
|
||||
COMMAND_ICONS.put(joystickINFO, UiUtils.loadIcon("joystick.png"));
|
||||
COMMAND_ICONS.put(joystickINFO, AutoupdateUtil.loadIcon("joystick.png"));
|
||||
COMMAND_ICONS.put(CANINFO, infoIcon);
|
||||
COMMAND_ICONS.put(FUELINFO, infoIcon);
|
||||
COMMAND_ICONS.put(TEMPINFO, infoIcon);
|
||||
COMMAND_ICONS.put(HIPINFO, UiUtils.loadIcon("knock.jpg"));
|
||||
COMMAND_ICONS.put(SDINFO, UiUtils.loadIcon("sdinfo.jpg"));
|
||||
COMMAND_ICONS.put(HIPINFO, AutoupdateUtil.loadIcon("knock.jpg"));
|
||||
COMMAND_ICONS.put(SDINFO, AutoupdateUtil.loadIcon("sdinfo.jpg"));
|
||||
COMMAND_ICONS.put(FSIOINFO, infoIcon);
|
||||
COMMAND_ICONS.put(PINS, infoIcon);
|
||||
COMMAND_ICONS.put(Fields.CMD_WRITECONFIG, UiUtils.loadIcon("writeconfig.jpg"));
|
||||
COMMAND_ICONS.put(SPEEDINFO, UiUtils.loadIcon("speedinfo.jpg"));
|
||||
COMMAND_ICONS.put(Fields.CMD_WRITECONFIG, AutoupdateUtil.loadIcon("writeconfig.jpg"));
|
||||
COMMAND_ICONS.put(SPEEDINFO, AutoupdateUtil.loadIcon("speedinfo.jpg"));
|
||||
}
|
||||
|
||||
private final JPanel content = new JPanel(new GridLayout(NUMBER_OF_COMMANDS + 1, 1));
|
||||
|
@ -167,7 +168,7 @@ public class RecentCommands {
|
|||
if (LinkManager.isLogViewer())
|
||||
content.add(createButton());
|
||||
|
||||
JButton reset = new JButton(UiUtils.loadIcon("undo.jpg"));
|
||||
JButton reset = new JButton(AutoupdateUtil.loadIcon("undo.jpg"));
|
||||
reset.setContentAreaFilled(false);
|
||||
reset.setFocusPainted(false);
|
||||
reset.setBorder(BorderFactory.createEmptyBorder());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.ui.livedocs;
|
||||
|
||||
import com.opensr5.ConfigurationImage;
|
||||
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
|
@ -11,7 +12,6 @@ import com.rusefi.ldmp.generated.*;
|
|||
import com.opensr5.ini.DialogModel;
|
||||
import com.opensr5.ini.IniFileModel;
|
||||
import com.rusefi.ui.livedocs.controls.Toolbox;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import com.rusefi.ui.widgets.DetachedSensor;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -78,7 +78,7 @@ public class LiveDocPanel {
|
|||
LiveDataContext context = getFieldContext(defaultContext, request.getStateContext());
|
||||
Field field = getField(defaultContext, request);
|
||||
JLabel label = new LessJumpyJLabel("*");
|
||||
label.setIcon(UiUtils.loadIcon("livedocs/variable.png"));
|
||||
label.setIcon(AutoupdateUtil.loadIcon("livedocs/variable.png"));
|
||||
label.setToolTipText("Variable " + field.getName());
|
||||
result.addControl(label);
|
||||
result.actionsListAdd(context, new RefreshActions() {
|
||||
|
@ -94,7 +94,7 @@ public class LiveDocPanel {
|
|||
Field field = Field.findField(Fields.VALUES, settingsInstancePrefix, request.getField());
|
||||
|
||||
JLabel label = new LessJumpyJLabel("*");
|
||||
label.setIcon(UiUtils.loadIcon("livedocs/setting.png"));
|
||||
label.setIcon(AutoupdateUtil.loadIcon("livedocs/setting.png"));
|
||||
label.setToolTipText(getTooltipText(field.getName()));
|
||||
result.addControl(label);
|
||||
// todo: use different notification flow altogether since configuration has nothing to do with live data structures
|
||||
|
@ -110,7 +110,7 @@ public class LiveDocPanel {
|
|||
SensorRequest request = (SensorRequest) r;
|
||||
Sensor sensor = Sensor.find(request.getValue());
|
||||
JLabel label = new LessJumpyJLabel("*");
|
||||
label.setIcon(UiUtils.loadIcon("livedocs/gauge.png"));
|
||||
label.setIcon(AutoupdateUtil.loadIcon("livedocs/gauge.png"));
|
||||
label.setToolTipText("Sensor " + request.getValue());
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
|
|
|
@ -124,14 +124,6 @@ public class UiUtils {
|
|||
return imageButton;
|
||||
}
|
||||
|
||||
public static ImageIcon loadIcon(String strPath) {
|
||||
URL imgURL = StartupFrame.class.getResource(strPath);
|
||||
if (imgURL != null)
|
||||
return new ImageIcon(imgURL);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void invokeAndWait(Runnable runnable) throws InterruptedException, InvocationTargetException {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
runnable.run();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.rusefi.output;
|
||||
|
||||
import com.opensr5.ini.RawIniFile;
|
||||
import com.rusefi.*;
|
||||
import com.rusefi.util.LazyFile;
|
||||
import com.rusefi.util.Output;
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
<delete file="${jar_file}"/>
|
||||
|
||||
<tstamp>
|
||||
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss"/>
|
||||
<format property="TODAY_DATE" pattern="yyyy-MM-dd"/>
|
||||
</tstamp>
|
||||
|
||||
<jar destfile="${jar_file}" basedir="build/classes">
|
||||
<manifest>
|
||||
<attribute name="Built-Date" value="${TODAY}"/>
|
||||
<attribute name="Built-Date" value="${TODAY_DATE}"/>
|
||||
<attribute name="Signature-Vendor" value="rusEFI LLC"/>
|
||||
</manifest>
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import javax.xml.bind.JAXBException;
|
|||
import java.awt.event.ActionEvent;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.jar.Attributes;
|
||||
|
@ -144,10 +145,18 @@ public class PluginEntry implements TsPluginBody {
|
|||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static String getVersion() {
|
||||
// all this magic below to make sure we are reading manifest of the *our* jar file not TS main jar file
|
||||
Class clazz = PluginEntry.class;
|
||||
String className = clazz.getSimpleName() + ".class";
|
||||
String classPath = clazz.getResource(className).toString();
|
||||
if (!classPath.startsWith("jar")) {
|
||||
// Class not from JAR
|
||||
return "Local Run";
|
||||
}
|
||||
String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) +
|
||||
"/META-INF/MANIFEST.MF";
|
||||
try {
|
||||
InputStream stream = PluginEntry.class.getResourceAsStream("/META-INF/MANIFEST.MF");
|
||||
Manifest manifest = new Manifest(stream);
|
||||
|
||||
Manifest manifest = new Manifest(new URL(manifestPath).openStream());
|
||||
Attributes attributes = manifest.getMainAttributes();
|
||||
System.out.println("Attributed " + attributes);
|
||||
System.out.println("Attributed " + attributes.keySet());
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
<mkdir dir="${jar_file_folder}"/>
|
||||
<delete file="${jar_file}"/>
|
||||
|
||||
<copy todir="build/classes">
|
||||
<fileset dir="resources" includes="**/*.png"/>
|
||||
</copy>
|
||||
|
||||
<tstamp>
|
||||
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss"/>
|
||||
</tstamp>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -26,17 +26,19 @@ public class Updater {
|
|||
public Updater() {
|
||||
content.add(new JLabel("" + VERSION));
|
||||
|
||||
ImageIcon logo = AutoupdateUtil.loadIcon("/rusefi_online_color_300.png");
|
||||
|
||||
content.add(new JLabel(logo));
|
||||
|
||||
String version = null;
|
||||
long localJarTimestamp = 0;
|
||||
File localFile = new File(LOCAL_JAR_FILE_NAME);
|
||||
if (localFile.exists()) {
|
||||
version = getVersion();
|
||||
|
||||
}
|
||||
|
||||
JButton download = new JButton("Download latest");
|
||||
JButton download = new JButton("Update plugin");
|
||||
if (version != null) {
|
||||
JButton run = new JButton("Run " + version);
|
||||
JButton run = new JButton("Run Version " + version);
|
||||
run.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
|
|
@ -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" />
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
Loading…
Reference in New Issue