removed trailing whitespace

This commit is contained in:
navid.sassan 2020-09-21 19:27:25 +02:00
parent ef7f5d1d23
commit 61950fc62a
4 changed files with 40 additions and 40 deletions

View File

@ -17,4 +17,4 @@ public class AnyServer implements CommandExecutor {
result.append("\"\n");
return result.toString();
}
}//AnyServer
}//AnyServer

View File

@ -12,7 +12,7 @@ public class ExBox {
public static void main(String[] args) throws Exception {
ExBoxFrame f = new ExBoxFrame();
f.setLocationRelativeTo(null);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}

View File

@ -5,9 +5,9 @@
*
* @author K.Rege
* @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.01 2018/2/5 AutoScale
* @version 2.01 2018/2/5 AutoScale
* @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 JComboBox history;
private JTextArea output;
private JScrollPane scrollPane;
private JScrollPane scrollPane;
private CommandExecutor command;
private boolean graphicOn;
private GraphicPanel graphic;
@ -54,7 +54,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
}
}
}
private void initMenu() {
JMenuBar menuBar = new JMenuBar();
JMenu menuFile = new JMenu();
@ -71,7 +71,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
menuFile.add(menuFileExit);
menuBar.add(menuFile);
JMenu menuServer = new JMenu("Server");
menuBar.add(menuServer);
connect = new JMenuItem("Connect");
@ -80,7 +80,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
test = new JMenuItem("Test");
test.addActionListener(this);
menuServer.add(test);
JMenu menuView = new JMenu("View");
menuBar.add(menuView);
textView = new JMenuItem("Text");
@ -89,11 +89,11 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
graphicView = new JMenuItem("Graphic");
graphicView.addActionListener(this);
menuView.add(graphicView);
open = new JMenuItem("Open...");
open.addActionListener(this);
menuFile.insert(open, 0);
setJMenuBar(menuBar);
menuFile.insert(open, 0);
setJMenuBar(menuBar);
}
private void initComponents() {
@ -114,9 +114,9 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
history = new JComboBox();
history.addItemListener(this);
panel.add(BorderLayout.SOUTH, history);
add(BorderLayout.SOUTH, panel);
add(BorderLayout.SOUTH, panel);
}
/**
* get default path for file open dialog
*/
@ -140,12 +140,12 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {
ex.printStackTrace();
}
}
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
if (screenSize.getWidth() > 1920) {
SCALE = 2;
}
setFontSize((int) (11 * SCALE));
setFontSize((int) (11 * SCALE));
setSize(new Dimension((int) (400 * SCALE), (int) (400 * SCALE)));
setTitle("ExBox");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -176,7 +176,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
}
}
}
private void setGraphicView() {
if (graphicOn) {
return;
@ -200,7 +200,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
validate();
repaint();
}
private String openFileDialog(String startDirectory, String pattern) {
FileDialog fd = new FileDialog(this, "Open");
if (pattern != null) {
@ -210,30 +210,30 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
fd.setDirectory(startDirectory);
}
fd.setVisible(true);
return fd.getDirectory() + fd.getFile();
return fd.getDirectory() + fd.getFile();
}
private void testCommand() throws Exception {
final java.util.List<String> failed = new LinkedList<String>();
final java.util.List<String> finished = new LinkedList<String>();
JUnitCore runner = new JUnitCore();
String name = openFileDialog(getPathCompiled(), "*Test.class");
runner.addListener(new RunListener() {
@Override
public void testFinished(Description description) throws Exception {
finished.add(description.getDisplayName());
}
finished.add(description.getDisplayName());
}
@Override
public void testFailure(Failure failure) throws Exception {
failed.add(failure.getDescription().getDisplayName());
}
}
});
Class testClass = ServerFactory.loadClass(name);
Result result = runner.run(testClass);
for (String test : finished) {
if (!failed.contains(test)) {
output.append(test + ": OK\n");
@ -249,7 +249,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
: result.getFailures().size() + " ERRORS")
+ "\n");
}
private void connectCommand() throws Exception {
String name = openFileDialog(getPathCompiled(), "*Server.class");
command = ServerFactory.createServer(name);
@ -257,10 +257,10 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
String fullClassName = command.getClass().getName();
String simpleClassName = fullClassName.substring(
fullClassName.lastIndexOf('.') + 1);
setTitle("ExBox connected to " + simpleClassName);
setTitle("ExBox connected to " + simpleClassName);
}
private void openFile() throws Exception {
String name = openFileDialog(null, null);
@ -272,7 +272,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
b.append(line);
b.append('\n');
}
interpret(b.toString());
interpret(b.toString());
}
public void itemStateChanged(ItemEvent e) {
@ -280,8 +280,8 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
arguments.setText((String) e.getItem());
interpret(arguments.getText());
} catch (Throwable ex) {
error(ex.toString());
}
error(ex.toString());
}
}
public void actionPerformed(ActionEvent e) {
@ -311,4 +311,4 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
protected void windowClosed() {
System.exit(0);
}
}
}

View File

@ -13,16 +13,16 @@ import java.io.*;
*/
class MyClassLoader extends ClassLoader {
private String path;
MyClassLoader(ClassLoader parent) {
super(parent);
}
private byte[] getBytes(String name) {
try {
RandomAccessFile file = new RandomAccessFile(name, "r");
byte data[] = new byte[(int) file.length()];
file.readFully(data);
file.readFully(data);
file.close();
return data;
} catch (IOException e) {}
@ -48,21 +48,21 @@ class MyClassLoader extends ClassLoader {
return defineClass(classData, 0, classData.length);
}
}
return findSystemClass(name);
return findSystemClass(name);
}
}
public class ServerFactory {
public static Class<?> loadClass(String name) throws Exception {
MyClassLoader myClassLoader = new MyClassLoader(
MyClassLoader.class.getClassLoader());
Class<?> clazz = myClassLoader.loadClass(name, true);
return clazz;
}
public static CommandExecutor createServer(String name) throws Exception {
return (CommandExecutor) loadClass(name).newInstance();
}
}
}