Minor cleanup.

This commit is contained in:
Fabian Becker 2012-04-15 18:45:12 +00:00
parent af1fae181e
commit e721e06e11
2 changed files with 44 additions and 51 deletions

View File

@ -101,11 +101,11 @@ public class EvAInfo {
////////////// Property handling... ////////////// Property handling...
private static Properties EVA_PROPERTIES; private static Properties evaProperties;
static { static {
try { try {
EVA_PROPERTIES = BasicResourceLoader.readProperties(EvAInfo.propertyFile); evaProperties = BasicResourceLoader.readProperties(EvAInfo.propertyFile);
} catch (Exception ex) { } catch (Exception ex) {
System.err.println(resourceNotFoundErrorMessage(EvAInfo.propertyFile)); System.err.println(resourceNotFoundErrorMessage(EvAInfo.propertyFile));
System.err.println(ex.getMessage()); System.err.println(ex.getMessage());
System.exit(1); System.exit(1);
@ -132,16 +132,16 @@ public class EvAInfo {
} }
public static String getProperty(String key) { public static String getProperty(String key) {
String myVal = EVA_PROPERTIES.getProperty(key); String myVal = evaProperties.getProperty(key);
return myVal; return myVal;
} }
public static Properties getProperties() { public static Properties getProperties() {
return EVA_PROPERTIES; return evaProperties;
} }
private static void setProperty(String key, String value) { private static void setProperty(String key, String value) {
EVA_PROPERTIES.setProperty(key, value); evaProperties.setProperty(key, value);
} }
public static String getVersion() { public static String getVersion() {

View File

@ -99,7 +99,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
private transient JProgressBar m_ProgressBar; private transient JProgressBar m_ProgressBar;
// LogPanel // LogPanel
private LogPanel logPanel; private LogPanel logPanel;
private Logger logger; private static final Logger logger = Logger.getLogger("EvAClient");
// Module: // Module:
private ExtAction m_actModuleLoad; private ExtAction m_actModuleLoad;
// GUI: // GUI:
@ -253,17 +253,18 @@ public class EvAClient implements RemoteStateListener, Serializable {
*/ */
public EvAClient(final String hostName, final Window parent, final String paramsFile, final InterfaceGOParameters goParams, final boolean autorun, final boolean noSplash, final boolean noGui, final boolean showTreeView) { public EvAClient(final String hostName, final Window parent, final String paramsFile, final InterfaceGOParameters goParams, final boolean autorun, final boolean noSplash, final boolean noGui, final boolean showTreeView) {
clientInited = false; clientInited = false;
final SplashScreenShell fSplashScreen = new SplashScreenShell(EvAInfo.splashLocation); final SplashScreen splashScreen = new SplashScreen(EvAInfo.splashLocation);
// preload some classes (into system cache) in a parallel thread // preload some classes (into system cache) in a parallel thread
preloadClasses(); preloadClasses();
withGUI = !noGui; withGUI = !noGui;
withTreeView = showTreeView; withTreeView = showTreeView;
// activate the splash screen (show later using SwingUtilities) // activate the splash screen (show later using SwingUtilities)
if (!noSplash && withGUI) { if (!noSplash && withGUI) {
try { try {
fSplashScreen.splash(); splashScreen.splash();
} catch (HeadlessException e) { } catch (HeadlessException e) {
System.err.println("Error: no xserver present - deactivating GUI."); System.err.println("Error: no xserver present - deactivating GUI.");
withGUI = false; withGUI = false;
@ -306,7 +307,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
// close splash screen // close splash screen
if (!noSplash && withGUI) { if (!noSplash && withGUI) {
fSplashScreen.dispose(); splashScreen.dispose();
} }
clientInited = true; clientInited = true;
notify(); notify();
@ -416,7 +417,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
logPanel = new LogPanel(); logPanel = new LogPanel();
evaFrame.getContentPane().add(logPanel, BorderLayout.CENTER); evaFrame.getContentPane().add(logPanel, BorderLayout.CENTER);
logger = Logger.getLogger("EvAClient");
logger.addHandler(new Handler() { logger.addHandler(new Handler() {
@Override @Override
@ -589,7 +590,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
public static String usage() { public static String usage() {
StringBuffer sbuf = new StringBuffer(); StringBuilder sbuf = new StringBuilder();
sbuf.append(EvAInfo.productName); sbuf.append(EvAInfo.productName);
sbuf.append(" - "); sbuf.append(" - ");
sbuf.append(EvAInfo.productLongName); sbuf.append(EvAInfo.productLongName);
@ -623,6 +624,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_actModuleLoad = new ExtAction("&Load", "Load Module", m_actModuleLoad = new ExtAction("&Load", "Load Module",
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
loadModuleFromServer(null, null); loadModuleFromServer(null, null);
} }
@ -631,6 +633,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_actAbout = new ExtAction("&About...", "Product Information", m_actAbout = new ExtAction("&About...", "Product Information",
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showAboutDialog(); showAboutDialog();
@ -639,6 +642,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_actLicense = new ExtAction("&License...", "View License", m_actLicense = new ExtAction("&License...", "View License",
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showLicense(); showLicense();
@ -647,6 +651,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_actHost = new ExtAction("&List of all servers", "All servers in list", m_actHost = new ExtAction("&List of all servers", "All servers in list",
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
selectAvailableHost(m_ComAdapter.getHostNameList()); selectAvailableHost(m_ComAdapter.getHostNameList());
@ -655,11 +660,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_actAvailableHost = new ExtAction("Available &Server", "Available server", m_actAvailableHost = new ExtAction("Available &Server", "Available server",
KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showPleaseWaitDialog(); showPleaseWaitDialog();
Thread xx = new Thread() { Thread xx = new Thread() {
@Override
public void run() { public void run() {
selectAvailableHost(m_ComAdapter.getAvailableHostNameList()); selectAvailableHost(m_ComAdapter.getAvailableHostNameList());
} }
@ -670,6 +677,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_actKillHost = new ExtAction("&Kill server", "Kill server process on selected host", m_actKillHost = new ExtAction("&Kill server", "Kill server process on selected host",
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showPleaseWaitDialog(); showPleaseWaitDialog();
@ -685,6 +693,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_actKillAllHosts = new ExtAction("Kill &all servers", "Kill all servers", m_actKillAllHosts = new ExtAction("Kill &all servers", "Kill all servers",
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showPleaseWaitDialog(); showPleaseWaitDialog();
@ -978,8 +987,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
// m_ModulGUIContainer.add(Temp); // m_ModulGUIContainer.add(Temp);
} catch (Exception e) { } catch (Exception e) {
currentModule = null; currentModule = null;
e.printStackTrace(); logger.log(Level.SEVERE, "Error while newModulAdapter.getModulFrame(): " + e.getMessage(), e);
logMessage("Error while newModulAdapter.getModulFrame(): " + e.getMessage());
EVAERROR.EXIT("Error while newModulAdapter.getModulFrame(): " + e.getMessage()); EVAERROR.EXIT("Error while newModulAdapter.getModulFrame(): " + e.getMessage());
} }
// try { TODO whats this? // try { TODO whats this?
@ -1021,15 +1029,15 @@ public class EvAClient implements RemoteStateListener, Serializable {
/** /**
* *
*/ */
private void selectAvailableHost(String[] HostNames) { private void selectAvailableHost(String[] hostNames) {
if (HostNames == null || HostNames.length == 0) { if (hostNames == null || hostNames.length == 0) {
showNoHostFoundDialog(); showNoHostFoundDialog();
} else { } else {
String HostName = (String) JOptionPane.showInputDialog(evaFrame.getContentPane(), String hostName = (String) JOptionPane.showInputDialog(evaFrame.getContentPane(),
"Which active host do you want to connect to?", "Host", JOptionPane.QUESTION_MESSAGE, null, "Which active host do you want to connect to?", "Host", JOptionPane.QUESTION_MESSAGE, null,
HostNames, m_ComAdapter.getHostName()); hostNames, m_ComAdapter.getHostName());
if (HostName != null) { if (hostName != null) {
selectHost(HostName); selectHost(hostName);
} }
} }
} }
@ -1048,13 +1056,20 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
private void showAboutDialog() { private void showAboutDialog() {
JOptionPane.showMessageDialog(evaFrame, StringBuilder aboutMessage = new StringBuilder();
EvAInfo.productName + " - " + EvAInfo.productLongName aboutMessage.append(EvAInfo.productName);
+ "\nUniversity of Tuebingen, T\u00FCbingen, Germany\nChair for Cognitive Systems\n" aboutMessage.append(" - ");
+ "Dr. M. Kronfeld, H. Planatscher, M. de Paly, Dr. A. Dr\u00E4ger,\n" aboutMessage.append(EvAInfo.productLongName);
+ "Dr. F. Streichert, Dr. H. Ulmer, and Prof. Dr. A. Zell \nCoypright \u00A9 " aboutMessage.append("\nUniversity of T\u00FCbingen, T\u00FCbingen, Germany\nChair for Cognitive Systems\n");
+ EvAInfo.copyrightYear + "\nVersion " + EvAInfo.getVersion() aboutMessage.append("Dr. M. Kronfeld, H. Planatscher, M. de Paly, Dr. A. Dr\u00E4ger,\n");
+ "\nSee: " + EvAInfo.url, EvAInfo.infoTitle, 1); aboutMessage.append("Dr. F. Streichert, Dr. H. Ulmer and Prof. Dr. A. Zell \nCoypright \u00A9 ");
aboutMessage.append(EvAInfo.copyrightYear);
aboutMessage.append("\nVersion ");
aboutMessage.append(EvAInfo.getVersion());
aboutMessage.append("\nSee: ");
aboutMessage.append(EvAInfo.url);
JOptionPane.showMessageDialog(evaFrame, aboutMessage, EvAInfo.infoTitle, 1);
} }
private void showLicense() { private void showLicense() {
@ -1152,29 +1167,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
} }
final class SplashScreenShell { final class SplashScreen extends Frame {
SplashScreen splScr = null;
String imgLoc = null;
public SplashScreenShell(String imageLoc) {
imgLoc = imageLoc;
}
public void splash() {
splScr = new SplashScreen(imgLoc);
splScr.splash();
}
public void dispose() {
if (splScr != null) {
splScr.dispose();
splScr = null;
}
}
}
class SplashScreen extends Frame {
private static final long serialVersionUID = 1281793825850423095L; private static final long serialVersionUID = 1281793825850423095L;
String imgLocation; String imgLocation;