auto-sync
This commit is contained in:
parent
eb8b0c8dfd
commit
049ac73810
|
@ -5,11 +5,14 @@ import com.irnems.core.MessagesCentral;
|
|||
import com.rusefi.*;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.ui.*;
|
||||
import com.rusefi.ui.storage.Node;
|
||||
import com.rusefi.ui.storage.PersistentConfiguration;
|
||||
import jssc.SerialPortList;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||
|
||||
/**
|
||||
* this is the main entry point of rusEfi ECU console
|
||||
* <p/>
|
||||
|
@ -37,13 +40,14 @@ public class Launcher extends FrameHelper {
|
|||
FileLog.MAIN.logLine("Console " + CONSOLE_VERSION);
|
||||
|
||||
|
||||
WavePanel wavePanel = new WavePanel(getConfig().getRoot().getChild("digital_sniffer"));
|
||||
if (LinkManager.isLogViewerMode(port))
|
||||
tabbedPane.add("Log Viewer", new LogViewer());
|
||||
tabbedPane.add("Log Viewer", new LogViewer(wavePanel));
|
||||
|
||||
RpmPanel rpmPanel = new RpmPanel();
|
||||
tabbedPane.addTab("Main", rpmPanel.createRpmPanel());
|
||||
RpmPanel mainGauges = new RpmPanel(getConfig().getRoot().getChild("main_gauges"));
|
||||
tabbedPane.addTab("Main", mainGauges.createRpmPanel());
|
||||
tabbedPane.addTab("Gauges", new GaugesPanel().getContent());
|
||||
tabbedPane.addTab("Digital Sniffer", WavePanel.getInstance().getPanel());
|
||||
tabbedPane.addTab("Digital Sniffer", wavePanel.getPanel());
|
||||
tabbedPane.addTab("Analog Sniffer", new AnalogChartPanel());
|
||||
|
||||
tabbedPane.addTab("LE controls", new FlexibleControls().getPanel());
|
||||
|
@ -54,12 +58,12 @@ public class Launcher extends FrameHelper {
|
|||
tabbedPane.add("ECU stimulation", stimulator.getPanel());
|
||||
}
|
||||
// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl());
|
||||
tabbedPane.add("Messages", new MessagesPane().getContent());
|
||||
tabbedPane.add("Messages", new MessagesPane(getConfig().getRoot().getChild("messages")).getContent());
|
||||
tabbedPane.add("Wizards", new Wizard().createPane());
|
||||
|
||||
|
||||
if (!LinkManager.isLogViewerMode(port)) {
|
||||
int selectedIndex = PersistentConfiguration.getInstance().getIntProperty("main_tab", 2);
|
||||
int selectedIndex = getConfig().getRoot().getIntProperty("main_tab", 2);
|
||||
tabbedPane.setSelectedIndex(selectedIndex);
|
||||
}
|
||||
|
||||
|
@ -93,14 +97,15 @@ public class Launcher extends FrameHelper {
|
|||
* looks like reconnectTimer in {@link RpmPanel} keeps AWT alive. Simplest solution would be to 'exit'
|
||||
*/
|
||||
SimulatorHelper.onWindowClosed();
|
||||
PersistentConfiguration.getInstance().setProperty("version", CONSOLE_VERSION);
|
||||
PersistentConfiguration.getInstance().setProperty(TAB_INDEX, tabbedPane.getSelectedIndex());
|
||||
PersistentConfiguration.getInstance().save();
|
||||
Node root = getConfig().getRoot();
|
||||
root.setProperty("version", CONSOLE_VERSION);
|
||||
root.setProperty(TAB_INDEX, tabbedPane.getSelectedIndex());
|
||||
getConfig().save();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
PersistentConfiguration.getInstance().load();
|
||||
getConfig().load();
|
||||
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
|
||||
VersionChecker.start();
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.irnems.ui.test;
|
|||
|
||||
import com.rusefi.ui.FrameHelper;
|
||||
import com.rusefi.ui.WavePanel;
|
||||
import com.rusefi.ui.storage.PersistentConfiguration;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -13,9 +14,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
public class WavePanelSandbox extends FrameHelper {
|
||||
|
||||
public WavePanelSandbox() {
|
||||
|
||||
|
||||
WavePanel wp = WavePanel.getInstance();
|
||||
WavePanel wp = new WavePanel(PersistentConfiguration.getConfig().getRoot());
|
||||
|
||||
wp.displayChart("Injector 1!down!55013038!crank!up!55013444!crank!down!55013781!Injector 3!up!55013789!Injector 3!down!55013969!crank2!up!55014065!crank!up!55014358!crank!down!55014706!input1 A8!up!55014730!Injector 4!up!55014734!Injector 4!down!55014933!input1 A8!down!55014941!crank!up!55015298!crank!down!55015638!Injector 2!up!55015644!Injector 2!down!55015823!crank2!down!55015932!crank!up!55016223!crank!down!55016566!Injector 1!up!55016574!Injector 1!down!55016753!crank!up!55017148!crank!down!55017494!Injector 3!up!55017499!Injector 3!down!55017679!crank2!up!55017777!crank!up!55018070!crank!down!55018406!Injector 4!input1 A8!up!55018414!up!55018416!input1 A8!down!55018439!input1 A8!up!55018439!Injector 4!down!55018593!input1 A8!down!55018600!crank!up!55018989!crank!down!55019330!Injector 2!up!55019338!Injector 2!down!55019517!crank2!down!55019618!crank!up!55019909!crank!down!55020246!Injector 1!up!55020251!Injector 1!down!55020430!crank!up!55020827!crank!down!55021171!Injector 3!up!55021179!Injector 3!down!55021358!crank2!up!55021453!crank!up!55021747!crank!down!55022084!Injector 4input1 A8!up!55022089!!up!55022093!Injector 4!down!55022270!input1 A8!down!55022276!input1 A8!up!55022276!input1 A8!down!55022276!crank!up!55022666!crank!down!55023006!Injector 2!up!55023011!Injector 2!down!55023191!crank2!down!55023294!crank!up!55023584!crank!down!55023928!Injector 1!up!55023932!Injector 1!down!55024109!crank!up!55024507!crank!down!55024846!Injector 3!up!55024871!Injector 3!down!55025072!crank2!up!55025138!crank!up!55025440!crank!down!55025780!Injector 4input1 A8!up!55025785!!up!55025791!input1 A8!down!55025923!input1 A8!up!55025923!Injector 4!down!55025970!input1 A8!down!55025976!input1 A8!up!55025976!crank!up!55026355!crank!down!55026690!Injector 2!up!55026696!Injector 2!down!55026874!crank2!down!55026979!crank!up!55027268!crank!down!55027611!Injector 1!up!55027619!Injector 1!down!55027800!crank!up!55028186!crank!down!55028520!,");
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class AnalogChartPanel extends JPanel {
|
|||
|
||||
unpackValues(values, message);
|
||||
|
||||
// MessagesCentral.getInstance().postMessage(AnalogChartPanel.class, "chart arrived, len=" + message.length());
|
||||
// MessagesCentral.getConfig().postMessage(AnalogChartPanel.class, "chart arrived, len=" + message.length());
|
||||
|
||||
processValues();
|
||||
UpDownImage.trueRepaint(analogChart);
|
||||
|
|
|
@ -230,7 +230,7 @@ public class EcuStimulator {
|
|||
|
||||
private static double getVRef() {
|
||||
// todo: make this adjustable via the UI
|
||||
//double vRef = SensorCentral.getInstance().getValue(Sensor.VREF) * PotCommand.VOLTAGE_CORRECTION;
|
||||
//double vRef = SensorCentral.getConfig().getValue(Sensor.VREF) * PotCommand.VOLTAGE_CORRECTION;
|
||||
return 4.7;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package com.rusefi.test;
|
|||
|
||||
import com.rusefi.ui.FrameHelper;
|
||||
import com.rusefi.ui.MessagesPane;
|
||||
import com.rusefi.ui.MessagesPanel;
|
||||
import com.rusefi.ui.storage.PersistentConfiguration;
|
||||
|
||||
public class MsgPanelSandbox extends FrameHelper {
|
||||
private MsgPanelSandbox() {
|
||||
showFrame(new MessagesPane().getContent());
|
||||
showFrame(new MessagesPane(PersistentConfiguration.getConfig().getRoot()).getContent());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -36,14 +36,16 @@ public class LogViewer extends JPanel {
|
|||
private final JLabel fileLabel = new JLabel();
|
||||
private final DefaultListModel<FIleItem> fileListModel = new DefaultListModel<FIleItem>();
|
||||
private final JList<FIleItem> fileList = new JList<FIleItem>(fileListModel);
|
||||
private final WavePanel wavePanel;
|
||||
private String currentFolder;
|
||||
private static JPanel descPanel = new JPanel();
|
||||
|
||||
|
||||
// int currentChartIndex = 0;
|
||||
|
||||
public LogViewer() {
|
||||
public LogViewer(WavePanel wavePanel) {
|
||||
super(new BorderLayout());
|
||||
this.wavePanel = wavePanel;
|
||||
|
||||
setBackground(Color.green);
|
||||
|
||||
|
@ -146,7 +148,7 @@ public class LogViewer extends JPanel {
|
|||
|
||||
|
||||
// private void refreshChart() {
|
||||
// String chart = ChartRepository.getInstance().getChart(currentChartIndex);
|
||||
// String chart = ChartRepository.getConfig().getChart(currentChartIndex);
|
||||
// }
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
|
@ -171,7 +173,7 @@ public class LogViewer extends JPanel {
|
|||
FileUtils.readFile2(filename, engineState);
|
||||
|
||||
if (ChartRepository.getInstance().getSize() > 0)
|
||||
WavePanel.getInstance().reloadFile();
|
||||
wavePanel.reloadFile();
|
||||
refreshCountPanel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.rusefi.ui.storage.Node;
|
||||
import com.rusefi.ui.widgets.IdleLabel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -14,8 +15,8 @@ public class MessagesPane {
|
|||
}
|
||||
};
|
||||
|
||||
public MessagesPane() {
|
||||
MessagesPanel messagesPanel = new MessagesPanel();
|
||||
public MessagesPane(Node config) {
|
||||
MessagesPanel messagesPanel = new MessagesPanel(config);
|
||||
content.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||
|
||||
JPanel middlePanel = new JPanel(new BorderLayout());
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.rusefi.ui;
|
|||
import com.irnems.core.MessagesCentral;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.serial.PortHolder;
|
||||
import com.rusefi.ui.storage.Node;
|
||||
import com.rusefi.ui.widgets.AnyCommand;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -26,14 +27,22 @@ public class MessagesPanel {
|
|||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH_mm");
|
||||
private static final int MAX_SIZE = 50000;
|
||||
|
||||
private final JTextPane messages = new JTextPane();
|
||||
private final AnyCommand anyCommand;
|
||||
private final JTextPane messages = new JTextPane() {
|
||||
@Override
|
||||
public void setVisible(boolean aFlag) {
|
||||
super.setVisible(aFlag);
|
||||
// todo: get focus on startup somehow
|
||||
// anyCommand.getText().requestFocus();
|
||||
}
|
||||
};
|
||||
private boolean isPaused;
|
||||
private final Style bold;
|
||||
private final Style italic;
|
||||
private final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
|
||||
private final JScrollPane messagesScroll = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
public MessagesPanel() {
|
||||
public MessagesPanel(Node config) {
|
||||
JPanel middlePanel = new JPanel(new BorderLayout());
|
||||
middlePanel.add(messagesScroll, BorderLayout.CENTER);
|
||||
buttonPanel.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||
|
@ -76,7 +85,8 @@ public class MessagesPanel {
|
|||
|
||||
buttonPanel.add(resetButton);
|
||||
buttonPanel.add(pauseButton);
|
||||
buttonPanel.add(new AnyCommand());
|
||||
anyCommand = new AnyCommand(config);
|
||||
buttonPanel.add(anyCommand.getContent());
|
||||
}
|
||||
|
||||
private void clearMessages(Document d) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.ui;
|
|||
|
||||
import com.irnems.core.EngineTimeListener;
|
||||
import com.irnems.core.Sensor;
|
||||
import com.rusefi.ui.storage.Node;
|
||||
import com.rusefi.ui.widgets.*;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.ui.widgets.SensorGauge;
|
||||
|
@ -17,13 +18,15 @@ import java.awt.event.ActionListener;
|
|||
* (c) Andrey Belomutskiy
|
||||
*/
|
||||
public class RpmPanel {
|
||||
private final Node config;
|
||||
private RpmControl rpmControl = new RpmControl();
|
||||
// that's for CKP signal emulation
|
||||
public final WaveInfoPanel wave0 = new WaveInfoPanel(0);
|
||||
public final WaveInfoPanel wave1 = new WaveInfoPanel(1);
|
||||
public final WaveInfoPanel wave2 = new WaveInfoPanel(2);
|
||||
|
||||
public RpmPanel() {
|
||||
public RpmPanel(Node config) {
|
||||
this.config = config;
|
||||
rpmControl.setSize(15);
|
||||
}
|
||||
|
||||
|
@ -43,12 +46,12 @@ public class RpmPanel {
|
|||
startConnectionWatchDog();
|
||||
|
||||
JPanel smallMessagePanel = new JPanel(new BorderLayout());
|
||||
MessagesPanel mp = new MessagesPanel();
|
||||
MessagesPanel mp = new MessagesPanel(config);
|
||||
smallMessagePanel.add(BorderLayout.NORTH, mp.getButtonPanel());
|
||||
smallMessagePanel.add(BorderLayout.CENTER, mp.getMessagesScroll());
|
||||
|
||||
JPanel msgPanel = new JPanel(new BorderLayout());
|
||||
msgPanel.add(new AnyCommand(), BorderLayout.NORTH);
|
||||
msgPanel.add(new AnyCommand(config).getContent(), BorderLayout.NORTH);
|
||||
msgPanel.add(smallMessagePanel, BorderLayout.CENTER);
|
||||
|
||||
JComponent rpmPanel = new JPanel(new BorderLayout());
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.irnems.core.EngineState;
|
|||
import com.irnems.core.Sensor;
|
||||
import com.irnems.core.SensorCentral;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.ui.storage.Node;
|
||||
import com.rusefi.ui.widgets.AnyCommand;
|
||||
import com.rusefi.ui.widgets.URLLabel;
|
||||
import com.rusefi.ui.widgets.UpDownImage;
|
||||
|
@ -14,6 +15,7 @@ import com.rusefi.waves.WaveChartParser;
|
|||
import com.rusefi.waves.WaveReport;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
@ -65,9 +67,7 @@ public class WavePanel {
|
|||
|
||||
private boolean isPaused;
|
||||
|
||||
private static WavePanel instance = new WavePanel();
|
||||
|
||||
private WavePanel() {
|
||||
public WavePanel(Node config) {
|
||||
LinkManager.engineState.registerStringValueAction("outpin", new EngineState.ValueCallback<String>() {
|
||||
@Override
|
||||
public void onUpdate(String value) {
|
||||
|
@ -120,8 +120,7 @@ public class WavePanel {
|
|||
buttonPanel.add(pauseButton);
|
||||
buttonPanel.add(new RpmControl().setSize(2).getContent());
|
||||
|
||||
JTextField command = AnyCommand.createCommandControl();
|
||||
command.setText("chartsize " + EFI_DEFAULT_CHART_SIZE);
|
||||
JComponent command = new AnyCommand(config, "chartsize " + EFI_DEFAULT_CHART_SIZE).getContent();
|
||||
buttonPanel.add(command);
|
||||
|
||||
buttonPanel.add(zoomControl);
|
||||
|
@ -175,10 +174,6 @@ public class WavePanel {
|
|||
images.put(CRANK1, crank);
|
||||
}
|
||||
|
||||
public static WavePanel getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void displayChart(String value) {
|
||||
WaveChart map = WaveChartParser.unpackToMap(value);
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package com.rusefi.ui.storage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Node {
|
||||
private String prefix;
|
||||
private Map<String, Object> config = new HashMap<>();
|
||||
|
||||
/**
|
||||
* this is needed for XMLEncoder
|
||||
*/
|
||||
public Node() {
|
||||
}
|
||||
|
||||
protected Node(String prefix, Map<String, Object> parent) {
|
||||
this.prefix = prefix;
|
||||
if (parent.containsKey(prefix)) {
|
||||
Node existing = (Node) parent.get(prefix);
|
||||
config = existing.getConfig();
|
||||
} else {
|
||||
parent.put(prefix, this);
|
||||
}
|
||||
}
|
||||
|
||||
public Node getChild(String name) {
|
||||
Node child = (Node) config.get(name);
|
||||
if (child == null) {
|
||||
child = new Node(name, config);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
public int getIntProperty(String key, int defaultValue) {
|
||||
try {
|
||||
String value = (String) config.get(key);
|
||||
return Integer.parseInt(value);
|
||||
} catch (Throwable e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void setProperty(String key, String value) {
|
||||
config.put(key, value);
|
||||
}
|
||||
|
||||
public void setProperty(String key, int value) {
|
||||
config.put(key, "" + value);
|
||||
}
|
||||
|
||||
public String getProperty(String key, String s) {
|
||||
String value = (String) config.get(key);
|
||||
return value == null ? s : value;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public Map<String, Object> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(Map<String, Object> config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Node{" +
|
||||
"prefix='" + prefix + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -13,16 +13,16 @@ public class PersistentConfiguration {
|
|||
private static final PersistentConfiguration INSTANCE = new PersistentConfiguration();
|
||||
public static final String CONFIG_FILE_NAME = "rusefi_console_properties.xml";
|
||||
|
||||
private Map<String, String> config = new HashMap<>();
|
||||
private Map<String, Object> config = new HashMap<>();
|
||||
|
||||
public static PersistentConfiguration getInstance() {
|
||||
public static PersistentConfiguration getConfig() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
try {
|
||||
XMLDecoder e = new XMLDecoder(new BufferedInputStream(new FileInputStream(CONFIG_FILE_NAME)));
|
||||
config = (Map<String, String>) e.readObject();
|
||||
config = (Map<String, Object>) e.readObject();
|
||||
e.close();
|
||||
} catch (Throwable e) {
|
||||
FileLog.rlog("Error reading from " + CONFIG_FILE_NAME);
|
||||
|
@ -41,16 +41,7 @@ public class PersistentConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
public int getIntProperty(String key, int defaultValue) {
|
||||
try {
|
||||
String value = config.get(key);
|
||||
return Integer.parseInt(value);
|
||||
} catch (Throwable e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void setProperty(String key, int value) {
|
||||
config.put(key, "" + value);
|
||||
public Node getRoot() {
|
||||
return new Node("root", config);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.ui.widgets;
|
||||
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.ui.storage.Node;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
|
@ -13,25 +14,31 @@ import java.awt.event.ActionListener;
|
|||
* Date: 3/20/13
|
||||
* (c) Andrey Belomutskiy
|
||||
*/
|
||||
public class AnyCommand extends JPanel {
|
||||
public class AnyCommand {
|
||||
private static final int COMMAND_CONFIRMATION_TIMEOUT = 1000;
|
||||
public static final String KEY = "last_value";
|
||||
private final JTextField text = new JTextField() {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = super.getPreferredSize();
|
||||
return new Dimension(200, size.height);
|
||||
}
|
||||
};
|
||||
|
||||
public AnyCommand() {
|
||||
// setBorder(BorderFactory.createLineBorder(Color.PINK));
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
add(new JLabel("Command: "));
|
||||
final JTextField text = createCommandControl();
|
||||
add(text);
|
||||
private final Node config;
|
||||
private JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
|
||||
public AnyCommand(final Node config) {
|
||||
this(config, config.getProperty(KEY, ""));
|
||||
}
|
||||
|
||||
public static JTextField createCommandControl() {
|
||||
final JTextField text = new JTextField() {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = super.getPreferredSize();
|
||||
return new Dimension(200, size.height);
|
||||
}
|
||||
};
|
||||
public AnyCommand(final Node config, String defaultCommand) {
|
||||
this.config = config;
|
||||
text.setText(defaultCommand);
|
||||
content.setBorder(BorderFactory.createLineBorder(Color.PINK));
|
||||
content.add(new JLabel("Command: "));
|
||||
content.add(text);
|
||||
|
||||
text.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -56,6 +63,7 @@ public class AnyCommand extends JPanel {
|
|||
public void changedUpdate(DocumentEvent e) {
|
||||
boolean isOk = isValidInput(text);
|
||||
text.setBorder(isOk ? null : BorderFactory.createLineBorder(Color.red));
|
||||
config.setProperty(KEY, text.getText());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -68,9 +76,17 @@ public class AnyCommand extends JPanel {
|
|||
// }
|
||||
// });
|
||||
// todo: limit the length of text in the text field
|
||||
}
|
||||
|
||||
public JTextField getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean requestFocusInWindow() {
|
||||
// return text.requestFocusInWindow();
|
||||
// }
|
||||
|
||||
private static boolean isValidInput(JTextField text) {
|
||||
boolean isOk = true;
|
||||
for (char c : text.getText().toCharArray()) {
|
||||
|
@ -85,4 +101,12 @@ public class AnyCommand extends JPanel {
|
|||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
public JComponent getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(JPanel content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue