removed trailing whitespace
This commit is contained in:
parent
ef7f5d1d23
commit
61950fc62a
@ -17,4 +17,4 @@ public class AnyServer implements CommandExecutor {
|
|||||||
result.append("\"\n");
|
result.append("\"\n");
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
}//AnyServer
|
}//AnyServer
|
||||||
|
@ -12,7 +12,7 @@ public class ExBox {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ExBoxFrame f = new ExBoxFrame();
|
ExBoxFrame f = new ExBoxFrame();
|
||||||
f.setLocationRelativeTo(null);
|
f.setLocationRelativeTo(null);
|
||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*
|
*
|
||||||
* @author K.Rege
|
* @author K.Rege
|
||||||
* @version 1.00 2014/2/3
|
* @version 1.00 2014/2/3
|
||||||
* @version 1.01 2016/8/2
|
* @version 1.01 2016/8/2
|
||||||
* @version 2.00 2017/8/30 Test
|
* @version 2.00 2017/8/30 Test
|
||||||
* @version 2.01 2018/2/5 AutoScale
|
* @version 2.01 2018/2/5 AutoScale
|
||||||
* @version 2d.02 2018/2/5 Reconnect (inspired by S. Kunz)
|
* @version 2d.02 2018/2/5 Reconnect (inspired by S. Kunz)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
private JCheckBox reconnect;
|
private JCheckBox reconnect;
|
||||||
private JComboBox history;
|
private JComboBox history;
|
||||||
private JTextArea output;
|
private JTextArea output;
|
||||||
private JScrollPane scrollPane;
|
private JScrollPane scrollPane;
|
||||||
private CommandExecutor command;
|
private CommandExecutor command;
|
||||||
private boolean graphicOn;
|
private boolean graphicOn;
|
||||||
private GraphicPanel graphic;
|
private GraphicPanel graphic;
|
||||||
@ -54,7 +54,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMenu() {
|
private void initMenu() {
|
||||||
JMenuBar menuBar = new JMenuBar();
|
JMenuBar menuBar = new JMenuBar();
|
||||||
JMenu menuFile = new JMenu();
|
JMenu menuFile = new JMenu();
|
||||||
@ -71,7 +71,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
|
|
||||||
menuFile.add(menuFileExit);
|
menuFile.add(menuFileExit);
|
||||||
menuBar.add(menuFile);
|
menuBar.add(menuFile);
|
||||||
|
|
||||||
JMenu menuServer = new JMenu("Server");
|
JMenu menuServer = new JMenu("Server");
|
||||||
menuBar.add(menuServer);
|
menuBar.add(menuServer);
|
||||||
connect = new JMenuItem("Connect");
|
connect = new JMenuItem("Connect");
|
||||||
@ -80,7 +80,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
test = new JMenuItem("Test");
|
test = new JMenuItem("Test");
|
||||||
test.addActionListener(this);
|
test.addActionListener(this);
|
||||||
menuServer.add(test);
|
menuServer.add(test);
|
||||||
|
|
||||||
JMenu menuView = new JMenu("View");
|
JMenu menuView = new JMenu("View");
|
||||||
menuBar.add(menuView);
|
menuBar.add(menuView);
|
||||||
textView = new JMenuItem("Text");
|
textView = new JMenuItem("Text");
|
||||||
@ -89,11 +89,11 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
graphicView = new JMenuItem("Graphic");
|
graphicView = new JMenuItem("Graphic");
|
||||||
graphicView.addActionListener(this);
|
graphicView.addActionListener(this);
|
||||||
menuView.add(graphicView);
|
menuView.add(graphicView);
|
||||||
|
|
||||||
open = new JMenuItem("Open...");
|
open = new JMenuItem("Open...");
|
||||||
open.addActionListener(this);
|
open.addActionListener(this);
|
||||||
menuFile.insert(open, 0);
|
menuFile.insert(open, 0);
|
||||||
setJMenuBar(menuBar);
|
setJMenuBar(menuBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
@ -114,9 +114,9 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
history = new JComboBox();
|
history = new JComboBox();
|
||||||
history.addItemListener(this);
|
history.addItemListener(this);
|
||||||
panel.add(BorderLayout.SOUTH, history);
|
panel.add(BorderLayout.SOUTH, history);
|
||||||
add(BorderLayout.SOUTH, panel);
|
add(BorderLayout.SOUTH, panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get default path for file open dialog
|
* get default path for file open dialog
|
||||||
*/
|
*/
|
||||||
@ -140,12 +140,12 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
if (screenSize.getWidth() > 1920) {
|
if (screenSize.getWidth() > 1920) {
|
||||||
SCALE = 2;
|
SCALE = 2;
|
||||||
}
|
}
|
||||||
setFontSize((int) (11 * SCALE));
|
setFontSize((int) (11 * SCALE));
|
||||||
setSize(new Dimension((int) (400 * SCALE), (int) (400 * SCALE)));
|
setSize(new Dimension((int) (400 * SCALE), (int) (400 * SCALE)));
|
||||||
setTitle("ExBox");
|
setTitle("ExBox");
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
@ -176,7 +176,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setGraphicView() {
|
private void setGraphicView() {
|
||||||
if (graphicOn) {
|
if (graphicOn) {
|
||||||
return;
|
return;
|
||||||
@ -200,7 +200,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
validate();
|
validate();
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String openFileDialog(String startDirectory, String pattern) {
|
private String openFileDialog(String startDirectory, String pattern) {
|
||||||
FileDialog fd = new FileDialog(this, "Open");
|
FileDialog fd = new FileDialog(this, "Open");
|
||||||
if (pattern != null) {
|
if (pattern != null) {
|
||||||
@ -210,30 +210,30 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
fd.setDirectory(startDirectory);
|
fd.setDirectory(startDirectory);
|
||||||
}
|
}
|
||||||
fd.setVisible(true);
|
fd.setVisible(true);
|
||||||
return fd.getDirectory() + fd.getFile();
|
return fd.getDirectory() + fd.getFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testCommand() throws Exception {
|
private void testCommand() throws Exception {
|
||||||
final java.util.List<String> failed = new LinkedList<String>();
|
final java.util.List<String> failed = new LinkedList<String>();
|
||||||
final java.util.List<String> finished = new LinkedList<String>();
|
final java.util.List<String> finished = new LinkedList<String>();
|
||||||
|
|
||||||
JUnitCore runner = new JUnitCore();
|
JUnitCore runner = new JUnitCore();
|
||||||
|
|
||||||
String name = openFileDialog(getPathCompiled(), "*Test.class");
|
String name = openFileDialog(getPathCompiled(), "*Test.class");
|
||||||
runner.addListener(new RunListener() {
|
runner.addListener(new RunListener() {
|
||||||
@Override
|
@Override
|
||||||
public void testFinished(Description description) throws Exception {
|
public void testFinished(Description description) throws Exception {
|
||||||
finished.add(description.getDisplayName());
|
finished.add(description.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testFailure(Failure failure) throws Exception {
|
public void testFailure(Failure failure) throws Exception {
|
||||||
failed.add(failure.getDescription().getDisplayName());
|
failed.add(failure.getDescription().getDisplayName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Class testClass = ServerFactory.loadClass(name);
|
Class testClass = ServerFactory.loadClass(name);
|
||||||
Result result = runner.run(testClass);
|
Result result = runner.run(testClass);
|
||||||
|
|
||||||
for (String test : finished) {
|
for (String test : finished) {
|
||||||
if (!failed.contains(test)) {
|
if (!failed.contains(test)) {
|
||||||
output.append(test + ": OK\n");
|
output.append(test + ": OK\n");
|
||||||
@ -249,7 +249,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
: result.getFailures().size() + " ERRORS")
|
: result.getFailures().size() + " ERRORS")
|
||||||
+ "\n");
|
+ "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectCommand() throws Exception {
|
private void connectCommand() throws Exception {
|
||||||
String name = openFileDialog(getPathCompiled(), "*Server.class");
|
String name = openFileDialog(getPathCompiled(), "*Server.class");
|
||||||
command = ServerFactory.createServer(name);
|
command = ServerFactory.createServer(name);
|
||||||
@ -257,10 +257,10 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
String fullClassName = command.getClass().getName();
|
String fullClassName = command.getClass().getName();
|
||||||
String simpleClassName = fullClassName.substring(
|
String simpleClassName = fullClassName.substring(
|
||||||
fullClassName.lastIndexOf('.') + 1);
|
fullClassName.lastIndexOf('.') + 1);
|
||||||
setTitle("ExBox connected to " + simpleClassName);
|
setTitle("ExBox connected to " + simpleClassName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openFile() throws Exception {
|
private void openFile() throws Exception {
|
||||||
String name = openFileDialog(null, null);
|
String name = openFileDialog(null, null);
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
b.append(line);
|
b.append(line);
|
||||||
b.append('\n');
|
b.append('\n');
|
||||||
}
|
}
|
||||||
interpret(b.toString());
|
interpret(b.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void itemStateChanged(ItemEvent e) {
|
public void itemStateChanged(ItemEvent e) {
|
||||||
@ -280,8 +280,8 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
arguments.setText((String) e.getItem());
|
arguments.setText((String) e.getItem());
|
||||||
interpret(arguments.getText());
|
interpret(arguments.getText());
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
error(ex.toString());
|
error(ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@ -311,4 +311,4 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
|
|||||||
protected void windowClosed() {
|
protected void windowClosed() {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,16 @@ import java.io.*;
|
|||||||
*/
|
*/
|
||||||
class MyClassLoader extends ClassLoader {
|
class MyClassLoader extends ClassLoader {
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
MyClassLoader(ClassLoader parent) {
|
MyClassLoader(ClassLoader parent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] getBytes(String name) {
|
private byte[] getBytes(String name) {
|
||||||
try {
|
try {
|
||||||
RandomAccessFile file = new RandomAccessFile(name, "r");
|
RandomAccessFile file = new RandomAccessFile(name, "r");
|
||||||
byte data[] = new byte[(int) file.length()];
|
byte data[] = new byte[(int) file.length()];
|
||||||
file.readFully(data);
|
file.readFully(data);
|
||||||
file.close();
|
file.close();
|
||||||
return data;
|
return data;
|
||||||
} catch (IOException e) {}
|
} catch (IOException e) {}
|
||||||
@ -48,21 +48,21 @@ class MyClassLoader extends ClassLoader {
|
|||||||
return defineClass(classData, 0, classData.length);
|
return defineClass(classData, 0, classData.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return findSystemClass(name);
|
return findSystemClass(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class ServerFactory {
|
public class ServerFactory {
|
||||||
|
|
||||||
public static Class<?> loadClass(String name) throws Exception {
|
public static Class<?> loadClass(String name) throws Exception {
|
||||||
MyClassLoader myClassLoader = new MyClassLoader(
|
MyClassLoader myClassLoader = new MyClassLoader(
|
||||||
MyClassLoader.class.getClassLoader());
|
MyClassLoader.class.getClassLoader());
|
||||||
Class<?> clazz = myClassLoader.loadClass(name, true);
|
Class<?> clazz = myClassLoader.loadClass(name, true);
|
||||||
return clazz;
|
return clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandExecutor createServer(String name) throws Exception {
|
public static CommandExecutor createServer(String name) throws Exception {
|
||||||
return (CommandExecutor) loadClass(name).newInstance();
|
return (CommandExecutor) loadClass(name).newInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user