Skip to content
Snippets Groups Projects
Verified Commit 1394a5f5 authored by BIGARET Sebastien's avatar BIGARET Sebastien
Browse files

Load as little classes as possible to display an error message

We want to use it to indicate that the JVM version is incorrect e.g.
So the less class are loaded, the best it is.
parent 2f6dee8d
No related branches found
No related tags found
No related merge requests found
......@@ -323,40 +323,6 @@ public class Client implements ApplicationListener
*/
private Utile.SimpleContainer connection_status = new Utile.SimpleContainer();
public void displayErrorMessage(String title, String message)
{
@SuppressWarnings("rawtypes")
Class MessageDialogClass = null;
if (!Configuration.getBoolean("client.no_gui"))
{
try
{
MessageDialogClass = Class.forName("eu.telecom_bretagne.praxis.client.ui.dialog.MessageDialog");
}
catch (Throwable e) { /* ignore */ }
}
if (MessageDialogClass!=null)
{
try
{
@SuppressWarnings("unchecked")
java.lang.reflect.Method showMessageDialog =
MessageDialogClass.getDeclaredMethod("showMessageDialog",
java.awt.Component.class,
java.lang.String.class,
int.class,
java.lang.String.class);
showMessageDialog.invoke(null, null, message, javax.swing.JOptionPane.ERROR_MESSAGE, title);
}
catch (Throwable t)
{
MessageDialogClass = null;
}
}
// log it in any cases
Log.log.severe(()->title+" - "+message);
}
public void connectAndWaitAnswer(String login, String password, boolean connectStorageManager)
{
cnx.addListener(new ServerToClientEventAdapter() {
......@@ -387,7 +353,7 @@ public class Client implements ApplicationListener
else
error_title = "Unknown error";
displayErrorMessage(error_title, error);
ErrorDialog.displayErrorMessage(error_title, error);
System.exit(-1);// TODO list & identify all exit status
}
connection_status.data = ( event.data instanceof Integer );
......
......@@ -4,6 +4,7 @@ package eu.telecom_bretagne.praxis.common;
import java.net.ProxySelector;
import eu.telecom_bretagne.praxis.client.Client;
import eu.telecom_bretagne.praxis.client.ErrorDialog;
import eu.telecom_bretagne.praxis.core.execution.ExecutionLoop;
import eu.telecom_bretagne.praxis.platform.Platform;
import eu.telecom_bretagne.praxis.platform.PlatformToClientBridge;
......@@ -82,7 +83,7 @@ public class Launcher
// we do not want to display anything for mac os x / vendor="Apple Inc.", the jvm shipped with mac os is okay.
// since java 7, vendor is Oracle Corporation
if (!"Sun Microsystems Inc.".equals(vendor) && !"Apple Inc.".equals(vendor) && !"Oracle Corporation".equals(vendor))
Client.uiClient.displayErrorMessage("JVM Warning",
ErrorDialog.displayWarningMessage("JVM Warning",
"We strongly recommend that you use a Java Virtual Machine provided by Oracle!\n\n"
+ "You're currently using the following JVM:\n - version: "
+ version
......@@ -92,7 +93,7 @@ public class Launcher
else if (jvmVersion >= 9)
{
Client.uiClient.displayErrorMessage("Error",
ErrorDialog.displayErrorMessage("Error",
"Error: this application requires java 8 but java "+jvmVersion+" is used.");
System.exit(-2);
}
......@@ -199,7 +200,7 @@ public class Launcher
}
catch (Throwable t)
{
Client.uiClient.displayErrorMessage("Connection error",
ErrorDialog.displayErrorMessage("Connection error",
"Error: unable to connect to the server\nReason: "+t.toString());
System.exit(1);
}
......
......@@ -13,6 +13,7 @@ import org.jdom.Document;
import org.jdom.Element;
import eu.telecom_bretagne.praxis.client.Client;
import eu.telecom_bretagne.praxis.client.ErrorDialog;
import eu.telecom_bretagne.praxis.common.Configuration;
import eu.telecom_bretagne.praxis.common.Environment;
import eu.telecom_bretagne.praxis.common.I18N;
......@@ -95,7 +96,7 @@ public class PlatformToClientBridge
Log.log.severe(()->error_title+": "+error);
client.displayErrorMessage(error_title, error);
ErrorDialog.displayErrorMessage(error_title, error);
System.exit(-1);// TODO list & identify all exit status
}
}
......@@ -196,7 +197,7 @@ public class PlatformToClientBridge
public void receivedMessage(ServerToClientEvent event)
{
if (event.forward)
client.displayErrorMessage("Message from server", (String)((Object[]) event.data)[0]);
ErrorDialog.displayWarningMessage("Message from server", (String)((Object[]) event.data)[0]);
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment