代码合并
This commit is contained in:
parent
46217e8275
commit
da1104c10c
|
@ -65,7 +65,7 @@ public class Module extends BaseModule {
|
|||
Container.cache.addComponent("robocode.host.vb", DotNetHost.class);
|
||||
Container.cache.addComponent("robocode.host.dotnet", DotNetHost.class);
|
||||
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
Logger.logError(e);
|
||||
throw new Error("Can't initialize .NET Robocode", e);
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ public class AutoExtract implements ActionListener {
|
|||
// Set native look and feel
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Throwable t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF
|
||||
} catch (RuntimeException t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF
|
||||
}
|
||||
|
||||
File suggestedDir;
|
||||
|
|
|
@ -40,33 +40,33 @@ public class TestMaxTurnRate extends RobocodeTestBed {
|
|||
if (event.getTurnSnapshot().getTurn() == 26) {
|
||||
final String out = buf.toString();
|
||||
|
||||
Assert.assertTrue(out.contains("1: 0.0, 0.0") | out.contains("1: 0.0, -0.0"));
|
||||
Assert.assertTrue(out.contains("2: 0.0, -1.0") | out.contains("2: 0.0, -0.999999999"));
|
||||
Assert.assertTrue(out.contains("3: 0.0, -2.0") | out.contains("3: 0.0, -1.999999999"));
|
||||
Assert.assertTrue(out.contains("4: 0.0, -3.0") | out.contains("4: 0.0, -2.999999999"));
|
||||
Assert.assertTrue(out.contains("5: 0.0, -4.0") | out.contains("5: 0.0, -3.999999999"));
|
||||
Assert.assertTrue(out.contains("6: 0.0, -5.0") | out.contains("6: 0.0, -4.999999999"));
|
||||
Assert.assertTrue(out.contains("7: 0.0, -6.0") | out.contains("7: 0.0, -5.999999999"));
|
||||
Assert.assertTrue(out.contains("8: 0.0, -7.0") | out.contains("8: 0.0, -6.999999999"));
|
||||
Assert.assertTrue(out.contains("9: 0.0, -8.0") | out.contains("9: 0.0, -7.999999999"));
|
||||
Assert.assertTrue(out.contains("10: 0.0, -9.0") | out.contains("10: 0.0, -8.999999999"));
|
||||
Assert.assertTrue(out.contains("11: 0.0, -10.0") | out.contains("11: 0.0, -9.999999999"));
|
||||
Assert.assertTrue(out.contains("12: 0.0, -10.0") | out.contains("12: 0.0, -9.999999999"));
|
||||
Assert.assertTrue(out.contains("13: 0.0, -10.0") | out.contains("13: 0.0, -9.999999999"));
|
||||
Assert.assertTrue(out.contains("1: 0.0, 0.0") || out.contains("1: 0.0, -0.0"));
|
||||
Assert.assertTrue(out.contains("2: 0.0, -1.0") || out.contains("2: 0.0, -0.999999999"));
|
||||
Assert.assertTrue(out.contains("3: 0.0, -2.0") || out.contains("3: 0.0, -1.999999999"));
|
||||
Assert.assertTrue(out.contains("4: 0.0, -3.0") || out.contains("4: 0.0, -2.999999999"));
|
||||
Assert.assertTrue(out.contains("5: 0.0, -4.0") || out.contains("5: 0.0, -3.999999999"));
|
||||
Assert.assertTrue(out.contains("6: 0.0, -5.0") || out.contains("6: 0.0, -4.999999999"));
|
||||
Assert.assertTrue(out.contains("7: 0.0, -6.0") || out.contains("7: 0.0, -5.999999999"));
|
||||
Assert.assertTrue(out.contains("8: 0.0, -7.0") || out.contains("8: 0.0, -6.999999999"));
|
||||
Assert.assertTrue(out.contains("9: 0.0, -8.0") || out.contains("9: 0.0, -7.999999999"));
|
||||
Assert.assertTrue(out.contains("10: 0.0, -9.0") || out.contains("10: 0.0, -8.999999999"));
|
||||
Assert.assertTrue(out.contains("11: 0.0, -10.0") || out.contains("11: 0.0, -9.999999999"));
|
||||
Assert.assertTrue(out.contains("12: 0.0, -10.0") || out.contains("12: 0.0, -9.999999999"));
|
||||
Assert.assertTrue(out.contains("13: 0.0, -10.0") || out.contains("13: 0.0, -9.999999999"));
|
||||
|
||||
Assert.assertTrue(out.contains("14: 0.0, 0.0") | out.contains("14: 0.0, -0.0"));
|
||||
Assert.assertTrue(out.contains("15: 0.0, 1.0") | out.contains("15: 0.0, 0.999999999"));
|
||||
Assert.assertTrue(out.contains("16: 0.0, 2.0") | out.contains("16: 0.0, 1.999999999"));
|
||||
Assert.assertTrue(out.contains("17: 0.0, 3.0") | out.contains("17: 0.0, 2.999999999"));
|
||||
Assert.assertTrue(out.contains("18: 0.0, 4.0") | out.contains("18: 0.0, 3.999999999"));
|
||||
Assert.assertTrue(out.contains("19: 0.0, 5.0") | out.contains("19: 0.0, 4.999999999"));
|
||||
Assert.assertTrue(out.contains("20: 0.0, 6.0") | out.contains("20: 0.0, 5.999999999"));
|
||||
Assert.assertTrue(out.contains("21: 0.0, 7.0") | out.contains("21: 0.0, 6.999999999"));
|
||||
Assert.assertTrue(out.contains("22: 0.0, 8.0") | out.contains("22: 0.0, 7.999999999"));
|
||||
Assert.assertTrue(out.contains("23: 0.0, 9.0") | out.contains("23: 0.0, 8.999999999"));
|
||||
Assert.assertTrue(out.contains("24: 0.0, 10.0") | out.contains("24: 0.0, 9.999999999"));
|
||||
Assert.assertTrue(out.contains("25: 0.0, 10.0") | out.contains("25: 0.0, 9.999999999"));
|
||||
Assert.assertTrue(out.contains("26: 0.0, 10.0") | out.contains("26: 0.0, 9.999999999"));
|
||||
Assert.assertTrue(out.contains("14: 0.0, 0.0") || out.contains("14: 0.0, -0.0"));
|
||||
Assert.assertTrue(out.contains("15: 0.0, 1.0") || out.contains("15: 0.0, 0.999999999"));
|
||||
Assert.assertTrue(out.contains("16: 0.0, 2.0") || out.contains("16: 0.0, 1.999999999"));
|
||||
Assert.assertTrue(out.contains("17: 0.0, 3.0") || out.contains("17: 0.0, 2.999999999"));
|
||||
Assert.assertTrue(out.contains("18: 0.0, 4.0") || out.contains("18: 0.0, 3.999999999"));
|
||||
Assert.assertTrue(out.contains("19: 0.0, 5.0") || out.contains("19: 0.0, 4.999999999"));
|
||||
Assert.assertTrue(out.contains("20: 0.0, 6.0") || out.contains("20: 0.0, 5.999999999"));
|
||||
Assert.assertTrue(out.contains("21: 0.0, 7.0") || out.contains("21: 0.0, 6.999999999"));
|
||||
Assert.assertTrue(out.contains("22: 0.0, 8.0") || out.contains("22: 0.0, 7.999999999"));
|
||||
Assert.assertTrue(out.contains("23: 0.0, 9.0") || out.contains("23: 0.0, 8.999999999"));
|
||||
Assert.assertTrue(out.contains("24: 0.0, 10.0") || out.contains("24: 0.0, 9.999999999"));
|
||||
Assert.assertTrue(out.contains("25: 0.0, 10.0") || out.contains("25: 0.0, 9.999999999"));
|
||||
Assert.assertTrue(out.contains("26: 0.0, 10.0") || out.contains("26: 0.0, 9.999999999"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ public class AutoExtract implements ActionListener {
|
|||
// Set native look and feel
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Throwable t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF
|
||||
} catch (RuntimeException t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF
|
||||
}
|
||||
|
||||
File installDir = null;
|
||||
|
|
|
@ -113,7 +113,7 @@ public class HiddenAccess {
|
|||
System.exit(-1);
|
||||
} catch (MalformedURLException e) {
|
||||
Logger.logError(e);
|
||||
} catch (Error e) {
|
||||
} catch (MyException e) {
|
||||
Logger.logError(e);
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onBattleStarted(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onBattleStarted " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onBattleCompleted(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onBattleCompleted " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onBattleFinished(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onBattleFinished " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onBattlePaused(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onBattlePaused " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onBattleResumed(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onBattleResumed " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onRoundStarted(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onRoundStarted " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onRoundEnded(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onRoundEnded " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onTurnStarted(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onTurnStarted " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onTurnEnded(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onTurnEnded " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onBattleMessage(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
logError("onBattleMessage " + listener.getClass(), ex);
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public class BattleEventDispatcher implements IBattleListener {
|
|||
for (IBattleListener listener : listeners) {
|
||||
try {
|
||||
listener.onBattleError(event);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
Logger.realErr.println(listener.getClass() + " " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ public final class RobocodeMain extends RobocodeMainBase {
|
|||
System.exit(8);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
Logger.logError(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class JavaHost implements IHost {
|
|||
}
|
||||
return checkInterfaces(robotClass, robotItem);
|
||||
|
||||
} catch (Throwable t) {
|
||||
} catch (RuntimeException t) {
|
||||
if (message) {
|
||||
logError("Got an error with " + robotItem.getFullClassName() + ": " + t); // just message here
|
||||
if (t.getMessage() != null && t.getMessage().contains("Bad version number in .class file")) {
|
||||
|
|
|
@ -382,7 +382,7 @@ public final class EventManager implements IEventManager {
|
|||
} catch (RuntimeException e) {
|
||||
currentTopEvent = null;
|
||||
throw e;
|
||||
} catch (Error e) {
|
||||
} catch (MyException e) {
|
||||
currentTopEvent = null;
|
||||
throw e;
|
||||
} finally {
|
||||
|
|
|
@ -157,7 +157,7 @@ abstract class HostingRobotProxy implements IHostingRobotProxy, IHostedThread {
|
|||
private void loadClassBattle() {
|
||||
try {
|
||||
robotClassLoader.loadRobotMainClass(true);
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
println("SYSTEM: Could not load " + statics.getName() + " : ");
|
||||
println(e);
|
||||
drainEnergy();
|
||||
|
@ -183,7 +183,7 @@ abstract class HostingRobotProxy implements IHostingRobotProxy, IHostedThread {
|
|||
robot = null;
|
||||
logError(e);
|
||||
return false;
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
println("SYSTEM: An error occurred during initialization of " + statics.getName());
|
||||
println("SYSTEM: " + e);
|
||||
println(e);
|
||||
|
@ -247,7 +247,7 @@ abstract class HostingRobotProxy implements IHostingRobotProxy, IHostedThread {
|
|||
println(e);
|
||||
logMessage(statics.getName() + " stopped successfully.");
|
||||
throw e; // must be re-thrown in order to stop the thread
|
||||
} catch (Throwable t) {
|
||||
} catch (RuntimeException t) {
|
||||
drainEnergy();
|
||||
println(t);
|
||||
logMessage(statics.getName() + ": Throwable: " + t); // without stack here
|
||||
|
|
|
@ -244,7 +244,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade
|
|||
} else {
|
||||
warnIfStaticRobotInstanceFields();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
robotClass = null;
|
||||
throw new ClassNotFoundException(e.getMessage(), e);
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
} catch (RuntimeException t) {
|
||||
Logger.logError(t);
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade
|
|||
Class<?> type = null;
|
||||
try {
|
||||
type = loadRobotClassLocaly(className, false);
|
||||
} catch (Throwable t) {
|
||||
} catch (RuntimeException t) {
|
||||
continue;
|
||||
}
|
||||
if (type != null) {
|
||||
|
@ -366,7 +366,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade
|
|||
modifiersField.setInt(field, modifiers & ~Modifier.FINAL); // Remove the FINAL modifier
|
||||
field.set(null, null);
|
||||
|
||||
} catch (Throwable ignore) {}
|
||||
} catch (RuntimeException ignore) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -383,7 +383,7 @@ public class RobotClassLoader extends URLClassLoader implements IRobotClassLoade
|
|||
for (Field field: type.getDeclaredFields()) {
|
||||
fields.add(field);
|
||||
}
|
||||
} catch (Throwable ignore) {// NoClassDefFoundError does occur with some robots, e.g. sgp.Drunken [1.12]
|
||||
} catch (RuntimeException ignore) {// NoClassDefFoundError does occur with some robots, e.g. sgp.Drunken [1.12]
|
||||
// We ignore all exceptions and errors here so we can proceed to retrieve
|
||||
// field from super classes.
|
||||
}
|
||||
|
|
|
@ -337,7 +337,7 @@ public class AutoExtract implements ActionListener {
|
|||
// Set native look and feel
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Throwable t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF
|
||||
} catch (RuntimeException t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF
|
||||
}
|
||||
|
||||
AutoExtract extractor = new AutoExtract();
|
||||
|
|
|
@ -204,7 +204,7 @@ public class FileTransfer {
|
|||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
} catch (Throwable ignore) {// we expect this, right ?
|
||||
} catch (RuntimeException ignore) {// we expect this, right ?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class AwtAttack extends AdvancedRobot {
|
|||
};
|
||||
|
||||
javax.swing.SwingUtilities.invokeLater(doHack);
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swalow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class AwtAttack extends AdvancedRobot {
|
|||
e.printStackTrace(out);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(out);
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swalow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ConstructorAwtAttack extends robocode.AdvancedRobot {
|
|||
};
|
||||
|
||||
javax.swing.SwingUtilities.invokeLater(doHack);
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swallow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class ConstructorAwtAttack extends robocode.AdvancedRobot {
|
|||
e.printStackTrace(out);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(out);
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swallow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ConstructorThreadAttack extends robocode.AdvancedRobot {
|
|||
Thread t = new Thread(a);
|
||||
|
||||
t.start();
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swallow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class ConstructorThreadAttack extends robocode.AdvancedRobot {
|
|||
Thread t = new Thread(tg, a);
|
||||
|
||||
t.start();
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swallow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class FileAttack extends AdvancedRobot {
|
|||
e.printStackTrace(out);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(out);
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swalow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class FileAttack extends AdvancedRobot {
|
|||
e.printStackTrace(out);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(out);
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swalow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class IncludeNamespaceAttack extends AdvancedRobot {
|
|||
private void namespaceAttack() {
|
||||
try {
|
||||
HiddenAccess.createRules(10, 10, 10, 10, 1, false, 100);
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// Swallow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class ThreadAttack extends AdvancedRobot {
|
|||
Thread t = new Thread(a);
|
||||
|
||||
t.start();
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swallow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class ThreadAttack extends AdvancedRobot {
|
|||
Thread t = new Thread(tg, a);
|
||||
|
||||
t.start();
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
// swallow security exception
|
||||
e.printStackTrace(out);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ThreadGroupAttack extends Robot {
|
|||
}
|
||||
}
|
||||
}).start();
|
||||
} catch (Throwable t) {
|
||||
} catch (RuntimeException t) {
|
||||
t.printStackTrace(out);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class UndeadThread extends AdvancedRobot {
|
|||
while (true) {
|
||||
try {
|
||||
body();
|
||||
} catch (Throwable t) {
|
||||
} catch (RuntimeException t) {
|
||||
// spamming the console
|
||||
out.println("Swalowed it, HA HA HA HA HAAAAA !!!!!");
|
||||
out.println(t);
|
||||
|
|
|
@ -22,7 +22,7 @@ public class Assert extends org.junit.Assert {
|
|||
public static void allAssertNear(double v1, double v2) {
|
||||
try {
|
||||
assertNear(v1, v2);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class Assert extends org.junit.Assert {
|
|||
public static <T> void allAssertThat(T t, org.hamcrest.Matcher<T> tMatcher) {
|
||||
try {
|
||||
org.junit.Assert.assertThat(t, tMatcher);
|
||||
} catch (Throwable ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ public class EditWindow extends JInternalFrame {
|
|||
setModified(editorPanel.getEditorPane().isModified());
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
} catch (RuntimeException e) {
|
||||
Logger.logError(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class WindowMenuItem extends JCheckBoxMenuItem implements ActionListener
|
|||
if (window.isIcon()) {
|
||||
try {
|
||||
window.setIcon(false);
|
||||
} catch (Throwable ignored) {}
|
||||
} catch (RuntimeException ignored) {}
|
||||
}
|
||||
if (window.getDesktopPane() != null) {
|
||||
window.getDesktopPane().setSelectedFrame(window);
|
||||
|
@ -83,7 +83,7 @@ public class WindowMenuItem extends JCheckBoxMenuItem implements ActionListener
|
|||
window.grabFocus();
|
||||
try {
|
||||
window.setSelected(true);
|
||||
} catch (Throwable ignored) {}
|
||||
} catch (RuntimeException ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -574,14 +574,14 @@ public class WindowManager implements IWindowManagerExt {
|
|||
private void setLookAndFeel() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Throwable t) {
|
||||
} catch (RuntimeException t) {
|
||||
// Work-around for problems with setting Look and Feel described here:
|
||||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6468089
|
||||
Locale.setDefault(Locale.US);
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Throwable t2) {
|
||||
} catch (RuntimeException t2) {
|
||||
// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF
|
||||
System.err.println("Could not set the Look and Feel (LAF). The default LAF is used instead");
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public final class AwtBattleAdaptor {
|
|||
calculateFPS();
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
} catch (RuntimeException t) {
|
||||
Logger.logError(t);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package net.sf.robocode.ui.dialog;
|
||||
|
||||
|
||||
|
@ -32,17 +31,14 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
private RobotSelectionPanel robotSelectionPanel;
|
||||
private TeamCreatorOptionsPanel teamCreatorOptionsPanel;
|
||||
|
||||
private final int minRobots = 2;//每个编队至少两人
|
||||
private final int maxRobots = 10;//每个编队最多10人
|
||||
private final int minRobots = 2;
|
||||
private final int maxRobots = 10;
|
||||
|
||||
private final EventHandler eventHandler = new EventHandler();
|
||||
|
||||
//EventHandler具体实现ActionListener接口,实现动作的监听操作
|
||||
class EventHandler implements ActionListener {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//e为传入的参数,传入临时变量e,为ActionEvent类型
|
||||
if (e.getActionCommand().equals("Refresh")) {
|
||||
//执行跟新操作
|
||||
getRobotSelectionPanel().refreshRobotList(true);
|
||||
}
|
||||
}
|
||||
|
@ -63,12 +59,9 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
return teamCreatorOptionsPanel;
|
||||
}
|
||||
|
||||
//获取创建编队嵌入框中的内容
|
||||
private JPanel getTeamCreatorContentPane() {
|
||||
if (teamCreatorContentPane == null) {
|
||||
//如果嵌入框内容为空
|
||||
teamCreatorContentPane = new JPanel();
|
||||
//新建嵌入框
|
||||
teamCreatorContentPane.setLayout(new BorderLayout());
|
||||
teamCreatorContentPane.add(getWizardController(), BorderLayout.SOUTH);
|
||||
teamCreatorContentPane.add(getWizardPanel(), BorderLayout.CENTER);
|
||||
|
@ -82,12 +75,8 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
return teamCreatorContentPane;
|
||||
}
|
||||
|
||||
//选择机器人组成编队
|
||||
protected RobotSelectionPanel getRobotSelectionPanel()
|
||||
{
|
||||
//如果当前选择为空
|
||||
if (robotSelectionPanel == null)
|
||||
{
|
||||
protected RobotSelectionPanel getRobotSelectionPanel() {
|
||||
if (robotSelectionPanel == null) {
|
||||
robotSelectionPanel = net.sf.robocode.core.Container.createComponent(RobotSelectionPanel.class);
|
||||
robotSelectionPanel.setup(minRobots, maxRobots, false, "Select the robots for this team.", false, true, true,
|
||||
false, false, false, null);
|
||||
|
@ -95,11 +84,8 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
return robotSelectionPanel;
|
||||
}
|
||||
|
||||
//新建一个嵌入板
|
||||
private WizardCardPanel getWizardPanel()
|
||||
{
|
||||
if (wizardPanel == null)
|
||||
{
|
||||
private WizardCardPanel getWizardPanel() {
|
||||
if (wizardPanel == null) {
|
||||
wizardPanel = new WizardCardPanel(this);
|
||||
wizardPanel.add(getRobotSelectionPanel(), "Select robots");
|
||||
wizardPanel.add(getTeamCreatorOptionsPanel(), "Select options");
|
||||
|
@ -107,27 +93,23 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
return wizardPanel;
|
||||
}
|
||||
|
||||
//窗口初始化
|
||||
public void initialize()
|
||||
{
|
||||
public void initialize() {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("Create a team");
|
||||
setContentPane(getTeamCreatorContentPane());
|
||||
}
|
||||
|
||||
private WizardController getWizardController() {
|
||||
if (wizardController == null)
|
||||
{
|
||||
if (wizardController == null) {
|
||||
wizardController = getWizardPanel().getWizardController();
|
||||
}
|
||||
return wizardController;
|
||||
}
|
||||
//添加取消键动作
|
||||
|
||||
public void cancelButtonActionPerformed() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
//添加完成键动作
|
||||
public void finishButtonActionPerformed() {
|
||||
try {
|
||||
int rc = createTeam();
|
||||
|
@ -145,14 +127,12 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
}
|
||||
}
|
||||
|
||||
//将创建的编队写入数据库
|
||||
public int createTeam() throws IOException {
|
||||
File file = new File(repositoryManager.getRobotsDirectory(),
|
||||
teamCreatorOptionsPanel.getTeamPackage().replace('.', File.separatorChar)
|
||||
+ teamCreatorOptionsPanel.getTeamNameField().getText() + ".team");
|
||||
|
||||
if (file.exists()) {
|
||||
//如果当前编队已经存在
|
||||
int ok = JOptionPane.showConfirmDialog(this, file + " already exists. Are you sure you want to replace it?",
|
||||
"Warning", JOptionPane.YES_NO_CANCEL_OPTION);
|
||||
|
||||
|
@ -170,13 +150,10 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
String webPageFieldString = teamCreatorOptionsPanel.getWebpageField().getText();
|
||||
|
||||
if (webPageFieldString != null && webPageFieldString.length() > 0) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
webPageUrl = new URL(webPageFieldString);
|
||||
} catch (MalformedURLException e)
|
||||
{
|
||||
try
|
||||
{
|
||||
} catch (MalformedURLException e) {
|
||||
try {
|
||||
webPageUrl = new URL("http://" + webPageFieldString);
|
||||
teamCreatorOptionsPanel.getWebpageField().setText(webPageUrl.toString());
|
||||
} catch (MalformedURLException ignored) {}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package net.sf.robocode.ui.dialog;
|
||||
|
||||
|
||||
|
@ -18,7 +17,6 @@ import java.net.URL;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class TeamCreatorOptionsPanel extends WizardPanel {
|
||||
private TeamCreator teamCreator;
|
||||
|
@ -41,20 +39,16 @@ public class TeamCreatorOptionsPanel extends WizardPanel {
|
|||
|
||||
private String teamPackage;
|
||||
|
||||
private class EventHandler implements ComponentListener, DocumentListener
|
||||
{
|
||||
public void insertUpdate(DocumentEvent e)
|
||||
{
|
||||
private class EventHandler implements ComponentListener, DocumentListener {
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
fireStateChanged();
|
||||
}
|
||||
|
||||
public void changedUpdate(DocumentEvent e)
|
||||
{
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
fireStateChanged();
|
||||
}
|
||||
|
||||
public void removeUpdate(DocumentEvent e)
|
||||
{
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
fireStateChanged();
|
||||
}
|
||||
|
||||
|
@ -65,38 +59,32 @@ public class TeamCreatorOptionsPanel extends WizardPanel {
|
|||
public void componentShown(ComponentEvent e) {
|
||||
List<IRobotSpecItem> selectedRobots;
|
||||
|
||||
if (teamCreator != null)
|
||||
{
|
||||
if (teamCreator != null) {
|
||||
selectedRobots = teamCreator.getRobotSelectionPanel().getSelectedRobots();
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
selectedRobots = teamPackager.getRobotSelectionPanel().getSelectedRobots();
|
||||
}
|
||||
|
||||
if (selectedRobots != null)
|
||||
{
|
||||
if (selectedRobots != null) {
|
||||
IRobotSpecItem robotSpecification = selectedRobots.get(0);
|
||||
|
||||
getTeamNameLabel().setText("Please choose a name for your team: (Must be a valid Java classname)");
|
||||
getTeamNameField().setText(robotSpecification.getShortClassName() + "Team");
|
||||
getTeamPackageLabel().setText(robotSpecification.getFullPackage() + ".");
|
||||
teamPackage = robotSpecification.getFullPackage();
|
||||
if (teamPackage != null)
|
||||
{
|
||||
if (teamPackage != null) {
|
||||
teamPackage += ".";
|
||||
}
|
||||
|
||||
String d = robotSpecification.getDescription();
|
||||
|
||||
if (d == null)
|
||||
{
|
||||
if (d == null) {
|
||||
d = "";
|
||||
}
|
||||
getDescriptionArea().setText(d);
|
||||
String a = robotSpecification.getAuthorName();
|
||||
|
||||
if (a == null)
|
||||
{
|
||||
if (a == null) {
|
||||
a = "";
|
||||
}
|
||||
getAuthorField().setText(a);
|
||||
|
@ -315,7 +303,11 @@ public class TeamCreatorOptionsPanel extends WizardPanel {
|
|||
return teamPackageLabel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 得到队伍包
|
||||
*
|
||||
* @return 返回一个字符串
|
||||
*/
|
||||
public String getTeamPackage() {
|
||||
return (teamPackage != null) ? teamPackage : ".";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue