auto-sync

This commit is contained in:
rusEfi 2015-10-18 19:02:34 -04:00
parent 4843593163
commit abb65372d6
1 changed files with 5 additions and 8 deletions

View File

@ -7,6 +7,7 @@ import com.rusefi.ui.storage.Node;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.text.JTextComponent;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -47,7 +48,7 @@ public class AnyCommand {
go.addActionListener(new ActionListener() { go.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
go(); send();
} }
}); });
content.add(go); content.add(go);
@ -76,7 +77,7 @@ public class AnyCommand {
text.addActionListener(new ActionListener() { text.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
go(); send();
} }
}); });
text.getDocument().addDocumentListener(new DocumentListener() { text.getDocument().addDocumentListener(new DocumentListener() {
@ -109,7 +110,7 @@ public class AnyCommand {
// todo: limit the length of text in the text field // todo: limit the length of text in the text field
} }
private void go() { private void send() {
index = 0; index = 0;
String cmd = text.getText(); String cmd = text.getText();
if (!isValidInput(text)) if (!isValidInput(text))
@ -120,11 +121,7 @@ public class AnyCommand {
reentrant = false; reentrant = false;
} }
public JTextField getText() { private static boolean isValidInput(JTextComponent text) {
return text;
}
private static boolean isValidInput(JTextField text) {
boolean isOk = true; boolean isOk = true;
for (char c : text.getText().toCharArray()) { for (char c : text.getText().toCharArray()) {
if (c > 127) { if (c > 127) {