fixes #9 GOE does now log all messages using internal logging. EvAClient log handler has been fixed.
This commit is contained in:
parent
7f373e99ca
commit
c62db5f36f
@ -15,6 +15,7 @@ import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Event;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
@ -24,12 +25,19 @@ import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.util.logging.*;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
@ -88,37 +96,40 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
private final int maxWindowMenuLength = 30;
|
||||
private boolean clientInited = false;
|
||||
private JEFrame evaFrame;
|
||||
private Runnable initRnbl = null;
|
||||
private EvAComAdapter m_ComAdapter;
|
||||
private transient JMenuBar m_barMenu;
|
||||
private transient JExtMenu m_mnuAbout;
|
||||
private transient JExtMenu m_mnuSelHosts;
|
||||
private transient JExtMenu m_mnuModule;
|
||||
private transient JExtMenu m_mnuWindow;
|
||||
private transient JExtMenu m_mnuOptions;
|
||||
private transient JProgressBar m_ProgressBar;
|
||||
private Runnable initRnbl = null;
|
||||
|
||||
private EvAComAdapter comAdapter;
|
||||
private transient JMenuBar menuBar;
|
||||
private transient JExtMenu menuAbout;
|
||||
private transient JExtMenu menuSelHosts;
|
||||
private transient JExtMenu menuModule;
|
||||
private transient JExtMenu menuWindow;
|
||||
private transient JExtMenu menuOptions;
|
||||
private transient JProgressBar progressBar;
|
||||
|
||||
// LogPanel
|
||||
private LogPanel logPanel;
|
||||
private static final Logger logger = Logger.getLogger("EvAClient");
|
||||
private static final Logger logger = Logger.getLogger(EvAInfo.defaultLogger);
|
||||
|
||||
// Module:
|
||||
private ExtAction m_actModuleLoad;
|
||||
// GUI:
|
||||
private ExtAction actModuleLoad;
|
||||
|
||||
// Hosts:
|
||||
private ExtAction m_actHost;
|
||||
private ExtAction m_actAvailableHost;
|
||||
private ExtAction m_actKillHost;
|
||||
private ExtAction m_actKillAllHosts;
|
||||
|
||||
private ExtAction actHost;
|
||||
private ExtAction actAvailableHost;
|
||||
private ExtAction actKillHost;
|
||||
private ExtAction actKillAllHosts;
|
||||
private ModuleAdapter currentModuleAdapter = null;
|
||||
// About:
|
||||
private ExtAction m_actAbout;
|
||||
private ExtAction m_actLicense;
|
||||
// private JPanel m_panelTool;
|
||||
// private FrameCloseListener m_frameCloseListener;
|
||||
// private JFileChooser m_FileChooser;
|
||||
// if not null, the module is loaded automatically and no other can be selected
|
||||
private String useDefaultModule = null;//"Genetic_Optimization";
|
||||
private ExtAction actAbout;
|
||||
private ExtAction actLicense;
|
||||
|
||||
// if not null, the module is loaded automatically and no other can be selected
|
||||
private String useDefaultModule = null; //"Genetic_Optimization";
|
||||
private boolean showLoadModules = false;
|
||||
private boolean localMode = false;
|
||||
|
||||
// This variable says whether, if running locally, a local server should be addressed by RMI.
|
||||
// False should be preferred here to avoid overhead
|
||||
private boolean useLocalRMI = false;
|
||||
@ -273,7 +284,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
currentModule = null;
|
||||
|
||||
m_ComAdapter = EvAComAdapter.getInstance();
|
||||
comAdapter = EvAComAdapter.getInstance();
|
||||
|
||||
SwingUtilities.invokeLater(initRnbl = new Runnable() {
|
||||
|
||||
@ -426,7 +437,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
sBuilder.append("[");
|
||||
sBuilder.append(record.getLevel().toString());
|
||||
sBuilder.append("] ");
|
||||
sBuilder.append(record.getMessage());
|
||||
MessageFormat messageFormat = new MessageFormat(record.getMessage());
|
||||
sBuilder.append(messageFormat.format(record.getParameters()));
|
||||
// Show message on LogPanel
|
||||
EvAClient.this.logPanel.logMessage(sBuilder.toString());
|
||||
}
|
||||
@ -443,8 +455,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
});
|
||||
|
||||
m_ProgressBar = new JProgressBar();
|
||||
evaFrame.getContentPane().add(m_ProgressBar, BorderLayout.SOUTH);
|
||||
progressBar = new JProgressBar();
|
||||
evaFrame.getContentPane().add(progressBar, BorderLayout.SOUTH);
|
||||
|
||||
if (EvAInfo.propShowModules() != null) {
|
||||
showLoadModules = true;
|
||||
@ -481,12 +493,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
});
|
||||
}
|
||||
|
||||
if (m_ComAdapter != null) {
|
||||
if (comAdapter != null) {
|
||||
if (hostName != null) {
|
||||
selectHost(hostName);
|
||||
}
|
||||
m_ComAdapter.setLogPanel(logPanel);
|
||||
logger.log(Level.INFO, "Selected Host: {0}", m_ComAdapter.getHostName());
|
||||
comAdapter.setLogPanel(logPanel);
|
||||
logger.log(Level.INFO, "Selected Host: {0}", comAdapter.getHostName());
|
||||
}
|
||||
// m_mnuModule.setText("Select module");
|
||||
// m_mnuModule.repaint();
|
||||
@ -621,7 +633,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Module:
|
||||
/////////////////////////////////////////////////////////////
|
||||
m_actModuleLoad = new ExtAction("&Load", "Load Module",
|
||||
actModuleLoad = new ExtAction("&Load", "Load Module",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -632,7 +644,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
};
|
||||
|
||||
m_actAbout = new ExtAction("&About...", "Product Information",
|
||||
actAbout = new ExtAction("&About...", "Product Information",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -643,7 +655,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
showAboutDialog();
|
||||
}
|
||||
};
|
||||
m_actLicense = new ExtAction("&License...", "View License",
|
||||
actLicense = new ExtAction("&License...", "View License",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -654,7 +666,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
showLicense();
|
||||
}
|
||||
};
|
||||
m_actHost = new ExtAction("&List of all servers", "All servers in list",
|
||||
actHost = new ExtAction("&List of all servers", "All servers in list",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -662,10 +674,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
logger.info(e.getActionCommand());
|
||||
selectAvailableHost(m_ComAdapter.getHostNameList());
|
||||
selectAvailableHost(comAdapter.getHostNameList());
|
||||
}
|
||||
};
|
||||
m_actAvailableHost = new ExtAction("Available &Server", "Available server",
|
||||
actAvailableHost = new ExtAction("Available &Server", "Available server",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -678,13 +690,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
selectAvailableHost(m_ComAdapter.getAvailableHostNameList());
|
||||
selectAvailableHost(comAdapter.getAvailableHostNameList());
|
||||
}
|
||||
};
|
||||
xx.start();
|
||||
}
|
||||
};
|
||||
m_actKillHost = new ExtAction("&Kill server", "Kill server process on selected host",
|
||||
actKillHost = new ExtAction("&Kill server", "Kill server process on selected host",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -696,13 +708,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
Thread xx = new Thread() {
|
||||
|
||||
public void run() {
|
||||
selectAvailableHostToKill(m_ComAdapter.getAvailableHostNameList());
|
||||
selectAvailableHostToKill(comAdapter.getAvailableHostNameList());
|
||||
}
|
||||
};
|
||||
xx.start();
|
||||
}
|
||||
};
|
||||
m_actKillAllHosts = new ExtAction("Kill &all servers", "Kill all servers",
|
||||
actKillAllHosts = new ExtAction("Kill &all servers", "Kill all servers",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -714,7 +726,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
Thread xx = new Thread() {
|
||||
|
||||
public void run() {
|
||||
selectAllAvailableHostToKill(m_ComAdapter.getAvailableHostNameList());
|
||||
selectAllAvailableHostToKill(comAdapter.getAvailableHostNameList());
|
||||
}
|
||||
};
|
||||
xx.start();
|
||||
@ -730,20 +742,20 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
private void buildMenu() {
|
||||
m_barMenu = new JMenuBar();
|
||||
evaFrame.setJMenuBar(m_barMenu);
|
||||
m_mnuModule = new JExtMenu("&Module");
|
||||
m_mnuModule.add(m_actModuleLoad);
|
||||
menuBar = new JMenuBar();
|
||||
evaFrame.setJMenuBar(menuBar);
|
||||
menuModule = new JExtMenu("&Module");
|
||||
menuModule.add(actModuleLoad);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
m_mnuWindow = new JExtMenu("&Window");
|
||||
m_mnuWindow.addMenuListener(new MenuListener() {
|
||||
menuWindow = new JExtMenu("&Window");
|
||||
menuWindow.addMenuListener(new MenuListener() {
|
||||
|
||||
public void menuSelected(MenuEvent e) {
|
||||
// System.out.println("Selected");
|
||||
m_mnuWindow.removeAll();
|
||||
JExtMenu curMenu = m_mnuWindow;
|
||||
menuWindow.removeAll();
|
||||
JExtMenu curMenu = menuWindow;
|
||||
// JScrollPane jsp = new JScrollPane();
|
||||
Object[] framelist = JEFrameRegister.getFrameList();
|
||||
for (int i = 0; i < framelist.length; i++) {
|
||||
@ -772,7 +784,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
String[] commonPrefixes = JEFrameRegister.getCommonPrefixes(10);
|
||||
if (commonPrefixes.length > 0) {
|
||||
m_mnuWindow.add(new JSeparator());
|
||||
menuWindow.add(new JSeparator());
|
||||
}
|
||||
for (int i = 0; i < commonPrefixes.length; i++) {
|
||||
final String prefix = commonPrefixes[i];
|
||||
@ -783,7 +795,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
JEFrameRegister.closeAllByPrefix(prefix);
|
||||
}
|
||||
}));
|
||||
m_mnuWindow.add(act);
|
||||
menuWindow.add(act);
|
||||
}
|
||||
|
||||
}
|
||||
@ -796,33 +808,33 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
m_mnuSelHosts = new JExtMenu("&Select Hosts");
|
||||
m_mnuSelHosts.setToolTipText("Select a host for the server application");
|
||||
menuSelHosts = new JExtMenu("&Select Hosts");
|
||||
menuSelHosts.setToolTipText("Select a host for the server application");
|
||||
//if (EvAClient.LITE_VERSION == false)
|
||||
m_mnuSelHosts.add(m_actHost);
|
||||
m_mnuSelHosts.add(m_actAvailableHost);
|
||||
m_mnuSelHosts.addSeparator();
|
||||
m_mnuSelHosts.add(m_actKillHost);
|
||||
m_mnuSelHosts.add(m_actKillAllHosts);
|
||||
menuSelHosts.add(actHost);
|
||||
menuSelHosts.add(actAvailableHost);
|
||||
menuSelHosts.addSeparator();
|
||||
menuSelHosts.add(actKillHost);
|
||||
menuSelHosts.add(actKillAllHosts);
|
||||
// m_mnuOptions.add(m_actStartServerManager);
|
||||
////////////////////////////////////////////////////////////////
|
||||
m_mnuAbout = new JExtMenu("&About");
|
||||
m_mnuAbout.add(m_actAbout);
|
||||
m_mnuAbout.add(m_actLicense);
|
||||
menuAbout = new JExtMenu("&About");
|
||||
menuAbout.add(actAbout);
|
||||
menuAbout.add(actLicense);
|
||||
//////////////////////////////////////////////////////////////
|
||||
// m_barMenu.add(m_Desktop.getWindowMenu());
|
||||
|
||||
m_mnuOptions = new JExtMenu("&Options");
|
||||
m_mnuOptions.add(m_mnuSelHosts);
|
||||
menuOptions = new JExtMenu("&Options");
|
||||
menuOptions.add(menuSelHosts);
|
||||
//m_barMenu.add(m_mnuSelHosts);
|
||||
// this is accessible if no default module is given
|
||||
if (showLoadModules) {
|
||||
m_barMenu.add(m_mnuModule);
|
||||
menuBar.add(menuModule);
|
||||
}
|
||||
|
||||
m_barMenu.add(m_mnuOptions);
|
||||
m_barMenu.add(m_mnuWindow);
|
||||
m_barMenu.add(m_mnuAbout);
|
||||
menuBar.add(menuOptions);
|
||||
menuBar.add(menuWindow);
|
||||
menuBar.add(menuAbout);
|
||||
|
||||
}
|
||||
|
||||
@ -840,37 +852,37 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
*
|
||||
*/
|
||||
private void loadModuleFromServer(String selectedModule, InterfaceGOParameters goParams) {
|
||||
if (m_ComAdapter.getHostName() == null) {
|
||||
if (comAdapter.getHostName() == null) {
|
||||
System.err.println("error in loadModuleFromServer!");
|
||||
return;
|
||||
}
|
||||
if (m_ComAdapter.getHostName().equals("localhost")) {
|
||||
if (comAdapter.getHostName().equals("localhost")) {
|
||||
localMode = true;
|
||||
if (useLocalRMI) {
|
||||
EvAServer Server = new EvAServer(true, false);
|
||||
m_ComAdapter.setLocalRMIServer(Server.getRMIServer());
|
||||
comAdapter.setLocalRMIServer(Server.getRMIServer());
|
||||
logger.info("Local EvAServer started");
|
||||
m_ComAdapter.setRunLocally(false); // this is not quite true but should have the desired effect
|
||||
comAdapter.setRunLocally(false); // this is not quite true but should have the desired effect
|
||||
} else {
|
||||
logger.info("Working locally");
|
||||
m_ComAdapter.setLocalRMIServer(null);
|
||||
m_ComAdapter.setRunLocally(true);
|
||||
comAdapter.setLocalRMIServer(null);
|
||||
comAdapter.setRunLocally(true);
|
||||
}
|
||||
} else {
|
||||
localMode = false;
|
||||
m_ComAdapter.setRunLocally(false);
|
||||
comAdapter.setRunLocally(false);
|
||||
}
|
||||
if (selectedModule == null) { // show a dialog and ask for a module
|
||||
String[] ModuleNameList = m_ComAdapter.getModuleNameList();
|
||||
String[] ModuleNameList = comAdapter.getModuleNameList();
|
||||
if (ModuleNameList == null) {
|
||||
JOptionPane.showMessageDialog(evaFrame.getContentPane(), "No modules available on " + m_ComAdapter.getHostName(), EvAInfo.infoTitle, 1);
|
||||
JOptionPane.showMessageDialog(evaFrame.getContentPane(), "No modules available on " + comAdapter.getHostName(), EvAInfo.infoTitle, 1);
|
||||
} else {
|
||||
String LastModuleName = Serializer.loadString("lastmodule.ser");
|
||||
if (LastModuleName == null) {
|
||||
LastModuleName = ModuleNameList[0];
|
||||
}
|
||||
selectedModule = (String) JOptionPane.showInputDialog(evaFrame.getContentPane(),
|
||||
"Which module do you want \n to load on host: " + m_ComAdapter.getHostName() + " ?", "Load optimization module on host",
|
||||
"Which module do you want \n to load on host: " + comAdapter.getHostName() + " ?", "Load optimization module on host",
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
ModuleNameList,
|
||||
@ -885,8 +897,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
loadSpecificModule(selectedModule, goParams);
|
||||
|
||||
if (withGUI) {
|
||||
m_actHost.setEnabled(true);
|
||||
m_actAvailableHost.setEnabled(true);
|
||||
actHost.setEnabled(true);
|
||||
actAvailableHost.setEnabled(true);
|
||||
}
|
||||
logger.info("Selected Module: " + selectedModule);
|
||||
// m_LogPanel.statusMessage("Selected Module: " + selectedModule);
|
||||
@ -933,7 +945,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
ModuleAdapter newModuleAdapter = null;
|
||||
//
|
||||
try {
|
||||
newModuleAdapter = m_ComAdapter.getModuleAdapter(selectedModule, goParams, withGUI ? null : "EvA2");
|
||||
newModuleAdapter = comAdapter.getModuleAdapter(selectedModule, goParams, withGUI ? null : "EvA2");
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, "Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage(), e);
|
||||
EVAERROR.EXIT("Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage());
|
||||
@ -953,14 +965,14 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
System.err.println("adding base dir and trying again...");
|
||||
System.setProperty("java.class.path", cp + System.getProperty("path.separator") + dir);
|
||||
ReflectPackage.resetDynCP();
|
||||
m_ComAdapter.updateLocalMainAdapter();
|
||||
comAdapter.updateLocalMainAdapter();
|
||||
loadSpecificModule(selectedModule, goParams); // end recursive call! handle with care!
|
||||
return;
|
||||
}
|
||||
showLoadModules = true;
|
||||
} else {
|
||||
newModuleAdapter.setConnection(!localMode);
|
||||
if (m_ComAdapter.isRunLocally()) {
|
||||
if (comAdapter.isRunLocally()) {
|
||||
// TODO in rmi-mode this doesnt work yet! meaning e.g. that theres no content in the info log
|
||||
newModuleAdapter.addRemoteStateListener((RemoteStateListener) this);
|
||||
}
|
||||
@ -978,7 +990,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
// nested info-panel so that we can stay with simple borderlayouts
|
||||
JPanel infoPanel = new JPanel();
|
||||
infoPanel.setLayout(new BorderLayout());
|
||||
infoPanel.add(m_ProgressBar, BorderLayout.SOUTH);
|
||||
infoPanel.add(progressBar, BorderLayout.SOUTH);
|
||||
infoPanel.add(logPanel, BorderLayout.NORTH);
|
||||
JComponent tree = null;
|
||||
|
||||
@ -1048,7 +1060,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
} else {
|
||||
String hostName = (String) JOptionPane.showInputDialog(evaFrame.getContentPane(),
|
||||
"Which active host do you want to connect to?", "Host", JOptionPane.QUESTION_MESSAGE, null,
|
||||
hostNames, m_ComAdapter.getHostName());
|
||||
hostNames, comAdapter.getHostName());
|
||||
if (hostName != null) {
|
||||
selectHost(hostName);
|
||||
}
|
||||
@ -1056,7 +1068,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
private void selectHost(String hostName) {
|
||||
m_ComAdapter.setHostName(hostName);
|
||||
comAdapter.setHostName(hostName);
|
||||
logger.info("Selected Host: " + hostName);
|
||||
if (currentModule != null) {
|
||||
logger.info("Reloading module from server...");
|
||||
@ -1103,12 +1115,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
String HostName = (String) JOptionPane.showInputDialog(evaFrame.getContentPane(),
|
||||
"Which server do you want to be killed ?", "Host", JOptionPane.QUESTION_MESSAGE, null,
|
||||
HostNames, m_ComAdapter.getHostName());
|
||||
HostNames, comAdapter.getHostName());
|
||||
if (HostName == null) {
|
||||
return;
|
||||
}
|
||||
logger.info("Kill host process on = " + HostName);
|
||||
m_ComAdapter.killServer(HostName);
|
||||
comAdapter.killServer(HostName);
|
||||
// m_LogPanel.statusMessage("");
|
||||
}
|
||||
|
||||
@ -1118,7 +1130,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
System.out.println("no host is running");
|
||||
return;
|
||||
}
|
||||
m_ComAdapter.killAllServers();
|
||||
comAdapter.killAllServers();
|
||||
}
|
||||
|
||||
public void performedRestart(String infoString) {
|
||||
@ -1168,11 +1180,11 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
if (msg != null) {
|
||||
logger.info(msg);
|
||||
}
|
||||
if (this.m_ProgressBar != null) {
|
||||
if (this.progressBar != null) {
|
||||
Runnable doSetProgressBarValue = new Runnable() {
|
||||
|
||||
public void run() {
|
||||
m_ProgressBar.setValue(percent);
|
||||
progressBar.setValue(percent);
|
||||
}
|
||||
};
|
||||
SwingUtilities.invokeLater(doSetProgressBarValue);
|
||||
@ -1202,12 +1214,13 @@ final class SplashScreen extends Frame {
|
||||
JWindow splashWindow = new JWindow(this);
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true);
|
||||
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
|
||||
JLabel splashLabel = new JLabel(ii);
|
||||
|
||||
splashWindow.add(splashLabel);
|
||||
splashWindow.pack();
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
splashWindow.setLocation(screenSize.width / 2 - splashWindow.getSize().width / 2, screenSize.height / 2 - splashWindow.getSize().height / 2);
|
||||
splashWindow.setVisible(true);
|
||||
splashWindow.setVisible(true);
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@ package eva2.gui;
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Copyright: Copyright (c) 2012
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher, Fabian Becker
|
||||
* @version: $Revision: 266 $
|
||||
* $Date: 2007-11-20 14:33:48 +0100 (Tue, 20 Nov 2007) $
|
||||
* $Author: mkron $
|
||||
@ -29,32 +29,30 @@ import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import eva2.EvAInfo;
|
||||
import eva2.client.EvAClient;
|
||||
import eva2.tools.ReflectPackage;
|
||||
import eva2.tools.jproxy.RMIProxyLocal;
|
||||
|
||||
|
||||
|
||||
/*==========================================================================*
|
||||
* CLASS DECLARATION
|
||||
*==========================================================================*/
|
||||
public class GenericObjectEditor implements PropertyEditor {
|
||||
static final public boolean TRACE = false;
|
||||
private static final Logger logger = Logger.getLogger(EvAInfo.defaultLogger);
|
||||
|
||||
private Object m_Object;
|
||||
private Object m_Backup;
|
||||
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
|
||||
private Class<?> m_ClassType;
|
||||
private GOEPanel m_EditorComponent;
|
||||
private boolean m_Enabled = true;
|
||||
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
private Class<?> classType;
|
||||
private GOEPanel editorComponent;
|
||||
private boolean isEnabled = true;
|
||||
|
||||
/**
|
||||
* Read the classes available for user selection from the properties or the classpath respectively
|
||||
*/
|
||||
public static ArrayList<String> getClassesFromProperties(String className, ArrayList<Class<?>> instances) {
|
||||
if (TRACE) System.out.println("getClassesFromProperties - requesting className: "+className);
|
||||
logger.log(Level.FINEST, "Requesting className: {0}", className);
|
||||
|
||||
// Try to read the predefined classes from the props file.
|
||||
String typeOptions = EvAInfo.getProperty(className);
|
||||
@ -66,15 +64,15 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
ArrayList<String> classes = new ArrayList<String>();
|
||||
while (st.hasMoreTokens()) {
|
||||
String current = st.nextToken().trim();
|
||||
//System.out.println("current ="+current);
|
||||
try {
|
||||
Class<?> clz = Class.forName(current); // test for instantiability
|
||||
if (instances!=null) instances.add(clz);
|
||||
if (instances != null) {
|
||||
instances.add(clz);
|
||||
}
|
||||
classes.add(current);
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Couldn't load class with name: " + current);
|
||||
System.err.println("ex:"+ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.log(Level.WARNING,
|
||||
String.format("Requesting className: %1$s, Couldn't load: %2%s", className, current), ex);
|
||||
}
|
||||
}
|
||||
return classes;
|
||||
@ -93,37 +91,42 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
*/
|
||||
public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) {
|
||||
ArrayList<String> classes = new ArrayList<String>();
|
||||
Class<?>[] clsArr;
|
||||
clsArr=ReflectPackage.getAssignableClasses(className, true, true);
|
||||
if (clsArr == null) {
|
||||
System.err.println("Warning: No assignable classes found in property file or on classpath: "
|
||||
+EvAInfo.propertyFile + " for "+className);
|
||||
Class<?>[] classArray;
|
||||
classArray=ReflectPackage.getAssignableClasses(className, true, true);
|
||||
if (classArray == null) {
|
||||
logger.log(Level.WARNING, String.format("No assignable classes found in property file or on classpath: %1$s for %2$s", EvAInfo.propertyFile, className));
|
||||
classes.add(className);
|
||||
} else {
|
||||
for (Class<?> class1 : clsArr) {
|
||||
int m = class1.getModifiers();
|
||||
for (Class<?> clazz : classArray) {
|
||||
int m = clazz.getModifiers();
|
||||
try {
|
||||
// a field allowing a class to indicate it doesnt want to be displayed
|
||||
Field f = class1.getDeclaredField("hideFromGOE");
|
||||
if (f.getBoolean(class1) == true) {
|
||||
if (TRACE) System.out.println("Class " + class1 + " wants to be hidden from GOE, skipping...");
|
||||
Field f = clazz.getDeclaredField("hideFromGOE");
|
||||
if (f.getBoolean(clazz) == true) {
|
||||
logger.log(Level.FINEST, "Class {0} wants to be hidden from GOE.", clazz);
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
} catch (Error e) {
|
||||
System.err.println("Error on checking fields of " + class1 + ": " + e);
|
||||
continue;
|
||||
} catch (NoSuchFieldException e) {
|
||||
/*
|
||||
* We are just logging this exception here. It is expected that
|
||||
* most classes do not have this field.
|
||||
*/
|
||||
logger.log(Level.FINER, String.format("%1$s does not have a hideFromGOE field", clazz.toString()), e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.log(Level.FINER, e.getMessage(), e);
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.log(Level.FINER, e.getMessage(), e);
|
||||
}
|
||||
// if (f)
|
||||
if (!Modifier.isAbstract(m) && !class1.isInterface()) { // dont take abstract classes or interfaces
|
||||
|
||||
|
||||
if (!Modifier.isAbstract(m) && !clazz.isInterface()) { // dont take abstract classes or interfaces
|
||||
try {
|
||||
Class<?>[] params = new Class[0];
|
||||
class1.getConstructor(params);
|
||||
if (instances!=null) instances.add(class1);
|
||||
classes.add(class1.getName());
|
||||
clazz.getConstructor(params);
|
||||
if (instances!=null) instances.add(clazz);
|
||||
classes.add(clazz.getName());
|
||||
} catch (NoSuchMethodException e) {
|
||||
System.err.println("GOE warning: Class " + class1.getName() + " has no default constructor, skipping...");
|
||||
logger.log(Level.WARNING, String.format("GOE warning: Class %1$s has no default constructor", clazz.getName()), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -155,7 +158,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
System.err.println("exception in setHideProperty for " + cls.getName() + "/" + property + " : " + e.getMessage());
|
||||
logger.log(Level.WARNING, String.format("Couldn't set expert property for %1$s/%2$s", cls.getName(), property), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -175,7 +178,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
*/
|
||||
public static boolean setHideProperty(Class<?> cls, String property, boolean hide) {
|
||||
try {
|
||||
BeanInfo bi = Introspector.getBeanInfo(cls);
|
||||
BeanInfo bi = Introspector.getBeanInfo(cls);
|
||||
PropertyDescriptor[] props = bi.getPropertyDescriptors();
|
||||
for (int i=0; i<props.length; i++) {
|
||||
if ((props[i].getName().equals(property))) {
|
||||
@ -185,10 +188,11 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
System.err.println("Error: property " + property + " not found!");
|
||||
|
||||
logger.log(Level.WARNING, "Property {0} not found", property);
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
System.err.println("exception in setHideProperty for " + cls.getName() + "/" + property + " : " + e.getMessage());
|
||||
} catch (IntrospectionException e) {
|
||||
logger.log(Level.WARNING, String.format("Couldn't set hide property for %1$s/%2$s", cls.getName(), property), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -211,8 +215,8 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
props[i].setHidden(hide);
|
||||
}
|
||||
return orig;
|
||||
} catch (Exception e) {
|
||||
System.err.println("exception in setHideProperty for " + cls.getName() + "/all : " + e.getMessage());
|
||||
} catch (IntrospectionException e) {
|
||||
logger.log(Level.WARNING, String.format("Couldn't hide all properties for %1$s/all", cls.getName()), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -223,8 +227,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
try {
|
||||
bi = Introspector.getBeanInfo(cls);
|
||||
} catch (IntrospectionException e) {
|
||||
System.err.println("Error on introspection of " + cls.getName() + ", " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
logger.log(Level.WARNING, String.format("Error on introspection of %1$s", cls.getName()), e);
|
||||
return;
|
||||
}
|
||||
PropertyDescriptor[] props = bi.getPropertyDescriptors();
|
||||
@ -257,8 +260,8 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* @param newVal a value of type 'boolean'
|
||||
*/
|
||||
public void setEnabled(boolean newVal) {
|
||||
if (newVal != m_Enabled) {
|
||||
m_Enabled = newVal;
|
||||
if (newVal != isEnabled) {
|
||||
isEnabled = newVal;
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,15 +271,15 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* @param type a value of type 'Class'
|
||||
*/
|
||||
public void setClassType(Class<?> type) {
|
||||
if (TRACE) System.out.println("GOE setClassType("+ (type == null? "<null>" : type.getName()) + ")");
|
||||
m_ClassType = type;
|
||||
if (m_EditorComponent != null)
|
||||
m_EditorComponent.updateClassType();
|
||||
//if (TRACE) System.out.println("GOE setClassType("+ (type == null? "<null>" : type.getName()) + ")");
|
||||
classType = type;
|
||||
if (editorComponent != null)
|
||||
editorComponent.updateClassType();
|
||||
|
||||
}
|
||||
|
||||
public Class<?> getClassType() {
|
||||
return m_ClassType;
|
||||
return classType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,17 +287,17 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* the chooser
|
||||
*/
|
||||
public void setDefaultValue() {
|
||||
if (m_ClassType == null) {
|
||||
System.err.println("No ClassType set up for GenericObjectEditor!!");
|
||||
if (classType == null) {
|
||||
logger.log(Level.WARNING, "No ClassType set up for GenericObjectEditor!");
|
||||
return;
|
||||
}
|
||||
|
||||
Vector<String> v=null;
|
||||
if (Proxy.isProxyClass(m_ClassType)) {
|
||||
if (TRACE) System.out.println("PROXY! original was " + ((RMIProxyLocal)Proxy.getInvocationHandler(((Proxy)m_Object))).getOriginalClass().getName());
|
||||
if (Proxy.isProxyClass(classType)) {
|
||||
//if (TRACE) System.out.println("PROXY! original was " + ((RMIProxyLocal)Proxy.getInvocationHandler(((Proxy)m_Object))).getOriginalClass().getName());
|
||||
v = new Vector<String>(getClassesFromProperties(((RMIProxyLocal)Proxy.getInvocationHandler(((Proxy)m_Object))).getOriginalClass().getName(), null));
|
||||
} else {
|
||||
v = new Vector<String>(getClassesFromProperties(m_ClassType.getName(), null));
|
||||
v = new Vector<String>(getClassesFromProperties(classType.getName(), null));
|
||||
}
|
||||
|
||||
// v = new Vector<String>(getClassesFromProperties(m_ClassType.getName()));
|
||||
@ -316,25 +319,25 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
public void setValue(Object o) {
|
||||
//System.err.println("setValue()" + m_ClassType.toString());
|
||||
|
||||
if (o==null || m_ClassType == null) {
|
||||
System.err.println("No ClassType set up for GenericObjectEditor!!");
|
||||
if (o==null || classType == null) {
|
||||
logger.log(Level.WARNING, "No ClassType set up for GenericObjectEditor!");
|
||||
return;
|
||||
}
|
||||
if (!m_ClassType.isAssignableFrom(o.getClass())) {
|
||||
if (m_ClassType.isPrimitive()) {
|
||||
System.err.println("setValue object not of correct type! Expected "+m_ClassType.getName()+", got " + o.getClass().getName());
|
||||
if (!classType.isAssignableFrom(o.getClass())) {
|
||||
if (classType.isPrimitive()) {
|
||||
System.err.println("setValue object not of correct type! Expected "+classType.getName()+", got " + o.getClass().getName());
|
||||
System.err.println("setting primitive type");
|
||||
setObject((Object)o);
|
||||
//throw new NullPointerException("ASDF");
|
||||
} else {
|
||||
System.err.println("setValue object not of correct type! Expected "+m_ClassType.getName()+", got " + o.getClass().getName());
|
||||
System.err.println("setValue object not of correct type! Expected "+classType.getName()+", got " + o.getClass().getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
setObject((Object)o);
|
||||
if (m_EditorComponent != null)
|
||||
m_EditorComponent.updateChooser();
|
||||
if (editorComponent != null)
|
||||
editorComponent.updateChooser();
|
||||
|
||||
}
|
||||
|
||||
@ -346,16 +349,16 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
*/
|
||||
private void setObject(Object c) {
|
||||
// This should really call equals() for comparison.
|
||||
if (TRACE) System.out.println("setObject "+ c.getClass().getName() + " " + c);
|
||||
//if (TRACE) System.out.println("setObject "+ c.getClass().getName() + " " + c);
|
||||
boolean trueChange = (c != getValue());
|
||||
|
||||
m_Backup = m_Object;
|
||||
m_Object = c;
|
||||
|
||||
if (m_EditorComponent != null) {
|
||||
m_EditorComponent.updateChildPropertySheet();
|
||||
if (editorComponent != null) {
|
||||
editorComponent.updateChildPropertySheet();
|
||||
if (trueChange)
|
||||
m_Support.firePropertyChange("", m_Backup, m_Object);
|
||||
propertyChangeSupport.firePropertyChange("", m_Backup, m_Object);
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,7 +400,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* @param box the area we are allowed to paint into
|
||||
*/
|
||||
public void paintValue(Graphics gfx,Rectangle box) {
|
||||
if (m_Enabled && m_Object != null) {
|
||||
if (isEnabled && m_Object != null) {
|
||||
int getNameMethod = -1;
|
||||
MethodDescriptor[] methods;
|
||||
String rep = "";
|
||||
@ -478,50 +481,29 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
* @return a value of type 'java.awt.Component'
|
||||
*/
|
||||
public Component getCustomEditor() {
|
||||
if (m_EditorComponent == null)
|
||||
m_EditorComponent = new GOEPanel(m_Object, m_Backup, m_Support, this);
|
||||
return m_EditorComponent;
|
||||
if (editorComponent == null)
|
||||
editorComponent = new GOEPanel(m_Object, m_Backup, propertyChangeSupport, this);
|
||||
return editorComponent;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void disableOKCancel() {
|
||||
if (m_EditorComponent == null)
|
||||
m_EditorComponent = new GOEPanel(m_Object, m_Backup, m_Support, this);
|
||||
m_EditorComponent.setEnabledOkCancelButtons(false);
|
||||
if (editorComponent == null)
|
||||
editorComponent = new GOEPanel(m_Object, m_Backup,
|
||||
propertyChangeSupport, this);
|
||||
editorComponent.setEnabledOkCancelButtons(false);
|
||||
}
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
m_Support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (m_Support == null) m_Support = new PropertyChangeSupport(this);
|
||||
m_Support.removePropertyChangeListener(l);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// public static void main(String [] args) {
|
||||
// try {
|
||||
// PropertyEditorManager.registerEditor(SelectedTag.class,TagEditor.class);
|
||||
// PropertyEditorManager.registerEditor(double[].class,GenericArrayEditor.class);
|
||||
// GenericObjectEditor editor = new GenericObjectEditor();
|
||||
// editor.setClassType(StatisticsParameter.class);
|
||||
// editor.setValue(new StatisticsParameterImpl());
|
||||
// PropertyDialog pd = new PropertyDialog(editor,EVAHELP.cutClassName(editor.getClass().getName()),110, 120);
|
||||
// pd.addWindowListener(new WindowAdapter() {
|
||||
// public void windowClosing(WindowEvent e) {
|
||||
// PropertyEditor pe = ((PropertyDialog)e.getSource()).getEditor();
|
||||
// Object c = (Object)pe.getValue();
|
||||
// String options = "";
|
||||
// if (TRACE) System.out.println(c.getClass().getName() + " " + options);
|
||||
// System.exit(0);
|
||||
// }
|
||||
// });
|
||||
// } catch (Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// System.out.println(ex.getMessage());
|
||||
// }
|
||||
// }
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (propertyChangeSupport == null)
|
||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
propertyChangeSupport.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
if (propertyChangeSupport == null)
|
||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
propertyChangeSupport.removePropertyChangeListener(l);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user