Additional switch against GUI dead-locks

This commit is contained in:
Marcel Kronfeld
2010-09-22 07:52:30 +00:00
parent 61d409ce4c
commit 25134617c3

View File

@@ -81,6 +81,7 @@ import eva2.tools.jproxy.RemoteStateListener;
public class EvAClient implements RemoteStateListener, Serializable { public class EvAClient implements RemoteStateListener, Serializable {
private final int splashScreenTime = 1500; private final int splashScreenTime = 1500;
private final int maxWindowMenuLength = 30; private final int maxWindowMenuLength = 30;
private boolean clientInited = false;
public static boolean TRACE = false; public static boolean TRACE = false;
@@ -219,7 +220,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
/** /**
* Constructor of GUI of EvA2. Works as client for the EvA2 server. GO parameters may be * Main constructor of the EvA2 client GUI. Works as standalone verson locally or
* as client for the EvA2 server. GO parameters may be
* loaded from a file (paramsFile) or given directly as a java instance. Both may be null * loaded from a file (paramsFile) or given directly as a java instance. Both may be null
* to start with standard parameters. If both are non null, the java instance has the * to start with standard parameters. If both are non null, the java instance has the
* higher priority. * higher priority.
@@ -234,6 +236,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
* @param noGui * @param noGui
*/ */
public EvAClient(final String hostName, final Window parent, final String paramsFile, final InterfaceGOParameters goParams, final boolean autorun, final boolean noSplash, final boolean noGui) { public EvAClient(final String hostName, final Window parent, final String paramsFile, final InterfaceGOParameters goParams, final boolean autorun, final boolean noSplash, final boolean noGui) {
clientInited = false;
final SplashScreenShell fSplashScreen = new SplashScreenShell(EvAInfo.splashLocation); final SplashScreenShell fSplashScreen = new SplashScreenShell(EvAInfo.splashLocation);
// preload some classes (into system cache) in a parallel thread // preload some classes (into system cache) in a parallel thread
@@ -277,6 +280,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
// close splash screen // close splash screen
if (!noSplash && withGUI) fSplashScreen.dispose(); if (!noSplash && withGUI) fSplashScreen.dispose();
clientInited = true;
notify(); notify();
} }
} }
@@ -288,9 +292,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
* may be called to await the full initialization of a client instance. * may be called to await the full initialization of a client instance.
* As soon as it returns, the EvAClient GUI is fully initialized. * As soon as it returns, the EvAClient GUI is fully initialized.
*/ */
public void awaitGuiInitialized() { public void awaitClientInitialized() {
if (initRnbl!=null) { if (initRnbl!=null) {
synchronized (initRnbl) { synchronized (initRnbl) {
if (!clientInited) {
try { try {
initRnbl.wait(); initRnbl.wait();
initRnbl=null; initRnbl=null;
@@ -300,6 +305,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
} }
} }
}
private void preloadClasses() { private void preloadClasses() {
ClassPreloader cp = new ClassPreloader( "eva2.server.go.strategies.InterfaceOptimizer", "eva2.server.go.problems.InterfaceOptimizationProblem", "eva2.server.go.InterfaceTerminator"); ClassPreloader cp = new ClassPreloader( "eva2.server.go.strategies.InterfaceOptimizer", "eva2.server.go.problems.InterfaceOptimizationProblem", "eva2.server.go.InterfaceTerminator");
@@ -326,7 +332,6 @@ public class EvAClient implements RemoteStateListener, Serializable {
*/ */
public void addWindowListener(WindowListener l) { public void addWindowListener(WindowListener l) {
if (m_Frame != null) { if (m_Frame != null) {
m_Frame.setName(getClass().getSimpleName());
m_Frame.addWindowListener(l); m_Frame.addWindowListener(l);
} else { } else {
System.err.println("Error, no JFrame existent in " System.err.println("Error, no JFrame existent in "
@@ -362,6 +367,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
if (withGUI ) { if (withGUI ) {
m_Frame = new JEFrame(EvAInfo.productName + " workbench"); m_Frame = new JEFrame(EvAInfo.productName + " workbench");
m_Frame.setName(this.getClass().getSimpleName()); // the name is set to recognize the client window
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
m_Frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); m_Frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));