Major update! Some related projects might be broken from now on - if so, let me know via email.

This is the first of a series of commits to manifest the new graphical user interface of EvA2.

This commit includes (incomplete list)

- New Icons that are used in the GUI
- A completely refactored GUI with a one-window layout.
- Plots/Text Output will now appear on a JDesktopPane
- Configuration can be done via the sidebar (not yet completely functional)
- New layouts for TabbedPane (currently not active) and JButton (vertical text)
- Code cleanup / removal of TRACE variable
- More classes are now using the Logging facility.

refs #8, #10, #14
fixes #12
This commit is contained in:
Fabian Becker 2012-05-14 13:57:39 +00:00
parent d4c8b802bd
commit d2059a5852
72 changed files with 5330 additions and 4519 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 KiB

BIN
resources/images/Help24.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
resources/images/Open16.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

BIN
resources/images/Save16.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

View File

@ -95,7 +95,7 @@ public class EvAInfo {
public static final String GPLFile= "gpl-3.0.txt"; public static final String GPLFile= "gpl-3.0.txt";
public static final String iconLocation = "resources/images/icon4.gif"; public static final String iconLocation = "resources/images/icon4.gif";
public static final String splashLocation = "resources/images/splashScreen2.png"; public static final String splashLocation = "resources/images/EvASplashScreen.png";
public static final String infoTitle = productName+" Information"; public static final String infoTitle = productName+" Information";
public static final String copyrightYear = "2010-2012"; public static final String copyrightYear = "2010-2012";

View File

@ -15,6 +15,7 @@ import eva2.EvAInfo;
import eva2.gui.*; import eva2.gui.*;
import eva2.server.EvAServer; import eva2.server.EvAServer;
import eva2.server.go.InterfaceGOParameters; import eva2.server.go.InterfaceGOParameters;
import eva2.server.go.strategies.GradientDescentAlgorithm;
import eva2.server.modules.AbstractModuleAdapter; import eva2.server.modules.AbstractModuleAdapter;
import eva2.server.modules.GOParameters; import eva2.server.modules.GOParameters;
import eva2.server.modules.GenericModuleAdapter; import eva2.server.modules.GenericModuleAdapter;
@ -28,8 +29,9 @@ import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.io.*; import java.io.*;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.Vector;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.*; import javax.swing.*;
@ -50,7 +52,10 @@ 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; private boolean clientInited = false;
private JEFrame evaFrame; private JDesktopPane desktopPane;
private JFrame mainFrame;
private JPanel configurationPane;
private JSplitPane horizontalSplit;
private Runnable initRnbl = null; private Runnable initRnbl = null;
private EvAComAdapter comAdapter; private EvAComAdapter comAdapter;
@ -95,7 +100,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
private long startTime = 0; private long startTime = 0;
// remember the module in use // remember the module in use
private transient String currentModule = null; private transient String currentModule = null;
Vector<RemoteStateListener> superListenerList = null; private List<RemoteStateListener> superListenerList = null;
private boolean withGUI = true; private boolean withGUI = true;
private boolean withTreeView = false; private boolean withTreeView = false;
private EvATabbedFrameMaker frameMaker = null; private EvATabbedFrameMaker frameMaker = null;
@ -103,7 +108,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
public void addRemoteStateListener(RemoteStateListener l) { public void addRemoteStateListener(RemoteStateListener l) {
if (superListenerList == null) { if (superListenerList == null) {
superListenerList = new Vector<RemoteStateListener>(); superListenerList = new ArrayList<RemoteStateListener>();
} }
superListenerList.add(l); superListenerList.add(l);
} }
@ -332,8 +337,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
* @param l * @param l
*/ */
public void addWindowListener(WindowListener l) { public void addWindowListener(WindowListener l) {
if (evaFrame != null) { if (mainFrame != null) {
evaFrame.addWindowListener(l); mainFrame.addWindowListener(l);
} else { } else {
System.err.println("Error, no JFrame existent in " System.err.println("Error, no JFrame existent in "
+ this.getClass().getSimpleName()); + this.getClass().getSimpleName());
@ -346,8 +351,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
* @param l * @param l
*/ */
public void removeWindowListener(WindowListener l) { public void removeWindowListener(WindowListener l) {
if (evaFrame != null) { if (mainFrame != null) {
evaFrame.removeWindowListener(l); mainFrame.removeWindowListener(l);
} else { } else {
System.err.println("Error, no JFrame existent in " System.err.println("Error, no JFrame existent in "
+ this.getClass().getSimpleName()); + this.getClass().getSimpleName());
@ -370,13 +375,25 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
if (withGUI) { if (withGUI) {
evaFrame = new JEFrame(EvAInfo.productName + " workbench"); GridBagConstraints gbConstraints = new GridBagConstraints();
evaFrame.setCloseAllOnClosed(true);
evaFrame.setName(this.getClass().getSimpleName()); // the name is set to recognize the client window /* Set Look and Feel */
try {
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {
LOGGER.log(Level.INFO, "Could not set Look&Feel", ex);
}
mainFrame = new JFrame(EvAInfo.productName + " Workbench");
mainFrame.setLayout(new GridBagLayout());
mainFrame.setMinimumSize(new Dimension(800, 600));
desktopPane = new JExtDesktopPane();
JEFrameRegister.getInstance().setDesktopPane(desktopPane);
horizontalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
evaFrame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); mainFrame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
try { try {
Thread.sleep(200); Thread.sleep(200);
@ -384,15 +401,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
System.out.println("Error" + e.getMessage()); System.out.println("Error" + e.getMessage());
} }
progressBar = new JProgressBar();
progressBar.setBorder(new TitledBorder("Progress"));
progressBar.setValue(0);
progressBar.setStringPainted(true);
evaFrame.getContentPane().add(progressBar, BorderLayout.NORTH);
evaFrame.getContentPane().setLayout(new BorderLayout());
logPanel = new LoggingPanel(LOGGER); logPanel = new LoggingPanel(LOGGER);
evaFrame.getContentPane().add(logPanel, BorderLayout.SOUTH); logPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
if (EvAInfo.propShowModules() != null) { if (EvAInfo.propShowModules() != null) {
@ -401,10 +411,59 @@ public class EvAClient implements RemoteStateListener, Serializable {
showLoadModules = false; // may be set to true again if default module couldnt be loaded showLoadModules = false; // may be set to true again if default module couldnt be loaded
} }
createActions(); createActions();
mainFrame.setSize(800, 600);
/* Create a new ConfigurationPanel (left side) */
configurationPane = new JPanel(new GridBagLayout());
gbConstraints.ipadx = 5;
gbConstraints.weightx = 0.0;
gbConstraints.weighty = 1.0;
/* Set configurationPane at 0,1 */
gbConstraints.gridx = 0;
gbConstraints.gridy = 1;
gbConstraints.fill = GridBagConstraints.VERTICAL;
gbConstraints.gridwidth = GridBagConstraints.RELATIVE;
gbConstraints.gridheight = GridBagConstraints.RELATIVE;
mainFrame.add(configurationPane, gbConstraints);
/* SplitPane for desktopPane and loggingPanel */
horizontalSplit.setTopComponent(desktopPane);
horizontalSplit.setBottomComponent(logPanel);
horizontalSplit.setDividerLocation(0.25);
horizontalSplit.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));
horizontalSplit.setContinuousLayout(true);
/* Add horizontal split pane at 1,1 */
gbConstraints.gridx = 1;
gbConstraints.gridy = 1;
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
gbConstraints.gridheight = GridBagConstraints.RELATIVE;
mainFrame.add(horizontalSplit, gbConstraints);
/* Create ProgressBar and add it to the bottom */
progressBar = new JProgressBar();
progressBar.setBorder(new TitledBorder("Progress"));
progressBar.setValue(0);
progressBar.setStringPainted(true);
gbConstraints.gridx = 0;
gbConstraints.gridy = 2;
gbConstraints.gridwidth = 2;
gbConstraints.weighty = 0.0;
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.anchor = GridBagConstraints.PAGE_END;
mainFrame.add(progressBar, gbConstraints);
mainFrame.pack();
mainFrame.setVisible(true);
} }
if (useDefaultModule != null) { if (useDefaultModule != null) {
// if goParams are not defined and a params file is defined /*
// try to load parameters from file * if goParams are not defined and a params file is defined
* try to load parameters from file
*/
if (goParams == null && (paramsFile != null && (paramsFile.length() > 0))) { if (goParams == null && (paramsFile != null && (paramsFile.length() > 0))) {
goParams = GOParameters.getInstance(paramsFile, false); goParams = GOParameters.getInstance(paramsFile, false);
} }
@ -413,9 +472,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
if (withGUI) { if (withGUI) {
buildMenu(); buildMenu();
evaFrame.addWindowListener(new WindowAdapter() { mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { public void windowClosing(final WindowEvent event) {
EvAClient.this.close(); EvAClient.this.close();
} }
}); });
@ -433,12 +492,22 @@ public class EvAClient implements RemoteStateListener, Serializable {
LOGGER.log(Level.INFO, "Working directory is: {0}", System.getProperty("user.dir")); LOGGER.log(Level.INFO, "Working directory is: {0}", System.getProperty("user.dir"));
LOGGER.log(Level.INFO, "Class path is: {0}", System.getProperty("java.class.path", ".")); LOGGER.log(Level.INFO, "Class path is: {0}", System.getProperty("java.class.path", "."));
if (!(evaFrame.isVisible())) { if (!(configurationPane.isVisible())) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
evaFrame.setLocation((int) ((screenSize.width - evaFrame.getWidth()) / 2), (int) ((screenSize.height - evaFrame.getHeight()) / 2.5)); //evaFrame.setLocation((int) ((screenSize.width - evaFrame.getWidth()) / 2), (int) ((screenSize.height - evaFrame.getHeight()) / 2.5));
evaFrame.pack(); configurationPane.setVisible(true);
evaFrame.setVisible(true);
} }
if (!(mainFrame.isVisible())) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
mainFrame.setLocation((int) ((screenSize.width - mainFrame.getWidth()) / 2), (int) ((screenSize.height - mainFrame.getHeight()) / 2.5));
mainFrame.pack();
mainFrame.setSize(screenSize);
mainFrame.setVisible(true);
mainFrame.setVisible(true);
}
// if this message is omitted, the stupid scroll pane runs to // if this message is omitted, the stupid scroll pane runs to
// the end of the last line which is ugly for a long class path // the end of the last line which is ugly for a long class path
LOGGER.info("EvA2 ready"); LOGGER.info("EvA2 ready");
@ -451,7 +520,6 @@ public class EvAClient implements RemoteStateListener, Serializable {
*/ */
public void close() { public void close() {
LOGGER.info("Closing EvA2 Client. Bye!"); LOGGER.info("Closing EvA2 Client. Bye!");
evaFrame.dispose();
Set<String> keys = System.getenv().keySet(); Set<String> keys = System.getenv().keySet();
if (keys.contains("MATLAB")) { if (keys.contains("MATLAB")) {
LOGGER.info("EvA2 workbench has been started from Matlab: not killing JVM"); LOGGER.info("EvA2 workbench has been started from Matlab: not killing JVM");
@ -481,7 +549,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
* @param args command line parameters * @param args command line parameters
*/ */
public static void main(String[] args) { public static void main(String[] args) {
String[] keys = new String[]{"--help", "--autorun", "--nosplash", "--nogui", "--remotehost", "--params", "--treeView"}; /* Available command-line parameters */
String[] keys = new String[]{
"--help", "--autorun", "--nosplash", "--nogui",
"--remotehost", "--params", "--treeView"
};
/* Number of arguments per parameter */
int[] arities = new int[]{0, 0, 0, 0, 1, 1, 0}; int[] arities = new int[]{0, 0, 0, 0, 1, 1, 0};
Object[] values = new Object[keys.length]; Object[] values = new Object[keys.length];
@ -532,9 +605,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
evaClient.awaitClientInitialized(); // this returns as soon as the evaClient.awaitClientInitialized(); // this returns as soon as the
// GUI is ready // GUI is ready
evaClient.addWindowListener(windowListener); evaClient.addWindowListener(windowListener);
// modify initial settings: // modify initial settings and activate output of all data:
evaClient.getStatistics().getStatisticsParameter().setOutputAllFieldsAsText(true); // activate output of all data evaClient.getStatistics().getStatisticsParameter().setOutputAllFieldsAsText(true);
// fields
// add a data listener instance: // add a data listener instance:
evaClient.getStatistics().addDataListener(statisticsListener); evaClient.getStatistics().addDataListener(statisticsListener);
@ -582,10 +654,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
actModuleLoad = new ExtAction("&Load", "Load Module", actModuleLoad = new ExtAction("&Load", "Load Module",
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
/* (non-Javadoc) @Override
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) public void actionPerformed(final ActionEvent event) {
*/
public void actionPerformed(ActionEvent e) {
loadModuleFromServer(null, null); loadModuleFromServer(null, null);
} }
}; };
@ -593,141 +663,123 @@ public class EvAClient implements RemoteStateListener, Serializable {
actAbout = new ExtAction("&About...", "Product Information", actAbout = new ExtAction("&About...", "Product Information",
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
/* (non-Javadoc) @Override
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) public void actionPerformed(final ActionEvent event) {
*/ LOGGER.info(event.getActionCommand());
public void actionPerformed(ActionEvent e) {
LOGGER.info(e.getActionCommand());
showAboutDialog(); showAboutDialog();
} }
}; };
actLicense = new ExtAction("&License...", "View License", actLicense = new ExtAction("&License...", "View License",
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
/* (non-Javadoc) @Override
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) public void actionPerformed(final ActionEvent event) {
*/ LOGGER.info(event.getActionCommand());
public void actionPerformed(ActionEvent e) {
LOGGER.info(e.getActionCommand());
showLicense(); showLicense();
} }
}; };
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)) { KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
/* (non-Javadoc) @Override
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) public void actionPerformed(final ActionEvent event) {
*/ LOGGER.info(event.getActionCommand());
public void actionPerformed(ActionEvent e) {
LOGGER.info(e.getActionCommand());
selectAvailableHost(comAdapter.getHostNameList()); selectAvailableHost(comAdapter.getHostNameList());
} }
}; };
actAvailableHost = new ExtAction("Available &Server", "Available server", actAvailableHost = new ExtAction("Available &Server", "Available server",
KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) {
/* (non-Javadoc) @Override
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) public void actionPerformed(final ActionEvent event) {
*/ LOGGER.info(event.getActionCommand());
public void actionPerformed(ActionEvent e) {
LOGGER.info(e.getActionCommand());
showPleaseWaitDialog(); showPleaseWaitDialog();
Thread xx = new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
selectAvailableHost(comAdapter.getAvailableHostNameList()); selectAvailableHost(comAdapter.getAvailableHostNameList());
} }
}; }.start();
xx.start();
} }
}; };
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)) { KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
/* (non-Javadoc) @Override
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) public void actionPerformed(final ActionEvent event) {
*/ LOGGER.info(event.getActionCommand());
public void actionPerformed(ActionEvent e) { new Thread() {
LOGGER.info(e.getActionCommand()); @Override
showPleaseWaitDialog();
Thread xx = new Thread() {
public void run() { public void run() {
selectAvailableHostToKill(comAdapter.getAvailableHostNameList()); selectAvailableHostToKill(comAdapter.getAvailableHostNameList());
} }
}; }.start();
xx.start(); showPleaseWaitDialog();
} }
}; };
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)) { KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
/* (non-Javadoc) @Override
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) public void actionPerformed(final ActionEvent event) {
*/ LOGGER.info(event.getActionCommand());
public void actionPerformed(ActionEvent e) { new Thread() {
LOGGER.info(e.getActionCommand()); @Override
showPleaseWaitDialog();
Thread xx = new Thread() {
public void run() { public void run() {
selectAllAvailableHostToKill(comAdapter.getAvailableHostNameList()); selectAllAvailableHostToKill(comAdapter.getAvailableHostNameList());
} }
}; }.start();
xx.start(); showPleaseWaitDialog();
} }
}; };
actQuit = new ExtAction("&Quit", "Quit EvA2 workbench", actQuit = new ExtAction("&Quit", "Quit EvA2 workbench",
KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK)) {
/* (non-Javadoc) @Override
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) public void actionPerformed(final ActionEvent event) {
*/
public void actionPerformed(ActionEvent e) {
EvAClient.this.close(); EvAClient.this.close();
} }
}; };
/*
* m_actStartServerManager = new ExtAction("Start &Server Manager",
* "Start &Server Manager", KeyStroke.getKeyStroke(KeyEvent.VK_S,
* Event.CTRL_MASK)){ public void actionPerformed(ActionEvent e){
* m_LogPanel.logMessage(e.getActionCommand()); ServerStartFrame sm =
* new ServerStartFrame(m_ComAdapter.getHostNameList()); } };
*/
} }
/**
* Create the main menu and add actions.
*/
private void buildMenu() { private void buildMenu() {
menuBar = new JMenuBar(); menuBar = new JMenuBar();
evaFrame.setJMenuBar(menuBar); mainFrame.setJMenuBar(menuBar);
menuModule = new JExtMenu("&Module"); menuModule = new JExtMenu("&Module");
menuModule.add(actModuleLoad); menuModule.add(actModuleLoad);
////////////////////////////////////////////////////////////////
menuWindow = new JExtMenu("&Window"); menuWindow = new JExtMenu("&Window");
menuWindow.addMenuListener(new MenuListener() { menuWindow.addMenuListener(new MenuListener() {
public void menuSelected(MenuEvent e) { @Override
// System.out.println("Selected"); public void menuSelected(final MenuEvent event) {
menuWindow.removeAll(); menuWindow.removeAll();
JExtMenu curMenu = menuWindow; JExtMenu curMenu = menuWindow;
// JScrollPane jsp = new JScrollPane(); List<JEFrame> frameList = JEFrameRegister.getInstance().getFrameList();
Object[] framelist = JEFrameRegister.getFrameList(); int frameIndex = 1;
for (int i = 0; i < framelist.length; i++) { for (JEFrame frame : frameList) {
JMenuItem act = new JMenuItem((i + 1) + ". " + ((JEFrame) framelist[i]).getTitle());
final JFrame selectedFrame = ((JEFrame) framelist[i]); JMenuItem act = new JMenuItem(frameIndex + ". " + frame.getTitle());
final JInternalFrame selectedFrame = frame;
act.addActionListener(new ActionListener() { act.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { @Override
if (!selectedFrame.isActive()) { public void actionPerformed(final ActionEvent event) {
selectedFrame.setExtendedState(JFrame.NORMAL); if (!selectedFrame.isFocusOwner()) {
//selectedFrame..setExtendedState(JFrame.NORMAL);
selectedFrame.setVisible(false); selectedFrame.setVisible(false);
selectedFrame.setVisible(true); // it seems to be quite a fuss to bring something to the front and actually mean it... // it seems to be quite a fuss to bring something to the front and actually mean it...
selectedFrame.toFront(); // this seems useless selectedFrame.setVisible(true);
selectedFrame.requestFocus(); // this seems useless too // this seems useless
selectedFrame.toFront();
// this seems useless too
selectedFrame.requestFocus();
} }
} }
}); });
@ -739,20 +791,24 @@ public class EvAClient implements RemoteStateListener, Serializable {
curMenu = subMenu; curMenu = subMenu;
} }
curMenu.add(act); curMenu.add(act);
/* Next frame index */
frameIndex++;
} }
String[] commonPrefixes = JEFrameRegister.getCommonPrefixes(10); String[] commonPrefixes = JEFrameRegister.getInstance().getCommonPrefixes(10);
if (commonPrefixes.length > 0) { if (commonPrefixes.length > 0) {
menuWindow.add(new JSeparator()); menuWindow.add(new JSeparator());
} }
for (int i = 0; i < commonPrefixes.length; i++) { for (int i = 0; i < commonPrefixes.length; i++) {
final String prefix = commonPrefixes[i]; final String prefix = commonPrefixes[i];
JMenuItem act = new JMenuItem("Close all of " + prefix + "..."); JMenuItem act = new JMenuItem("Close all of " + prefix + "...");
act.addActionListener((new ActionListener() { act.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { @Override
JEFrameRegister.closeAllByPrefix(prefix); public void actionPerformed(final ActionEvent event) {
JEFrameRegister.getInstance().closeAllByPrefix(prefix);
} }
})); });
menuWindow.add(act); menuWindow.add(act);
} }
@ -765,7 +821,6 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
}); });
////////////////////////////////////////////////////////////////
menuSelHosts = new JExtMenu("&Select Hosts"); menuSelHosts = new JExtMenu("&Select Hosts");
menuSelHosts.setToolTipText("Select a host for the server application"); menuSelHosts.setToolTipText("Select a host for the server application");
menuSelHosts.add(actHost); menuSelHosts.add(actHost);
@ -773,11 +828,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
menuSelHosts.addSeparator(); menuSelHosts.addSeparator();
menuSelHosts.add(actKillHost); menuSelHosts.add(actKillHost);
menuSelHosts.add(actKillAllHosts); menuSelHosts.add(actKillAllHosts);
////////////////////////////////////////////////////////////////
menuAbout = new JExtMenu("&About"); menuAbout = new JExtMenu("&About");
menuAbout.add(actAbout); menuAbout.add(actAbout);
menuAbout.add(actLicense); menuAbout.add(actLicense);
//////////////////////////////////////////////////////////////
menuOptions = new JExtMenu("&Options"); menuOptions = new JExtMenu("&Options");
menuOptions.add(menuSelHosts); menuOptions.add(menuSelHosts);
@ -791,17 +845,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
menuBar.add(menuWindow); menuBar.add(menuWindow);
menuBar.add(menuAbout); menuBar.add(menuAbout);
menuBar.add(((JExtDesktopPane) desktopPane).getWindowMenu());
} }
public static String getProductName() {
return EvAInfo.productName;
}
protected void logMessage(String msg) {
if (logPanel != null) {
logPanel.logMessage(msg);
}
}
/** /**
* *
@ -830,7 +877,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
if (selectedModule == null) { // show a dialog and ask for a module if (selectedModule == null) { // show a dialog and ask for a module
String[] ModuleNameList = comAdapter.getModuleNameList(); String[] ModuleNameList = comAdapter.getModuleNameList();
if (ModuleNameList == null) { if (ModuleNameList == null) {
JOptionPane.showMessageDialog(evaFrame.getContentPane(), "No modules available on " + comAdapter.getHostName(), EvAInfo.infoTitle, 1); JOptionPane.showMessageDialog(configurationPane, "No modules available on " + comAdapter.getHostName(), EvAInfo.infoTitle, 1);
} else { } else {
String lastModule = null; String lastModule = null;
@ -846,7 +893,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
LOGGER.log(Level.INFO, "Defaulting to module: {0}", lastModule); LOGGER.log(Level.INFO, "Defaulting to module: {0}", lastModule);
} }
selectedModule = (String) JOptionPane.showInputDialog(evaFrame.getContentPane(), selectedModule = (String) JOptionPane.showInputDialog(configurationPane,
"Which module do you want \n to load on host: " + comAdapter.getHostName() + " ?", "Which module do you want \n to load on host: " + comAdapter.getHostName() + " ?",
"Load optimization module on host", "Load optimization module on host",
JOptionPane.QUESTION_MESSAGE, JOptionPane.QUESTION_MESSAGE,
@ -872,7 +919,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
actHost.setEnabled(true); actHost.setEnabled(true);
actAvailableHost.setEnabled(true); actAvailableHost.setEnabled(true);
} }
LOGGER.info("Selected Module: " + selectedModule); LOGGER.log(Level.INFO, "Selected Module: {0}", selectedModule);
} }
} }
@ -951,36 +998,41 @@ public class EvAClient implements RemoteStateListener, Serializable {
if (withGUI) { if (withGUI) {
// this (or rather: EvAModuleButtonPanelMaker) is where the start button etc come from! // this (or rather: EvAModuleButtonPanelMaker) is where the start button etc come from!
frameMaker = newModuleAdapter.getModuleFrame(); frameMaker = newModuleAdapter.getModuleFrame();
// newModuleAdapter.setLogPanel(m_LogPanel);
JPanel moduleContainer = frameMaker.makePanel(); // MK the main frame is actually painted in here
boolean wasVisible = evaFrame.isVisible(); /* This is the left TabPane on the main frame */
evaFrame.setVisible(false); JPanel moduleContainer = frameMaker.makePanel();
evaFrame.getContentPane().removeAll();
boolean wasVisible = configurationPane.isVisible();
configurationPane.setVisible(false);
configurationPane.removeAll();
// nested info-panel so that we can stay with simple borderlayouts
JPanel infoPanel = new JPanel();
infoPanel.setLayout(new BorderLayout());
infoPanel.add(progressBar, BorderLayout.SOUTH);
infoPanel.add(logPanel, BorderLayout.NORTH);
JComponent tree = null; JComponent tree = null;
if (withTreeView && (newModuleAdapter instanceof AbstractModuleAdapter)) { if (withTreeView && (newModuleAdapter instanceof AbstractModuleAdapter)) {
tree = getEvATreeView(frameMaker.getGOPanel(), "GOParameters", ((AbstractModuleAdapter) newModuleAdapter).getGOParameters()); tree = getEvATreeView(frameMaker.getGOPanel(), "GOParameters", ((AbstractModuleAdapter) newModuleAdapter).getGOParameters());
evaFrame.add(tree, BorderLayout.WEST); configurationPane.add(tree, BorderLayout.LINE_START);
} }
evaFrame.add(frameMaker.getToolBar(), BorderLayout.NORTH);
evaFrame.add(moduleContainer, BorderLayout.CENTER);
//m_Frame.add(m_ProgressBar, BorderLayout.CENTER);
//m_Frame.add(m_LogPanel, BorderLayout.SOUTH);
evaFrame.add(infoPanel, BorderLayout.SOUTH);
evaFrame.pack(); GridBagConstraints gbConstraints = new GridBagConstraints();
evaFrame.setVisible(wasVisible); gbConstraints.weightx = 1.0;
gbConstraints.weighty = 0.0;
gbConstraints.gridx = 0;
gbConstraints.gridy = 0;
gbConstraints.gridwidth = 2;
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.anchor = GridBagConstraints.PAGE_START;
mainFrame.add(frameMaker.getToolBar(), gbConstraints);
GridBagConstraints gbConstraints2 = new GridBagConstraints();
gbConstraints2.gridx = 0;
gbConstraints2.gridy = 0;
gbConstraints2.fill = GridBagConstraints.VERTICAL;
gbConstraints2.gridheight = GridBagConstraints.REMAINDER;
gbConstraints2.weighty = 1.0;
configurationPane.add(moduleContainer, gbConstraints2);
configurationPane.validate();
} }
currentModule = selectedModule; currentModule = selectedModule;
// m_ModulGUIContainer.add(Temp);
} catch (Exception e) { } catch (Exception e) {
currentModule = null; currentModule = null;
LOGGER.log(Level.SEVERE, "Error while newModulAdapter.getModulFrame(): " + e.getMessage(), e); LOGGER.log(Level.SEVERE, "Error while newModulAdapter.getModulFrame(): " + e.getMessage(), e);
@ -1029,7 +1081,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
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(configurationPane,
"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, comAdapter.getHostName()); hostNames, comAdapter.getHostName());
if (hostName != null) { if (hostName != null) {
@ -1048,7 +1100,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
private void showPleaseWaitDialog() { private void showPleaseWaitDialog() {
JOptionPane.showMessageDialog(evaFrame.getContentPane(), "Please wait one moment.", EvAInfo.infoTitle, 1); JOptionPane.showMessageDialog(configurationPane, "Please wait one moment.", EvAInfo.infoTitle, 1);
} }
private void showAboutDialog() { private void showAboutDialog() {
@ -1065,7 +1117,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
aboutMessage.append("\nSee: "); aboutMessage.append("\nSee: ");
aboutMessage.append(EvAInfo.url); aboutMessage.append(EvAInfo.url);
JOptionPane.showMessageDialog(evaFrame, aboutMessage, EvAInfo.infoTitle, 1); JOptionPane.showMessageDialog(configurationPane, aboutMessage, EvAInfo.infoTitle, 1);
} }
private void showLicense() { private void showLicense() {
@ -1076,7 +1128,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
private void showNoHostFoundDialog() { private void showNoHostFoundDialog() {
JOptionPane.showMessageDialog(evaFrame.getContentPane(), "No host with running EVASERVER found. Please start one or \nadd the correct address to the properties list.", EvAInfo.infoTitle, 1); JOptionPane.showMessageDialog(configurationPane, "No host with running EVASERVER found. Please start one or \nadd the correct address to the properties list.", EvAInfo.infoTitle, 1);
} }
private void selectAvailableHostToKill(String[] HostNames) { private void selectAvailableHostToKill(String[] HostNames) {
@ -1084,7 +1136,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
showNoHostFoundDialog(); showNoHostFoundDialog();
return; return;
} }
String HostName = (String) JOptionPane.showInputDialog(evaFrame.getContentPane(), String HostName = (String) JOptionPane.showInputDialog(configurationPane,
"Which server do you want to be killed ?", "Host", JOptionPane.QUESTION_MESSAGE, null, "Which server do you want to be killed ?", "Host", JOptionPane.QUESTION_MESSAGE, null,
HostNames, comAdapter.getHostName()); HostNames, comAdapter.getHostName());
if (HostName == null) { if (HostName == null) {

View File

@ -23,15 +23,15 @@ import java.rmi.RemoteException;
* *
*/ */
public class EvAComAdapter extends ComAdapter { public class EvAComAdapter extends ComAdapter {
private LoggingPanel m_LogPanel; private LoggingPanel loggingPanel;
private EvAMainAdapterImpl localMainAdapter; private EvAMainAdapterImpl localMainAdapter;
private boolean runLocally = false; private boolean runLocally = false;
/** /**
* *
*/ */
public void setLogPanel(LoggingPanel OutputFrame) { public void setLogPanel(LoggingPanel loggingPanel) {
m_LogPanel = OutputFrame; this.loggingPanel = loggingPanel;
} }
/** /**
* *
@ -54,8 +54,10 @@ public class EvAComAdapter extends ComAdapter {
//ret = evaAdapter.getModuleAdapter(Modul, hostAdd, this.m_MainAdapterClient); //ret = evaAdapter.getModuleAdapter(Modul, hostAdd, this.m_MainAdapterClient);
newModuleAdapter = getLocalMainAdapter().getModuleAdapter(selectedModuleName, true, getHostName(), goParams, noGuiStatsFile, null); newModuleAdapter = getLocalMainAdapter().getModuleAdapter(selectedModuleName, true, getHostName(), goParams, noGuiStatsFile, null);
} else { } else {
newModuleAdapter = ((RMIConnectionEvA)getConnection(getHostName())).getModuleAdapter(selectedModuleName); newModuleAdapter = ((RMIConnectionEvA) getConnection(getHostName())).getModuleAdapter(selectedModuleName);
if (newModuleAdapter == null) System.err.println("RMI Error for getting ModuleAdapterObject : " + selectedModuleName); if (newModuleAdapter == null) {
System.err.println("RMI Error for getting ModuleAdapterObject : " + selectedModuleName);
}
} }
return newModuleAdapter; return newModuleAdapter;
} }
@ -86,12 +88,12 @@ public class EvAComAdapter extends ComAdapter {
} }
list = ((EvAMainAdapter)Connection.getMainAdapter()).getModuleNameList(); list = ((EvAMainAdapter)Connection.getMainAdapter()).getModuleNameList();
} }
if (m_LogPanel != null) if (loggingPanel != null)
m_LogPanel.logMessage("List of modules on server:"); loggingPanel.logMessage("List of modules on server:");
if (list != null) if (list != null)
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
if ( (String) list[i] != null && m_LogPanel != null) if ( (String) list[i] != null && loggingPanel != null)
m_LogPanel.logMessage( (String) list[i]); loggingPanel.logMessage( (String) list[i]);
} }
return list; return list;
} }

View File

@ -898,12 +898,14 @@ public class BeanInspector {
if (mname.equals(tipName)) { if (mname.equals(tipName)) {
if (meth.getReturnType().equals(String.class)) { if (meth.getReturnType().equals(String.class)) {
try { try {
Object args[] = { }; Object args[] = {};
String tempTip = (String)(meth.invoke(target, args)); String tempTip = (String) (meth.invoke(target, args));
result = tempTip; result = tempTip;
if (stripToolTipToFirstPoint) { if (stripToolTipToFirstPoint) {
int ci = tempTip.indexOf('.'); int ci = tempTip.indexOf('.');
if (ci > 0) result = tempTip.substring(0, ci); if (ci > 0) {
result = tempTip.substring(0, ci);
}
} }
} catch (Exception ex) { } catch (Exception ex) {
} }
@ -911,8 +913,11 @@ public class BeanInspector {
} }
} }
} // end for looking for tiptext } // end for looking for tiptext
if (toHTMLLen > 0) return StringTools.toHTML(result, toHTMLLen); if (toHTMLLen > 0) {
else return result; return StringTools.toHTML(result, toHTMLLen);
} else {
return result;
}
} }
/** /**

View File

@ -16,6 +16,8 @@ import java.beans.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
/*==========================================================================* /*==========================================================================*
* CLASS DECLARATION * CLASS DECLARATION
@ -40,9 +42,12 @@ public class BigStringEditor implements PropertyEditor {
PropertyDialog frame = new PropertyDialog(editor,file, 50, 50); PropertyDialog frame = new PropertyDialog(editor,file, 50, 50);
//frame.setSize(200, 200); //frame.setSize(200, 200);
frame.addWindowListener(new WindowAdapter() { frame.addInternalFrameListener(new InternalFrameAdapter() {
public void windowClosing (WindowEvent e) {
m_finished=true; @Override
public void internalFrameClosing(InternalFrameEvent e) {
super.internalFrameClosing(e);
m_finished = true;
} }
}); });
while (m_finished==false) { while (m_finished==false) {
@ -187,8 +192,11 @@ public class BigStringEditor implements PropertyEditor {
PropertyDialog frame = new PropertyDialog(editor, "test", 50, 50); PropertyDialog frame = new PropertyDialog(editor, "test", 50, 50);
frame.setSize(200, 200); frame.setSize(200, 200);
frame.addWindowListener(new WindowAdapter() { frame.addInternalFrameListener(new InternalFrameAdapter() {
public void windowClosing (WindowEvent e) {
@Override
public void internalFrameClosing(InternalFrameEvent e) {
super.internalFrameClosing(e);
System.exit(0); System.exit(0);
} }
}); });

View File

@ -1,17 +1,13 @@
package eva2.gui; package eva2.gui;
/* /*
* Title: EvA2 * Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
* Description: * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 272
* Copyright: Copyright (c) 2003 * $ $Date: 2007-11-21 18:06:36 +0100 (Wed, 21 Nov 2007) $ $Author: mkron $
* Company: University of Tuebingen, Computer Architecture */
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher /*
* @version: $Revision: 272 $ * ==========================================================================* IMPORTS
* $Date: 2007-11-21 18:06:36 +0100 (Wed, 21 Nov 2007) $ *==========================================================================
* $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
@ -25,101 +21,118 @@ import javax.swing.JTabbedPane;
import eva2.server.go.InterfaceNotifyOnInformers; import eva2.server.go.InterfaceNotifyOnInformers;
import eva2.server.go.problems.InterfaceAdditionalPopulationInformer; import eva2.server.go.problems.InterfaceAdditionalPopulationInformer;
import java.awt.*;
import java.awt.event.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.plaf.TabbedPaneUI;
import javax.swing.plaf.basic.BasicButtonUI;
/** /**
* Produces the main EvA2 frame and a tool bar instance. * Produces the main EvA2 frame and a tool bar instance. TODO This class should be removed
* TODO This class should be removed alltogether. * alltogether.
*/ */
public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceNotifyOnInformers { public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceNotifyOnInformers {
private static final Logger LOGGER = Logger.getLogger(eva2.EvAInfo.defaultLogger);
private static final long serialVersionUID = 2637376545826821423L; private static final long serialVersionUID = 2637376545826821423L;
private ArrayList<PanelMaker> pmContainer = null; private ArrayList<PanelMaker> pmContainer = null;
private JExtToolBar m_BarStandard; private JExtToolBar extToolBar;
EvAModuleButtonPanelMaker butPanelMkr=null; EvAModuleButtonPanelMaker butPanelMkr = null;
private JTabbedPane tabbedPane;
public EvATabbedFrameMaker() { public EvATabbedFrameMaker() {
pmContainer = null; pmContainer = null;
} }
public void addPanelMaker(PanelMaker pm) { public void addPanelMaker(PanelMaker pm) {
if (pmContainer==null) pmContainer = new ArrayList<PanelMaker>(2); if (pmContainer == null) {
pmContainer = new ArrayList<PanelMaker>(2);
}
pmContainer.add(pm); pmContainer.add(pm);
} }
public JPanel makePanel() { public JPanel makePanel() {
JPanel m_SuperPanel = new JPanel(); JPanel tabControlPanel = new JPanel(new GridBagLayout());
m_SuperPanel.setLayout(new GridBagLayout());
GridBagConstraints gbconst = new GridBagConstraints();
gbconst.fill = GridBagConstraints.BOTH;
gbconst.weightx = 1;
gbconst.weighty = 1;
gbconst.gridwidth = GridBagConstraints.REMAINDER;
final JTabbedPane m_MainPanel = new JTabbedPane(); GridBagConstraints gbConstraints = new GridBagConstraints();
// m_MainPanel.addChangeListener(new ChangeListener() { gbConstraints.fill = GridBagConstraints.VERTICAL;
// /* gbConstraints.gridy = 0;
// * This listener was added to catch the switch to the statistics panel. In that event,
// * the stats selection string may have to be updated.
// */
// public void stateChanged(ChangeEvent e) {
//// System.out.println("AAAA " + e.toString());
// if (m_MainPanel.getSelectedIndex()==1) {
// // the statistics panel is being activated!
//// System.out.println(guiContainer);
// // the third object should be the statistics panel, refer to GenericModuleAdapter
// JParaPanel statsPan = (JParaPanel) guiContainer.get(2);
//// System.out.println(statsPan.m_LocalParameter);
//// statsPan.m_Editor.setValue(statsPan.m_Editor.getValue()); // really update the contents of the stats panel --
// this is now done in a cleaner way using this class as a listener from AbstractGOParameters
// }
// }});
m_BarStandard = new JExtToolBar(); tabbedPane = new JTabbedPane();
m_BarStandard.setFloatable(false); tabbedPane.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));
//tabbedPane.setUI(new eva2.gui.utils.CustomTabbedPaneUI());
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
for (int i=0;i<pmContainer.size();i++) {
PanelMaker element = pmContainer.get(i); /* This toolbar will hold the closed tabs */
JToolBar tabToolBar = new JToolBar(JToolBar.VERTICAL);
tabToolBar.setFloatable(false);
/* ToDo: The control buttons shouldn't be added here.. */
extToolBar = new JExtToolBar();
extToolBar.setFloatable(false);
for (PanelMaker element : pmContainer) {
JComponent panel = element.makePanel(); JComponent panel = element.makePanel();
if (element instanceof EvAModuleButtonPanelMaker) { if (element instanceof EvAModuleButtonPanelMaker) {
m_BarStandard.add(panel); extToolBar.add(panel);
butPanelMkr=(EvAModuleButtonPanelMaker)element; butPanelMkr = (EvAModuleButtonPanelMaker) element;
} else if (element instanceof JParaPanel) { } else if (element instanceof JParaPanel) {
m_MainPanel.addTab (((JParaPanel)element).getName(), panel); tabbedPane.addTab(((JParaPanel) element).getName(), panel);
} }
} }
m_SuperPanel.add(m_MainPanel, gbconst);
return m_SuperPanel;
}
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
tabbedPane.setTabComponentAt(i, new ClosableTabComponent(tabbedPane, tabToolBar));
}
gbConstraints.weighty = 1.0;
gbConstraints.gridx = 0;
tabControlPanel.add(tabToolBar, gbConstraints);
gbConstraints.gridx = 1;
tabControlPanel.add(tabbedPane, gbConstraints);
tabbedPane.validate();
return tabControlPanel;
}
/**
* @deprecated
* @return The toolbar with control buttons
*/
public JExtToolBar getToolBar() { public JExtToolBar getToolBar() {
return m_BarStandard; return extToolBar;
} }
/** /**
* Emulate pressing the start button. * Emulate pressing the start button.
*/ */
public void onUserStart() { public void onUserStart() {
if (butPanelMkr!=null) { if (butPanelMkr != null) {
butPanelMkr.onUserStart(); butPanelMkr.onUserStart();
} else System.err.println("Error: button panel was null (EvATabbedFrameMaker)"); } else {
System.err.println("Error: button panel was null (EvATabbedFrameMaker)");
}
} }
public void refreshPanels() { public void refreshPanels() {
for (PanelMaker jpp : pmContainer) { for (PanelMaker jpp : pmContainer) {
if (jpp instanceof JParaPanel) ((JParaPanel)jpp).m_Editor.setValue(((JParaPanel)jpp).m_Editor.getValue()); if (jpp instanceof JParaPanel) {
((JParaPanel) jpp).propertyEditor.setValue(((JParaPanel) jpp).propertyEditor.getValue());
}
} }
} }
public void setInformers( public void setInformers(List<InterfaceAdditionalPopulationInformer> informers) {
List<InterfaceAdditionalPopulationInformer> informers) {
// if the informers have changed, update the GUI element which displays them // if the informers have changed, update the GUI element which displays them
try { try {
JParaPanel statsPan = getStatsPanel(); JParaPanel statsPan = getStatsPanel();
if (statsPan.m_Editor!=null) { if (statsPan.propertyEditor != null) {
statsPan.m_Editor.setValue(statsPan.m_Editor.getValue()); // really update the contents of the stats panel // really update the contents of the stats panel
// System.out.println("OOO setting informers to stats panel succeeded!"); statsPan.propertyEditor.setValue(statsPan.propertyEditor.getValue());
} }
} catch(Exception e) { } catch (Exception e) {
System.err.println("Failed to update statistics panel from " + this.getClass()); System.err.println("Failed to update statistics panel from " + this.getClass());
System.err.println(e.getMessage()); System.err.println(e.getMessage());
e.printStackTrace(System.err); e.printStackTrace(System.err);
@ -130,7 +143,7 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
try { try {
JParaPanel sP = (JParaPanel) pmContainer.get(1); JParaPanel sP = (JParaPanel) pmContainer.get(1);
return sP; return sP;
} catch(Exception e) { } catch (Exception e) {
System.err.println("Failed to get GO panel from " + this.getClass()); System.err.println("Failed to get GO panel from " + this.getClass());
} }
return null; return null;
@ -140,9 +153,148 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
try { try {
JParaPanel sP = (JParaPanel) pmContainer.get(2); JParaPanel sP = (JParaPanel) pmContainer.get(2);
return sP; return sP;
} catch(Exception e) { } catch (Exception e) {
System.err.println("Failed to get statistics panel from " + this.getClass()); System.err.println("Failed to get statistics panel from " + this.getClass());
} }
return null; return null;
} }
} }
/**
* Component to be used as tabComponent;
* Contains a JLabel to show the text and
* a JButton to close the tab it belongs to
*/
class ClosableTabComponent extends JPanel {
private final JTabbedPane pane;
private final JToolBar toolBar;
public ClosableTabComponent(final JTabbedPane pane, final JToolBar toolBar) {
super(new FlowLayout(FlowLayout.LEADING, 0, 0));
if (pane == null) {
throw new NullPointerException("TabbedPane is null");
}
this.pane = pane;
this.toolBar = toolBar;
this.toolBar.setVisible(false);
setOpaque(false);
//make JLabel read titles from JTabbedPane
JLabel label = new JLabel() {
public String getText() {
int index = pane.indexOfTabComponent(ClosableTabComponent.this);
if (index != -1) {
return pane.getTitleAt(index);
}
return null;
}
};
add(label);
//add more space between the label and the button
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
//tab button
JButton button = new TabButton();
add(button);
//add more space to the top of the component
setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
}
private class TabButton extends JButton implements ActionListener {
public TabButton() {
int size = 17;
setPreferredSize(new Dimension(size, size));
setToolTipText("Hide this Tab");
//Make the button looks the same for all Laf's
setUI(new BasicButtonUI());
//Make it transparent
setContentAreaFilled(false);
//No need to be focusable
setFocusable(false);
setBorder(BorderFactory.createEtchedBorder());
setBorderPainted(false);
//Making nice rollover effect
//we use the same listener for all buttons
addMouseListener(buttonMouseListener);
setRolloverEnabled(true);
//Close the proper tab by clicking the button
addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
int i = pane.indexOfTabComponent(ClosableTabComponent.this);
if (i != -1) {
final String tabTitle = pane.getTitleAt(i);
final Component tabPane = pane.getComponentAt(i);
final int tabPosition = i;
pane.remove(i);
if(pane.getTabCount() == 0) {
pane.setVisible(false);
}
/* Create a button to be shown in the ToolBar */
JButton tabButton = new JButton(tabTitle);
/* Rotate it by -90° */
tabButton.setUI(new eva2.gui.utils.VerticalButtonUI(-90));
tabButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
/* Add the Tab Panel again */
pane.insertTab(tabTitle, null, tabPane, "", tabPosition);
pane.setVisible(true);
/* Remove the Button */
toolBar.remove((Component)e.getSource());
/* If the Button was the last one, hide ToolBar again */
if(toolBar.getComponentCount() == 0) {
toolBar.setVisible(false);
}
}
});
/* Add it to the ToolBar */
if(!toolBar.isVisible()) {
toolBar.setVisible(true);
}
toolBar.add(tabButton);
}
}
//we don't want to update UI for this button
public void updateUI() {
}
//paint the cross
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
//shift the image for pressed buttons
if (getModel().isPressed()) {
g2.translate(1, 1);
}
g2.setStroke(new BasicStroke(2));
g2.setColor(Color.BLACK);
int delta = 6;
g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
g2.dispose();
}
}
private final static MouseListener buttonMouseListener = new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setBorderPainted(true);
}
}
public void mouseExited(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setBorderPainted(false);
}
}
};
}

View File

@ -9,62 +9,79 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $ * $Author: streiche $
*/ */
/*==========================================================================* import java.awt.Component;
* IMPORTS import java.awt.Event;
*==========================================================================*/ import java.util.logging.Level;
import javax.swing.*; import java.util.logging.Logger;
import java.awt.*; import javax.swing.DefaultDesktopManager;
import javax.swing.JInternalFrame;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
/** /**
* *
*/ */
public class ExtDesktopManager extends DefaultDesktopManager{ public class ExtDesktopManager extends DefaultDesktopManager {
private static final Logger LOGGER = Logger.getLogger(eva2.EvAInfo.defaultLogger);
int WINDOW_LIST_START; int WINDOW_LIST_START;
public final static String INDEX = "Index"; public final static String INDEX = "Index";
public final static String FRAME = "Frame"; public final static String FRAME = "Frame";
private JInternalFrame activeFrame = null; private JInternalFrame activeFrame = null;
private JExtDesktopPane desktop; private JExtDesktopPane desktop;
public ExtDesktopManager(JExtDesktopPane desktop){
public ExtDesktopManager(JExtDesktopPane desktop) {
this.desktop = desktop; this.desktop = desktop;
} }
public void activateFrame(JInternalFrame f){
public void activateFrame(JInternalFrame f) {
super.activateFrame(f); super.activateFrame(f);
activeFrame = f; activeFrame = f;
} }
public void deactivateFrame(JInternalFrame f){
public void deactivateFrame(JInternalFrame f) {
super.deactivateFrame(f); super.deactivateFrame(f);
if(activeFrame == f) activeFrame = null; if (activeFrame == f) {
activeFrame = null;
} }
public JInternalFrame getActiveFrame(){ }
public JInternalFrame getActiveFrame() {
return activeFrame; return activeFrame;
} }
public void closeFrame(JInternalFrame f){
System.out.println("closed internalframe called"); public void closeFrame(JInternalFrame internalFrame) {
super.closeFrame(f); LOGGER.log(Level.FINE, "Closing Internal Frame: {0}", internalFrame.getTitle());
int index = ((Integer)f.getClientProperty(INDEX)).intValue() + WINDOW_LIST_START - 1; super.closeFrame(internalFrame);
int index = ((Integer) internalFrame.getClientProperty(INDEX)).intValue() + WINDOW_LIST_START - 1;
int i; int i;
desktop.m_mnuWindow.remove(index); desktop.m_mnuWindow.remove(index);
for(i = index; i < Math.min(WINDOW_LIST_START + 9, desktop.m_mnuWindow.getItemCount()); i++){ for (i = index; i < Math.min(WINDOW_LIST_START + 9, desktop.m_mnuWindow.getItemCount()); i++) {
JMenuItem m = desktop.m_mnuWindow.getItem(i); JMenuItem m = desktop.m_mnuWindow.getItem(i);
JInternalFrame frame = (JInternalFrame)m.getClientProperty(FRAME); JInternalFrame frame = (JInternalFrame) m.getClientProperty(FRAME);
frame.putClientProperty(INDEX, new Integer(((Integer)frame.getClientProperty(INDEX)).intValue() - 1)); frame.putClientProperty(INDEX, new Integer(((Integer) frame.getClientProperty(INDEX)).intValue() - 1));
int winIndex = i - WINDOW_LIST_START + 1; int winIndex = i - WINDOW_LIST_START + 1;
m.setText((winIndex) + " " + frame.getTitle()); m.setText((winIndex) + " " + frame.getTitle());
m.setMnemonic((char)(0x30 + winIndex)); m.setMnemonic((char) (0x30 + winIndex));
m.setAccelerator(KeyStroke.getKeyStroke(0x30 + winIndex, Event.ALT_MASK)); m.setAccelerator(KeyStroke.getKeyStroke(0x30 + winIndex, Event.ALT_MASK));
} }
if(f.isSelected()){ if (internalFrame.isSelected()) {
Component tmp = null; Component tmp = null;
boolean found = false; boolean found = false;
for(i = 0; i < desktop.getComponentCount() && !found; i++){ for (i = 0; i < desktop.getComponentCount() && !found; i++) {
tmp = desktop.getComponent(i); tmp = desktop.getComponent(i);
if(tmp instanceof JInternalFrame) found = true; if (tmp instanceof JInternalFrame) {
found = true;
}
} }
if(found) desktop.selectFrame((JInternalFrame)tmp); if (found) {
else activeFrame = null; desktop.selectFrame((JInternalFrame) tmp);
} else {
activeFrame = null;
}
} }
} }
} }

View File

@ -1,10 +1,11 @@
package eva2.gui; package eva2.gui;
import eva2.server.go.tools.FileTools;
import java.awt.BorderLayout; import eva2.tools.BasicResourceLoader;
import java.awt.Component; import eva2.tools.EVAHELP;
import java.awt.GridLayout; import eva2.tools.SerializedObject;
import java.awt.Window; import eva2.tools.jproxy.RMIProxyLocal;
import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@ -18,46 +19,48 @@ import java.lang.reflect.Proxy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.plaf.basic.BasicComboBoxRenderer; import javax.swing.plaf.basic.BasicComboBoxRenderer;
import eva2.server.go.tools.FileTools;
import eva2.tools.EVAHELP;
import eva2.tools.SerializedObject;
import eva2.tools.jproxy.RMIProxyLocal;
/** /**
* *
*/ */
public class GOEPanel extends JPanel implements ItemListener { public class GOEPanel extends JPanel implements ItemListener {
private Object m_Backup;
private PropertyChangeSupport m_Support;
private static boolean TRACE = false;
/** The chooser component */ private Object backupObject;
private JComboBox m_ObjectChooser; private PropertyChangeSupport propChangeSupport;
/** The component that performs classifier customization */ private static boolean TRACE = false;
private PropertySheetPanel m_ChildPropertySheet; /**
/** The model containing the list of names to select from */ * The chooser component
private DefaultComboBoxModel m_ObjectNames; */
/** Open object from disk */ private JComboBox objectChooser;
/**
* The component that performs classifier customization
*/
private PropertySheetPanel propertySheetPanel;
/**
* The model containing the list of names to select from
*/
private DefaultComboBoxModel comboBoxModel;
/**
* Open object from disk
*/
private JButton openButton; private JButton openButton;
/** Save object to disk */ /**
* Save object to disk
*/
private JButton saveButton; private JButton saveButton;
/** ok button */ /**
* ok button
*/
private JButton okayButton; private JButton okayButton;
/** cancel button */ /**
* cancel button
*/
private JButton cancelButton; private JButton cancelButton;
/** edit source button */ /**
// private JButton m_editSourceBut; * Creates the GUI editor component
/** Creates the GUI editor component */ */
// private Vector<String> m_ClassesLongName; // private Vector<String> m_ClassesLongName;
private GenericObjectEditor genericObjectEditor = null; private GenericObjectEditor genericObjectEditor = null;
private boolean withComboBoxToolTips = true; // should tool tips for the combo box be created? private boolean withComboBoxToolTips = true; // should tool tips for the combo box be created?
@ -75,36 +78,38 @@ public class GOEPanel extends JPanel implements ItemListener {
*/ */
public GOEPanel(Object target, Object backup, PropertyChangeSupport support, GenericObjectEditor goe, boolean withCancel) { public GOEPanel(Object target, Object backup, PropertyChangeSupport support, GenericObjectEditor goe, boolean withCancel) {
Object m_Object = target; Object m_Object = target;
m_Backup = backup; backupObject = backup;
m_Support = support; propChangeSupport = support;
genericObjectEditor = goe; genericObjectEditor = goe;
// System.out.println("GOEPanel.Constructor !! " + this);
try { try {
if (!(Proxy.isProxyClass(m_Object.getClass()))) m_Backup = copyObject(m_Object); if (!(Proxy.isProxyClass(m_Object.getClass()))) {
} catch(OutOfMemoryError err) { backupObject = copyObject(m_Object);
m_Backup=null; }
} catch (OutOfMemoryError err) {
backupObject = null;
System.gc(); System.gc();
System.err.println("Could not create backup object: not enough memory (GOEPanel backup of " + m_Object + ")"); System.err.println("Could not create backup object: not enough memory (GOEPanel backup of " + m_Object + ")");
} }
m_ObjectNames = new DefaultComboBoxModel(new String [0]); comboBoxModel = new DefaultComboBoxModel(new String[0]);
m_ObjectChooser = new JComboBox(m_ObjectNames); objectChooser = new JComboBox(comboBoxModel);
m_ObjectChooser.setEditable(false); objectChooser.setEditable(false);
m_ChildPropertySheet = new PropertySheetPanel(); propertySheetPanel = new PropertySheetPanel();
m_ChildPropertySheet.addPropertyChangeListener( propertySheetPanel.addPropertyChangeListener(
new PropertyChangeListener() { new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (TRACE) System.out.println("GOE Property Change Listener: " + evt); public void propertyChange(final PropertyChangeEvent event) {
m_Support.firePropertyChange("", m_Backup, genericObjectEditor.getValue()); propChangeSupport.firePropertyChange("", backupObject, genericObjectEditor.getValue());
} }
}); });
openButton = new JButton("Open"); openButton = makeIconButton("resources/images/Open16.gif", "Open");
openButton.setToolTipText("Load a configured object"); openButton.setToolTipText("Load a configured object");
openButton.setEnabled(true); openButton.setEnabled(true);
openButton.addActionListener(new ActionListener() { openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(final ActionEvent event) {
Object object = FileTools.openObject(openButton, genericObjectEditor.getClassType()); Object object = FileTools.openObject(openButton, genericObjectEditor.getClassType());
// Object object = openObject();
if (object != null) { if (object != null) {
// setValue takes care of: Making sure obj is of right type, // setValue takes care of: Making sure obj is of right type,
// and firing property change. // and firing property change.
@ -116,79 +121,125 @@ public class GOEPanel extends JPanel implements ItemListener {
} }
}); });
saveButton = new JButton("Save"); saveButton = makeIconButton("resources/images/Save16.gif", "Save");
saveButton.setToolTipText("Save the current configured object"); saveButton.setToolTipText("Save the current configured object");
saveButton.setEnabled(true); saveButton.setEnabled(true);
saveButton.addActionListener(new ActionListener() { saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(final ActionEvent event) {
FileTools.saveObjectWithFileChooser(saveButton, genericObjectEditor.getValue()); FileTools.saveObjectWithFileChooser(saveButton, genericObjectEditor.getValue());
// saveObject(m_goe.getValue());
} }
}); });
okayButton = new JButton("OK"); okayButton = new JButton("OK");
okayButton.setEnabled(true); okayButton.setEnabled(true);
okayButton.addActionListener(new ActionListener() { okayButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
m_Backup = copyObject(genericObjectEditor.getValue()); @Override
// System.out.println("Backup is now " + BeanInspector.toString(m_Backup)); public void actionPerformed(final ActionEvent event) {
if ((getTopLevelAncestor() != null) && (getTopLevelAncestor() instanceof Window)) { backupObject = copyObject(genericObjectEditor.getValue());
Window w = (Window) getTopLevelAncestor();
w.dispose(); updateClassType();
updateChooser();
updateChildPropertySheet();
/*
* ToDo: This is really ugly. Find a way to make this better.
*/
Container container = GOEPanel.this.getParent();
while (!(container instanceof JDialog)) {
container = container.getParent();
} }
((JDialog) container).dispose();
} }
}); });
cancelButton = new JButton("Cancel"); cancelButton = new JButton("Cancel");
cancelButton.setEnabled(true); cancelButton.setEnabled(true);
cancelButton.addActionListener(new ActionListener() { cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (m_Backup != null) { @Override
// m_Object = copyObject(m_Backup); public void actionPerformed(final ActionEvent event) {
if (backupObject != null) {
// TODO m_goe.setObject(m_Object); // TODO m_goe.setObject(m_Object);
// System.out.println("Backup was " + BeanInspector.toString(m_Backup)); genericObjectEditor.setValue(copyObject(backupObject));
genericObjectEditor.setValue(copyObject(m_Backup));
updateClassType(); updateClassType();
updateChooser(); updateChooser();
updateChildPropertySheet(); updateChildPropertySheet();
} }
if ((getTopLevelAncestor() != null) /*
&& (getTopLevelAncestor() instanceof Window)) { * ToDo: This is really ugly. Find a way to make this better.
Window w = (Window) getTopLevelAncestor(); */
w.dispose(); Container container = GOEPanel.this.getParent();
while (!(container instanceof JDialog)) {
container = container.getParent();
} }
((JDialog) container).dispose();
} }
}); });
setLayout(new BorderLayout()); setLayout(new GridBagLayout());
add(m_ObjectChooser, BorderLayout.NORTH); // important GridBagConstraints gbConstraints = new GridBagConstraints();
//add(m_ChildPropertySheet, BorderLayout.CENTER); gbConstraints.fill = GridBagConstraints.HORIZONTAL;
// Since we resize to the size of the property sheet, a scrollpane isn't gbConstraints.gridx = 0;
// typically needed (O Rly?) gbConstraints.gridy = 0;
JScrollPane myScrollPane =new JScrollPane(m_ChildPropertySheet,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); add(objectChooser, gbConstraints);
gbConstraints.weightx = 1.0;
gbConstraints.weighty = 1.0;
gbConstraints.gridy = 1;
gbConstraints.gridheight = GridBagConstraints.RELATIVE;
gbConstraints.fill = GridBagConstraints.BOTH;
add(propertySheetPanel, gbConstraints);
myScrollPane.setBorder(null); JToolBar buttonBar = new JToolBar();
add(myScrollPane, BorderLayout.CENTER); buttonBar.setRollover(true);
buttonBar.setFloatable(false);
buttonBar.add(openButton);
buttonBar.add(saveButton);
/* Add spacer to the end of the line */
buttonBar.add(Box.createHorizontalGlue());
JPanel okcButs = new JPanel(); if (withCancel) {
okcButs.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); buttonBar.add(cancelButton);
okcButs.setLayout(new GridLayout(1, 4, 5, 5)); }
okcButs.add(openButton); buttonBar.add(okayButton);
okcButs.add(saveButton);
// okcButs.add(m_editSourceBut);
if (withCancel) okcButs.add(cancelButton);
okcButs.add(okayButton);
add(okcButs, BorderLayout.SOUTH); gbConstraints.weightx = 0.0;
gbConstraints.weighty = 0.0;
gbConstraints.gridy = 2;
gbConstraints.anchor = GridBagConstraints.LINE_START;
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
add(buttonBar, gbConstraints);
if (genericObjectEditor.getClassType() != null) { if (genericObjectEditor.getClassType() != null) {
updateClassType(); updateClassType();
updateChooser(); updateChooser();
updateChildPropertySheet(); updateChildPropertySheet();
} }
m_ObjectChooser.addItemListener(this); objectChooser.addItemListener(this);
}
/**
* This method is duplicated from EvAModuleButtonPanelMaker.
* ToDo: Refactor this.
*
* @param iconSrc
* @param title
* @return
*/
private JButton makeIconButton(final String iconSrc, final String title) {
JButton newButton;
byte[] bytes;
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false);
if (bytes == null) {
newButton = new JButton(title);
} else {
newButton = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
}
return newButton;
} }
public void setEnabledOkCancelButtons(boolean enabled) { public void setEnabledOkCancelButtons(boolean enabled) {
@ -197,7 +248,8 @@ public class GOEPanel extends JPanel implements ItemListener {
} }
/** /**
* Makes a copy of an object using serialization * Makes a copy of an object using serialization.
*
* @param source the object to copy * @param source the object to copy
* @return a copy of the source object * @return a copy of the source object
*/ */
@ -207,7 +259,7 @@ public class GOEPanel extends JPanel implements ItemListener {
// System.out.println("Copying " + BeanInspector.toString(source)); // System.out.println("Copying " + BeanInspector.toString(source));
SerializedObject so = new SerializedObject(source); SerializedObject so = new SerializedObject(source);
result = so.getObject(); result = so.getObject();
so=null; so = null;
} catch (Exception ex) { } catch (Exception ex) {
System.err.println("GenericObjectEditor: Problem making backup object"); System.err.println("GenericObjectEditor: Problem making backup object");
System.err.println(source.getClass().getName()); System.err.println(source.getClass().getName());
@ -217,7 +269,8 @@ public class GOEPanel extends JPanel implements ItemListener {
} }
/** /**
* This is used to hook an action listener to the ok button * This is used to hook an action listener to the ok button.
*
* @param a The action listener. * @param a The action listener.
*/ */
public void addOkListener(ActionListener a) { public void addOkListener(ActionListener a) {
@ -226,6 +279,7 @@ public class GOEPanel extends JPanel implements ItemListener {
/** /**
* This is used to hook an action listener to the cancel button * This is used to hook an action listener to the cancel button
*
* @param a The action listener. * @param a The action listener.
*/ */
public void addCancelListener(ActionListener a) { public void addCancelListener(ActionListener a) {
@ -234,6 +288,7 @@ public class GOEPanel extends JPanel implements ItemListener {
/** /**
* This is used to remove an action listener from the ok button * This is used to remove an action listener from the ok button
*
* @param a The action listener * @param a The action listener
*/ */
public void removeOkListener(ActionListener a) { public void removeOkListener(ActionListener a) {
@ -242,6 +297,7 @@ public class GOEPanel extends JPanel implements ItemListener {
/** /**
* This is used to remove an action listener from the cancel button * This is used to remove an action listener from the cancel button
*
* @param a The action listener * @param a The action listener
*/ */
public void removeCancelListener(ActionListener a) { public void removeCancelListener(ActionListener a) {
@ -249,71 +305,85 @@ public class GOEPanel extends JPanel implements ItemListener {
} }
public void setTarget(Object o) { public void setTarget(Object o) {
m_ChildPropertySheet.setTarget(o); propertySheetPanel.setTarget(o);
} }
/** /**
* *
*/ */
protected void updateClassType() { protected void updateClassType() {
if (TRACE) System.out.println("# updating class "+genericObjectEditor.getClassType().getName());
Vector<String> classesLongNames; Vector<String> classesLongNames;
ArrayList<Class<?>> instances = new ArrayList<Class<?>>(5); ArrayList<Class<?>> instances = new ArrayList<Class<?>>(5);
if (Proxy.isProxyClass(genericObjectEditor.getClassType())) { if (Proxy.isProxyClass(genericObjectEditor.getClassType())) {
if (TRACE) System.out.println("PROXY! original was " + ((RMIProxyLocal)Proxy.getInvocationHandler(((Proxy)genericObjectEditor.getValue()))).getOriginalClass().getName()); classesLongNames = new Vector<String>(GenericObjectEditor.getClassesFromProperties(((RMIProxyLocal) Proxy.getInvocationHandler(((Proxy) genericObjectEditor.getValue()))).getOriginalClass().getName(), null));
classesLongNames = new Vector<String>(GenericObjectEditor.getClassesFromProperties(((RMIProxyLocal)Proxy.getInvocationHandler(((Proxy)genericObjectEditor.getValue()))).getOriginalClass().getName(), null));
} else { } else {
classesLongNames = new Vector<String>(GenericObjectEditor.getClassesFromProperties(genericObjectEditor.getClassType().getName(), instances)); classesLongNames = new Vector<String>(GenericObjectEditor.getClassesFromProperties(genericObjectEditor.getClassType().getName(), instances));
} }
if (classesLongNames.size() > 1) { if (classesLongNames.size() > 1) {
m_ObjectChooser.setModel(new DefaultComboBoxModel(classesLongNames)); objectChooser.setModel(new DefaultComboBoxModel(classesLongNames));
if (withComboBoxToolTips) m_ObjectChooser.setRenderer(new ToolTipComboBoxRenderer(collectComboToolTips(instances, tipMaxLen) )); if (withComboBoxToolTips) {
add(m_ObjectChooser, BorderLayout.NORTH); objectChooser.setRenderer(new ToolTipComboBoxRenderer(collectComboToolTips(instances, tipMaxLen)));
} else remove(m_ObjectChooser); }
if (TRACE) System.out.println("# done updating class "+genericObjectEditor.getClassType().getName()); GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.gridx = 0;
gbConstraints.gridy = 0;
add(objectChooser, gbConstraints);
} else {
remove(objectChooser);
}
} }
private String[] collectComboToolTips(List<Class<?>> instances, int maxLen) { private String[] collectComboToolTips(List<Class<?>> instances, int maxLen) {
String[] tips = new String[instances.size()]; String[] tips = new String[instances.size()];
for (int i=0; i<tips.length; i++) { for (int i = 0; i < tips.length; i++) {
tips[i]=null; tips[i] = null;
Class[] classParams = new Class[]{}; Class[] classParams = new Class[]{};
try { try {
String tip=null; String tip = null;
Method giMeth = instances.get(i).getDeclaredMethod("globalInfo", classParams); Method giMeth = instances.get(i).getDeclaredMethod("globalInfo", classParams);
if (Modifier.isStatic(giMeth.getModifiers())) { if (Modifier.isStatic(giMeth.getModifiers())) {
tip = (String)giMeth.invoke(null, (Object[])null); tip = (String) giMeth.invoke(null, (Object[]) null);
} }
if (tip!=null) { if (tip != null) {
if (tip.length()<=maxLen) tips[i]=tip; if (tip.length() <= maxLen) {
else tips[i] = tip.substring(0,maxLen-2)+".."; tips[i] = tip;
} else {
tips[i] = tip.substring(0, maxLen - 2) + "..";
}
}
} catch (Exception e) {
} }
} catch (Exception e) {}
} }
return tips; return tips;
} }
protected void updateChooser() { protected void updateChooser() {
String objectName = /*EVAHELP.cutClassName*/ (genericObjectEditor.getValue().getClass().getName()); String objectName = /*
* EVAHELP.cutClassName
*/ (genericObjectEditor.getValue().getClass().getName());
boolean found = false; boolean found = false;
for (int i = 0; i < m_ObjectNames.getSize(); i++) { for (int i = 0; i < comboBoxModel.getSize(); i++) {
if (TRACE) System.out.println("in updateChooser: looking at "+(String)m_ObjectNames.getElementAt(i)); if (TRACE) {
if (objectName.equals((String)m_ObjectNames.getElementAt(i))) { System.out.println("in updateChooser: looking at " + (String) comboBoxModel.getElementAt(i));
}
if (objectName.equals((String) comboBoxModel.getElementAt(i))) {
found = true; found = true;
break; break;
} }
} }
if (!found) if (!found) {
m_ObjectNames.addElement(objectName); comboBoxModel.addElement(objectName);
m_ObjectChooser.getModel().setSelectedItem(objectName); }
objectChooser.getModel().setSelectedItem(objectName);
} }
/**
/** Updates the child property sheet, and creates if needed */ * Updates the child property sheet, and creates if needed
*/
public void updateChildPropertySheet() { public void updateChildPropertySheet() {
//System.err.println("GOE::updateChildPropertySheet()");
// Set the object as the target of the propertysheet // Set the object as the target of the propertysheet
m_ChildPropertySheet.setTarget(genericObjectEditor.getValue()); propertySheetPanel.setTarget(genericObjectEditor.getValue());
// Adjust size of containing window if possible // Adjust size of containing window if possible
if ((getTopLevelAncestor() != null) if ((getTopLevelAncestor() != null)
&& (getTopLevelAncestor() instanceof Window)) { && (getTopLevelAncestor() instanceof Window)) {
@ -322,30 +392,25 @@ public class GOEPanel extends JPanel implements ItemListener {
} }
/** /**
* When the chooser selection is changed, ensures that the Object * When the chooser selection is changed, ensures that the Object is changed appropriately.
* is changed appropriately.
* *
* @param e a value of type 'ItemEvent' * @param e a value of type 'ItemEvent'
*/ */
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
String className = (String)m_ObjectChooser.getSelectedItem(); String className;
if (TRACE) System.out.println("Event-Quelle: " + e.getSource().toString()); if ((e.getSource() == objectChooser) && (e.getStateChange() == ItemEvent.SELECTED)) {
if ((e.getSource() == m_ObjectChooser) && (e.getStateChange() == ItemEvent.SELECTED)){ className = (String) objectChooser.getSelectedItem();
className = (String)m_ObjectChooser.getSelectedItem();
try { try {
if (TRACE) System.out.println(className); Object n = (Object) Class.forName(className).newInstance();
// Object n = (Object)Class.forName(className, true, this.getClass().getClassLoader()).newInstance();
Object n = (Object)Class.forName(className).newInstance();
genericObjectEditor.setValue(n); genericObjectEditor.setValue(n);
// TODO ? setObject(n); // TODO ? setObject(n);
} catch (Exception ex) { } catch (Exception ex) {
System.err.println("Exeption in itemStateChanged "+ex.getMessage()); System.err.println("Exeption in itemStateChanged " + ex.getMessage());
System.err.println("Classpath is " + System.getProperty("java.class.path")); System.err.println("Classpath is " + System.getProperty("java.class.path"));
ex.printStackTrace(); ex.printStackTrace();
m_ObjectChooser.hidePopup(); objectChooser.hidePopup();
m_ObjectChooser.setSelectedIndex(0); objectChooser.setSelectedIndex(0);
JOptionPane.showMessageDialog(this, JOptionPane.showMessageDialog(this,
"Could not create an example of\n" "Could not create an example of\n"
+ className + "\n" + className + "\n"
@ -359,12 +424,13 @@ public class GOEPanel extends JPanel implements ItemListener {
} }
class ToolTipComboBoxRenderer extends BasicComboBoxRenderer { class ToolTipComboBoxRenderer extends BasicComboBoxRenderer {
private static final long serialVersionUID = -5781643352198561208L; private static final long serialVersionUID = -5781643352198561208L;
String[] toolTips = null; String[] toolTips = null;
public ToolTipComboBoxRenderer(String[] tips) { public ToolTipComboBoxRenderer(String[] tips) {
super(); super();
toolTips=tips; toolTips = tips;
} }
@Override @Override
@ -373,8 +439,10 @@ class ToolTipComboBoxRenderer extends BasicComboBoxRenderer {
if (isSelected) { if (isSelected) {
setBackground(list.getSelectionBackground()); setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground()); setForeground(list.getSelectionForeground());
if ((toolTips!=null) && (index >= 0)) { if ((toolTips != null) && (index >= 0)) {
if (toolTips[index]!=null) list.setToolTipText(toolTips[index]); if (toolTips[index] != null) {
list.setToolTipText(toolTips[index]);
}
} }
} else { } else {
setBackground(list.getBackground()); setBackground(list.getBackground());

View File

@ -1,34 +1,14 @@
package eva2.gui; package eva2.gui;
/* /*
* Title: EvA2 * Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
* Description: * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 235
* Copyright: Copyright (c) 2003 * $ $Date: 2007-11-08 13:53:51 +0100 (Thu, 08 Nov 2007) $ $Author: mkron $
* Company: University of Tuebingen, Computer Architecture
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
* @version: $Revision: 235 $
* $Date: 2007-11-08 13:53:51 +0100 (Thu, 08 Nov 2007) $
* $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import eva2.tools.EVAHELP;
import java.awt.BorderLayout; import eva2.tools.SerializedObject;
import java.awt.Component; import java.awt.*;
import java.awt.Dimension; import java.awt.event.*;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeSupport;
@ -36,80 +16,80 @@ import java.beans.PropertyEditor;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.swing.*;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.SwingConstants;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import eva2.tools.EVAHELP; public class GenericArrayEditor extends JPanel implements PropertyEditor {
import eva2.tools.SerializedObject;
/*==========================================================================* /**
* CLASS DECLARATION * Handles property change notification
*==========================================================================*/ */
public class GenericArrayEditor extends JPanel
implements PropertyEditor {
/** Handles property change notification */
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
/** The label for when we can't edit that type */ /**
* The label for when we can't edit that type
*/
private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER);
/** The list component displaying current values */ /**
* The list component displaying current values
*/
private JList m_ElementList = new JList(); private JList m_ElementList = new JList();
/** The class of objects allowed in the array */ /**
* The class of objects allowed in the array
*/
private Class m_ElementClass = String.class; private Class m_ElementClass = String.class;
/** The defaultlistmodel holding our data */ /**
* The defaultlistmodel holding our data
*/
private DefaultListModel m_ListModel; private DefaultListModel m_ListModel;
/** The property editor for the class we are editing */ /**
* The property editor for the class we are editing
*/
private PropertyEditor m_ElementEditor; private PropertyEditor m_ElementEditor;
/** Cheat to handle selectable lists as well */ /**
* Cheat to handle selectable lists as well
*/
private PropertySelectableList selectableList = null; private PropertySelectableList selectableList = null;
/** Click this to delete the selected array values */ /**
* Click this to delete the selected array values
*/
private JButton m_DeleteBut = new JButton("Delete"); private JButton m_DeleteBut = new JButton("Delete");
/** list of additional buttons above the list */ /**
* list of additional buttons above the list
*/
private List<JButton> m_AdditionalUpperButtonList = new LinkedList<JButton>(); private List<JButton> m_AdditionalUpperButtonList = new LinkedList<JButton>();
/** list of additional buttons below the list */ /**
* list of additional buttons below the list
*/
private List<JButton> m_AdditionalLowerButtonList = new LinkedList<JButton>(); private List<JButton> m_AdditionalLowerButtonList = new LinkedList<JButton>();
private JComponent additionalCenterComp = null;
private JPanel additionalCenterPane = null;
private List<JMenuItem> m_popupItemList = new LinkedList<JMenuItem>(); private List<JMenuItem> m_popupItemList = new LinkedList<JMenuItem>();
private JButton m_AddBut = new JButton("Add"); private JButton m_AddBut = new JButton("Add");
private JButton m_SetBut = new JButton("Set"); private JButton m_SetBut = new JButton("Set");
private JButton m_SetAllBut = new JButton("Set all"); private JButton m_SetAllBut = new JButton("Set all");
private boolean withAddButton = true; private boolean withAddButton = true;
private boolean withSetButton = true; private boolean withSetButton = true;
private boolean withDeleteButton = true; private boolean withDeleteButton = true;
private Component m_View = null; private Component m_View = null;
/** Listens to buttons being pressed and taking the appropriate action */ /**
* Listens to buttons being pressed and taking the appropriate action
*/
private ActionListener m_InnerActionListener = private ActionListener m_InnerActionListener =
new ActionListener() { new ActionListener() {
// //
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
boolean consistentView = true; // be optimistic... boolean consistentView = true; // be optimistic...
if (m_View instanceof PropertyText) { // check consistency! if (m_View instanceof PropertyText) { // check consistency!
consistentView = ((PropertyText)m_View).checkConsistency(); consistentView = ((PropertyText) m_View).checkConsistency();
if (!consistentView) { if (!consistentView) {
// System.err.println("Warning, inconsistent view!"); ((PropertyText) m_View).updateFromEditor();
((PropertyText)m_View).updateFromEditor();
} }
} }
if (e.getSource() == m_DeleteBut) { if (e.getSource() == m_DeleteBut) {
int [] selected = m_ElementList.getSelectedIndices(); int[] selected = m_ElementList.getSelectedIndices();
if (selected != null) { if (selected != null) {
for (int i = selected.length-1; i>=0; i--) { for (int i = selected.length - 1; i >= 0; i--) {
int current = selected[i]; int current = selected[i];
m_ListModel.removeElementAt(current); m_ListModel.removeElementAt(current);
if (m_ListModel.size() > current) { if (m_ListModel.size() > current) {
@ -118,7 +98,9 @@ implements PropertyEditor {
m_ElementList.setModel(m_ListModel); m_ElementList.setModel(m_ListModel);
} }
if (selectableList!=null) selectableList.setObjects(modelToArray(selectableList.getObjects(), m_ListModel)); if (selectableList != null) {
selectableList.setObjects(modelToArray(selectableList.getObjects(), m_ListModel));
}
m_Support.firePropertyChange("", null, null); m_Support.firePropertyChange("", null, null);
} }
if (m_ElementList.getSelectedIndex() == -1) { if (m_ElementList.getSelectedIndex() == -1) {
@ -132,36 +114,38 @@ implements PropertyEditor {
try { try {
SerializedObject so = new SerializedObject(addObj); SerializedObject so = new SerializedObject(addObj);
addObj = so.getObject(); addObj = so.getObject();
so=null; so = null;
if (selected != -1) { if (selected != -1) {
m_ListModel.insertElementAt(addObj, selected); m_ListModel.insertElementAt(addObj, selected);
} else { } else {
m_ListModel.addElement(addObj); m_ListModel.addElement(addObj);
} }
m_ElementList.setModel(m_ListModel); m_ElementList.setModel(m_ListModel);
if (selectableList!=null) selectableList.setObjects(modelToArray(selectableList.getObjects(), m_ListModel)); if (selectableList != null) {
selectableList.setObjects(modelToArray(selectableList.getObjects(), m_ListModel));
}
m_Support.firePropertyChange("", null, null); m_Support.firePropertyChange("", null, null);
} catch (Exception ex) { } catch (Exception ex) {
JOptionPane.showMessageDialog(GenericArrayEditor.this,"Could not create an object copy",null,JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(GenericArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE);
} }
} else if (e.getSource() == m_SetAllBut) { } else if (e.getSource() == m_SetAllBut) {
Object addObj = m_ElementEditor.getValue(); Object addObj = m_ElementEditor.getValue();
for (int i=0; i<m_ListModel.size(); i++) { for (int i = 0; i < m_ListModel.size(); i++) {
try { try {
m_ListModel.setElementAt(new SerializedObject(addObj).getObject(), i); m_ListModel.setElementAt(new SerializedObject(addObj).getObject(), i);
} catch (Exception e1) { } catch (Exception e1) {
JOptionPane.showMessageDialog(GenericArrayEditor.this,"Could not create an object copy",null,JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(GenericArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE);
} }
} }
m_Support.firePropertyChange("", null, null); m_Support.firePropertyChange("", null, null);
} else if (e.getSource() == m_SetBut) { } else if (e.getSource() == m_SetBut) {
int selected = m_ElementList.getSelectedIndex(); int selected = m_ElementList.getSelectedIndex();
Object addObj = m_ElementEditor.getValue(); Object addObj = m_ElementEditor.getValue();
if (selected>=0 && (selected <m_ListModel.size())) { if (selected >= 0 && (selected < m_ListModel.size())) {
try { try {
m_ListModel.setElementAt(new SerializedObject(addObj).getObject(), selected); m_ListModel.setElementAt(new SerializedObject(addObj).getObject(), selected);
} catch (Exception e1) { } catch (Exception e1) {
JOptionPane.showMessageDialog(GenericArrayEditor.this,"Could not create an object copy",null,JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(GenericArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE);
} }
m_Support.firePropertyChange("", null, null); m_Support.firePropertyChange("", null, null);
} }
@ -169,8 +153,8 @@ implements PropertyEditor {
} }
}; };
public void setAdditionalCenterPane(JPanel panel) { public void setAdditionalCenterPane(JComponent component) {
this.additionalCenterPane = panel; this.additionalCenterComp = component;
} }
private Object[] modelToArray(Object[] origArray, DefaultListModel listModel) { private Object[] modelToArray(Object[] origArray, DefaultListModel listModel) {
@ -178,16 +162,18 @@ implements PropertyEditor {
Object[] os = (Object[]) java.lang.reflect.Array.newInstance(objClass, listModel.size()); Object[] os = (Object[]) java.lang.reflect.Array.newInstance(objClass, listModel.size());
// Object[] os= new Object[listModel.size()]; // Object[] os= new Object[listModel.size()];
for (int i=0; i<listModel.size(); i++) { for (int i = 0; i < listModel.size(); i++) {
os[i]=listModel.get(i); os[i] = listModel.get(i);
} }
return os; return os;
} }
/**
/** Listens to list items being selected and takes appropriate action */ * Listens to list items being selected and takes appropriate action
*/
private ListSelectionListener m_InnerSelectionListener = private ListSelectionListener m_InnerSelectionListener =
new ListSelectionListener() { new ListSelectionListener() {
// //
public void valueChanged(ListSelectionEvent e) { public void valueChanged(ListSelectionEvent e) {
if (e.getSource() == m_ElementList) { if (e.getSource() == m_ElementList) {
@ -195,7 +181,9 @@ implements PropertyEditor {
if (m_ElementList.getSelectedIndex() != -1) { if (m_ElementList.getSelectedIndex() != -1) {
m_DeleteBut.setEnabled(true); m_DeleteBut.setEnabled(true);
m_ElementEditor.setValue(m_ElementList.getSelectedValue()); m_ElementEditor.setValue(m_ElementList.getSelectedValue());
if (m_View instanceof PropertyText) ((PropertyText)m_View).updateFromEditor(); if (m_View instanceof PropertyText) {
((PropertyText) m_View).updateFromEditor();
}
} }
} }
} }
@ -222,63 +210,53 @@ implements PropertyEditor {
} }
private class ActionJList extends MouseAdapter { private class ActionJList extends MouseAdapter {
protected JList list; protected JList list;
GenericArrayEditor gae=null; GenericArrayEditor gae = null;
// PropertyPanel propPanel=null; // PropertyPanel propPanel=null;
public ActionJList(JList l, GenericArrayEditor genAE) {
public ActionJList(JList l, GenericArrayEditor genAE){
list = l; list = l;
gae=genAE; gae = genAE;
// if (pPan instanceof PropertyPanel ) propPanel = (PropertyPanel) pPan;
// else {
// System.err.println("Error, invalid property panel in " + this.getClass());
// }
} }
public void mouseClicked(MouseEvent e){ public void mouseClicked(MouseEvent e) {
if(e.getClickCount() == 2){ if (e.getClickCount() == 2) {
int index = list.locationToIndex(e.getPoint()); int index = list.locationToIndex(e.getPoint());
// Check if the index is valid and if the indexed cell really contains the clicked point // Check if the index is valid and if the indexed cell really contains the clicked point
if (index>=0 && (list.getCellBounds(index, index).contains(e.getPoint()))) { if (index >= 0 && (list.getCellBounds(index, index).contains(e.getPoint()))) {
PropertyPanel propPanel=null; PropertyPanel propPanel = null;
Component comp = gae.m_View; Component comp = gae.m_View;
if (comp instanceof PropertyPanel ) propPanel = (PropertyPanel) comp; if (comp instanceof PropertyPanel) {
else System.err.println("Error, invalid property panel in " + this.getClass()); propPanel = (PropertyPanel) comp;
} else {
System.err.println("Error, invalid property panel in " + this.getClass());
}
ListModel dlm = list.getModel(); ListModel dlm = list.getModel();
Object item = dlm.getElementAt(index); Object item = dlm.getElementAt(index);
list.ensureIndexIsVisible(index); list.ensureIndexIsVisible(index);
// System.out.println(e);
// System.out.println("Double clicked on " + item);
propPanel.getEditor().setValue(item); propPanel.getEditor().setValue(item);
propPanel.showDialog(e.getXOnScreen(), e.getYOnScreen()); propPanel.showDialog(e.getXOnScreen(), e.getYOnScreen());
propPanel=null; propPanel = null;
// int x = getLocationOnScreen().x;
// int y = getLocationOnScreen().y;
// if (m_PropertyDialog == null)
// m_PropertyDialog = new PropertyDialog(gae.m_ElementEditor, EVAHELP.cutClassName(gae.m_ElementEditor.getClass().getName()) , x, y);
// else {
// m_PropertyDialog.updateFrameTitle(gae.m_ElementEditor);
// m_PropertyDialog.set
// m_PropertyDialog.setVisible(false);
// m_PropertyDialog.setExtendedState(JFrame.NORMAL);
// m_PropertyDialog.setVisible(true);
// m_PropertyDialog.requestFocus();
// }
} }
} }
} }
} }
/* This class handles the creation of list cell renderers from the /*
* property editors. * This class handles the creation of list cell renderers from the property editors.
*/ */
private class EditorListCellRenderer implements ListCellRenderer { private class EditorListCellRenderer implements ListCellRenderer {
/** The class of the property editor for array objects */
/**
* The class of the property editor for array objects
*/
private Class m_EditorClass; private Class m_EditorClass;
/** The class of the array values */ /**
* The class of the array values
*/
private Class m_ValueClass; private Class m_ValueClass;
/** /**
* Creates the list cell renderer. * Creates the list cell renderer.
* *
@ -289,6 +267,7 @@ implements PropertyEditor {
m_EditorClass = editorClass; m_EditorClass = editorClass;
m_ValueClass = valueClass; m_ValueClass = valueClass;
} }
/** /**
* Creates a cell rendering component. * Creates a cell rendering component.
* *
@ -305,29 +284,25 @@ implements PropertyEditor {
final boolean isSelected, final boolean isSelected,
final boolean cellHasFocus) { final boolean cellHasFocus) {
try { try {
final PropertyEditor e = (PropertyEditor)m_EditorClass.newInstance(); final PropertyEditor e = (PropertyEditor) m_EditorClass.newInstance();
if (e instanceof GenericObjectEditor) { if (e instanceof GenericObjectEditor) {
// ((GenericObjectEditor) e).setDisplayOnly(true); // ((GenericObjectEditor) e).setDisplayOnly(true);
((GenericObjectEditor) e).setClassType(m_ValueClass); ((GenericObjectEditor) e).setClassType(m_ValueClass);
} }
e.setValue(value); e.setValue(value);
JPanel cellPanel = new JPanel() { JPanel cellPanel = new JPanel() {
// return new JCheckBox("", isSelected) {
// public void paintComponent(Graphics g) {
// String name = (String)BeanInspector.callIfAvailable(value, "getName", new Object[]{});
// if (name==null) setText(value.getClass().getSimpleName());
// else setText(name);
// super.paintComponent(g);
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
Insets i = this.getInsets(); Insets i = this.getInsets();
Rectangle box = new Rectangle(i.left,i.top, Rectangle box = new Rectangle(i.left, i.top,
this.getWidth(), //- i.right, this.getWidth(), //- i.right,
this.getHeight() );//- i.bottom +20); this.getHeight());//- i.bottom +20);
g.setColor(isSelected ? list.getSelectionBackground() : list.getBackground()); g.setColor(isSelected ? list.getSelectionBackground() : list.getBackground());
g.fillRect(0, 0, this.getWidth(), this.getHeight()); g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.setColor(isSelected ? list.getSelectionForeground(): list.getForeground()); g.setColor(isSelected ? list.getSelectionForeground() : list.getForeground());
e.paintValue(g, box); e.paintValue(g, box);
} }
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Font f = this.getFont(); Font f = this.getFont();
FontMetrics fm = this.getFontMetrics(f); FontMetrics fm = this.getFontMetrics(f);
@ -345,8 +320,7 @@ implements PropertyEditor {
} }
/** /**
* Updates the type of object being edited, so attempts to find an * Updates the type of object being edited, so attempts to find an appropriate propertyeditor.
* appropriate propertyeditor.
* *
* @param o a value of type 'Object' * @param o a value of type 'Object'
*/ */
@ -361,12 +335,16 @@ implements PropertyEditor {
if ((obj != null) && (obj.getClass().isArray() || (obj instanceof PropertySelectableList))) { if ((obj != null) && (obj.getClass().isArray() || (obj instanceof PropertySelectableList))) {
Object arrayInstance = obj; Object arrayInstance = obj;
if (!(obj.getClass().isArray())) { if (!(obj.getClass().isArray())) {
arrayInstance=((PropertySelectableList)obj).getObjects(); arrayInstance = ((PropertySelectableList) obj).getObjects();
selectableList = (PropertySelectableList)obj; selectableList = (PropertySelectableList) obj;
} else selectableList = null; } else {
selectableList = null;
}
Class elementClass = arrayInstance.getClass().getComponentType(); Class elementClass = arrayInstance.getClass().getComponentType();
PropertyEditor editor = PropertyEditorProvider.findEditor(elementClass); PropertyEditor editor = PropertyEditorProvider.findEditor(elementClass);
if (editor instanceof EnumEditor) editor.setValue(obj); if (editor instanceof EnumEditor) {
editor.setValue(obj);
}
m_View = null; m_View = null;
ListCellRenderer lcr = new DefaultListCellRenderer(); ListCellRenderer lcr = new DefaultListCellRenderer();
if (editor != null) { if (editor != null) {
@ -393,7 +371,7 @@ implements PropertyEditor {
m_ListModel = new DefaultListModel(); m_ListModel = new DefaultListModel();
m_ElementClass = elementClass; m_ElementClass = elementClass;
for (int i = 0; i < Array.getLength(arrayInstance); i++) { for (int i = 0; i < Array.getLength(arrayInstance); i++) {
m_ListModel.addElement(Array.get(arrayInstance,i)); m_ListModel.addElement(Array.get(arrayInstance, i));
} }
m_ElementList.setCellRenderer(lcr); m_ElementList.setCellRenderer(lcr);
m_ElementList.setModel(m_ListModel); m_ElementList.setModel(m_ListModel);
@ -409,48 +387,69 @@ implements PropertyEditor {
m_ElementEditor.setValue(m_ListModel.getElementAt(0)); m_ElementEditor.setValue(m_ListModel.getElementAt(0));
} else { } else {
if (m_ElementEditor instanceof GenericObjectEditor) { if (m_ElementEditor instanceof GenericObjectEditor) {
((GenericObjectEditor)m_ElementEditor).setDefaultValue(); ((GenericObjectEditor) m_ElementEditor).setDefaultValue();
} else { } else {
if (m_ElementEditor.getValue()!=null) { if (m_ElementEditor.getValue() != null) {
m_ElementEditor.setValue(m_ElementClass.newInstance()); m_ElementEditor.setValue(m_ElementClass.newInstance());
} }
} }
} }
setPreferredSize(new Dimension(300,400)); //setPreferredSize(new Dimension(400,500));
// JPanel panel = new JPanel();
// panel.setLayout(new BorderLayout());
// panel.add(view, BorderLayout.CENTER);
// panel.add(m_AddBut, BorderLayout.EAST);
// JPanel buttonPanel=new JPanel(new FlowLayout());
if (withAddButton && !(m_AdditionalUpperButtonList.contains(m_AddBut))) m_AdditionalUpperButtonList.add(m_AddBut); if (withAddButton && !(m_AdditionalUpperButtonList.contains(m_AddBut))) {
if (withSetButton && !(m_AdditionalUpperButtonList.contains(m_SetBut))) m_AdditionalUpperButtonList.add(m_SetBut); m_AdditionalUpperButtonList.add(m_AddBut);
if (withSetButton && !(m_AdditionalUpperButtonList.contains(m_SetAllBut))) m_AdditionalUpperButtonList.add(m_SetAllBut); }
if (withSetButton && !(m_AdditionalUpperButtonList.contains(m_SetBut))) {
m_AdditionalUpperButtonList.add(m_SetBut);
}
if (withSetButton && !(m_AdditionalUpperButtonList.contains(m_SetAllBut))) {
m_AdditionalUpperButtonList.add(m_SetAllBut);
}
// Upper Button Panel
JPanel combiUpperPanel = new JPanel(getButtonLayout(1, m_AdditionalUpperButtonList)); JPanel combiUpperPanel = new JPanel(getButtonLayout(1, m_AdditionalUpperButtonList));
combiUpperPanel.add(m_View ); combiUpperPanel.add(m_View);
for (JButton but : m_AdditionalUpperButtonList) { for (JButton but : m_AdditionalUpperButtonList) {
combiUpperPanel.add(but); combiUpperPanel.add(but);
} }
add(combiUpperPanel, BorderLayout.NORTH);
if (additionalCenterPane==null) add(new JScrollPane(m_ElementList), BorderLayout.CENTER);
else {
JPanel centerPane=new JPanel();
centerPane.setLayout(new GridLayout(2, 1));
centerPane.add(new JScrollPane(m_ElementList));
centerPane.add(additionalCenterPane);
add(centerPane, BorderLayout.CENTER);
}
if (withDeleteButton && !m_AdditionalLowerButtonList.contains(m_DeleteBut)) m_AdditionalLowerButtonList.add(m_DeleteBut); setLayout(new GridBagLayout());
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.gridx = 0;
gbConstraints.gridy = 0;
add(combiUpperPanel, gbConstraints);
// Job List
gbConstraints.gridy++;
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
add(new JScrollPane(m_ElementList), gbConstraints);
// Lower Button Panel
if (withDeleteButton && !m_AdditionalLowerButtonList.contains(m_DeleteBut)) {
m_AdditionalLowerButtonList.add(m_DeleteBut);
}
JPanel combiLowerPanel = new JPanel(getButtonLayout(0, m_AdditionalLowerButtonList)); JPanel combiLowerPanel = new JPanel(getButtonLayout(0, m_AdditionalLowerButtonList));
for (JButton but : m_AdditionalLowerButtonList) { for (JButton but : m_AdditionalLowerButtonList) {
combiLowerPanel.add(but); combiLowerPanel.add(but);
} }
add(combiLowerPanel, BorderLayout.SOUTH); gbConstraints.gridy++;
add(combiLowerPanel, gbConstraints);
// Additional Center Panel (e.g. PropertySheetPanel)
if (additionalCenterComp != null) {
gbConstraints.weightx = 1.0;
gbConstraints.weighty = 1.0;
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.gridy++;
add(additionalCenterComp, gbConstraints);
}
m_ElementEditor.addPropertyChangeListener(new PropertyChangeListener() { m_ElementEditor.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
repaint(); repaint();
} }
@ -472,15 +471,15 @@ implements PropertyEditor {
} }
/** /**
* Make a fitting grid layout for a list of buttons. An additional offset may be given * Make a fitting grid layout for a list of buttons. An additional offset may be given if
* if further components should be added besides the buttons. * further components should be added besides the buttons.
* *
* @param additionalOffset * @param additionalOffset
* @param bList * @param bList
* @return * @return
*/ */
private LayoutManager getButtonLayout(int additionalOffset, List<JButton> bList) { private LayoutManager getButtonLayout(int additionalOffset, List<JButton> bList) {
int lines = 1+((bList.size()+additionalOffset-1)/3); int lines = 1 + ((bList.size() + additionalOffset - 1) / 3);
int cols = 3; int cols = 3;
return new GridLayout(lines, cols); return new GridLayout(lines, cols);
} }
@ -501,7 +500,9 @@ implements PropertyEditor {
break; break;
} }
} }
if (but!=null) bList.remove(but); if (but != null) {
bList.remove(but);
}
} }
public void addUpperActionButton(String text, ActionListener al) { public void addUpperActionButton(String text, ActionListener al) {
@ -509,15 +510,17 @@ implements PropertyEditor {
} }
/** /**
* Wrap an action listener such that the selection state will always be up to date * Wrap an action listener such that the selection state will always be up to date in the
* in the selectableList (if it exists). * selectableList (if it exists).
*
* @param al * @param al
* @return * @return
*/ */
private ActionListener makeSelectionKnownAL(final ActionListener al) { private ActionListener makeSelectionKnownAL(final ActionListener al) {
return new ActionListener() { return new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (selectableList!=null) { if (selectableList != null) {
selectableList.setSelectionByIndices(m_ElementList.getSelectedIndices()); selectableList.setSelectionByIndices(m_ElementList.getSelectedIndices());
} }
al.actionPerformed(e); al.actionPerformed(e);
@ -549,13 +552,18 @@ implements PropertyEditor {
* Select all items. If all are selected, then deselect all items. * Select all items. If all are selected, then deselect all items.
*/ */
public void selectDeselectAll() { public void selectDeselectAll() {
if (areAllSelected()) m_ElementList.getSelectionModel().clearSelection(); if (areAllSelected()) {
else m_ElementList.setSelectionInterval(0, m_ElementList.getModel().getSize()-1); m_ElementList.getSelectionModel().clearSelection();
} else {
m_ElementList.setSelectionInterval(0, m_ElementList.getModel().getSize() - 1);
}
} }
public boolean areAllSelected() { public boolean areAllSelected() {
for (int i=0; i<m_ElementList.getModel().getSize(); i++) { for (int i = 0; i < m_ElementList.getModel().getSize(); i++) {
if (!m_ElementList.isSelectedIndex(i)) return false; if (!m_ElementList.isSelectedIndex(i)) {
return false;
}
} }
return true; return true;
} }
@ -569,7 +577,7 @@ implements PropertyEditor {
if (m_ListModel == null) { if (m_ListModel == null) {
return null; return null;
} }
if (selectableList!=null) { if (selectableList != null) {
return selectableList; return selectableList;
} else { } else {
// Convert the listmodel to an array of strings and return it. // Convert the listmodel to an array of strings and return it.
@ -588,17 +596,20 @@ implements PropertyEditor {
} }
public void addPopupMenu() { public void addPopupMenu() {
if (m_popupItemList.size()>0) { if (m_popupItemList.size() > 0) {
m_ElementList.addMouseListener(new MouseAdapter() { m_ElementList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (selectableList!=null) { if (selectableList != null) {
selectableList.setSelectionByIndices(m_ElementList.getSelectedIndices()); selectableList.setSelectionByIndices(m_ElementList.getSelectedIndices());
} }
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) { if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) {
// do nothing // do nothing
} else { // right click released, so show popup } else { // right click released, so show popup
JPopupMenu popupMenu = new JPopupMenu(); JPopupMenu popupMenu = new JPopupMenu();
for (JMenuItem item : m_popupItemList) popupMenu.add(item); for (JMenuItem item : m_popupItemList) {
popupMenu.add(item);
}
popupMenu.show(GenericArrayEditor.this, e.getX(), e.getY()); popupMenu.show(GenericArrayEditor.this, e.getX(), e.getY());
} }
} }
@ -607,8 +618,8 @@ implements PropertyEditor {
} }
/** /**
* Create a menu item with given title and listener, add it to the menu and * Create a menu item with given title and listener, add it to the menu and return it. It may be
* return it. It may be enabled or disabled. * enabled or disabled.
* *
* @param menu * @param menu
* @param title * @param title
@ -626,10 +637,9 @@ implements PropertyEditor {
} }
/** /**
* Supposedly returns an initialization string to create a classifier * Supposedly returns an initialization string to create a classifier identical to the current
* identical to the current one, including it's state, but this doesn't * one, including it's state, but this doesn't appear possible given that the initialization
* appear possible given that the initialization string isn't supposed to * string isn't supposed to contain multiple statements.
* contain multiple statements.
* *
* @return the java source code initialisation string * @return the java source code initialisation string
*/ */
@ -638,8 +648,7 @@ implements PropertyEditor {
} }
/** /**
* Returns true to indicate that we can paint a representation of the * Returns true to indicate that we can paint a representation of the string array
* string array
* *
* @return true * @return true
*/ */
@ -658,40 +667,46 @@ implements PropertyEditor {
int vpad = (box.height - fm.getAscent()) / 2; int vpad = (box.height - fm.getAscent()) / 2;
// System.out.println(m_ListModel + " --- " + m_ElementClass); // System.out.println(m_ListModel + " --- " + m_ElementClass);
String rep; String rep;
if (m_ListModel.getSize() == 0) rep="Empty"; if (m_ListModel.getSize() == 0) {
else { rep = "Empty";
} else {
rep = m_ListModel.getSize() + " of " + EVAHELP.cutClassName(m_ElementClass.getName()); rep = m_ListModel.getSize() + " of " + EVAHELP.cutClassName(m_ElementClass.getName());
Object maybeName = BeanInspector.callIfAvailable(m_ListModel.get(0), "getName", new Object[]{}); Object maybeName = BeanInspector.callIfAvailable(m_ListModel.get(0), "getName", new Object[]{});
if (maybeName!=null) { if (maybeName != null) {
rep = rep + " ("+(String)maybeName + "...)"; rep = rep + " (" + (String) maybeName + "...)";
} }
} }
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
} }
/** /**
* *
*/ */
public String getAsText() { public String getAsText() {
return null; return null;
} }
/** /**
* *
*/ */
public void setAsText(String text) throws IllegalArgumentException { public void setAsText(String text) throws IllegalArgumentException {
throw new IllegalArgumentException(text); throw new IllegalArgumentException(text);
} }
/** /**
* *
*/ */
public String[] getTags() { public String[] getTags() {
return null; return null;
} }
/** /**
* *
*/ */
public boolean supportsCustomEditor() { public boolean supportsCustomEditor() {
return true; return true;
} }
/** /**
* *
*/ */
@ -700,52 +715,31 @@ implements PropertyEditor {
} }
public void addPropertyChangeListener(PropertyChangeListener l) { public void addPropertyChangeListener(PropertyChangeListener l) {
if (m_Support == null) m_Support = new PropertyChangeSupport(this); if (m_Support == null) {
m_Support = new PropertyChangeSupport(this);
}
m_Support.addPropertyChangeListener(l); m_Support.addPropertyChangeListener(l);
} }
public void removePropertyChangeListener(PropertyChangeListener l) { public void removePropertyChangeListener(PropertyChangeListener l) {
if (m_Support == null) m_Support = new PropertyChangeSupport(this); if (m_Support == null) {
m_Support = new PropertyChangeSupport(this);
}
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
/**
*
*/
// public static void main(String [] args) {
// try {
// java.beans.PropertyEditorManager.registerEditor(SelectedTag.class,TagEditor.class);
// java.beans.PropertyEditorManager.registerEditor(int [].class,GenericArrayEditor.class);
// java.beans.PropertyEditorManager.registerEditor(double [].class,GenericArrayEditor.class);
// GenericArrayEditor editor = new GenericArrayEditor();
//
//
// int[] initial = { 3,45, 7};
// editor.setValue(initial);
// PropertyDialog pd = new PropertyDialog(editor,EVAHELP.cutClassName(editor.getClass().getName())
// , 100, 100);
//// pd.setSize(200,200);
// pd.addWindowListener(new WindowAdapter() {
// public void windowClosing(WindowEvent e) {
// System.exit(0);
// }
// });
// editor.setValue(initial);
// //ce.validate();
// } catch (Exception ex) {
// ex.printStackTrace();
// System.err.println(ex.getMessage());
// }
// }
public boolean isWithAddButton() { public boolean isWithAddButton() {
return withAddButton; return withAddButton;
} }
public void setWithAddButton(boolean withAddButton) { public void setWithAddButton(boolean withAddButton) {
this.withAddButton = withAddButton; this.withAddButton = withAddButton;
} }
public boolean isWithSetButton() { public boolean isWithSetButton() {
return withSetButton; return withSetButton;
} }
public void setWithSetButton(boolean withSetButton) { public void setWithSetButton(boolean withSetButton) {
this.withSetButton = withSetButton; this.withSetButton = withSetButton;
} }
@ -753,6 +747,7 @@ implements PropertyEditor {
public boolean isWithDeleteButton() { public boolean isWithDeleteButton() {
return withDeleteButton; return withDeleteButton;
} }
public void setWithDeleteButton(boolean wB) { public void setWithDeleteButton(boolean wB) {
this.withDeleteButton = wB; this.withDeleteButton = wB;
} }
@ -761,4 +756,3 @@ implements PropertyEditor {
super.removeNotify(); super.removeNotify();
} }
} }

View File

@ -1,16 +1,10 @@
package eva2.gui; package eva2.gui;
/* /*
* Title: EvA2 * Title: EvA2 Description: Copyright: Copyright (c) 2012 Company: University of Tuebingen, Computer
* Description: * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher, Fabian Becker @version:
* Copyright: Copyright (c) 2012 * $Revision: 266 $ $Date: 2007-11-20 14:33:48 +0100 (Tue, 20 Nov 2007) $ $Author: mkron $
* Company: University of Tuebingen, Computer Architecture
* @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 $
*/ */
import java.awt.Component; import java.awt.Component;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
@ -36,11 +30,9 @@ import eva2.EvAInfo;
import eva2.tools.ReflectPackage; import eva2.tools.ReflectPackage;
import eva2.tools.jproxy.RMIProxyLocal; import eva2.tools.jproxy.RMIProxyLocal;
public class GenericObjectEditor implements PropertyEditor { public class GenericObjectEditor implements PropertyEditor {
private static final Logger logger = Logger.getLogger(EvAInfo.defaultLogger);
private static final Logger logger = Logger.getLogger(EvAInfo.defaultLogger);
private Object m_Object; private Object m_Object;
private Object m_Backup; private Object m_Backup;
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
@ -49,7 +41,8 @@ public class GenericObjectEditor implements PropertyEditor {
private boolean isEnabled = true; private boolean isEnabled = true;
/** /**
* Read the classes available for user selection from the properties or the classpath respectively * Read the classes available for user selection from the properties or the classpath
* respectively
*/ */
public static ArrayList<String> getClassesFromProperties(String className, ArrayList<Class<?>> instances) { public static ArrayList<String> getClassesFromProperties(String className, ArrayList<Class<?>> instances) {
logger.log(Level.FINEST, "Requesting className: {0}", className); logger.log(Level.FINEST, "Requesting className: {0}", className);
@ -80,10 +73,10 @@ public class GenericObjectEditor implements PropertyEditor {
} }
/** /**
* Return the names of all classes in the same package that are assignable * Return the names of all classes in the same package that are assignable from the named class,
* from the named class, and that can be loaded through the classpath. * and that can be loaded through the classpath. If a class has a declared field called
* If a class has a declared field called "hideFromGOE" this method will skip it. * "hideFromGOE" this method will skip it. Abstract classes and interfaces will be skipped as
* Abstract classes and interfaces will be skipped as well. * well.
* *
* @see ReflectPackage.getAssignableClassesInPackage * @see ReflectPackage.getAssignableClassesInPackage
* @param className * @param className
@ -92,7 +85,7 @@ public class GenericObjectEditor implements PropertyEditor {
public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) { public static ArrayList<String> getClassesFromClassPath(String className, ArrayList<Class<?>> instances) {
ArrayList<String> classes = new ArrayList<String>(); ArrayList<String> classes = new ArrayList<String>();
Class<?>[] classArray; Class<?>[] classArray;
classArray=ReflectPackage.getAssignableClasses(className, true, true); classArray = ReflectPackage.getAssignableClasses(className, true, true);
if (classArray == null) { 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)); 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); classes.add(className);
@ -108,8 +101,8 @@ public class GenericObjectEditor implements PropertyEditor {
} }
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
/* /*
* We are just logging this exception here. It is expected that * We are just logging this exception here. It is expected that most classes do
* most classes do not have this field. * not have this field.
*/ */
logger.log(Level.FINER, String.format("%1$s does not have a hideFromGOE field", clazz.toString()), e); logger.log(Level.FINER, String.format("%1$s does not have a hideFromGOE field", clazz.toString()), e);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -123,7 +116,9 @@ public class GenericObjectEditor implements PropertyEditor {
try { try {
Class<?>[] params = new Class[0]; Class<?>[] params = new Class[0];
clazz.getConstructor(params); clazz.getConstructor(params);
if (instances!=null) instances.add(clazz); if (instances != null) {
instances.add(clazz);
}
classes.add(clazz.getName()); classes.add(clazz.getName());
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
logger.log(Level.WARNING, String.format("GOE warning: Class %1$s has no default constructor", clazz.getName()), e); logger.log(Level.WARNING, String.format("GOE warning: Class %1$s has no default constructor", clazz.getName()), e);
@ -135,12 +130,11 @@ public class GenericObjectEditor implements PropertyEditor {
} }
/** /**
* Hide or show the editable property of a class, this makes sense for classes * Hide or show the editable property of a class, this makes sense for classes which are
* which are represented visually using the GenericObjectEditor. * represented visually using the GenericObjectEditor. Returns false, if an error occurs, else
* Returns false, if an error occurs, else true. * true. An instance may call this statically on itself by means of this.getClass(). Actually
* An instance may call this statically on itself by means of this.getClass(). * this only sets the hidden property of the java bean which is checked in the wasModified
* Actually this only sets the hidden property of the java bean which is checked in the * method of PropertySheetPanel.
* wasModified method of PropertySheetPanel.
* *
* @param cls class the property belongs to * @param cls class the property belongs to
* @param property string name of the property * @param property string name of the property
@ -151,9 +145,11 @@ public class GenericObjectEditor implements PropertyEditor {
try { try {
BeanInfo bi = Introspector.getBeanInfo(cls); BeanInfo bi = Introspector.getBeanInfo(cls);
PropertyDescriptor[] props = bi.getPropertyDescriptors(); PropertyDescriptor[] props = bi.getPropertyDescriptors();
for (int i=0; i<props.length; i++) { for (int i = 0; i < props.length; i++) {
if ((props[i].getName().equals(property))) { if ((props[i].getName().equals(property))) {
if (expertValue != props[i].isExpert()) props[i].setExpert(expertValue); if (expertValue != props[i].isExpert()) {
props[i].setExpert(expertValue);
}
} }
} }
return true; return true;
@ -164,12 +160,11 @@ public class GenericObjectEditor implements PropertyEditor {
} }
/** /**
* Hide or show the editable property of a class, this makes sense for classes * Hide or show the editable property of a class, this makes sense for classes which are
* which are represented visually using the GenericObjectEditor. * represented visually using the GenericObjectEditor. Returns false, if an error occurs, else
* Returns false, if an error occurs, else true. * true. An instance may call this statically on itself by means of this.getClass(). Actually
* An instance may call this statically on itself by means of this.getClass(). * this only sets the hidden property of the java bean which is checked in the wasModified
* Actually this only sets the hidden property of the java bean which is checked in the * method of PropertySheetPanel.
* wasModified method of PropertySheetPanel.
* *
* @param cls class the property belongs to * @param cls class the property belongs to
* @param property string name of the property * @param property string name of the property
@ -180,7 +175,7 @@ public class GenericObjectEditor implements PropertyEditor {
try { try {
BeanInfo bi = Introspector.getBeanInfo(cls); BeanInfo bi = Introspector.getBeanInfo(cls);
PropertyDescriptor[] props = bi.getPropertyDescriptors(); PropertyDescriptor[] props = bi.getPropertyDescriptors();
for (int i=0; i<props.length; i++) { for (int i = 0; i < props.length; i++) {
if ((props[i].getName().equals(property))) { if ((props[i].getName().equals(property))) {
if (hide != props[i].isHidden()) { if (hide != props[i].isHidden()) {
props[i].setHidden(hide); props[i].setHidden(hide);
@ -199,7 +194,8 @@ public class GenericObjectEditor implements PropertyEditor {
/** /**
* Hide or unhide all properties of a given class. Added to avoid the problem with hidden * Hide or unhide all properties of a given class. Added to avoid the problem with hidden
* properties of inherited classes hide the property for all classes within the same inheritance tree. * properties of inherited classes hide the property for all classes within the same inheritance
* tree.
* *
* @param cls * @param cls
* @param hide * @param hide
@ -210,8 +206,8 @@ public class GenericObjectEditor implements PropertyEditor {
BeanInfo bi = Introspector.getBeanInfo(cls); BeanInfo bi = Introspector.getBeanInfo(cls);
PropertyDescriptor[] props = bi.getPropertyDescriptors(); PropertyDescriptor[] props = bi.getPropertyDescriptors();
boolean[] orig = new boolean[props.length]; boolean[] orig = new boolean[props.length];
for (int i=0; i<props.length; i++) { for (int i = 0; i < props.length; i++) {
orig[i]=props[i].isHidden(); orig[i] = props[i].isHidden();
props[i].setHidden(hide); props[i].setHidden(hide);
} }
return orig; return orig;
@ -222,7 +218,7 @@ public class GenericObjectEditor implements PropertyEditor {
} }
public static void setHideProperties(Class<?> cls, boolean[] hideStates) { public static void setHideProperties(Class<?> cls, boolean[] hideStates) {
if (hideStates!=null) { if (hideStates != null) {
BeanInfo bi; BeanInfo bi;
try { try {
bi = Introspector.getBeanInfo(cls); bi = Introspector.getBeanInfo(cls);
@ -232,7 +228,7 @@ public class GenericObjectEditor implements PropertyEditor {
} }
PropertyDescriptor[] props = bi.getPropertyDescriptors(); PropertyDescriptor[] props = bi.getPropertyDescriptors();
if (hideStates.length == props.length) { if (hideStates.length == props.length) {
for (int i=0; i<props.length; i++) { for (int i = 0; i < props.length; i++) {
props[i].setHidden(hideStates[i]); props[i].setHidden(hideStates[i]);
} }
} else { } else {
@ -254,8 +250,7 @@ public class GenericObjectEditor implements PropertyEditor {
} }
/** /**
* Sets whether the editor is "enabled", meaning that the current * Sets whether the editor is "enabled", meaning that the current values will be painted.
* values will be painted.
* *
* @param newVal a value of type 'boolean' * @param newVal a value of type 'boolean'
*/ */
@ -273,8 +268,9 @@ public class GenericObjectEditor implements PropertyEditor {
public void setClassType(Class<?> type) { public void setClassType(Class<?> type) {
//if (TRACE) System.out.println("GOE setClassType("+ (type == null? "<null>" : type.getName()) + ")"); //if (TRACE) System.out.println("GOE setClassType("+ (type == null? "<null>" : type.getName()) + ")");
classType = type; classType = type;
if (editorComponent != null) if (editorComponent != null) {
editorComponent.updateClassType(); editorComponent.updateClassType();
}
} }
@ -283,8 +279,7 @@ public class GenericObjectEditor implements PropertyEditor {
} }
/** /**
* Sets the current object to be the default, taken as the first item in * Sets the current object to be the default, taken as the first item in the chooser
* the chooser
*/ */
public void setDefaultValue() { public void setDefaultValue() {
if (classType == null) { if (classType == null) {
@ -292,58 +287,58 @@ public class GenericObjectEditor implements PropertyEditor {
return; return;
} }
Vector<String> v=null; Vector<String> v = null;
if (Proxy.isProxyClass(classType)) { if (Proxy.isProxyClass(classType)) {
//if (TRACE) System.out.println("PROXY! original was " + ((RMIProxyLocal)Proxy.getInvocationHandler(((Proxy)m_Object))).getOriginalClass().getName()); //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)); v = new Vector<String>(getClassesFromProperties(((RMIProxyLocal) Proxy.getInvocationHandler(((Proxy) m_Object))).getOriginalClass().getName(), null));
} else { } else {
v = new Vector<String>(getClassesFromProperties(classType.getName(), null)); v = new Vector<String>(getClassesFromProperties(classType.getName(), null));
} }
// v = new Vector<String>(getClassesFromProperties(m_ClassType.getName())); // v = new Vector<String>(getClassesFromProperties(m_ClassType.getName()));
try { try {
if (v.size() > 0) if (v.size() > 0) {
setObject((Object)Class.forName((String)v.get(0)).newInstance()); setObject((Object) Class.forName((String) v.get(0)).newInstance());
}
} catch (Exception ex) { } catch (Exception ex) {
System.err.println("Exception in setDefaultValue !!!"+ex.getMessage()); System.err.println("Exception in setDefaultValue !!!" + ex.getMessage());
} }
} }
/** /**
* Sets the current Object. If the Object is in the * Sets the current Object. If the Object is in the Object chooser, this becomes the selected
* Object chooser, this becomes the selected item (and added * item (and added to the chooser if necessary).
* to the chooser if necessary).
* *
* @param o an object that must be a Object. * @param o an object that must be a Object.
*/ */
public void setValue(Object o) { public void setValue(Object o) {
//System.err.println("setValue()" + m_ClassType.toString()); //System.err.println("setValue()" + m_ClassType.toString());
if (o==null || classType == null) { if (o == null || classType == null) {
logger.log(Level.WARNING, "No ClassType set up for GenericObjectEditor!"); logger.log(Level.WARNING, "No ClassType set up for GenericObjectEditor!");
return; return;
} }
if (!classType.isAssignableFrom(o.getClass())) { if (!classType.isAssignableFrom(o.getClass())) {
if (classType.isPrimitive()) { if (classType.isPrimitive()) {
System.err.println("setValue object not of correct type! Expected "+classType.getName()+", got " + o.getClass().getName()); System.err.println("setValue object not of correct type! Expected " + classType.getName() + ", got " + o.getClass().getName());
System.err.println("setting primitive type"); System.err.println("setting primitive type");
setObject((Object)o); setObject((Object) o);
//throw new NullPointerException("ASDF"); //throw new NullPointerException("ASDF");
} else { } else {
System.err.println("setValue object not of correct type! Expected "+classType.getName()+", got " + o.getClass().getName()); System.err.println("setValue object not of correct type! Expected " + classType.getName() + ", got " + o.getClass().getName());
} }
return; return;
} }
setObject((Object)o); setObject((Object) o);
if (editorComponent != null) if (editorComponent != null) {
editorComponent.updateChooser(); editorComponent.updateChooser();
}
} }
/** /**
* Sets the current Object, but doesn't worry about updating * Sets the current Object, but doesn't worry about updating the state of the Object chooser.
* the state of the Object chooser.
* *
* @param c a value of type 'Object' * @param c a value of type 'Object'
*/ */
@ -357,11 +352,11 @@ public class GenericObjectEditor implements PropertyEditor {
if (editorComponent != null) { if (editorComponent != null) {
editorComponent.updateChildPropertySheet(); editorComponent.updateChildPropertySheet();
if (trueChange) if (trueChange) {
propertyChangeSupport.firePropertyChange("", m_Backup, m_Object); propertyChangeSupport.firePropertyChange("", m_Backup, m_Object);
} }
} }
}
/** /**
* Gets the current Object. * Gets the current Object.
@ -373,10 +368,9 @@ public class GenericObjectEditor implements PropertyEditor {
} }
/** /**
* Supposedly returns an initialization string to create a Object * Supposedly returns an initialization string to create a Object identical to the current one,
* identical to the current one, including it's state, but this doesn't * including it's state, but this doesn't appear possible given that the initialization string
* appear possible given that the initialization string isn't supposed to * isn't supposed to contain multiple statements.
* contain multiple statements.
* *
* @return the java source code initialization string * @return the java source code initialization string
*/ */
@ -385,8 +379,7 @@ public class GenericObjectEditor implements PropertyEditor {
} }
/** /**
* Returns true to indicate that we can paint a representation of the * Returns true to indicate that we can paint a representation of the Object.
* Object.
* *
* @return true * @return true
*/ */
@ -394,12 +387,13 @@ public class GenericObjectEditor implements PropertyEditor {
return true; return true;
} }
/** Paints a representation of the current Object. /**
* Paints a representation of the current Object.
* *
* @param gfx the graphics context to use * @param gfx the graphics context to use
* @param box the area we are allowed to paint into * @param box the area we are allowed to paint into
*/ */
public void paintValue(Graphics gfx,Rectangle box) { public void paintValue(Graphics gfx, Rectangle box) {
if (isEnabled && m_Object != null) { if (isEnabled && m_Object != null) {
int getNameMethod = -1; int getNameMethod = -1;
MethodDescriptor[] methods; MethodDescriptor[] methods;
@ -408,7 +402,9 @@ public class GenericObjectEditor implements PropertyEditor {
BeanInfo beanInfo = Introspector.getBeanInfo(m_Object.getClass()); BeanInfo beanInfo = Introspector.getBeanInfo(m_Object.getClass());
methods = beanInfo.getMethodDescriptors(); methods = beanInfo.getMethodDescriptors();
for (int i = 0; i < methods.length; i++) { for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equalsIgnoreCase("getName")) getNameMethod = i; if (methods[i].getName().equalsIgnoreCase("getName")) {
getNameMethod = i;
}
} }
} catch (IntrospectionException ex) { } catch (IntrospectionException ex) {
System.err.println("PropertySheetPanel.setTarget(): Couldn't introspect"); System.err.println("PropertySheetPanel.setTarget(): Couldn't introspect");
@ -416,27 +412,24 @@ public class GenericObjectEditor implements PropertyEditor {
} }
if (getNameMethod >= 0) { if (getNameMethod >= 0) {
try { try {
rep = (String)methods[getNameMethod].getMethod().invoke(m_Object, (Object[])null); rep = (String) methods[getNameMethod].getMethod().invoke(m_Object, (Object[]) null);
} catch (java.lang.IllegalAccessException e1) { } catch (java.lang.IllegalAccessException e1) {
} catch (java.lang.reflect.InvocationTargetException e2) { } catch (java.lang.reflect.InvocationTargetException e2) {
} }
} }
if (rep.length() <= 0) { if (rep.length() <= 0) {
rep = m_Object.getClass().getName(); rep = m_Object.getClass().getName();
int dotPos = rep.lastIndexOf('.'); int dotPos = rep.lastIndexOf('.');
if (dotPos != -1) if (dotPos != -1) {
rep = rep.substring(dotPos + 1); rep = rep.substring(dotPos + 1);
} }
}
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getHeight()) / 2; int vpad = (box.height - fm.getHeight()) / 2;
gfx.drawString(rep, 2, fm.getHeight() + vpad -2 ); gfx.drawString(rep, 2, fm.getHeight() + vpad - 2);
} else {
} }
} }
/** /**
* Returns null as we don't support getting/setting values as text. * Returns null as we don't support getting/setting values as text.
* *
@ -450,8 +443,7 @@ public class GenericObjectEditor implements PropertyEditor {
* Returns null as we don't support getting/setting values as text. * Returns null as we don't support getting/setting values as text.
* *
* @param text the text value * @param text the text value
* @exception IllegalArgumentException as we don't support * @exception IllegalArgumentException as we don't support getting/setting values as text.
* getting/setting values as text.
*/ */
public void setAsText(String text) throws IllegalArgumentException { public void setAsText(String text) throws IllegalArgumentException {
throw new IllegalArgumentException(text); throw new IllegalArgumentException(text);
@ -481,29 +473,34 @@ public class GenericObjectEditor implements PropertyEditor {
* @return a value of type 'java.awt.Component' * @return a value of type 'java.awt.Component'
*/ */
public Component getCustomEditor() { public Component getCustomEditor() {
if (editorComponent == null) if (editorComponent == null) {
editorComponent = new GOEPanel(m_Object, m_Backup, propertyChangeSupport, this); editorComponent = new GOEPanel(m_Object, m_Backup, propertyChangeSupport, this);
}
return editorComponent; return editorComponent;
} }
/** /**
* *
*/ */
public void disableOKCancel() { public void disableOKCancel() {
if (editorComponent == null) if (editorComponent == null) {
editorComponent = new GOEPanel(m_Object, m_Backup, editorComponent = new GOEPanel(m_Object, m_Backup,
propertyChangeSupport, this); propertyChangeSupport, this);
}
editorComponent.setEnabledOkCancelButtons(false); editorComponent.setEnabledOkCancelButtons(false);
} }
public void addPropertyChangeListener(PropertyChangeListener l) { public void addPropertyChangeListener(PropertyChangeListener l) {
if (propertyChangeSupport == null) if (propertyChangeSupport == null) {
propertyChangeSupport = new PropertyChangeSupport(this); propertyChangeSupport = new PropertyChangeSupport(this);
}
propertyChangeSupport.addPropertyChangeListener(l); propertyChangeSupport.addPropertyChangeListener(l);
} }
public void removePropertyChangeListener(PropertyChangeListener l) { public void removePropertyChangeListener(PropertyChangeListener l) {
if (propertyChangeSupport == null) if (propertyChangeSupport == null) {
propertyChangeSupport = new PropertyChangeSupport(this); propertyChangeSupport = new PropertyChangeSupport(this);
}
propertyChangeSupport.removePropertyChangeListener(l); propertyChangeSupport.removePropertyChangeListener(l);
} }
} }

View File

@ -33,6 +33,7 @@ import eva2.server.go.problems.InterfaceOptimizationTarget;
import eva2.server.go.tools.AbstractObjectEditor; import eva2.server.go.tools.AbstractObjectEditor;
import eva2.server.go.tools.GeneralGOEProperty; import eva2.server.go.tools.GeneralGOEProperty;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import java.awt.Color;
/** /**
@ -127,7 +128,6 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
p2.add(help, BorderLayout.NORTH); p2.add(help, BorderLayout.NORTH);
jp.add(p2, BorderLayout.EAST); jp.add(p2, BorderLayout.EAST);
GridBagConstraints gbConstraints = new GridBagConstraints(); GridBagConstraints gbConstraints = new GridBagConstraints();
this.m_Editor.add(jp, BorderLayout.NORTH); this.m_Editor.add(jp, BorderLayout.NORTH);
this.updateEditor(); this.updateEditor();

View File

@ -15,6 +15,8 @@ import eva2.tools.SelectedTag;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
public class GenericSelectableArrayEditor extends GenericArrayEditor { public class GenericSelectableArrayEditor extends GenericArrayEditor {
protected JCheckBox[] m_BlackCheck; protected JCheckBox[] m_BlackCheck;
@ -32,8 +34,11 @@ public class GenericSelectableArrayEditor extends GenericArrayEditor {
PropertyDialog pd = new PropertyDialog(editor,EVAHELP.cutClassName(editor.getClass().getName()) PropertyDialog pd = new PropertyDialog(editor,EVAHELP.cutClassName(editor.getClass().getName())
, 100, 100); , 100, 100);
pd.setSize(200,200); pd.setSize(200,200);
pd.addWindowListener(new WindowAdapter() { pd.addInternalFrameListener(new InternalFrameAdapter() {
public void windowClosing(WindowEvent e) {
@Override
public void internalFrameClosing(InternalFrameEvent e) {
super.internalFrameClosing(e);
System.exit(0); System.exit(0);
} }
}); });

View File

@ -12,74 +12,79 @@ import java.io.Serializable;
* $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007) $ * $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
public class Graph implements Serializable { public class Graph implements Serializable {
private PlotInterface m_Plotter;
private int m_GraphLabel; private PlotInterface plotter;
private String m_Info; private int graphLabel;
private String infoString;
/** /**
* *
*/ */
public Graph(String Info, PlotInterface Plotter,int x) { public Graph(String info, PlotInterface plotter, int x) {
m_Info = Info; infoString = info;
m_Plotter = Plotter; this.plotter = plotter;
m_GraphLabel = x; graphLabel = x;
if (m_Plotter==null) if (plotter == null) {
System.out.println("In constructor m_Plotter == null"); System.out.println("In constructor m_Plotter == null");
m_Plotter.setInfoString(m_GraphLabel,Info, (float) 1.0 );
} }
plotter.setInfoString(graphLabel, info, (float) 1.0);
}
/** /**
* *
* @param Info * @param Info
* @param stroke * @param stroke
*/ */
public String getInfo() {return m_Info;} public String getInfo() {
/** return infoString;
*
*/
public void setInfoString(String Info,float stroke) {
m_Plotter.setInfoString(m_GraphLabel, Info,stroke);
} }
/** /**
* *
*/ */
public int getGraphLabel () { public void setInfoString(String info, float stroke) {
return m_GraphLabel; plotter.setInfoString(graphLabel, info, stroke);
} }
/** /**
* *
*/ */
public void setConnectedPoint(double x,double y) { public int getGraphLabel() {
m_Plotter.setConnectedPoint(x,y,m_GraphLabel); return graphLabel;
}
/**
*
*/
public void setConnectedPoint(double x, double y) {
plotter.setConnectedPoint(x, y, graphLabel);
} }
/** /**
* *
*/ */
public void clear() { public void clear() {
m_Plotter.clearGraph(m_GraphLabel); plotter.clearGraph(graphLabel);
} }
/** /**
* *
*/ */
public void setUnconnectedPoint(double x,double y) { public void setUnconnectedPoint(double x, double y) {
m_Plotter.setUnconnectedPoint(x,y,m_GraphLabel); plotter.setUnconnectedPoint(x, y, graphLabel);
} }
public int getPointCount() { public int getPointCount() {
return m_Plotter.getPointCount(m_GraphLabel); return plotter.getPointCount(graphLabel);
} }
/** /**
* Add a graph to this graph object. Uses "force" for mismatching point counts, but returns false * Add a graph to this graph object. Uses "force" for mismatching point counts, but returns
* if force was used and points possibly have been lost. * false if force was used and points possibly have been lost.
* *
* @return true if the graph could be added directly or false if the graph was added by force losing some data points * @return true if the graph could be added directly or false if the graph was added by force
* losing some data points
* @see PlotInterface.addGraph * @see PlotInterface.addGraph
*/ */
public boolean addGraph(Graph x) { public boolean addGraph(Graph x) {
@ -89,25 +94,19 @@ public class Graph implements Serializable {
//System.err.println("mismatching graphs, point counts were " + getPointCount() + " " + x.getPointCount()); //System.err.println("mismatching graphs, point counts were " + getPointCount() + " " + x.getPointCount());
useForce = true; useForce = true;
} }
m_Plotter.jump(); plotter.jump();
m_Plotter.addGraph(m_GraphLabel, x.getGraphLabel(), useForce); plotter.addGraph(graphLabel, x.getGraphLabel(), useForce);
return !useForce; return !useForce;
} }
/** /**
* Causes the PlotInterface to interrupt the connected painting at the * Causes the PlotInterface to interrupt the connected painting at the current position.
* current position.
*/ */
public void jump() { public void jump() {
m_Plotter.jump(); plotter.jump();
} }
public void setColorByIndex(int j) { public void setColorByIndex(int j) {
((Plot)m_Plotter).setColorByIndex(m_GraphLabel, j); ((Plot) plotter).setColorByIndex(graphLabel, j);
} }
// public boolean isValid() { // this was evil in RMI, use GraphWindow instead
// //return true;
// return (m_Plotter != null) && (m_Plotter.getFunctionArea() != null);
// }
} }

View File

@ -1,94 +1,84 @@
package eva2.gui; package eva2.gui;
/* /*
* Title: EvA2 * Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
* Description: * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 320
* Copyright: Copyright (c) 2003 * $ $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $ $Author: mkron $
* Company: University of Tuebingen, Computer Architecture
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
* @version: $Revision: 320 $
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
* $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList; import java.util.ArrayList;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
import eva2.tools.jproxy.RMIProxyRemote; import eva2.tools.jproxy.RMIProxyRemote;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* It represents one plot window in the client GUI. * It represents one plot window in the client GUI.
*/ */
public class GraphWindow { public class GraphWindow {
public static boolean TRACE = false;
static private int m_GraphCounter = -1; public static boolean TRACE = false;
static private PlotContainer m_PlotContainer; static private int graphCounter = -1;
private MainAdapterClient m_MainAdapterClient; static private PlotContainer plotContainer;
private PlotInterface m_Plotter; private MainAdapterClient mainAdapterClient;
private String m_Name; private PlotInterface plotter;
private String name;
/** /**
* *
*/ */
public static GraphWindow getInstance (MainAdapterClient client,String GraphWindowName, public static GraphWindow getInstance(MainAdapterClient client, String graphWindowName,
String strx,String stry) { String strx, String stry) {
if (m_PlotContainer == null) if (plotContainer == null) {
m_PlotContainer = new PlotContainer(); plotContainer = new PlotContainer();
GraphWindow ret =null; }
GraphWindow ret = null;
try { try {
// if (!m_PlotContainer.containsName(GraphWindowName)) { if (plotContainer.containsName(graphWindowName)) {
// ret = new GraphWindow(client,GraphWindowName,strx,stry); ret = plotContainer.getPlot(graphWindowName);
// m_PlotContainer.add(ret);
// }
// else {
// ret = m_PlotContainer.getPlot(GraphWindowName);
// }
if (m_PlotContainer.containsName(GraphWindowName)) {
ret = m_PlotContainer.getPlot(GraphWindowName);
} }
if ((ret == null) || !(ret.isValid())) { if ((ret == null) || !(ret.isValid())) {
if (ret != null) { if (ret != null) {
m_PlotContainer.remove(ret); // remove if not valid any more plotContainer.remove(ret); // remove if not valid any more
} }
ret = new GraphWindow(client,GraphWindowName,strx,stry); ret = new GraphWindow(client, graphWindowName, strx, stry);
m_PlotContainer.add(ret); plotContainer.add(ret);
} }
} catch (Exception ee) { } catch (Exception ee) {
System.out.println("GraphWindow ERROR : "+ee.getMessage()); System.out.println("GraphWindow ERROR : " + ee.getMessage());
ee.printStackTrace(); ee.printStackTrace();
} }
return ret; return ret;
} }
public boolean isValid() { public boolean isValid() {
return (m_Plotter != null) && (m_Plotter.isValid()); return (plotter != null) && (plotter.isValid());
} }
public PlotInterface getPlotter() { public PlotInterface getPlotter() {
return m_Plotter; return plotter;
} }
/** /**
* *
*/ */
private GraphWindow(MainAdapterClient client,String PlotName,String strx,String stry){ private GraphWindow(MainAdapterClient client, String plotName, String strx, String stry) {
if (TRACE) System.out.println("Constructor GraphWindow"); if (TRACE) {
m_MainAdapterClient = client; System.out.println("Constructor GraphWindow");
m_Name = PlotName; }
try { mainAdapterClient = client;
if ((client==null) || client.getHostName().equals(InetAddress.getLocalHost().getHostName())) { name = plotName;
if (TRACE) System.out.println("no RMI"); try {
m_Plotter = new Plot(PlotName, strx, stry, true); if ((client == null) || client.getHostName().equals(InetAddress.getLocalHost().getHostName())) {
if (TRACE) {
System.out.println("no RMI");
}
plotter = new Plot(plotName, strx, stry, true);
} else {
plotter = (PlotInterface) RMIProxyRemote.newInstance(new Plot(plotName, strx, stry, false), mainAdapterClient);
plotter.init();
if (TRACE) {
System.out.println("with RMI");
} }
else {
m_Plotter = (PlotInterface) RMIProxyRemote.newInstance(new Plot(PlotName,strx,stry,false), m_MainAdapterClient);
m_Plotter.init();
if (TRACE) System.out.println("with RMI");
} }
} catch (Exception e) { } catch (Exception e) {
System.err.println("InetAddress.getLocalHost().getHostAddress() --> ERROR" + e.getMessage()); System.err.println("InetAddress.getLocalHost().getHostAddress() --> ERROR" + e.getMessage());
@ -98,38 +88,46 @@ public class GraphWindow {
/** /**
* *
*/ */
public String getName () { public String getName() {
return m_Name; return name;
} }
/** /**
* *
*/ */
public Graph getNewGraph(String InfoString) { public Graph getNewGraph(String infoString) {
m_GraphCounter++; graphCounter++;
if (TRACE) System.out.println("Graph.getNewGraph No:"+m_GraphCounter + " - " + InfoString); if (TRACE) {
return new Graph (InfoString,m_Plotter,m_GraphCounter); System.out.println("Graph.getNewGraph No:" + graphCounter + " - " + infoString);
}
return new Graph(infoString, plotter, graphCounter);
} }
} }
/** /**
* *
*/ */
class PlotContainer extends ArrayList<GraphWindow> { class PlotContainer extends ArrayList<GraphWindow> {
/** /**
* *
*/ */
private static final long serialVersionUID = 4194675772084989958L; private static final long serialVersionUID = 4194675772084989958L;
private GraphWindow m_actualPlot; private GraphWindow actualPlot;
/** /**
* *
*/ */
public PlotContainer() {} public PlotContainer() {
}
/** /**
* *
*/ */
public boolean containsName (String name) { public boolean containsName(String name) {
GraphWindow temp = null; GraphWindow temp = null;
for (int i=0;i<size();i++) { for (int i = 0; i < size(); i++) {
temp = (GraphWindow)(get(i)); temp = (GraphWindow) (get(i));
if (name.equals(temp.getName())) { if (name.equals(temp.getName())) {
return true; return true;
} }
@ -139,23 +137,26 @@ class PlotContainer extends ArrayList<GraphWindow> {
public void remove(GraphWindow gw) { public void remove(GraphWindow gw) {
super.remove(gw); super.remove(gw);
if (m_actualPlot == gw) m_actualPlot=null; if (actualPlot == gw) {
actualPlot = null;
}
} }
/** /**
* *
*/ */
public GraphWindow getPlot (String name) { public GraphWindow getPlot(String name) {
if ((m_actualPlot!=null) && m_actualPlot.isValid()) { if ((actualPlot != null) && actualPlot.isValid()) {
if (m_actualPlot.getName().equals(name)) if (actualPlot.getName().equals(name)) {
return m_actualPlot; return actualPlot;
}
} }
GraphWindow temp = null; GraphWindow temp = null;
for (int i=0;i<size();i++) { for (int i = 0; i < size(); i++) {
temp = (GraphWindow)(get(i)); temp = (GraphWindow) (get(i));
if (name.equals(temp.getName())) { if (name.equals(temp.getName())) {
m_actualPlot = temp; actualPlot = temp;
return m_actualPlot; return actualPlot;
} }
} }
return null; return null;

View File

@ -10,16 +10,18 @@ package eva2.gui;
* $Author: streiche $ * $Author: streiche $
*/ */
import javax.swing.JFrame; import java.awt.Event;
import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.WindowListener; import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.KeyStroke;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
public class JEFrame extends JFrame { public class JEFrame extends JInternalFrame {
private boolean closeAllOnClose = false; private boolean closeAllOnClose = false;
public JEFrame() { public JEFrame() {
@ -42,36 +44,35 @@ public class JEFrame extends JFrame {
} }
@Override @Override
public void addWindowListener(WindowListener l) { public void addInternalFrameListener(InternalFrameListener l) {
super.addWindowListener(l); super.addInternalFrameListener(l);
} }
private void init() { private void init() {
setDefaultCloseOperation(DISPOSE_ON_CLOSE); setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.addWindowListener(new WindowAdapter() { this.addInternalFrameListener(new InternalFrameAdapter() {
@Override @Override
public void windowClosed(WindowEvent e) { public void internalFrameClosed(InternalFrameEvent e) {
super.windowClosed(e); super.internalFrameClosed(e);
JEFrameRegister.unregister((JEFrame) e.getWindow()); JEFrameRegister.getInstance().unregister((JEFrame) e.getInternalFrame());
if (closeAllOnClose) { if (closeAllOnClose) {
JEFrameRegister.closeAll(); JEFrameRegister.getInstance().closeAll();
} }
// ((JFrame) e.getWindow()).dispose();
} }
@Override @Override
public void windowOpened(WindowEvent e) { public void internalFrameOpened(InternalFrameEvent e) {
super.windowOpened(e); super.internalFrameOpened(e);
JEFrameRegister.register((JEFrame) e.getWindow()); JEFrameRegister.getInstance().register((JEFrame) e.getInternalFrame());
} }
@Override @Override
public void windowActivated(WindowEvent e) { public void internalFrameActivated(InternalFrameEvent e) {
JEFrameRegister.register((JEFrame) e.getWindow()); JEFrameRegister.getInstance().register((JEFrame) e.getInternalFrame());
super.windowActivated(e); super.internalFrameActivated(e);
} }
}); });
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK),
@ -81,8 +82,7 @@ public class JEFrame extends JFrame {
"ctrlFpressed", "ctrlFpressed",
new AbstractAction("ctrlFpressed") { new AbstractAction("ctrlFpressed") {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
((JEFrame) JEFrameRegister.getFrameList()[0]).setExtendedState(JEFrame.NORMAL); JEFrameRegister.getInstance().getFrameList().get(0).toFront();
((JEFrame) JEFrameRegister.getFrameList()[0]).toFront();
} }
} }
); );
@ -94,12 +94,10 @@ public class JEFrame extends JFrame {
"ctrlOpressed", "ctrlOpressed",
new AbstractAction("ctrlOpressed") { new AbstractAction("ctrlOpressed") {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
Object[] fl = JEFrameRegister.getFrameList(); java.util.List<JEFrame> frameList = JEFrameRegister.getInstance().getFrameList();
for (int i = 0; i < fl.length; i++) { for (JEFrame frame : frameList) {
((JEFrame) JEFrameRegister.getFrameList()[i]).setExtendedState(JEFrame.NORMAL); frame.toFront();
((JEFrame) JEFrameRegister.getFrameList()[i]).toFront();
} }
} }
} }
); );
@ -112,9 +110,16 @@ public class JEFrame extends JFrame {
"ctrlSmallerpressed", "ctrlSmallerpressed",
new AbstractAction("ctrlSmallerpressed") { new AbstractAction("ctrlSmallerpressed") {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
JEFrameRegister.setFocusToNext(self); JEFrameRegister.getInstance().setFocusToNext(self);
} }
} }
); );
this.setMaximizable(true);
this.setResizable(true);
this.setIconifiable(true);
this.setClosable(true);
} }
} }

View File

@ -1,5 +1,7 @@
package eva2.gui; package eva2.gui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.swing.JDesktopPane;
/* /*
* Title: EvA2 * Title: EvA2
* Description: * Description:
@ -12,55 +14,87 @@ import java.util.ArrayList;
*/ */
public class JEFrameRegister { public final class JEFrameRegister {
private static ArrayList<JEFrame> JEFrameList; /**
* Singleton instance.
*/
private static JEFrameRegister instance = null;
static { /**
JEFrameList = new ArrayList<JEFrame>(); * List of all frames maintained.
*/
private List<JEFrame> frameList;
private JDesktopPane desktopPane;
private JEFrameRegister() {
this.frameList = new ArrayList<JEFrame>();
} }
public static void register(JEFrame jf) { public static JEFrameRegister getInstance() {
if (!JEFrameList.contains(jf)) JEFrameList.add(jf); if (instance == null) {
// System.out.println("reg " + jf.getTitle() + "/" + (jf.hashCode()) + ", list size: " + JEFrameList.size()); instance = new JEFrameRegister();
}
return instance;
} }
public static void unregister(JEFrame jf) { public void setDesktopPane(JDesktopPane desktopPane) {
JEFrameList.remove(jf); // Plot windows produce double closing events, so ignore it this.desktopPane = desktopPane;
// if (!JEFrameList.remove(jf)) System.err.println("Warning: tried to unregister frame " + jf.getTitle() + " which was not registered! (JEFrameRegister)"); if (!frameList.isEmpty()) {
// System.out.println("unreg " + jf.getTitle() + "/" + jf.hashCode() + ", list size:" + JEFrameList.size()); for (JEFrame frame : frameList) {
this.desktopPane.add(frame);
}
}
} }
public static Object[] getFrameList() { public void register(JEFrame jeFrame) {
return JEFrameList.toArray(); if (!frameList.contains(jeFrame)) {
frameList.add(jeFrame);
if (desktopPane != null) {
desktopPane.add(jeFrame);
}
}
} }
public static void setFocusToNext(JEFrame jf) { public void unregister(JEFrame jeFrame) {
int idx = JEFrameList.indexOf(jf); // Plot windows produce double closing events, so ignore it
idx = (idx + 1) % JEFrameList.size(); frameList.remove(jeFrame);
JEFrame toset = ((JEFrame) JEFrameList.get(idx)); }
toset.setExtendedState(JEFrame.NORMAL);
public List<JEFrame> getFrameList() {
return frameList;
}
public void setFocusToNext(JEFrame jeFrame) {
int idx = frameList.indexOf(jeFrame);
idx = (idx + 1) % frameList.size();
JEFrame toset = ((JEFrame) frameList.get(idx));
toset.toFront(); toset.toFront();
} }
/** /**
* Return all prefixes which occur at least twice in the registered frame list. * Return all prefixes which occur at least twice in the registered frame list.
* @param prefLen *
* @return * @param prefLen Preferred length of prefixes
* @return List of prefixes
*/ */
public static String[] getCommonPrefixes(int prefLen) { public String[] getCommonPrefixes(final int prefLen) {
ArrayList<String> prefixes = new ArrayList<String>(); List<String> prefixes = new ArrayList<String>();
ArrayList<Integer> count = new ArrayList<Integer>(); List<Integer> count = new ArrayList<Integer>();
for (int i=0; i<JEFrameList.size(); i++) { for (int i = 0; i < frameList.size(); i++) {
String title = JEFrameList.get(i).getTitle(); String title = frameList.get(i).getTitle();
String titPref = title.substring(0, Math.min(prefLen, title.length())); String titPref = title.substring(0, Math.min(prefLen, title.length()));
int earlierIndex = prefixes.indexOf(titPref); int earlierIndex = prefixes.indexOf(titPref);
if (earlierIndex<0) { if (earlierIndex < 0) {
prefixes.add(titPref); prefixes.add(titPref);
count.add(1); count.add(1);
} else count.set(earlierIndex, 1+count.get(earlierIndex)); } else {
count.set(earlierIndex, 1 + count.get(earlierIndex));
} }
for (int i=prefixes.size()-1; i>=0; i--) { }
if (count.get(i)<=1) { for (int i = prefixes.size() - 1; i >= 0; i--) {
if (count.get(i) <= 1) {
prefixes.remove(i); prefixes.remove(i);
count.remove(i); count.remove(i);
} }
@ -71,21 +105,23 @@ public class JEFrameRegister {
/** /**
* Close (dispose) all frames whose title starts with a given prefix. * Close (dispose) all frames whose title starts with a given prefix.
* *
* @param prefix * @param prefix The prefix
*/ */
public static void closeAllByPrefix(String prefix) { public void closeAllByPrefix(final String prefix) {
for (int i=0; i<JEFrameList.size(); i++) { for (int i = 0; i < frameList.size(); i++) {
String title = JEFrameList.get(i).getTitle(); String title = frameList.get(i).getTitle();
if (title.startsWith(prefix)) JEFrameList.get(i).dispose(); if (title.startsWith(prefix)) {
frameList.get(i).dispose();
}
} }
} }
/** /**
* Close (dispose) all frames registered in this list. * Close (dispose) all frames registered in this list.
*/ */
public static void closeAll() { public void closeAll() {
for (int i=0; i<JEFrameList.size(); i++) { for (int i = 0; i < frameList.size(); i++) {
JEFrameList.get(i).dispose(); frameList.get(i).dispose();
} }
} }
} }

View File

@ -9,18 +9,21 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $ * $Author: streiche $
*/ */
/*==========================================================================* import java.awt.Component;
* IMPORTS import java.awt.Dimension;
*==========================================================================*/ import java.awt.Event;
import javax.swing.*; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.awt.event.*;
import java.awt.*;
import java.util.Vector; import java.util.Vector;
import javax.swing.*;
/** /**
* *
*/ */
public class JExtDesktopPane extends JDesktopPane{ public class JExtDesktopPane extends JDesktopPane {
private ActionListener m_actMenuFrame; private ActionListener m_actMenuFrame;
private ExtDesktopManager m_manager; private ExtDesktopManager m_manager;
public JExtMenu m_mnuWindow; public JExtMenu m_mnuWindow;
@ -35,63 +38,75 @@ public class JExtDesktopPane extends JDesktopPane{
public final static int WINDOW_ARRANGEICONS = 3; public final static int WINDOW_ARRANGEICONS = 3;
public final static int WINDOW_LIST = 4; public final static int WINDOW_LIST = 4;
public final static int TITLEBAR_HEIGHT = 25; public final static int TITLEBAR_HEIGHT = 25;
/** /**
* *
*/ */
public JExtDesktopPane(){ public JExtDesktopPane() {
super(); super();
m_mnuWindow = new JExtMenu("&Windows"); m_mnuWindow = new JExtMenu("&Windows");
m_manager = new ExtDesktopManager(this); m_manager = new ExtDesktopManager(this);
setDesktopManager(m_manager); setDesktopManager(m_manager);
m_actMenuFrame = new ActionListener(){ m_actMenuFrame = new ActionListener() {
public void actionPerformed(ActionEvent e){
if(!(e.getSource() instanceof JMenuItem)) return; public void actionPerformed(ActionEvent e) {
JInternalFrame frame = (JInternalFrame)((JMenuItem)e.getSource()).getClientProperty(ExtDesktopManager.FRAME); if (!(e.getSource() instanceof JMenuItem)) {
return;
}
JInternalFrame frame = (JInternalFrame) ((JMenuItem) e.getSource()).getClientProperty(ExtDesktopManager.FRAME);
selectFrame(frame); selectFrame(frame);
} }
}; };
m_mnuWindow.add(actWindowTileVert = new ExtAction("&Nebeneinander", "Ordnet die Fenster nebeneinander an"){ m_mnuWindow.add(actWindowTileVert = new ExtAction("&Nebeneinander", "Ordnet die Fenster nebeneinander an") {
public void actionPerformed(ActionEvent e){
public void actionPerformed(ActionEvent e) {
tileWindows(SwingConstants.HORIZONTAL); tileWindows(SwingConstants.HORIZONTAL);
} }
}); });
m_mnuWindow.add(actWindowTileHorz = new ExtAction("&Untereinander", "Ordnet die Fenster untereinander an"){ m_mnuWindow.add(actWindowTileHorz = new ExtAction("&Untereinander", "Ordnet die Fenster untereinander an") {
public void actionPerformed(ActionEvent e){
public void actionPerformed(ActionEvent e) {
tileWindows(SwingConstants.VERTICAL); tileWindows(SwingConstants.VERTICAL);
} }
}); });
m_mnuWindow.add(actWindowOverlap = new ExtAction("<EFBFBD>&berlappend", "Ordnet die Fenster <20>berlappend an"){ m_mnuWindow.add(actWindowOverlap = new ExtAction("Ü&berlappend", "Ordnet die Fenster Überlappend an") {
public void actionPerformed(ActionEvent e){
public void actionPerformed(ActionEvent e) {
overlapWindows(); overlapWindows();
} }
}); });
m_mnuWindow.add(actWindowArrangeIcons = new ExtAction("&Symbole anordnen", "Ordnet die Symbole auf dem Desktop an"){ m_mnuWindow.add(actWindowArrangeIcons = new ExtAction("&Symbole anordnen", "Ordnet die Symbole auf dem Desktop an") {
public void actionPerformed(ActionEvent e){
public void actionPerformed(ActionEvent e) {
} }
}); });
m_mnuWindow.add(actWindowList = new ExtAction("Fenster&liste...", "Zeigt eine Liste aller Fenster an", KeyStroke.getKeyStroke(KeyEvent.VK_0, Event.ALT_MASK)){ m_mnuWindow.add(actWindowList = new ExtAction("Fenster&liste...", "Zeigt eine Liste aller Fenster an", KeyStroke.getKeyStroke(KeyEvent.VK_0, Event.ALT_MASK)) {
public void actionPerformed(ActionEvent e){
public void actionPerformed(ActionEvent e) {
Vector l = new Vector(); Vector l = new Vector();
JInternalFrame frames[] = getAllFrames(); JInternalFrame frames[] = getAllFrames();
for(int i = 0; i < frames.length; i++) for (int i = 0; i < frames.length; i++) {
l.add(frames[i].getTitle()); l.add(frames[i].getTitle());
}
JList list = new JList(l); JList list = new JList(l);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane pane = new JScrollPane(list); JScrollPane pane = new JScrollPane(list);
pane.setPreferredSize(new Dimension(pane.getPreferredSize().width, 150)); pane.setPreferredSize(new Dimension(pane.getPreferredSize().width, 150));
if(JOptionPane.showOptionDialog(JExtDesktopPane.this, pane, "Fenster ausw<73>hlen", JOptionPane.OK_CANCEL_OPTION, if (JOptionPane.showOptionDialog(JExtDesktopPane.this, pane, "Fenster auswählen", JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE, null, null, null) == JOptionPane.OK_OPTION) JOptionPane.PLAIN_MESSAGE, null, null, null) == JOptionPane.OK_OPTION) {
if(list.getSelectedIndex() != -1) selectFrame(frames[list.getSelectedIndex()]); if (list.getSelectedIndex() != -1) {
selectFrame(frames[list.getSelectedIndex()]);
}
}
} }
}); });
@ -99,83 +114,94 @@ public class JExtDesktopPane extends JDesktopPane{
m_manager.WINDOW_LIST_START = 6; m_manager.WINDOW_LIST_START = 6;
} }
public ExtAction getWindowAction(int action){ public ExtAction getWindowAction(int action) {
switch(action){ switch (action) {
case WINDOW_TILEVERT: return actWindowTileVert; case WINDOW_TILEVERT:
case WINDOW_TILEHORZ: return actWindowTileHorz; return actWindowTileVert;
case WINDOW_OVERLAP: return actWindowOverlap; case WINDOW_TILEHORZ:
case WINDOW_ARRANGEICONS: return actWindowArrangeIcons; return actWindowTileHorz;
case WINDOW_LIST: return actWindowList; case WINDOW_OVERLAP:
return actWindowOverlap;
case WINDOW_ARRANGEICONS:
return actWindowArrangeIcons;
case WINDOW_LIST:
return actWindowList;
} }
return null; return null;
} }
public void overlapWindows(){ public void overlapWindows() {
final int minWidth = 150, minHeight = 100; final int minWidth = 150, minHeight = 100;
int fWidth, fHeight, int fWidth, fHeight,
oCount, i, indent; oCount, i, indent;
JInternalFrame[] frames = getOpenFrames(); JInternalFrame[] frames = getOpenFrames();
if(frames.length == 0) return; if (frames.length == 0) {
return;
}
oCount = Math.min(frames.length, Math.min((getWidth() - minWidth) / TITLEBAR_HEIGHT + 1, (getHeight() - minHeight) / TITLEBAR_HEIGHT + 1)); oCount = Math.min(frames.length, Math.min((getWidth() - minWidth) / TITLEBAR_HEIGHT + 1, (getHeight() - minHeight) / TITLEBAR_HEIGHT + 1));
fWidth = getWidth() - (oCount - 1) * TITLEBAR_HEIGHT; fWidth = getWidth() - (oCount - 1) * TITLEBAR_HEIGHT;
fHeight = getHeight() - (oCount - 1) * TITLEBAR_HEIGHT; fHeight = getHeight() - (oCount - 1) * TITLEBAR_HEIGHT;
indent = 0; indent = 0;
for(i = 0; i < frames.length; i++){ for (i = 0; i < frames.length; i++) {
frames[frames.length - i - 1].setLocation(indent * TITLEBAR_HEIGHT, indent * TITLEBAR_HEIGHT); frames[frames.length - i - 1].setLocation(indent * TITLEBAR_HEIGHT, indent * TITLEBAR_HEIGHT);
frames[frames.length - i - 1].setSize(fWidth, fHeight); frames[frames.length - i - 1].setSize(fWidth, fHeight);
indent = (i + 1) % oCount == 0 ? 0 : indent + 1; indent = (i + 1) % oCount == 0 ? 0 : indent + 1;
} }
} }
/** /**
* *
*/ */
public void tileWindows(int orientation){ public void tileWindows(int orientation) {
int rows, cols, int rows, cols,
rHeight, cWidth, rHeight, cWidth,
row, col, row, col,
i; i;
JInternalFrame[] frames = getOpenFrames(); JInternalFrame[] frames = getOpenFrames();
if(frames.length == 0) return; if (frames.length == 0) {
return;
}
if(orientation == SwingConstants.HORIZONTAL){ if (orientation == SwingConstants.HORIZONTAL) {
rows = (int)(Math.rint(Math.sqrt(frames.length) - 0.49)); rows = (int) (Math.rint(Math.sqrt(frames.length) - 0.49));
cols = frames.length / rows; cols = frames.length / rows;
rHeight = getHeight() / rows; rHeight = getHeight() / rows;
cWidth = getWidth() / cols; cWidth = getWidth() / cols;
row = col = 0; row = col = 0;
for(i = 0; i < frames.length; i++){ for (i = 0; i < frames.length; i++) {
frames[i].setLocation(col * cWidth, row * rHeight); frames[i].setLocation(col * cWidth, row * rHeight);
frames[i].setSize(cWidth, rHeight); frames[i].setSize(cWidth, rHeight);
if(col == cols - 1){ if (col == cols - 1) {
row++; row++;
col = 0; col = 0;
} else {
col++;
} }
else col++; if (row > 0 && frames.length - i - (cols + 1) * (rows - row) > 0) {
if(row > 0 && frames.length - i - (cols + 1) * (rows - row) > 0){
cols++; cols++;
cWidth = getWidth() / cols; cWidth = getWidth() / cols;
} }
} }
} } else if (orientation == SwingConstants.VERTICAL) {
else if(orientation == SwingConstants.VERTICAL){ cols = (int) (Math.rint(Math.sqrt(frames.length) - 0.49));
cols = (int)(Math.rint(Math.sqrt(frames.length) - 0.49));
rows = frames.length / cols; rows = frames.length / cols;
cWidth = getWidth() / cols; cWidth = getWidth() / cols;
rHeight = getHeight() / rows; rHeight = getHeight() / rows;
col = row = 0; col = row = 0;
for(i = 0; i < frames.length; i++){ for (i = 0; i < frames.length; i++) {
frames[i].setLocation(col * cWidth, row * rHeight); frames[i].setLocation(col * cWidth, row * rHeight);
frames[i].setSize(cWidth, rHeight); frames[i].setSize(cWidth, rHeight);
if(row == rows - 1){ if (row == rows - 1) {
col++; col++;
row = 0; row = 0;
} else {
row++;
} }
else row++; if (col > 0 && frames.length - i - (rows + 1) * (cols - col) > 0) {
if(col > 0 && frames.length - i - (rows + 1) * (cols - col) > 0){
rows++; rows++;
rHeight = getHeight() / rows; rHeight = getHeight() / rows;
} }
@ -183,14 +209,16 @@ public class JExtDesktopPane extends JDesktopPane{
} }
} }
public JInternalFrame[] getOpenFrames(){ public JInternalFrame[] getOpenFrames() {
JInternalFrame[] result; JInternalFrame[] result;
Vector vResults = new Vector(10); Vector vResults = new Vector(10);
Component tmp; Component tmp;
for(int i = 0; i < getComponentCount(); i++){ for (int i = 0; i < getComponentCount(); i++) {
tmp = getComponent(i); tmp = getComponent(i);
if(tmp instanceof JInternalFrame) vResults.addElement(tmp); if (tmp instanceof JInternalFrame) {
vResults.addElement(tmp);
}
} }
result = new JInternalFrame[vResults.size()]; result = new JInternalFrame[vResults.size()];
@ -198,40 +226,54 @@ public class JExtDesktopPane extends JDesktopPane{
return result; return result;
} }
public int getFrameCount(){
return getComponentCount(new ComponentFilter(){ public int getFrameCount() {
public boolean accept(Component c){ return getComponentCount(new ComponentFilter() {
return c instanceof JInternalFrame ||
(c instanceof JInternalFrame.JDesktopIcon && public boolean accept(Component c) {
((JInternalFrame.JDesktopIcon)c).getInternalFrame() != null); return c instanceof JInternalFrame
|| (c instanceof JInternalFrame.JDesktopIcon
&& ((JInternalFrame.JDesktopIcon) c).getInternalFrame() != null);
} }
}); });
} }
public int getComponentCount(ComponentFilter c){
public int getComponentCount(ComponentFilter c) {
int result = 0; int result = 0;
for(int i = 0; i < getComponentCount(); i++) if(c.accept(getComponent(i))) result++; for (int i = 0; i < getComponentCount(); i++) {
if (c.accept(getComponent(i))) {
result++;
}
}
return result; return result;
} }
public void selectFrame(JInternalFrame f){
if(f != null){ public void selectFrame(JInternalFrame f) {
try{ if (f != null) {
if(f.isIcon()) f.setIcon(false); try {
else f.setSelected(true); if (f.isIcon()) {
f.setIcon(false);
} else {
f.setSelected(true);
} }
catch(PropertyVetoException exc){} } catch (PropertyVetoException exc) {
} }
} }
public void addImpl(Component comp, Object constraints, int index){ }
public void addImpl(Component comp, Object constraints, int index) {
super.addImpl(comp, constraints, index); super.addImpl(comp, constraints, index);
//System.out.println("JExtDesktopPane.addImpl"); //System.out.println("JExtDesktopPane.addImpl");
if(comp instanceof JDocFrame){ if (comp instanceof JDocFrame) {
JDocFrame f = (JDocFrame)comp; JDocFrame f = (JDocFrame) comp;
int frameIndex = m_mnuWindow.getItemCount() - m_manager.WINDOW_LIST_START + 1; int frameIndex = m_mnuWindow.getItemCount() - m_manager.WINDOW_LIST_START + 1;
if(f.getClientProperty(ExtDesktopManager.INDEX) != null) return; if (f.getClientProperty(ExtDesktopManager.INDEX) != null) {
return;
}
f.putClientProperty(ExtDesktopManager.INDEX, new Integer(frameIndex)); f.putClientProperty(ExtDesktopManager.INDEX, new Integer(frameIndex));
JMenuItem m = new JMenuItem((frameIndex < 10 ? frameIndex + " " : "") + f.getTitle()); JMenuItem m = new JMenuItem((frameIndex < 10 ? frameIndex + " " : "") + f.getTitle());
if(frameIndex < 10){ if (frameIndex < 10) {
m.setMnemonic((char)(0x30 + frameIndex)); m.setMnemonic((char) (0x30 + frameIndex));
m.setAccelerator(KeyStroke.getKeyStroke(0x30 + frameIndex, Event.ALT_MASK)); m.setAccelerator(KeyStroke.getKeyStroke(0x30 + frameIndex, Event.ALT_MASK));
} }
m.setToolTipText("Shows the window " + f.getTitle() + " an"); m.setToolTipText("Shows the window " + f.getTitle() + " an");
@ -255,7 +297,8 @@ public class JExtDesktopPane extends JDesktopPane{
// m_mnuWindow.add(m); // m_mnuWindow.add(m);
// } // }
} }
public JMenu getWindowMenu(){
public JMenu getWindowMenu() {
return m_mnuWindow; return m_mnuWindow;
} }
} }

View File

@ -9,13 +9,11 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $ * $Author: streiche $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.Insets; import java.awt.Insets;
import java.beans.*; import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.*;
/** /**
* *
*/ */

View File

@ -7,33 +7,25 @@ package eva2.gui;
* Company: University of Tuebingen, Computer Architecture * Company: University of Tuebingen, Computer Architecture
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher * @author Holger Ulmer, Felix Streichert, Hannes Planatscher
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.awt.BorderLayout; import eva2.server.stat.EvAJobList;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.beans.PropertyEditor; import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager; import java.beans.PropertyEditorManager;
import java.io.Serializable; import java.io.Serializable;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import eva2.server.stat.EvAJobList;
public class JParaPanel implements Serializable, PanelMaker { public class JParaPanel implements Serializable, PanelMaker {
public static boolean TRACE = false; protected String name = "undefined";
protected String m_Name = "undefined"; protected Object localParameter;
protected Object m_LocalParameter; protected Object proxyParameter;
protected Object m_ProxyParameter; protected PropertyEditor propertyEditor;
protected PropertyEditor m_Editor;
private JPanel m_Panel; /**
* ToDo: Should be removed in future.
*/
private JPanel tempPanel = new JPanel();
public JParaPanel() { public JParaPanel() {
} }
@ -41,44 +33,36 @@ public class JParaPanel implements Serializable, PanelMaker {
/** /**
*/ */
public JParaPanel(Object Parameter, String name) { public JParaPanel(Object Parameter, String name) {
m_Name = name; this.name = name;
m_LocalParameter = Parameter; localParameter = Parameter;
} }
/** /**
*/ */
public JComponent makePanel() { public JComponent makePanel() {
m_Panel = new JPanel();
//m_Panel.setPreferredSize(new Dimension(200, 200)); // MK: this was evil, killing all the auto-layout mechanisms
PropertyEditorProvider.installEditors(); PropertyEditorProvider.installEditors();
if (m_LocalParameter instanceof EvAJobList) { if (localParameter instanceof EvAJobList) {
m_Editor = EvAJobList.makeEditor(m_Panel, (EvAJobList)m_LocalParameter); /* ToDo: First parameter is useless and should be removed */
propertyEditor = EvAJobList.makeEditor(tempPanel, (EvAJobList) localParameter);
} else { } else {
m_Editor = new GenericObjectEditor(); propertyEditor = new GenericObjectEditor();
((GenericObjectEditor) (m_Editor)).setClassType(m_LocalParameter.getClass()); ((GenericObjectEditor) (propertyEditor)).setClassType(localParameter.getClass());
((GenericObjectEditor) (m_Editor)).setValue(m_LocalParameter); ((GenericObjectEditor) (propertyEditor)).setValue(localParameter);
((GenericObjectEditor) (m_Editor)).disableOKCancel(); ((GenericObjectEditor) (propertyEditor)).disableOKCancel();
} }
m_Panel.setLayout(new BorderLayout()); return (JComponent) propertyEditor.getCustomEditor();
m_Panel.add(m_Editor.getCustomEditor(), BorderLayout.CENTER);
m_Panel.setLayout(new FlowLayout(FlowLayout.TRAILING, 10, 10));
m_Panel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
m_Panel.setLayout(new GridBagLayout());
m_Panel.add(Box.createRigidArea(new Dimension(0, 10)));
return m_Panel;
} }
/** /**
*/ */
public String getName() { public String getName() {
return m_Name; return name;
} }
public PropertyEditor getEditor() { public PropertyEditor getEditor() {
return m_Editor; return propertyEditor;
} }
/** This method will allow you to add a new Editor to a given class /** This method will allow you to add a new Editor to a given class
@ -90,7 +74,6 @@ public class JParaPanel implements Serializable, PanelMaker {
try { try {
PropertyEditorManager.registerEditor(object, editor); PropertyEditorManager.registerEditor(object, editor);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace();
System.err.println(ex.getMessage()); System.err.println(ex.getMessage());
return false; return false;
} }

View File

@ -9,57 +9,48 @@ package eva2.gui;
* $Date: 2007-11-15 14:58:12 +0100 (Thu, 15 Nov 2007) $ * $Date: 2007-11-15 14:58:12 +0100 (Thu, 15 Nov 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.server.go.tools.FileTools; import eva2.server.go.tools.FileTools;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Point; import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.*; import java.awt.event.*;
import java.io.Serializable; import java.io.Serializable;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
/*==========================================================================* import javax.swing.event.InternalFrameAdapter;
* CLASS DECLARATION import javax.swing.event.InternalFrameEvent;
*==========================================================================*/
/** /**
* *
*/ */
public class JTextoutputFrame implements JTextoutputFrameInterface, public class JTextoutputFrame implements JTextoutputFrameInterface, ActionListener, Serializable {
ActionListener,
Serializable {
private JMenuItem clearItem, saveItem; private JMenuItem clearItem, saveItem;
public static boolean TRACE = false; public static boolean TRACE = false;
protected String m_Name ="undefined"; protected String frameTitle = "undefined";
private transient JTextArea m_TextArea = null; private transient JTextArea textArea = null;
// private boolean m_firstprint = true; private final JInternalFrame frame;
private final JFrame frame; private JPopupMenu popup;
JPopupMenu popup;
/** /**
* *
*/ */
public JTextoutputFrame(String Title) { public JTextoutputFrame(String title) {
if (TRACE) System.out.println("JTextoutputFrame Constructor"); if (TRACE) System.out.println("JTextoutputFrame Constructor");
m_Name = Title; frameTitle = title;
frame = new JEFrame(m_Name); frame = new JEFrame(frameTitle);
m_TextArea = null; textArea = null;
} }
/** /**
* *
*/ */
public void print(String Text) { public void print(String text) {
//System.out.println("Print:"+Text); //System.out.println("Print:"+Text);
if (m_TextArea == null) { if (textArea == null) {
createFrame(); createFrame();
} }
m_TextArea.append(Text); textArea.append(text);
m_TextArea.repaint(); textArea.repaint();
} }
public void println(String txt) { public void println(String txt) {
@ -70,9 +61,9 @@ Serializable {
if (frame.isVisible() != bShow) { if (frame.isVisible() != bShow) {
if (frame.isVisible()) { if (frame.isVisible()) {
frame.dispose(); frame.dispose();
m_TextArea.setText(null); textArea.setText(null);
} else { } else {
if (m_TextArea == null) createFrame(); if (textArea == null) createFrame();
else frame.setVisible(true); else frame.setVisible(true);
frame.setEnabled(true); frame.setEnabled(true);
} }
@ -84,26 +75,29 @@ Serializable {
*/ */
private void createFrame() { private void createFrame() {
if (TRACE) System.out.println("JTextoutputFrame createFrame"); if (TRACE) System.out.println("JTextoutputFrame createFrame");
m_TextArea = new JTextArea(10,80); textArea = new JTextArea(10,80);
m_TextArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
m_TextArea.setLineWrap(true); textArea.setLineWrap(true);
m_TextArea.setWrapStyleWord(true); textArea.setWrapStyleWord(true);
m_TextArea.setEditable(false); textArea.setEditable(false);
m_TextArea.setCaretPosition(0); textArea.setCaretPosition(0);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); //frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
frame.addWindowListener(new WindowAdapter() { frame.addInternalFrameListener(new InternalFrameAdapter() {
public void windowClosing(WindowEvent e) {
@Override
public void internalFrameClosing(InternalFrameEvent e) {
super.internalFrameClosing(e);
frame.dispose(); frame.dispose();
frame.setEnabled(false); frame.setEnabled(false);
} }
}); });
frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().setLayout(new BorderLayout());
//frame.getContentPane().add(new JScrollPane(m_TextArea), BorderLayout.CENTER); //frame.getContentPane().add(new JScrollPane(m_TextArea), BorderLayout.CENTER);
final JScrollPane scrollpane = new JScrollPane(m_TextArea); final JScrollPane scrollpane = new JScrollPane(textArea);
frame.getContentPane().add(scrollpane, BorderLayout.CENTER); frame.getContentPane().add(scrollpane, BorderLayout.CENTER);
scrollpane.getViewport().addChangeListener(new ChangeListener() { scrollpane.getViewport().addChangeListener(new ChangeListener() {
private int lastHeight; private int lastHeight;
@ -122,23 +116,7 @@ Serializable {
frame.pack(); frame.pack();
frame.setSize(800, 400); frame.setSize(800, 400);
frame.setVisible(true); frame.setVisible(true);
frame.setState(Frame.ICONIFIED); // frame.setState(Frame.ICONIFIED);
}
/**
*output
*/
public static void main( String[] args ){
JTextoutputFrame test = new JTextoutputFrame("hi");
while (test.frame.isEnabled()) {
test.print("Test 12345");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Done!");
} }
@ -158,7 +136,7 @@ Serializable {
//Add listener to components that can bring up popup menus. //Add listener to components that can bring up popup menus.
MouseListener popupListener = new PopupListener(popup); MouseListener popupListener = new PopupListener(popup);
// frame.addMouseListener(popupListener); // frame.addMouseListener(popupListener);
m_TextArea.addMouseListener(popupListener); textArea.addMouseListener(popupListener);
// menuBar.addMouseListener(popupListener); // menuBar.addMouseListener(popupListener);
@ -167,9 +145,9 @@ Serializable {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JMenuItem src = (JMenuItem)e.getSource(); JMenuItem src = (JMenuItem)e.getSource();
if (src == clearItem) { if (src == clearItem) {
m_TextArea.setText(null); textArea.setText(null);
} else if (src == saveItem) { } else if (src == saveItem) {
FileTools.saveObjectWithFileChooser(frame, m_TextArea.getText()); FileTools.saveObjectWithFileChooser(frame, textArea.getText());
// File outfile = FileTools.writeString("TextOutput.txt", m_TextArea.getText()); // File outfile = FileTools.writeString("TextOutput.txt", m_TextArea.getText());
} else System.err.println("Unknown popup component (JTextoutputFrame)!"); } else System.err.println("Unknown popup component (JTextoutputFrame)!");
} }

View File

@ -28,6 +28,7 @@ import javax.swing.event.ChangeListener;
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import java.awt.Color;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.*; import java.awt.event.*;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
@ -52,19 +53,20 @@ public class LoggingPanel extends JPanel {
public LoggingPanel(Logger logger) { public LoggingPanel(Logger logger) {
this.logger = logger; this.logger = logger;
loggingTextArea.setEditable(false); loggingTextArea.setEditable(false);
loggingTextArea.setBorder(BorderFactory.createEmptyBorder(4,4,4,4));
loggingTextArea.setLineWrap(true); loggingTextArea.setLineWrap(true);
loggingTextArea.setBorder(BorderFactory.createEmptyBorder());
JPanel mainPanel = new JPanel(); setLayout(new BorderLayout());
mainPanel.setBorder(BorderFactory.createTitledBorder("Info"));
add(new JLabel("Info"), BorderLayout.PAGE_START);
this.loggingHandler = new LoggingHandler(this); this.loggingHandler = new LoggingHandler(this);
logger.addHandler(loggingHandler); logger.addHandler(loggingHandler);
mainPanel.setLayout(new BorderLayout());
final JScrollPane scrollpane = new JScrollPane(loggingTextArea); final JScrollPane scrollpane = new JScrollPane(loggingTextArea);
scrollpane.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
// scrollpane.setAutoscrolls(false); // scrollpane.setAutoscrolls(false);
mainPanel.add(scrollpane, BorderLayout.CENTER); add(scrollpane, BorderLayout.CENTER);
scrollpane.getViewport().addChangeListener(new ChangeListener() { scrollpane.getViewport().addChangeListener(new ChangeListener() {
private int lastHeight; private int lastHeight;
// //
@ -78,8 +80,6 @@ public class LoggingPanel extends JPanel {
} }
} }
}); });
setLayout(new BorderLayout());
add(mainPanel, BorderLayout.CENTER);
} }
/** /**
* *

View File

@ -10,38 +10,46 @@ package eva2.gui;
/** /**
* *
*/ */
class Mnemonic{ class Mnemonic {
private char mnemonic; private char mnemonic;
private String text; private String text;
/** /**
* *
*/ */
public Mnemonic(String s){ public Mnemonic(String s) {
setString(s); setString(s);
} }
/** /**
* *
*/ */
public void setString(String s){ public void setString(String s) {
StringBuffer buf = new StringBuffer(s); StringBuffer buf = new StringBuffer(s);
for(int i = 0; i < buf.length(); i++) for (int i = 0; i < buf.length(); i++) {
if(buf.charAt(i) == '&'){ if (buf.charAt(i) == '&') {
buf.deleteCharAt(i); buf.deleteCharAt(i);
i++; i++;
if(i < buf.length() && buf.charAt(i) != '&') mnemonic = buf.charAt(i - 1); if (i < buf.length() && buf.charAt(i) != '&') {
mnemonic = buf.charAt(i - 1);
}
}
} }
text = buf.toString(); text = buf.toString();
} }
/** /**
* *
*/ */
public char getMnemonic(){ public char getMnemonic() {
return mnemonic; return mnemonic;
} }
/** /**
* *
*/ */
public String getText(){ public String getText() {
return text; return text;
} }
} }

View File

@ -48,6 +48,9 @@ import eva2.server.go.individuals.AbstractEAIndividual;
import eva2.server.go.populations.Population; import eva2.server.go.populations.Population;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import eva2.tools.chart2d.DPointSet; import eva2.tools.chart2d.DPointSet;
import javax.swing.*;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
/*==========================================================================* /*==========================================================================*
* CLASS DECLARATION * CLASS DECLARATION
@ -68,7 +71,7 @@ public class Plot implements PlotInterface, Serializable {
private String m_xname; private String m_xname;
private String m_yname; private String m_yname;
protected FunctionArea m_PlotArea; protected FunctionArea m_PlotArea;
protected JFrame m_Frame; protected JInternalFrame m_Frame;
/** /**
* You might want to try to assign the x-range as x and y-range as y array * You might want to try to assign the x-range as x and y-range as y array
@ -221,7 +224,7 @@ public class Plot implements PlotInterface, Serializable {
m_Frame = new JEFrame("Plot: " + m_PlotName); m_Frame = new JEFrame("Plot: " + m_PlotName);
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));
m_ButtonPanel = new JPanel(); m_ButtonPanel = new JPanel();
m_PlotArea = new FunctionArea(m_xname, m_yname); m_PlotArea = new FunctionArea(m_xname, m_yname);
@ -233,8 +236,11 @@ public class Plot implements PlotInterface, Serializable {
m_Frame.getContentPane().add(m_ButtonPanel, "South"); m_Frame.getContentPane().add(m_ButtonPanel, "South");
m_Frame.getContentPane().add(m_PlotArea, "Center"); // north was not so m_Frame.getContentPane().add(m_PlotArea, "Center"); // north was not so
// nice // nice
m_Frame.addWindowListener(new WindowAdapter() { m_Frame.addInternalFrameListener(new InternalFrameAdapter() {
public void windowClosing(WindowEvent e) {
@Override
public void internalFrameClosing(InternalFrameEvent e) {
super.internalFrameClosing(e);
m_PlotArea.clearAll(); // this was a memory leak m_PlotArea.clearAll(); // this was a memory leak
m_PlotArea = null; m_PlotArea = null;
m_Frame.dispose(); m_Frame.dispose();

View File

@ -1,17 +1,10 @@
package eva2.gui; package eva2.gui;
/* /*
* Title: EvA2 * Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
* Description: * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 14 $
* Copyright: Copyright (c) 2003 * $Date: 2006-12-18 16:32:23 +0100 (Mon, 18 Dec 2006) $ $Author: marcekro $
* Company: University of Tuebingen, Computer Architecture
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
* @version: $Revision: 14 $
* $Date: 2006-12-18 16:32:23 +0100 (Mon, 18 Dec 2006) $
* $Author: marcekro $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Toolkit; import java.awt.Toolkit;
@ -20,30 +13,31 @@ import java.beans.PropertyEditor;
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import eva2.tools.EVAHELP; import eva2.tools.EVAHELP;
/*==========================================================================* import javax.swing.JDialog;
* CLASS DECLARATION import javax.swing.JFrame;
*==========================================================================*/
/** /**
* *
*/ */
public class PropertyDialog extends JEFrame { public class PropertyDialog extends JDialog {
private PropertyEditor m_Editor;
private Component m_EditorComponent; private PropertyEditor propertyEditor;
private Component editorComponent;
/** /**
* *
*/ */
public PropertyDialog (PropertyEditor editor,String Title, int x, int y) { public PropertyDialog(PropertyEditor editor, String title, int x, int y) {
super(getFrameNameFromEditor(editor)); // that was the long class name !! super();
setTitle(getFrameNameFromEditor(editor));
//super(getFrameNameFromEditor(editor)); // that was the long class name !!
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); setDefaultCloseOperation(HIDE_ON_CLOSE);
setLayout(new BorderLayout());
//System.out.println("PropertyDialog.Constructor of "+ Title); propertyEditor = editor;
setDefaultCloseOperation(DISPOSE_ON_CLOSE); editorComponent = editor.getCustomEditor();
getContentPane().setLayout(new BorderLayout()); add(editorComponent, BorderLayout.CENTER);
m_Editor = editor;
m_EditorComponent = editor.getCustomEditor();
getContentPane().add(m_EditorComponent, BorderLayout.CENTER);
pack(); pack();
setLocation(x, y); setLocation(x, y);
setVisible(true); setVisible(true);
@ -52,7 +46,9 @@ public class PropertyDialog extends JEFrame {
protected static String getFrameNameFromEditor(PropertyEditor editor) { protected static String getFrameNameFromEditor(PropertyEditor editor) {
if (editor.getValue().getClass().isArray()) { if (editor.getValue().getClass().isArray()) {
return "Array of " + EVAHELP.cutClassName(editor.getValue().getClass().getComponentType().getName()); return "Array of " + EVAHELP.cutClassName(editor.getValue().getClass().getComponentType().getName());
} else return EVAHELP.cutClassName(editor.getValue().getClass().getName()); } else {
return EVAHELP.cutClassName(editor.getValue().getClass().getName());
}
} }
/** /**
@ -68,7 +64,6 @@ public class PropertyDialog extends JEFrame {
* *
*/ */
public PropertyEditor getEditor() { public PropertyEditor getEditor() {
return m_Editor; return propertyEditor;
} }
} }

View File

@ -9,69 +9,71 @@ package eva2.gui;
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $ * $Author: streiche $
*/ */
/*==========================================================================* import eva2.tools.EVAHELP;
* IMPORTS import java.awt.*;
*==========================================================================*/ import java.awt.event.ActionEvent;
import java.awt.Dimension; import java.awt.event.ActionListener;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.beans.PropertyEditor; import java.beans.PropertyEditor;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JFrame; import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import eva2.tools.EVAHELP;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
public class PropertyPanel extends JPanel { public class PropertyPanel extends JPanel {
private PropertyEditor m_PropertyEditor; private PropertyEditor propertyEditor;
private PropertyDialog m_PropertyDialog; private PropertyDialog propertyDialog;
private JLabel textLabel;
/** /**
* *
*/ */
public PropertyPanel(PropertyEditor Editor) { public PropertyPanel(PropertyEditor editor) {
setBorder(BorderFactory.createEtchedBorder());
setToolTipText("Click to edit properties for this object"); setToolTipText("Click to edit properties for this object");
setOpaque(true); setOpaque(true);
m_PropertyEditor = Editor;
addMouseListener(new MouseAdapter() { setLayout(new GridBagLayout());
public void mouseClicked(MouseEvent evt) { GridBagConstraints gbConstraints = new GridBagConstraints();
if (m_PropertyEditor.getValue() != null) { gbConstraints.gridx = 0;
gbConstraints.gridy = 0;
gbConstraints.weightx = 1.0;
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
propertyEditor = editor;
textLabel = new JLabel();
add(textLabel, gbConstraints);
JButton dialogButton = new JButton("...");
dialogButton.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.LIGHT_GRAY));
dialogButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
if (propertyEditor.getValue() != null) {
showDialog(getLocationOnScreen().x, getLocationOnScreen().y); showDialog(getLocationOnScreen().x, getLocationOnScreen().y);
} }
} }
}); });
Dimension newPref = getPreferredSize(); gbConstraints.weighty = 1.0;
newPref.height = getFontMetrics(getFont()).getHeight() * 6 / 4; //6 / 4; gbConstraints.fill = GridBagConstraints.VERTICAL;
newPref.width = newPref.height * 6; //5 gbConstraints.anchor = GridBagConstraints.LINE_END;
setPreferredSize(newPref); gbConstraints.gridx = 1;
add(dialogButton, gbConstraints);
} }
public void showDialog(int initX, int initY) { public void showDialog(int initX, int initY) {
if (m_PropertyDialog == null) { if (propertyDialog == null) {
// int x = getLocationOnScreen().x; propertyDialog = new PropertyDialog(propertyEditor, EVAHELP.cutClassName(propertyEditor.getClass().getName()) , initX, initY);
// int y = getLocationOnScreen().y; propertyDialog.setPreferredSize(new Dimension(500,300));
m_PropertyDialog = new PropertyDialog(m_PropertyEditor, EVAHELP.cutClassName(m_PropertyEditor.getClass().getName()) , initX, initY); propertyDialog.setVisible(true);
m_PropertyDialog.setPreferredSize(new Dimension(500,300));
} }
else { else {
m_PropertyDialog.updateFrameTitle(m_PropertyEditor); propertyDialog.updateFrameTitle(propertyEditor);
// System.out.println("" + BeanInspector.toString(m_PropertyDialog)); propertyDialog.setVisible(false);
m_PropertyDialog.setVisible(false); propertyDialog.setVisible(true);
m_PropertyDialog.setExtendedState(JFrame.NORMAL); propertyDialog.requestFocus();
m_PropertyDialog.setVisible(true);
m_PropertyDialog.requestFocus();
// System.out.println("" + BeanInspector.toString(m_PropertyDialog));
// System.out.println("Aft: " + m_PropertyDialog.isShowing() + " " + m_PropertyDialog.isVisible() + " " + m_PropertyDialog.isActive() + " " + m_PropertyDialog.isFocused());
} }
} }
@ -79,15 +81,8 @@ public class PropertyPanel extends JPanel {
* *
*/ */
public void removeNotify() { public void removeNotify() {
if (m_PropertyDialog != null) { if (propertyDialog != null) {
// System.out.println(" m_PropertyDialog.dispose();"); propertyDialog = null;
// System.out.println(m_PropertyDialog.isActive());
// System.out.println(m_PropertyDialog.isVisible());
// System.out.println(m_PropertyDialog.isValid());
// System.out.println(m_PropertyDialog.isDisplayable());
// if (m_PropertyDialog.isDisplayable()) m_PropertyDialog.dispose(); // this caused a deadlock!
// m_PropertyDialog.dispose(); // this also caused a deadlock!
m_PropertyDialog = null;
} }
} }
@ -95,14 +90,14 @@ public class PropertyPanel extends JPanel {
* *
*/ */
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
Insets i = getInsets(); Insets i = textLabel.getInsets();
Rectangle box = new Rectangle(i.left, i.top, Rectangle box = new Rectangle(i.left, i.top,
getSize().width - i.left - i.right , getSize().width - i.left - i.right ,
getSize().height - i.top - i.bottom); getSize().height - i.top - i.bottom);
g.clearRect(i.left, i.top, g.clearRect(i.left, i.top,
getSize().width - i.right - i.left, getSize().width - i.right - i.left,
getSize().height - i.bottom - i.top); getSize().height - i.bottom - i.top);
m_PropertyEditor.paintValue(g, box); propertyEditor.paintValue(g, box);
// Rectangle box = new Rectangle(i.left,i.top, // Rectangle box = new Rectangle(i.left,i.top,
// this.getWidth() - i.right, // this.getWidth() - i.right,
@ -110,6 +105,6 @@ public class PropertyPanel extends JPanel {
} }
public PropertyEditor getEditor() { public PropertyEditor getEditor() {
return m_PropertyEditor; return propertyEditor;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -27,30 +27,29 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
public class PropertySheetPanelStat extends JPanel implements Serializable { public class PropertySheetPanelStat extends JPanel implements Serializable {
public final static boolean TRACE = false; public final static boolean TRACE = false;
private Object[] m_Values; private Object[] m_Values;
private JCheckBoxFlag[] m_Views; private JCheckBoxFlag[] m_Views;
private JLabel[] m_Labels; private JLabel[] m_Labels;
private boolean[] m_flag; private boolean[] m_flag;
/** /**
* Creates the property sheet panel. * Creates the property sheet panel.
*/ */
public PropertySheetPanelStat() { public PropertySheetPanelStat() {
// setBorder(BorderFactory.createLineBorder(Color.red)); // setBorder(BorderFactory.createLineBorder(Color.red));
setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
} }
/** A support object for handling property change listeners */ /**
* A support object for handling property change listeners
*/
private PropertyChangeSupport m_support = new PropertyChangeSupport(this); private PropertyChangeSupport m_support = new PropertyChangeSupport(this);
public synchronized void setTarget(String[] names, boolean[] flag) { public synchronized void setTarget(String[] names, boolean[] flag) {
int componentOffset = 0; int componentOffset = 0;
// Close any child windows at this point // Close any child windows at this point
@ -60,8 +59,6 @@ public class PropertySheetPanelStat extends JPanel implements Serializable {
setVisible(false); setVisible(false);
int rowHeight = 12; int rowHeight = 12;
JTextArea jt = new JTextArea();
JScrollPane js = null;
m_Values = new Object[flag.length]; m_Values = new Object[flag.length];
m_Views = new JCheckBoxFlag[flag.length]; m_Views = new JCheckBoxFlag[flag.length];
@ -69,23 +66,25 @@ public class PropertySheetPanelStat extends JPanel implements Serializable {
for (int i = 0; i < names.length; i++) { for (int i = 0; i < names.length; i++) {
m_Labels[i] = new JLabel(names[i], SwingConstants.RIGHT); m_Labels[i] = new JLabel(names[i], SwingConstants.RIGHT);
m_Labels[i].setBorder(BorderFactory.createEmptyBorder(10,10,0,5)); m_Labels[i].setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
m_Views[i] = new JCheckBoxFlag(flag[i]); m_Views[i] = new JCheckBoxFlag(flag[i]);
GridBagConstraints gbConstraints = new GridBagConstraints(); GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.anchor = GridBagConstraints.EAST; gbConstraints.anchor = GridBagConstraints.EAST;
gbConstraints.fill = GridBagConstraints.HORIZONTAL; gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.gridy = i+componentOffset; gbConstraints.gridx = 0; gbConstraints.gridy = i + componentOffset;
gbConstraints.gridx = 0;
gbLayout.setConstraints(m_Labels[i], gbConstraints); gbLayout.setConstraints(m_Labels[i], gbConstraints);
add(m_Labels[i]); add(m_Labels[i]);
JPanel newPanel = new JPanel(); JPanel newPanel = new JPanel();
newPanel.setBorder(BorderFactory.createEmptyBorder(10,5,0,10)); newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
newPanel.setLayout(new BorderLayout()); newPanel.setLayout(new BorderLayout());
newPanel.add(m_Views[i], BorderLayout.CENTER); newPanel.add(m_Views[i], BorderLayout.CENTER);
gbConstraints = new GridBagConstraints(); gbConstraints = new GridBagConstraints();
gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.anchor = GridBagConstraints.WEST;
gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.gridy = i+componentOffset; gbConstraints.gridx = 1; gbConstraints.gridy = i + componentOffset;
gbConstraints.gridx = 1;
gbConstraints.weightx = 100; gbConstraints.weightx = 100;
gbLayout.setConstraints(newPanel, gbConstraints); gbLayout.setConstraints(newPanel, gbConstraints);
add(newPanel); add(newPanel);
@ -93,28 +92,32 @@ public class PropertySheetPanelStat extends JPanel implements Serializable {
validate(); validate();
setVisible(true); setVisible(true);
} }
/** /**
* *
*/ */
public boolean[] getState() { public boolean[] getState() {
boolean[] ret = new boolean[this.m_Views.length]; boolean[] ret = new boolean[this.m_Views.length];
for (int i=0;i<ret.length;i++) { for (int i = 0; i < ret.length; i++) {
ret[i] = m_Views[i].isSelected(); ret[i] = m_Views[i].isSelected();
} }
return ret; return ret;
} }
} }
/** /**
* *
*/ */
class JCheckBoxFlag extends JCheckBox { class JCheckBoxFlag extends JCheckBox {
private boolean m_Flag = true; private boolean m_Flag = true;
public JCheckBoxFlag (boolean flag) {
public JCheckBoxFlag(boolean flag) {
super(); super();
m_Flag = flag; m_Flag = flag;
addItemListener(new ItemListener () { addItemListener(new ItemListener() {
public void itemStateChanged (ItemEvent evt) {
public void itemStateChanged(ItemEvent evt) {
if (evt.getStateChange() == evt.SELECTED) { if (evt.getStateChange() == evt.SELECTED) {
m_Flag = true; m_Flag = true;
} }
@ -126,5 +129,3 @@ class JCheckBoxFlag extends JCheckBox {
} }
} }

View File

@ -1,97 +1,103 @@
package eva2.gui; package eva2.gui;
/* /*
* Title: EvA2 * Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
* Description: * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 10 $
* Copyright: Copyright (c) 2003 * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ $Author: streiche $
* Company: University of Tuebingen, Computer Architecture
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
* @version: $Revision: 10 $
* $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $
* $Author: streiche $
*/ */
/*==========================================================================* import java.awt.event.FocusAdapter;
* IMPORTS import java.awt.event.FocusEvent;
*==========================================================================*/ import java.awt.event.KeyAdapter;
import java.awt.*; import java.awt.event.KeyEvent;
import java.awt.event.*; import java.beans.PropertyChangeEvent;
import java.beans.*; import java.beans.PropertyChangeListener;
import javax.swing.*; import java.beans.PropertyEditor;
import javax.swing.*; import javax.swing.JPanel;
import javax.swing.event.*; import javax.swing.JSlider;
import javax.swing.text.*; import javax.swing.event.ChangeEvent;
import javax.swing.border.*; import javax.swing.event.ChangeListener;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
class PropertySlider extends JPanel { class PropertySlider extends JPanel {
private PropertyEditor m_Editor;
private JSlider m_Slider; private PropertyEditor propertyEditor;
private JSlider slider;
/** /**
* *
*/ */
PropertySlider(PropertyEditor pe) { PropertySlider(PropertyEditor pe) {
//super(pe.getAsText()); //super(pe.getAsText());
m_Editor = pe; propertyEditor = pe;
//setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); //setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
//setBorder(new TitledBorder(getString("SliderDemo.plain"))); //setBorder(new TitledBorder(getString("SliderDemo.plain")));
m_Slider = new JSlider(-10, 90, 20); slider = new JSlider(-10, 90, 20);
//s.getAccessibleContext().setAccessibleName(getString("SliderDemo.plain")); //s.getAccessibleContext().setAccessibleName(getString("SliderDemo.plain"));
//s.getAccessibleContext().setAccessibleDescription(getString("SliderDemo.a_plain_slider")); //s.getAccessibleContext().setAccessibleDescription(getString("SliderDemo.a_plain_slider"));
m_Slider.addChangeListener(new SliderListener()); slider.addChangeListener(new SliderListener());
m_Slider.setValue(((Integer)m_Editor.getValue()).intValue()); slider.setValue(((Integer) propertyEditor.getValue()).intValue());
m_Slider.setPaintTicks(true); slider.setPaintTicks(true);
m_Slider.setMajorTickSpacing(20); slider.setMajorTickSpacing(20);
m_Slider.setMinorTickSpacing(5); slider.setMinorTickSpacing(5);
m_Slider.setPaintLabels( true ); slider.setPaintLabels(true);
this.add(m_Slider); this.add(slider);
m_Editor.addPropertyChangeListener(new PropertyChangeListener() { propertyEditor.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
updateUs(); updateUs();
} }
}); });
addKeyListener(new KeyAdapter() { addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
// if (e.getKeyCode() == KeyEvent.VK_ENTER) // if (e.getKeyCode() == KeyEvent.VK_ENTER)
updateEditor(); updateEditor();
} }
}); });
addFocusListener(new FocusAdapter() { addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
updateEditor(); updateEditor();
} }
}); });
} }
/** /**
* *
*/ */
protected void updateUs() { protected void updateUs() {
try { try {
//String x = m_Editor.getAsText(); //String x = m_Editor.getAsText();
m_Slider.setValue(((Integer)m_Editor.getValue()).intValue()); slider.setValue(((Integer) propertyEditor.getValue()).intValue());
} catch (IllegalArgumentException ex) {} } catch (IllegalArgumentException ex) {
} }
}
/** /**
* *
*/ */
protected void updateEditor() { protected void updateEditor() {
try { try {
m_Editor.setValue(new Integer (m_Slider.getValue())); propertyEditor.setValue(new Integer(slider.getValue()));
} catch (IllegalArgumentException ex) {} } catch (IllegalArgumentException ex) {
} }
}
/** /**
* *
*/ */
class SliderListener implements ChangeListener { class SliderListener implements ChangeListener {
/** /**
* *
*/ */
public SliderListener() {} public SliderListener() {
}
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
JSlider s1 = (JSlider)e.getSource(); JSlider s1 = (JSlider) e.getSource();
System.out.println("slider"+s1.getValue()); System.out.println("slider" + s1.getValue());
updateEditor(); updateEditor();
} }
} }

View File

@ -5,7 +5,7 @@ import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.beans.PropertyEditor; import java.beans.PropertyEditor;
import javax.swing.BorderFactory;
import javax.swing.JTextField; import javax.swing.JTextField;
/** /**
@ -13,13 +13,14 @@ import javax.swing.JTextField;
* *
*/ */
public class PropertyText extends JTextField { public class PropertyText extends JTextField {
private PropertyEditor m_Editor; private PropertyEditor propertyEditor;
/** /**
* *
*/ */
public PropertyText(PropertyEditor pe) { public PropertyText(PropertyEditor pe) {
super(pe.getAsText()); super(pe.getAsText());
m_Editor = pe; this.setBorder(BorderFactory.createEmptyBorder());
propertyEditor = pe;
// m_Editor.addPropertyChangeListener(new PropertyChangeListener() { // m_Editor.addPropertyChangeListener(new PropertyChangeListener() {
// public void propertyChange(PropertyChangeEvent evt) { // public void propertyChange(PropertyChangeEvent evt) {
// updateUs(); // updateUs();
@ -44,8 +45,8 @@ public class PropertyText extends JTextField {
protected void updateEditor() { protected void updateEditor() {
try { try {
String x = getText(); String x = getText();
if (!m_Editor.getAsText().equals(x)) { if (!propertyEditor.getAsText().equals(x)) {
m_Editor.setAsText(x); propertyEditor.setAsText(x);
// setText(m_Editor.getAsText()); // setText(m_Editor.getAsText());
} }
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
@ -55,10 +56,10 @@ public class PropertyText extends JTextField {
public boolean checkConsistency() { public boolean checkConsistency() {
String x = getText(); String x = getText();
return x.equals(m_Editor.getAsText()); return x.equals(propertyEditor.getAsText());
} }
public void updateFromEditor() { public void updateFromEditor() {
setText(m_Editor.getAsText()); setText(propertyEditor.getAsText());
} }
} }

View File

@ -1,55 +1,48 @@
package eva2.gui; package eva2.gui;
/* /*
* Title: EvA2 * Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of Tuebingen, Computer
* Description: * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher @version: $Revision: 57 $
* Copyright: Copyright (c) 2003 * $Date: 2007-05-04 14:22:16 +0200 (Fri, 04 May 2007) $ $Author: mkron $
* Company: University of Tuebingen, Computer Architecture
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
* @version: $Revision: 57 $
* $Date: 2007-05-04 14:22:16 +0200 (Fri, 04 May 2007) $
* $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
import java.beans.PropertyEditor;
import java.beans.PropertyEditor;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel; import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox; import javax.swing.JComboBox;
public class PropertyValueSelector extends JComboBox { public class PropertyValueSelector extends JComboBox {
PropertyEditor m_Editor;
private PropertyEditor propertyEditor;
/** /**
* *
*/ */
public PropertyValueSelector(PropertyEditor pe) { public PropertyValueSelector(PropertyEditor pe) {
m_Editor = pe; propertyEditor = pe;
Object value = m_Editor.getAsText(); this.setBorder(BorderFactory.createEmptyBorder());
String tags[] = m_Editor.getTags(); Object value = propertyEditor.getAsText();
String[] tags = propertyEditor.getTags();
/** /**
* *
*/ */
ComboBoxModel model = new DefaultComboBoxModel(tags) { ComboBoxModel model = new DefaultComboBoxModel(tags) {
/** /**
* *
*/ */
public Object getSelectedItem() { public Object getSelectedItem() {
return m_Editor.getAsText(); return propertyEditor.getAsText();
} }
/** /**
* *
*/ */
public void setSelectedItem(Object o) { public void setSelectedItem(Object o) {
m_Editor.setAsText((String)o); propertyEditor.setAsText((String) o);
} }
}; };
setModel(model); setModel(model);
setSelectedItem(value); setSelectedItem(value);
} }
} }

View File

@ -9,33 +9,29 @@ package eva2.gui;
* $Date: 2007-10-23 13:43:24 +0200 (Tue, 23 Oct 2007) $ * $Date: 2007-10-23 13:43:24 +0200 (Tue, 23 Oct 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.beans.*; import java.beans.*;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import eva2.server.stat.GenericStatistics; import eva2.server.stat.GenericStatistics;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
public class StatisticsEditor implements PropertyEditor { public class StatisticsEditor implements PropertyEditor {
private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); private PropertyChangeSupport m_Support = new PropertyChangeSupport(this);
private PropertySheetPanelStat m_StatPanel; private PropertySheetPanelStat m_StatPanel;
private JScrollPane m_ScrollPane; private JScrollPane m_ScrollPane;
private JPanel m_Panel; private JPanel m_Panel;
private GenericStatistics m_Value; private GenericStatistics m_Value;
/** /**
* *
*/ */
public StatisticsEditor () { public StatisticsEditor() {
super(); super();
m_StatPanel = new PropertySheetPanelStat(); m_StatPanel = new PropertySheetPanelStat();
m_StatPanel.addPropertyChangeListener( m_StatPanel.addPropertyChangeListener(
new PropertyChangeListener() { new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
m_Support.firePropertyChange("", null, null); m_Support.firePropertyChange("", null, null);
} }
@ -47,89 +43,97 @@ public class StatisticsEditor implements PropertyEditor {
m_Panel.add(m_ScrollPane, BorderLayout.CENTER); m_Panel.add(m_ScrollPane, BorderLayout.CENTER);
} }
/** /**
* *
*/ */
public void setValue (Object value) { public void setValue(Object value) {
if (value instanceof GenericStatistics) { if (value instanceof GenericStatistics) {
m_Value=(GenericStatistics) value; m_Value = (GenericStatistics) value;
m_StatPanel.setTarget(m_Value.getPropertyNames(),m_Value.getState()); m_StatPanel.setTarget(m_Value.getPropertyNames(), m_Value.getState());
} }
m_Support.firePropertyChange("", null, null); m_Support.firePropertyChange("", null, null);
} }
/** /**
* *
*/ */
public Object getValue () { public Object getValue() {
System.out.println("getValue !!!!!!!!!!!!"); System.out.println("getValue !!!!!!!!!!!!");
m_Value.setState(m_StatPanel.getState()); m_Value.setState(m_StatPanel.getState());
return m_Value; return m_Value;
} }
/** /**
* *
*/ */
public String getJavaInitializationString () { public String getJavaInitializationString() {
return "null"; return "null";
} }
/** /**
* *
*/ */
public boolean isPaintable () { public boolean isPaintable() {
return true; return true;
} }
/** /**
* *
*/ */
public void paintValue (Graphics gfx, Rectangle box) { public void paintValue(Graphics gfx, Rectangle box) {
FontMetrics fm = gfx.getFontMetrics(); FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent())/2; int vpad = (box.height - fm.getAscent()) / 2;
//String rep = EVAHELP.cutClassName(m_ElementClass.getName()); //String rep = EVAHELP.cutClassName(m_ElementClass.getName());
gfx.drawString("StatisticeEditor", 2, fm.getHeight() + vpad - 3); gfx.drawString("StatisticeEditor", 2, fm.getHeight() + vpad - 3);
} }
/** /**
* *
*/ */
public String getAsText () { public String getAsText() {
return null; return null;
} }
/** /**
* *
*/ */
public void setAsText (String text) throws IllegalArgumentException { public void setAsText(String text) throws IllegalArgumentException {
throw new IllegalArgumentException(text); throw new IllegalArgumentException(text);
} }
/** /**
* *
*/ */
public String[] getTags () { public String[] getTags() {
return null; return null;
} }
/** /**
* *
*/ */
public boolean supportsCustomEditor () { public boolean supportsCustomEditor() {
return true; return true;
} }
/** /**
* *
*/ */
public Component getCustomEditor () { public Component getCustomEditor() {
return m_Panel; return m_Panel;
} }
public void addPropertyChangeListener(PropertyChangeListener l) { public void addPropertyChangeListener(PropertyChangeListener l) {
if (m_Support == null) m_Support = new PropertyChangeSupport(this); if (m_Support == null) {
m_Support = new PropertyChangeSupport(this);
}
m_Support.addPropertyChangeListener(l); m_Support.addPropertyChangeListener(l);
} }
public void removePropertyChangeListener(PropertyChangeListener l) { public void removePropertyChangeListener(PropertyChangeListener l) {
if (m_Support == null) m_Support = new PropertyChangeSupport(this); if (m_Support == null) {
m_Support = new PropertyChangeSupport(this);
}
m_Support.removePropertyChangeListener(l); m_Support.removePropertyChangeListener(l);
} }
} }

View File

@ -0,0 +1,248 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eva2.gui.utils;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTabbedPaneUI;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
public class CustomTabbedPaneUI extends BasicTabbedPaneUI {
private static final Insets NO_INSETS = new Insets(0, 0, 0, 0);
private ColorSet selectedColorSet;
private ColorSet defaultColorSet;
private ColorSet hoverColorSet;
private boolean contentTopBorderDrawn = true;
private Color lineColor = new Color(158, 158, 158);
private Color dividerColor = new Color(200, 200, 200);
private Insets contentInsets = new Insets(10, 10, 10, 10);
private int lastRollOverTab = -1;
public static ComponentUI createUI(JComponent c) {
return new CustomTabbedPaneUI();
}
public CustomTabbedPaneUI() {
selectedColorSet = new ColorSet();
selectedColorSet.topGradColor1 = new Color(233, 237, 248);
selectedColorSet.topGradColor2 = new Color(158, 199, 240);
selectedColorSet.bottomGradColor1 = new Color(112, 173, 239);
selectedColorSet.bottomGradColor2 = new Color(183, 244, 253);
defaultColorSet = new ColorSet();
defaultColorSet.topGradColor1 = new Color(253, 253, 253);
defaultColorSet.topGradColor2 = new Color(237, 237, 237);
defaultColorSet.bottomGradColor1 = new Color(222, 222, 222);
defaultColorSet.bottomGradColor2 = new Color(255, 255, 255);
hoverColorSet = new ColorSet();
hoverColorSet.topGradColor1 = new Color(244, 244, 244);
hoverColorSet.topGradColor2 = new Color(223, 223, 223);
hoverColorSet.bottomGradColor1 = new Color(211, 211, 211);
hoverColorSet.bottomGradColor2 = new Color(235, 235, 235);
maxTabHeight = 20;
setContentInsets(0);
}
public void setContentTopBorderDrawn(boolean b) {
contentTopBorderDrawn = b;
}
public void setContentInsets(Insets i) {
contentInsets = i;
}
public void setContentInsets(int i) {
contentInsets = new Insets(i, i, i, i);
}
public int getTabRunCount(JTabbedPane pane) {
return 1;
}
protected void installDefaults() {
super.installDefaults();
RollOverListener l = new RollOverListener();
tabPane.addMouseListener(l);
tabPane.addMouseMotionListener(l);
tabAreaInsets = NO_INSETS;
tabInsets = new Insets(0, 0, 0, 1);
}
protected boolean scrollableTabLayoutEnabled() {
return false;
}
protected Insets getContentBorderInsets(int tabPlacement) {
return contentInsets;
}
protected int calculateTabHeight(int tabPlacement, int tabIndex,
int fontHeight) {
return 21;
}
protected int calculateTabWidth(int tabPlacement, int tabIndex,
FontMetrics metrics) {
int w = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
int wid = metrics.charWidth('M');
w += wid * 2;
return w;
}
protected int calculateMaxTabHeight(int tabPlacement) {
return 21;
}
protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) {
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(new GradientPaint(0, 0, defaultColorSet.topGradColor1, 0,
10, defaultColorSet.topGradColor2));
g2d.fillRect(0, 0, tabPane.getWidth(), 10);
g2d.setPaint(new GradientPaint(0, 10, defaultColorSet.bottomGradColor1,
0, 21, defaultColorSet.bottomGradColor2));
g2d.fillRect(0, 10, tabPane.getWidth(), 11);
super.paintTabArea(g, tabPlacement, selectedIndex);
if (contentTopBorderDrawn) {
g2d.setColor(lineColor);
g2d.drawLine(0, 20, tabPane.getWidth() - 1, 20);
}
}
protected void paintTabBackground(Graphics g, int tabPlacement,
int tabIndex, int x, int y, int w, int h, boolean isSelected) {
Graphics2D g2d = (Graphics2D) g;
ColorSet colorSet;
Rectangle rect = rects[tabIndex];
if (isSelected) {
colorSet = selectedColorSet;
} else if (getRolloverTab() == tabIndex) {
colorSet = hoverColorSet;
} else {
colorSet = defaultColorSet;
}
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int width = rect.width;
int xpos = rect.x;
if (tabIndex > 0) {
width--;
xpos++;
}
g2d.setPaint(new GradientPaint(xpos, 0, colorSet.topGradColor1, xpos,
10, colorSet.topGradColor2));
g2d.fillRect(xpos, 0, width, 10);
g2d.setPaint(new GradientPaint(0, 10, colorSet.bottomGradColor1, 0, 21,
colorSet.bottomGradColor2));
g2d.fillRect(xpos, 10, width, 11);
if (contentTopBorderDrawn) {
g2d.setColor(lineColor);
g2d.drawLine(rect.x, 20, rect.x + rect.width - 1, 20);
}
}
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
int x, int y, int w, int h, boolean isSelected) {
Rectangle rect = getTabBounds(tabIndex, new Rectangle(x, y, w, h));
g.setColor(dividerColor);
g.drawLine(rect.x + rect.width, 0, rect.x + rect.width, 20);
}
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
int selectedIndex, int x, int y, int w, int h) {
}
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
int selectedIndex, int x, int y, int w, int h) {
// Do nothing
}
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
int selectedIndex, int x, int y, int w, int h) {
// Do nothing
}
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
int selectedIndex, int x, int y, int w, int h) {
// Do nothing
}
protected void paintFocusIndicator(Graphics g, int tabPlacement,
Rectangle[] rects, int tabIndex, Rectangle iconRect,
Rectangle textRect, boolean isSelected) {
// Do nothing
}
protected int getTabLabelShiftY(int tabPlacement, int tabIndex,
boolean isSelected) {
return 0;
}
private class ColorSet {
Color topGradColor1;
Color topGradColor2;
Color bottomGradColor1;
Color bottomGradColor2;
}
private class RollOverListener implements MouseMotionListener,
MouseListener {
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
checkRollOver();
}
public void mouseClicked(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
checkRollOver();
}
public void mouseExited(MouseEvent e) {
tabPane.repaint();
}
private void checkRollOver() {
int currentRollOver = getRolloverTab();
if (currentRollOver != lastRollOverTab) {
lastRollOverTab = currentRollOver;
Rectangle tabsRect = new Rectangle(0, 0, tabPane.getWidth(), 20);
tabPane.repaint(tabsRect);
}
}
}
}

View File

@ -0,0 +1,86 @@
package eva2.gui.utils;
import java.awt.*;
import java.awt.geom.AffineTransform;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicButtonUI;
public class VerticalButtonUI extends BasicButtonUI {
protected int angle;
public VerticalButtonUI(int angle) {
super();
this.angle = angle;
}
@Override
public Dimension getPreferredSize(JComponent c) {
Dimension dim = super.getPreferredSize(c);
return new Dimension( dim.height, dim.width );
}
private static Rectangle paintIconR = new Rectangle();
private static Rectangle paintTextR = new Rectangle();
private static Rectangle paintViewR = new Rectangle();
private static Insets paintViewInsets = new Insets(0, 0, 0, 0);
@Override
public void paint(Graphics g, JComponent c) {
JButton button = (JButton)c;
String text = button.getText();
Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();
if ((icon == null) && (text == null)) {
return;
}
FontMetrics fm = g.getFontMetrics();
paintViewInsets = c.getInsets(paintViewInsets);
paintViewR.x = paintViewInsets.left;
paintViewR.y = paintViewInsets.top;
// Use inverted height & width
paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
Graphics2D g2 = (Graphics2D) g;
AffineTransform tr = g2.getTransform();
if (angle == 90) {
g2.rotate( Math.PI / 2 );
g2.translate( 0, - c.getWidth() );
paintViewR.x = c.getHeight()/2 - (int)fm.getStringBounds(text, g).getWidth()/2;
paintViewR.y = c.getWidth()/2 - (int)fm.getStringBounds(text, g).getHeight()/2;
}
else if (angle == 270 || angle == -90) {
g2.rotate( - Math.PI / 2 );
g2.translate( - c.getHeight(), 0 );
paintViewR.x = c.getHeight()/2 - (int)fm.getStringBounds(text, g).getWidth()/2;
paintViewR.y = c.getWidth()/2 - (int)fm.getStringBounds(text, g).getHeight()/2;
}
if (icon != null) {
icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
}
if (text != null) {
int textX = paintTextR.x;
int textY = paintTextR.y + fm.getAscent();
if (button.isEnabled()) {
paintText(g,c,new Rectangle(paintViewR.x,paintViewR.y,textX,textY),text);
} else {
paintText(g,c,new Rectangle(paintViewR.x,paintViewR.y,textX,textY),text);
}
}
g2.setTransform( tr );
}
}

View File

@ -8,17 +8,10 @@ package eva2.server;
* $Date: 2007-11-16 17:25:09 +0100 (Fri, 16 Nov 2007) $ * $Date: 2007-11-16 17:25:09 +0100 (Fri, 16 Nov 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import eva2.server.go.InterfaceGOParameters; import eva2.server.go.InterfaceGOParameters;
import eva2.server.modules.ModuleAdapter; import eva2.server.modules.ModuleAdapter;
import eva2.tools.jproxy.MainAdapter; import eva2.tools.jproxy.MainAdapter;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
@ -26,6 +19,7 @@ public interface EvAMainAdapter extends MainAdapter {
public String[] getModuleNameList(); public String[] getModuleNameList();
// returns the corresponding ModuleAdapter // returns the corresponding ModuleAdapter
public ModuleAdapter getModuleAdapter(String selectedModuleName, public ModuleAdapter getModuleAdapter(String selectedModuleName,
boolean withoutRMI, boolean withoutRMI,
String hostAddress, String hostAddress,

View File

@ -9,40 +9,33 @@ package eva2.server;
* $Date: 2007-12-04 15:23:57 +0100 (Tue, 04 Dec 2007) $ * $Date: 2007-12-04 15:23:57 +0100 (Tue, 04 Dec 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import eva2.EvAInfo; import eva2.EvAInfo;
import eva2.server.go.InterfaceGOParameters; import eva2.server.go.InterfaceGOParameters;
import eva2.server.modules.ModuleAdapter; import eva2.server.modules.ModuleAdapter;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
import eva2.tools.jproxy.MainAdapterImpl; import eva2.tools.jproxy.MainAdapterImpl;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
public class EvAMainAdapterImpl extends MainAdapterImpl implements EvAMainAdapter { public class EvAMainAdapterImpl extends MainAdapterImpl implements EvAMainAdapter {
private ModuleServer m_ModulServer=null;
private ModuleServer moduleServer = null;
public EvAMainAdapterImpl() { public EvAMainAdapterImpl() {
super(); super();
m_ModulServer = new ModuleServer(EvAInfo.getProperties()); moduleServer = new ModuleServer(EvAInfo.getProperties());
} }
public String[] getModuleNameList() { public String[] getModuleNameList() {
return m_ModulServer.getModuleNameList(); return moduleServer.getModuleNameList();
} }
public ModuleAdapter getModuleAdapter(String selectedModuleName, boolean withoutRMI, String hostAddress, MainAdapterClient client) { public ModuleAdapter getModuleAdapter(String selectedModule, boolean withoutRMI, String hostAddress, MainAdapterClient client) {
return getModuleAdapter(selectedModuleName, withoutRMI, hostAddress, null, null, client); return getModuleAdapter(selectedModule, withoutRMI, hostAddress, null, null, client);
} }
public ModuleAdapter getModuleAdapter(String selectedModuleName, boolean withoutRMI, String hostAddress, InterfaceGOParameters goParams,String noGuiStatsFile, MainAdapterClient client) { public ModuleAdapter getModuleAdapter(String selectedModule, boolean withoutRMI, String hostAddress, InterfaceGOParameters goParams, String noGuiStatsFile, MainAdapterClient client) {
if (TRACE) System.out.println("MainAdapterImpl.GetModuleAdapter() for module " + return moduleServer.createModuleAdapter(selectedModule, client, withoutRMI, hostAddress, goParams, noGuiStatsFile);
selectedModuleName +" for Client: "+hostAddress+ " called");
return m_ModulServer.createModuleAdapter(selectedModuleName,client,withoutRMI,hostAddress, goParams, noGuiStatsFile);
} }
} }

View File

@ -29,10 +29,9 @@ import java.util.logging.Logger;
* Collect available ModuleAdapter implementations and load them on request. * Collect available ModuleAdapter implementations and load them on request.
*/ */
public class ModuleServer { public class ModuleServer {
private static final Logger logger = Logger.getLogger(eva2.EvAInfo.defaultLogger); private static final Logger LOGGER = Logger.getLogger(eva2.EvAInfo.defaultLogger);
private int m_InstanceCounter = 0; private static int instanceCounter = 0;
private List<Class<?>> moduleClassList; private List<Class<?>> moduleClassList;
// private ArrayList m_RunnungModules;
private ModuleAdapter moduleAdapter; private ModuleAdapter moduleAdapter;
private int moduleAdapterCounter = 0; private int moduleAdapterCounter = 0;
@ -40,7 +39,7 @@ public class ModuleServer {
* *
*/ */
public ModuleServer(Properties EvAProps) { public ModuleServer(Properties EvAProps) {
if (m_InstanceCounter > 0) { if (instanceCounter > 0) {
EVAERROR.EXIT("ModuleServer created twice"); EVAERROR.EXIT("ModuleServer created twice");
} }
moduleClassList = new ArrayList<Class<?>>(); moduleClassList = new ArrayList<Class<?>>();
@ -48,13 +47,14 @@ public class ModuleServer {
String modulePckg = null; String modulePckg = null;
Class<?> filterBy = null; Class<?> filterBy = null;
try { try {
/* Fetch the name of the package containing the modules */
modulePckg = EvAProps.getProperty("ModulePackage"); modulePckg = EvAProps.getProperty("ModulePackage");
/* Fetch the the super class for all modules */
filterBy = Class.forName(EvAProps.getProperty("ModuleFilterClass")); filterBy = Class.forName(EvAProps.getProperty("ModuleFilterClass"));
} catch(Exception e) { } catch (Exception ex) {
System.err.println("Creating ModuleServer failed: couldnt load modules:" + e.getMessage()); System.err.println("Creating ModuleServer failed: couldnt load modules:" + ex.getMessage());
System.err.println("module path was " + modulePckg + ", is it valid?"); System.err.println("module path was " + modulePckg + ", is it valid?");
System.err.println("filter class path was " + ((filterBy==null) ? "null" : filterBy.getName())); System.err.println("filter class path was " + ((filterBy == null) ? "null" : filterBy.getName()));
// e.printStackTrace();
} }
// this gets a list of all valid modules from the package // this gets a list of all valid modules from the package
@ -63,30 +63,34 @@ public class ModuleServer {
moduleClassList.add((Class<?>) cls); moduleClassList.add((Class<?>) cls);
} }
m_InstanceCounter++; instanceCounter++;
} }
/** /**
* Iterates over the list of available modules and fetches
* the name of the module by calling the static getName()
* method.
* *
* @return Array of available modules
*/ */
public String[] getModuleNameList() { public String[] getModuleNameList() {
List<String> moduleNameList = new ArrayList<String>(); List<String> moduleNameList = new ArrayList<String>();
for (int i = 0; i < moduleClassList.size(); i++) { for (Class<?> module : moduleClassList) {
try { try {
Class<?> Modul = (Class<?>) moduleClassList.get(i); Method[] methods = module.getDeclaredMethods();
Method[] methods = Modul.getDeclaredMethods(); for (Method method : methods) {
for (int ii = 0; ii < methods.length; ii++) { if (method.getName().equals("getName")) {
if (methods[ii].getName().equals("getName") == true) { String name = (String) method.invoke((Object[]) null, (Object[]) null);
//System.out.println("name is =="+methods[ii].invoke(null,null)); if (name != null) {
String name = (String)methods[ii].invoke((Object[])null, (Object[])null); moduleNameList.add(name);
if (name != null) moduleNameList.add(name); } else {
LOGGER.log(Level.FINE, "Module {0} does not specify a diplayable name.", module.getCanonicalName());
}
break; break;
} }
} }
//ModuleNameList.add ( Modul.getName()); } catch (Exception ex) {
} LOGGER.log(Level.WARNING, "Error while fetching name from module.", ex);
catch (Exception e) {
System.err.println("ModuleServer.getModuleNameList() " + e.getMessage());
} }
} }
@ -122,21 +126,19 @@ public class ModuleServer {
moduleAdapterCounter++; moduleAdapterCounter++;
String adapterName = "ERROR MODULADAPTER !!"; String adapterName = "ERROR MODULADAPTER !!";
String moduleName = null; String moduleName = null;
Class<?> module;
Method[] methods; Method[] methods;
for (int i = 0; i < moduleClassList.size(); i++) { for (Class<?> module : moduleClassList) {
module = moduleClassList.get(i);
try { try {
methods = module.getDeclaredMethods(); methods = module.getDeclaredMethods();
for (int ii = 0; ii < methods.length; ii++) { for (Method method : methods) {
if (methods[ii].getName().equals("getName") == true) { if (method.getName().equals("getName")) {
moduleName = (String) methods[ii].invoke((Object[]) null, (Object[]) null); moduleName = (String) method.invoke((Object[]) null, (Object[]) null);
} }
} }
} }
catch (Exception ex) { catch (Exception ex) {
logger.log(Level.WARNING, ex.getMessage(), ex); LOGGER.log(Level.WARNING, ex.getMessage(), ex);
} }
if ((moduleName != null) && (selectedModuleName.equals(moduleName))) { if ((moduleName != null) && (selectedModuleName.equals(moduleName))) {
try { try {
@ -163,10 +165,10 @@ public class ModuleServer {
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(Para); moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(Para);
} else { } else {
Object[] param = new Object[4]; Object[] param = new Object[4];
param[0] = (String)adapterName; param[0] = (String) adapterName;
param[1] = (InterfaceGOParameters)goParams; param[1] = (InterfaceGOParameters) goParams;
param[2] = (String)noGuiLogFile; param[2] = (String) noGuiLogFile;
param[3] = (MainAdapterClient)Client; param[3] = (MainAdapterClient) Client;
while ((constructorArr[constrIndex].getParameterTypes().length!=4) && (constrIndex < constructorArr.length)) { while ((constructorArr[constrIndex].getParameterTypes().length!=4) && (constrIndex < constructorArr.length)) {
constrIndex++; constrIndex++;
} }
@ -178,13 +180,13 @@ public class ModuleServer {
* implement the ModuleAdapter interface for a strange reason, * implement the ModuleAdapter interface for a strange reason,
* it is _not_ enough if a superclass implements the same interface! * it is _not_ enough if a superclass implements the same interface!
*/ */
moduleAdapter = (ModuleAdapter)RMIProxyLocal.newInstance(moduleAdapter, adapterName); moduleAdapter = (ModuleAdapter) RMIProxyLocal.newInstance(moduleAdapter, adapterName);
(moduleAdapter).setRemoteThis(moduleAdapter); (moduleAdapter).setRemoteThis(moduleAdapter);
} }
// m_RunnungModules.add(m_ModuleAdapter); // m_RunnungModules.add(m_ModuleAdapter);
} }
catch (Exception ex) { catch (Exception ex) {
logger.log(Level.SEVERE, "Error in RMI-Moduladapter initialization", ex); LOGGER.log(Level.SEVERE, "Error in RMI-Moduladapter initialization", ex);
EVAERROR.EXIT("Error in RMI-Moduladapter initialization: " + ex.getMessage()); EVAERROR.EXIT("Error in RMI-Moduladapter initialization: " + ex.getMessage());
return null; return null;
} }
@ -207,7 +209,7 @@ public class ModuleServer {
// } // }
// } // }
logger.log(Level.SEVERE, "No valid module defined: {0}", selectedModuleName); LOGGER.log(Level.SEVERE, "No valid module defined: {0}", selectedModuleName);
return null; return null;
} }
} }

View File

@ -36,7 +36,7 @@ public class RMIServerEvA extends RMIServer {
mainAdapterName + "_" + numberOfVM); mainAdapterName + "_" + numberOfVM);
mainRemoteObject.setRemoteThis(mainRemoteObject); mainRemoteObject.setRemoteThis(mainRemoteObject);
} catch (Exception ex) { } catch (Exception ex) {
logger.log(Level.WARNING, "Could not create main remote object!", ex); LOGGER.log(Level.WARNING, "Could not create main remote object!", ex);
} }
} }
} }

View File

@ -12,19 +12,37 @@ import eva2.tools.jproxy.RemoteStateListener;
* $Date: 2007-12-04 14:22:52 +0100 (Tue, 04 Dec 2007) $ * $Date: 2007-12-04 14:22:52 +0100 (Tue, 04 Dec 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/** /**
* * Interface for Optimization Processor.
*/ */
public interface InterfaceProcessor { public interface InterfaceProcessor {
public void startOpt();
public void restartOpt(); /**
public void stopOpt(); * Start optimization.
public void addListener(RemoteStateListener module); */
public String getInfoString(); void startOpt();
/**
* Restart optimization.
*/
void restartOpt();
/**
* Stop optimization if running.
*/
void stopOpt();
/**
* Adds a new RemoteStateListener.
*
* @param module The module to add.
*/
void addListener(RemoteStateListener module);
/**
* Get Info String about the Optimization.
* @return The info String
*/
String getInfoString();
} }

View File

@ -20,6 +20,7 @@ import javax.swing.JOptionPane;
import eva2.gui.BeanInspector; import eva2.gui.BeanInspector;
import eva2.tools.BasicResourceLoader; import eva2.tools.BasicResourceLoader;
import eva2.tools.StringTools; import eva2.tools.StringTools;
import java.beans.XMLEncoder;
/** /**
@ -201,9 +202,9 @@ public class FileTools {
} }
public static JFileChooser createFileChooser() { public static JFileChooser createFileChooser() {
JFileChooser fc = new JFileChooser(new File("resources")); JFileChooser fileChooser = new JFileChooser(new File("resources"));
fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
return fc; return fileChooser;
} }
public static boolean saveObjectToFolder(Object object, File folder, boolean forceOverwrite, Component parentComponent) { public static boolean saveObjectToFolder(Object object, File folder, boolean forceOverwrite, Component parentComponent) {

View File

@ -153,7 +153,7 @@ public class GeneralGenericObjectEditorPanel extends JPanel implements ItemListe
// add(new JScrollPane(m_ChildPropertySheet), BorderLayout.CENTER); // add(new JScrollPane(m_ChildPropertySheet), BorderLayout.CENTER);
JPanel okcButs = new JPanel(); JPanel okcButs = new JPanel();
okcButs.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); okcButs.setBorder(BorderFactory.createEmptyBorder());
okcButs.setLayout(new GridLayout(1, 4, 5, 5)); okcButs.setLayout(new GridLayout(1, 4, 5, 5));
okcButs.add(m_OpenBut); okcButs.add(m_OpenBut);
okcButs.add(m_SaveBut); okcButs.add(m_SaveBut);

View File

@ -9,9 +9,6 @@ package eva2.server.modules;
* $Date: 2007-12-04 14:22:52 +0100 (Tue, 04 Dec 2007) $ * $Date: 2007-12-04 14:22:52 +0100 (Tue, 04 Dec 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.io.Serializable; import java.io.Serializable;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Vector; import java.util.Vector;
@ -20,6 +17,8 @@ import eva2.server.go.InterfaceGOParameters;
import eva2.server.go.InterfaceProcessor; import eva2.server.go.InterfaceProcessor;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
import eva2.tools.jproxy.RemoteStateListener; import eva2.tools.jproxy.RemoteStateListener;
import java.util.ArrayList;
import java.util.List;
/** /**
* The module server expects a constructor with two arguments: String adapterName and MainAdapterClient client. * The module server expects a constructor with two arguments: String adapterName and MainAdapterClient client.
@ -27,176 +26,183 @@ import eva2.tools.jproxy.RemoteStateListener;
* *
*/ */
abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializable { abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializable {
public static boolean TRACE = false;
private static int m_InstanceCounter;
protected int m_Instance;
protected String m_AdapterName;
protected InterfaceProcessor m_Processor;
protected String m_myHostName = "not defined";
protected boolean m_Connection = true;
protected ModuleAdapter m_RemoteThis = null;
protected boolean m_RMI = true;
protected MainAdapterClient m_MainAdapterClient; // connection to client
private Vector<RemoteStateListener> m_RemoteStateListeners;
protected AbstractModuleAdapter(MainAdapterClient Client) { private static int instanceCounter;
if (TRACE) System.out.println("AbstractModuleAdapter.AbstractModuleAdapter()"); protected int instanceNumber;
m_InstanceCounter++; protected String adapterName;
m_Instance = m_InstanceCounter; protected InterfaceProcessor processor;
if (TRACE) System.out.println ("AbstractModuleAdapter Nr. "+m_InstanceCounter +" on EvAServer"); protected String hostName = "not defined";
protected boolean hasConnection = true;
protected ModuleAdapter remoteModuleAdapter = null;
protected boolean useRMI = true;
protected MainAdapterClient mainAdapterClient; // connection to client
private List<RemoteStateListener> remoteStateListeners;
if (Client != null) { protected AbstractModuleAdapter(MainAdapterClient client) {
instanceCounter++;
instanceNumber = instanceCounter;
if (client != null) {
try { try {
m_myHostName = InetAddress.getLocalHost().getHostName(); hostName = InetAddress.getLocalHost().getHostName();
} catch (Exception e) { } catch (Exception e) {
System.out.println("InetAddress.getLocalHost().getHostAddress() --> ERROR" + e.getMessage()); System.out.println("InetAddress.getLocalHost().getHostAddress() --> ERROR" + e.getMessage());
} }
} else m_myHostName = "localhost"; } else {
hostName = "localhost";
if ((Client==null) || Client.getHostName().equals(m_myHostName)) {
m_RMI = false;
} else {// we use RMI
m_RMI = true;
} }
m_RemoteStateListeners = new Vector<RemoteStateListener>();
if ((client == null) || client.getHostName().equals(hostName)) {
useRMI = false;
} else {
/* we use RMI */
useRMI = true;
}
remoteStateListeners = new ArrayList<RemoteStateListener>();
} }
/** /**
* From the interface RemoteStateListener. Added this method to make progress bar possible. * From the interface RemoteStateListener. Added this method to make progress bar possible.
*/ */
public void updateProgress(final int percent, String msg) { public void updateProgress(final int percent, String msg) {
if (TRACE) System.out.println("AbstractModuleAdapter::updateProgress"); for (RemoteStateListener listener : remoteStateListeners) {
for (RemoteStateListener listener : m_RemoteStateListeners) {
listener.updateProgress(percent, msg); listener.updateProgress(percent, msg);
} }
} }
/** /**
* Get the name of the current adapter.
* *
* @return The adapter name
*/ */
public String getAdapterName() { public String getAdapterName() {
return m_AdapterName; return adapterName;
} }
/** /**
* * Start optimization on processor.
*/ */
public void startOpt() { public void startOpt() {
if (TRACE) System.out.println("Module AbstractModuleAdapter on EvA-Server StartOpt called:" ); processor.startOpt();
m_Processor.startOpt();
} }
/** /**
* * Restart optimization on processor.
*/ */
public void restartOpt() { public void restartOpt() {
if (TRACE) System.out.println("Module AbstractModuleAdapter on EvA-Server ReStartOpt called:" ); processor.restartOpt();
m_Processor.restartOpt();
} }
/** /**
* * Stop optimization on processor.
*/ */
public void stopOpt() { public void stopOpt() {
if (TRACE) System.out.println("Module AbstractModuleAdapter on EvA-Server StopOpt called:" ); // This means user break
m_Processor.stopOpt(); // This means user break processor.stopOpt();
} }
/**
* Returns whether the current optimization provides post processing.
*
* @return true if post processing is available
*/
public boolean hasPostProcessing() { public boolean hasPostProcessing() {
return ((m_Processor instanceof Processor) && ((Processor)m_Processor).getGOParams().getPostProcessParams().isDoPostProcessing()); return ((processor instanceof Processor) && ((Processor) processor).getGOParams().getPostProcessParams().isDoPostProcessing());
} }
/**
* Starts post processing if available.
*
* @return true if post processing was performed, false otherwise.
*/
public boolean startPostProcessing() { public boolean startPostProcessing() {
if (hasPostProcessing() && ((Processor)m_Processor).getGOParams().getPostProcessParams().isDoPostProcessing()) { if (hasPostProcessing() && ((Processor) processor).getGOParams().getPostProcessParams().isDoPostProcessing()) {
((Processor)m_Processor).performPostProcessing(); ((Processor) processor).performPostProcessing();
return true; return true;
} else return false; } else {
return false;
}
} }
public InterfaceGOParameters getGOParameters() { public InterfaceGOParameters getGOParameters() {
if ((m_Processor != null) && (m_Processor instanceof Processor)) { if ((processor != null) && (processor instanceof Processor)) {
return ((Processor)m_Processor).getGOParams(); return ((Processor) processor).getGOParams();
} else return null; } else {
return null;
}
} }
public void setGOParameters(InterfaceGOParameters goParams) { public void setGOParameters(InterfaceGOParameters goParams) {
if ((m_Processor != null) && (m_Processor instanceof Processor)) { if ((processor != null) && (processor instanceof Processor)) {
((Processor)m_Processor).setGOParams(goParams); ((Processor) processor).setGOParams(goParams);
} }
} }
// public void loadGOParameters(String serParamsFile) {
// if ((m_Processor != null) && (m_Processor instanceof Processor)) {
// ((Processor)m_Processor).setGOParams(GOParameters.getInstance(serParamsFile, false));
// }
// }
public boolean isOptRunning() { public boolean isOptRunning() {
if ((m_Processor != null) && (m_Processor instanceof Processor)) { if ((processor != null) && (processor instanceof Processor)) {
return ((Processor)m_Processor).isOptRunning(); return ((Processor) processor).isOptRunning();
} else return false; } else {
return false;
}
}
/**
* Adds a remote state listener.
*/
public void addRemoteStateListener(RemoteStateListener remoteListener) {
remoteStateListeners.add(remoteListener);
} }
/** /**
* *
*/ */
public void runScript() { public void setConnection(boolean flag) {
hasConnection = flag;
}
/**
*
*/
public void addRemoteStateListener(RemoteStateListener x) {
if (TRACE) System.out.println("module adapter on Server addRemoteStateListener called:" );
m_RemoteStateListeners.add(x);
}
/**
*
*/
public void setConnection (boolean flag) {
if (TRACE) System.out.println("module adapter on Server setConnection "+flag+" called:" );
m_Connection = flag;
} }
/**
* Returns whether the module has a connection.
*
* @return true if the adapter has a connection.
*/
public boolean hasConnection() { public boolean hasConnection() {
return m_Connection; return hasConnection;
} }
/** /**
* *
*/ */
public void setRemoteThis (ModuleAdapter x) { public void setRemoteThis(ModuleAdapter x) {
if (TRACE) System.out.println("module adapter on Server setRemoteThis called:" ); remoteModuleAdapter = x;
m_RemoteThis = x;
} }
/**
* Returns the host name.
*
* @return The host name
*/
public String getHostName() {
return hostName;
}
/** /**
* *
*/ */
public String getHostName () { public void performedStop() {
if (TRACE) System.out.println("module adapter on Server getHostName called:"+m_myHostName ); for (RemoteStateListener listener : remoteStateListeners) {
return m_myHostName;
}
/**
*
*/
public void performedStop () {
if (TRACE) System.out.println("AbstractModuleAdapter::performedStop");
for (RemoteStateListener listener : m_RemoteStateListeners) {
listener.performedStop(); listener.performedStop();
} }
// if (logPanel != null) logPanel.logMessage("Stopped optimization run");
} }
public void performedStart(String infoString) { public void performedStart(String infoString) {
if (TRACE) System.out.println("AbstractModuleAdapter::performedStart"); for (RemoteStateListener listener : remoteStateListeners) {
for (RemoteStateListener listener : m_RemoteStateListeners) {
listener.performedStart(infoString); listener.performedStart(infoString);
} }
// if (logPanel != null) logPanel.logMessage("Started optimization " + m_Processor.getInfoString());
} }
public void performedRestart(String infoString) { public void performedRestart(String infoString) {
if (TRACE) System.out.println("AbstractModuleAdapter::performedRestart"); for (RemoteStateListener listener : remoteStateListeners) {
for (RemoteStateListener listener : m_RemoteStateListeners) {
listener.performedRestart(infoString); listener.performedRestart(infoString);
} }
// if (logPanel != null) logPanel.logMessage("Restarted optimization run");
} }
} }

View File

@ -3,26 +3,23 @@ package eva2.server.modules;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/** This the DE module adapter necessary to access this implementation /**
* from the EvA top level. * This the DE module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 27.10.2004
* Time: 13:54:55
* To change this template use File | Settings | File Templates.
*/ */
public class DEModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { public class DEModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
public static String m_Name = "Differential_Evolution";
private static final String moduleName = "Differential_Evolution";
public DEModuleAdapter(String adapterName, MainAdapterClient client) { public DEModuleAdapter(String adapterName, MainAdapterClient client) {
super (adapterName, "DE.html", client, DEParameters.getInstance(), true); super(adapterName, "DE.html", client, DEParameters.getInstance(), true);
} }
/** This method returns the name of the ModulAdapters /**
* This method returns the name of the ModulAdapters.
*
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -2,26 +2,23 @@ package eva2.server.modules;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/** This the EP module adapter necessary to access this implementation /**
* from the EvA top level. * This the EP module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 27.10.2004
* Time: 13:54:55
* To change this template use File | Settings | File Templates.
*/ */
public class EPModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { public class EPModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
public static String m_Name = "Evolutionary_Programming"; private static final String moduleName = "Evolutionary_Programming";
public EPModuleAdapter(String adapterName, MainAdapterClient client) { public EPModuleAdapter(String adapterName, MainAdapterClient client) {
super (adapterName, "EP.html", client, EPParameters.getInstance(), true); super(adapterName, "EP.html", client, EPParameters.getInstance(), true);
} }
/** This method returns the name of the ModulAdapters /**
* This method returns the name of the ModulAdapter
*
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -2,26 +2,23 @@ package eva2.server.modules;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/** This the GA module adapter necessary to access this implementation /**
* from the EvA top level. * This the GA module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 08.06.2004
* Time: 21:29:20
* To change this template use File | Settings | File Templates.
*/ */
public class GAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { public class GAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
public static String m_Name = "Genetic_Algorithm"; private static final String moduleName = "Genetic_Algorithm";
public GAModuleAdapter(String adapterName, MainAdapterClient client) { public GAModuleAdapter(String adapterName, MainAdapterClient client) {
super (adapterName, "GA.html", client, GAParameters.getInstance(), true); super(adapterName, "GA.html", client, GAParameters.getInstance(), true);
} }
/** This method returns the name of the ModulAdapters /**
* This method returns the name of the ModulAdapters
*
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -1,27 +1,22 @@
package eva2.server.modules; package eva2.server.modules;
import java.io.Serializable;
import eva2.server.go.InterfaceGOParameters; import eva2.server.go.InterfaceGOParameters;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
import java.io.Serializable;
/** /**
* Starts a statistics GUI and the GOProcessor thread. * Starts a statistics GUI and the GOProcessor thread.
*
* User: streiche
* Date: 11.05.2003
* Time: 13:08:38
* To change this template use Options | File Templates.
*/ */
public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapter, Serializable { public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapter, Serializable {
public static String m_Name = "Genetic_Optimization";
private static final String moduleName = "Genetic_Optimization";
/** /**
* *
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
/** /**
@ -44,7 +39,6 @@ public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
//super(adapterName, "", client, GOParameters.getInstance(serParamsFile, false), false); //super(adapterName, "", client, GOParameters.getInstance(serParamsFile, false), false);
super(adapterName, "", client, goParams, false, noGuiLogFile); super(adapterName, "", client, goParams, false, noGuiLogFile);
} }
// /** // /**
// * Starts a statistics GUI and the GOProcessor thread with a given GOParameters file. // * Starts a statistics GUI and the GOProcessor thread with a given GOParameters file.
// * // *

View File

@ -20,34 +20,36 @@ import eva2.tools.jproxy.RMIProxyLocal;
public class GenericModuleAdapter extends AbstractModuleAdapter implements Serializable { public class GenericModuleAdapter extends AbstractModuleAdapter implements Serializable {
private AbstractStatistics m_StatisticsModul; private AbstractStatistics statisticsModule;
private EvAJobList jobList = null; private EvAJobList jobList = null;
public String helperFilename; public String helperFilename;
JParaPanel jobPanel=null, paramPanel=null; JParaPanel jobPanel = null, paramPanel = null;
/** /**
* Constructor of the ModuleAdapter * Constructor of the ModuleAdapter
*
* @param adapterName The AdapterName * @param adapterName The AdapterName
* @param helperFName name of a html help file name * @param helperFName Name of a HTML help file name
* @param Client The client to serve * @param adapterClient The client to serve
* @param params a parameter set describing the optimizer module * @param params A parameter set describing the optimizer module
* @param optimizerExpert set to true if setting the optimizer is an expert option being hidden from the gui * @param optimizerExpert Set to true if setting the optimizer is an expert option being hidden
* @param noGUIStatOut if null, statistics with GUI are used, else the standalone statistics with given output filename. * from the gui
* @param noGUIStatOut If null, statistics with GUI are used, else the standalone statistics
* with given output filename.
*/ */
public GenericModuleAdapter(String adapterName, String helperFName, MainAdapterClient Client, InterfaceGOParameters params, boolean optimizerExpert, String noGUIStatOut) { public GenericModuleAdapter(String adapterName, String helperFName, MainAdapterClient adapterClient, InterfaceGOParameters params, boolean optimizerExpert, String noGUIStatOut) {
super (Client); super(adapterClient);
if (TRACE) System.out.println("Constructor GenericModuleAdapter --> start"); remoteModuleAdapter = this;
m_RemoteThis = this; this.adapterName = adapterName;
m_AdapterName = adapterName; mainAdapterClient = adapterClient;
m_MainAdapterClient = Client;
helperFilename = helperFName; helperFilename = helperFName;
if (noGUIStatOut==null) { if (noGUIStatOut==null) {
m_StatisticsModul = new StatisticsWithGUI(Client); statisticsModule = new StatisticsWithGUI(adapterClient);
} else { } else {
m_StatisticsModul = new StatisticsStandalone(noGUIStatOut); statisticsModule = new StatisticsStandalone(noGUIStatOut);
} }
m_Processor = new Processor(m_StatisticsModul,this, params); processor = new Processor(statisticsModule, this, params);
// the statistics want to be informed if the strategy or the optimizer (which provide statistical data as InterfaceAdditionalInformer) change. // the statistics want to be informed if the strategy or the optimizer (which provide statistical data as InterfaceAdditionalInformer) change.
// THIS is now done directly in the constructor of a Processor // THIS is now done directly in the constructor of a Processor
@ -56,8 +58,7 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
// this prevents the optimizer property to be shown by the GOE if optimizerExpert is true // this prevents the optimizer property to be shown by the GOE if optimizerExpert is true
GenericObjectEditor.setExpertProperty(params.getClass(), "optimizer", optimizerExpert); GenericObjectEditor.setExpertProperty(params.getClass(), "optimizer", optimizerExpert);
((Processor)m_Processor).start(); ((Processor) processor).start();
if (TRACE) System.out.println("Constructor GenericModuleAdapter <-- end");
} }
/** /**
@ -86,36 +87,42 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
* @return the EvATabbedFrameMaker * @return the EvATabbedFrameMaker
*/ */
public EvATabbedFrameMaker getModuleFrame() { public EvATabbedFrameMaker getModuleFrame() {
if (TRACE) System.out.println("GenericModulAdapter.getModuleFrame"); if (!(statisticsModule instanceof StatisticsWithGUI)) {
if (!(m_StatisticsModul instanceof StatisticsWithGUI)) {
System.err.println("Error: Unable to create Frame when startet with noGUI option (GenericModuleAdapter)!"); System.err.println("Error: Unable to create Frame when startet with noGUI option (GenericModuleAdapter)!");
return null; return null;
} }
EvATabbedFrameMaker frmMkr = new EvATabbedFrameMaker(); EvATabbedFrameMaker frmMkr = new EvATabbedFrameMaker();
InterfaceStatisticsParameter Stat = ((StatisticsWithGUI)m_StatisticsModul).getStatisticsParameter(); InterfaceStatisticsParameter Stat = ((StatisticsWithGUI) statisticsModule).getStatisticsParameter();
EvAModuleButtonPanelMaker ButtonPanel = new EvAModuleButtonPanelMaker(m_RemoteThis,((Processor)m_Processor).isOptRunning()); EvAModuleButtonPanelMaker ButtonPanel = new EvAModuleButtonPanelMaker(remoteModuleAdapter, ((Processor) processor).isOptRunning());
ButtonPanel.setHelperFilename(helperFilename); ButtonPanel.setHelperFilename(helperFilename);
frmMkr.addPanelMaker(ButtonPanel); frmMkr.addPanelMaker(ButtonPanel);
InterfaceGOParameters goParams = ((Processor)m_Processor).getGOParams(); InterfaceGOParameters goParams = ((Processor) processor).getGOParams();
if (TRACE) System.out.println("parameters are of type "+goParams.getClass());
// TODO do we really need proxies here? // TODO do we really need proxies here?
if (m_RMI && !Proxy.isProxyClass(goParams.getClass())) frmMkr.addPanelMaker(paramPanel = new JParaPanel( RMIProxyLocal.newInstance(goParams), goParams.getName())); if (useRMI && !Proxy.isProxyClass(goParams.getClass())) {
else frmMkr.addPanelMaker(paramPanel = new JParaPanel(goParams, goParams.getName())); frmMkr.addPanelMaker(paramPanel = new JParaPanel(RMIProxyLocal.newInstance(goParams), goParams.getName()));
if (m_RMI && !Proxy.isProxyClass(Stat.getClass())) frmMkr.addPanelMaker(new JParaPanel( RMIProxyLocal.newInstance(Stat), Stat.getName())); } else {
else frmMkr.addPanelMaker(new JParaPanel(Stat, Stat.getName())); frmMkr.addPanelMaker(paramPanel = new JParaPanel(goParams, goParams.getName()));
}
if (useRMI && !Proxy.isProxyClass(Stat.getClass())) {
frmMkr.addPanelMaker(new JParaPanel(RMIProxyLocal.newInstance(Stat), Stat.getName()));
} else {
frmMkr.addPanelMaker(new JParaPanel(Stat, Stat.getName()));
}
jobList = new EvAJobList(new EvAJob[]{}); jobList = new EvAJobList(new EvAJob[]{});
jobList.setModule(this); jobList.setModule(this);
jobList.addTextListener((AbstractStatistics) ((Processor)m_Processor).getStatistics()); jobList.addTextListener((AbstractStatistics) ((Processor) processor).getStatistics());
// if (m_RMI && !Proxy.isProxyClass(Stat.getClass())) frmMkr.addPanelMaker(new JParaPanel( RMIProxyLocal.newInstance(jobList), jobList.getName()));
// else frmMkr.addPanelMaker(new JParaPanel(jobList, jobList.getName())); if (useRMI && !Proxy.isProxyClass(Stat.getClass())) {
if (m_RMI && !Proxy.isProxyClass(Stat.getClass())) jobPanel = new JParaPanel( RMIProxyLocal.newInstance(jobList), jobList.getName()); jobPanel = new JParaPanel(RMIProxyLocal.newInstance(jobList), jobList.getName());
else jobPanel = new JParaPanel(jobList, jobList.getName()); } else {
jobPanel = new JParaPanel(jobList, jobList.getName());
}
frmMkr.addPanelMaker(jobPanel); frmMkr.addPanelMaker(jobPanel);
((Processor)m_Processor).getGOParams().addInformableInstance(frmMkr); ((Processor) processor).getGOParams().addInformableInstance(frmMkr);
return frmMkr; return frmMkr;
} }
@ -123,7 +130,7 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
public void performedStart(String infoString) { public void performedStart(String infoString) {
super.performedStart(infoString); super.performedStart(infoString);
EvAJob job = scheduleJob(); EvAJob job = scheduleJob();
((AbstractStatistics)(((Processor)m_Processor).getStatistics())).addDataListener(job); ((AbstractStatistics) (((Processor) processor).getStatistics())).addDataListener(job);
} }
@Override @Override
@ -137,14 +144,15 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
/** /**
* Return the statistics module instance of this module. * Return the statistics module instance of this module.
*
* @return * @return
*/ */
public AbstractStatistics getStatistics() { public AbstractStatistics getStatistics() {
return m_StatisticsModul; return statisticsModule;
} }
public EvAJob scheduleJob() { public EvAJob scheduleJob() {
EvAJob job = jobList.addJob(((Processor)m_Processor).getGOParams(), (AbstractStatistics)(((Processor)m_Processor).getStatistics())); EvAJob job = jobList.addJob(((Processor) processor).getGOParams(), (AbstractStatistics) (((Processor) processor).getStatistics()));
jobPanel.getEditor().setValue(jobList); jobPanel.getEditor().setValue(jobList);
return job; return job;
} }

View File

@ -2,30 +2,29 @@ package eva2.server.modules;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/** This the HC module adapter necessary to access this implementation /**
* from the EvA top level. * This the HC module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 08.06.2004
* Time: 21:17:02
* To change this template use File | Settings | File Templates.
*/ */
public class HCModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { public class HCModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
public static String m_Name = "Hill_Climber"; private static final String moduleName = "Hill_Climber";
/** Constructor of the Moduladapter /**
* Constructor of the ModuleAdapter
*
* @param AdapterName The AdapterName * @param AdapterName The AdapterName
* @param Client The client to serve * @param Client The client to serve
*/ */
public HCModuleAdapter(String adapterName, MainAdapterClient client) { public HCModuleAdapter(String adapterName, MainAdapterClient client) {
super (adapterName, "HC.html", client, HCParameters.getInstance(), true); super(adapterName, "HC.html", client, HCParameters.getInstance(), true);
} }
/** This method returns the name of the ModulAdapters /**
* This method returns the name of the ModulAdapters
*
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -2,30 +2,29 @@ package eva2.server.modules;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/** This the MC module adapter necessary to access this implementation /**
* from the EvA top level. * This the MC module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 08.06.2004
* Time: 21:00:48
* To change this template use File | Settings | File Templates.
*/ */
public class MCModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { public class MCModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
public static String m_Name = "Monte_Carlo_Search";
/** Constructor of the Moduladapter private static final String moduleName = "Monte_Carlo_Search";
* @param AdapterName The AdapterName
* @param Client The client to serve /**
* Constructor of the ModuleAdapter.
*
* @param adapterName The AdapterName
* @param client The client to serve
*/ */
public MCModuleAdapter(String adapterName, MainAdapterClient client) { public MCModuleAdapter(String adapterName, MainAdapterClient client) {
super (adapterName, "MC.html", client, MCParameters.getInstance(), true); super(adapterName, "MC.html", client, MCParameters.getInstance(), true);
} }
/**
/** This method returns the name of the ModulAdapters * This method returns the name of the ModulAdapters
*
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -4,30 +4,29 @@ import eva2.tools.jproxy.MainAdapterClient;
import java.io.Serializable; import java.io.Serializable;
/** This the MOEA module adapter necessary to access this implementation /**
* from the EvA top level. * This the MOEA module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 27.10.2004
* Time: 13:54:55
* To change this template use File | Settings | File Templates.
*/ */
public class MOEAModuleAdapter extends GenericModuleAdapter implements Serializable, ModuleAdapter { public class MOEAModuleAdapter extends GenericModuleAdapter implements Serializable, ModuleAdapter {
public static String m_Name = "Multi-Objective_Evolutionary_Algorithms"; private static final String moduleName = "Multi-Objective_Evolutionary_Algorithms";
/** Constructor of the Moduladapter /**
* Constructor of the ModuleAdapter
*
* @param AdapterName The AdapterName * @param AdapterName The AdapterName
* @param Client The client to serve * @param Client The client to serve
*/ */
public MOEAModuleAdapter(String adapterName, MainAdapterClient client) { public MOEAModuleAdapter(String adapterName, MainAdapterClient client) {
super (adapterName, "MOEA.html", client, MOEAParameters.getInstance(), true); super(adapterName, "MOEA.html", client, MOEAParameters.getInstance(), true);
} }
/** This method returns the name of the ModulAdapters /**
* This method returns the name of the ModulAdapters
*
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -9,43 +9,54 @@ package eva2.server.modules;
* $Date: 2007-11-21 18:06:36 +0100 (Wed, 21 Nov 2007) $ * $Date: 2007-11-21 18:06:36 +0100 (Wed, 21 Nov 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import eva2.gui.EvATabbedFrameMaker; import eva2.gui.EvATabbedFrameMaker;
import eva2.server.stat.EvAJob; import eva2.server.stat.EvAJob;
import eva2.tools.jproxy.RemoteStateListener; import eva2.tools.jproxy.RemoteStateListener;
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
public interface ModuleAdapter extends RemoteStateListener { public interface ModuleAdapter extends RemoteStateListener {
public EvATabbedFrameMaker getModuleFrame();
public void startOpt(); // called from client EvATabbedFrameMaker getModuleFrame();
void startOpt(); // called from client
/** /**
* Schedule a certain job to a job list. * Schedule a certain job to a job list.
*
* @return A new Job
*/ */
public EvAJob scheduleJob(); EvAJob scheduleJob();
public void restartOpt();
public void stopOpt(); void restartOpt();
public void runScript();
void stopOpt();
//void runScript();
/** /**
* Return true if post processing is available in principle, else false. * Return true if post processing is available in principle, else false.
*
* @return true if post processing is available in principle, else false * @return true if post processing is available in principle, else false
*/ */
public boolean hasPostProcessing(); boolean hasPostProcessing();
/** /**
* Return true if post processing was performed, else false. * Return true if post processing was performed, else false.
*
* @return true if post processing was performed, else false * @return true if post processing was performed, else false
*/ */
public boolean startPostProcessing(); boolean startPostProcessing();
public void addRemoteStateListener(RemoteStateListener x);
public String getAdapterName(); void addRemoteStateListener(RemoteStateListener x);
public void setConnection(boolean flag);
public boolean hasConnection(); String getAdapterName();
public void setRemoteThis(ModuleAdapter x);
public String getHostName(); void setConnection(boolean flag);
boolean hasConnection();
void setRemoteThis(ModuleAdapter x);
String getHostName();
} }

View File

@ -2,30 +2,29 @@ package eva2.server.modules;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/** This the PBIL module adapter necessary to access this implementation /**
* from the EvA top level. * This the PBIL module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 08.06.2004
* Time: 21:52:22
* To change this template use File | Settings | File Templates.
*/ */
public class PBILModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { public class PBILModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
public static String m_Name = "Population_Based_Incremental_Learning"; private static final String moduleName = "Population_Based_Incremental_Learning";
/** Constructor of the Moduladapter /**
* Constructor of the ModuleAdapter
*
* @param AdapterName The AdapterName * @param AdapterName The AdapterName
* @param Client The client to serve * @param Client The client to serve
*/ */
public PBILModuleAdapter(String adapterName, MainAdapterClient client) { public PBILModuleAdapter(String adapterName, MainAdapterClient client) {
super (adapterName, "PBIL.html", client, PBILParameters.getInstance(), true); super(adapterName, "PBIL.html", client, PBILParameters.getInstance(), true);
} }
/** This method returns the name of the ModulAdapters /**
* This method returns the name of the ModulAdapters
*
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -2,30 +2,29 @@ package eva2.server.modules;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/** This the PSO module adapter necessary to access this implementation /**
* from the EvA top level. * This the PSO module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 16.11.2004
* Time: 17:58:19
* To change this template use File | Settings | File Templates.
*/ */
public class PSOModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { public class PSOModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
public static String m_Name = "Particle_Swarm_Optimization"; private static final String moduleName = "Particle_Swarm_Optimization";
/** Constructor of the Moduladapter /**
* Constructor of the Moduladapter
*
* @param AdapterName The AdapterName * @param AdapterName The AdapterName
* @param Client The client to serve * @param Client The client to serve
*/ */
public PSOModuleAdapter(String adapterName, MainAdapterClient client) { public PSOModuleAdapter(String adapterName, MainAdapterClient client) {
super (adapterName, "PSO.html", client, PSOParameters.getInstance(), true); super(adapterName, "PSO.html", client, PSOParameters.getInstance(), true);
} }
/** This method returns the name of the ModulAdapters /**
* This method returns the name of the ModulAdapter
*
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -2,17 +2,12 @@ package eva2.server.modules;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/** This the SA module adapter necessary to access this implementation /**
* from the EvA top level. * This the SA module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 08.06.2004
* Time: 21:25:00
* To change this template use File | Settings | File Templates.
*/ */
public class SAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { public class SAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
public static String m_Name = "Simulated_Annealing"; private static final String moduleName = "Simulated_Annealing";
/** Constructor of the Moduladapter /** Constructor of the Moduladapter
* @param AdapterName The AdapterName * @param AdapterName The AdapterName
@ -23,10 +18,11 @@ public class SAModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
super (adapterName, "SA.html", client, SAParameters.getInstance(), true); super (adapterName, "SA.html", client, SAParameters.getInstance(), true);
} }
/** This method returns the name of the ModulAdapters /**
* This method returns the name of the ModulAdapter
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -2,30 +2,29 @@ package eva2.server.modules;
import eva2.tools.jproxy.MainAdapterClient; import eva2.tools.jproxy.MainAdapterClient;
/** This the SSGA module adapter necessary to access this implementation /**
* from the EvA top level. * This the SSGA module adapter necessary to access this implementation from the EvA top level.
* Created by IntelliJ IDEA.
* User: streiche
* Date: 19.07.2005
* Time: 15:44:53
* To change this template use File | Settings | File Templates.
*/ */
public class SSGAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter { public class SSGAModuleAdapter extends GenericModuleAdapter implements ModuleAdapter {
public static String m_Name = "Steady_State_Genetic_Algorithm"; private static final String moduleName = "Steady_State_Genetic_Algorithm";
/** Constructor of the Moduladapter /**
* Constructor of the ModuleAdapter
*
* @param AdapterName The AdapterName * @param AdapterName The AdapterName
* @param Client The client to serve * @param Client The client to serve
*/ */
public SSGAModuleAdapter(String adapterName, MainAdapterClient client) { public SSGAModuleAdapter(String adapterName, MainAdapterClient client) {
super (adapterName, "SSGA.html", client, SSGAParameters.getInstance(), true); super(adapterName, "SSGA.html", client, SSGAParameters.getInstance(), true);
} }
/** This method returns the name of the ModulAdapters /**
* This method returns the name of the ModulAdapters
*
* @return The name * @return The name
*/ */
public static String getName() { public static String getName() {
return m_Name; return moduleName;
} }
} }

View File

@ -25,16 +25,19 @@ import eva2.server.modules.AbstractModuleAdapter;
import eva2.server.modules.GenericModuleAdapter; import eva2.server.modules.GenericModuleAdapter;
import eva2.server.modules.ModuleAdapter; import eva2.server.modules.ModuleAdapter;
import eva2.tools.Serializer; import eva2.tools.Serializer;
import java.awt.Color;
import javax.swing.*;
/** /**
* A selectable list of EvAJobs. Each job contains a GOParameters instance and potentially statistical data. * A selectable list of EvAJobs. Each job contains a GOParameters instance and potentially
* statistical data.
* *
* @author mkron * @author mkron
* *
*/ */
public class EvAJobList extends PropertySelectableList<EvAJob> implements Serializable, InterfaceTextListener { public class EvAJobList extends PropertySelectableList<EvAJob> implements Serializable, InterfaceTextListener {
List<InterfaceTextListener> listeners = null;
List<InterfaceTextListener> listeners = null;
private ModuleAdapter module = null; private ModuleAdapter module = null;
public EvAJobList(EvAJob[] initial) { public EvAJobList(EvAJob[] initial) {
@ -56,7 +59,7 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
* @param stats * @param stats
*/ */
public EvAJob addJob(InterfaceGOParameters params, AbstractStatistics stats) { public EvAJob addJob(InterfaceGOParameters params, AbstractStatistics stats) {
EvAJob job = new EvAJob((InterfaceGOParameters)Serializer.deepClone(params), stats); EvAJob job = new EvAJob((InterfaceGOParameters) Serializer.deepClone(params), stats);
stats.addDataListener(job); stats.addDataListener(job);
addJob(job, true); addJob(job, true);
return job; return job;
@ -66,7 +69,7 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
EvAJob[] curArr = getObjects(); EvAJob[] curArr = getObjects();
EvAJob[] newArr = null; EvAJob[] newArr = null;
boolean[] newSelection = null; boolean[] newSelection = null;
if (curArr!=null && curArr.length>0) { if (curArr != null && curArr.length > 0) {
newArr = new EvAJob[curArr.length + 1]; newArr = new EvAJob[curArr.length + 1];
newSelection = new boolean[newArr.length]; newSelection = new boolean[newArr.length];
System.arraycopy(curArr, 0, newArr, 0, curArr.length); System.arraycopy(curArr, 0, newArr, 0, curArr.length);
@ -75,8 +78,8 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
newArr = new EvAJob[1]; newArr = new EvAJob[1];
newSelection = new boolean[1]; newSelection = new boolean[1];
} }
newSelection[newArr.length-1]=selected; newSelection[newArr.length - 1] = selected;
newArr[newArr.length-1] = j; newArr[newArr.length - 1] = j;
setObjects(newArr, newSelection); setObjects(newArr, newSelection);
} }
@ -87,8 +90,11 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
*/ */
public EvAJob lastJob() { public EvAJob lastJob() {
EvAJob[] curArr = getObjects(); EvAJob[] curArr = getObjects();
if (curArr!=null && curArr.length>0) return curArr[curArr.length-1]; if (curArr != null && curArr.length > 0) {
else return null; return curArr[curArr.length - 1];
} else {
return null;
}
} }
/** /**
@ -100,45 +106,54 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
EvAJob[] selected = getSelectedObjects(); EvAJob[] selected = getSelectedObjects();
ArrayList<EvAJob> l = new ArrayList<EvAJob>(); ArrayList<EvAJob> l = new ArrayList<EvAJob>();
for (EvAJob j : selected) { for (EvAJob j : selected) {
if (j!=null) l.add(j); if (j != null) {
l.add(j);
}
} }
return l; return l;
} }
public boolean saveSelectedJobs(Component parentComponent) { public boolean saveSelectedJobs(Component parentComponent) {
EvAJob[] selected = getSelectedObjects(); EvAJob[] selected = getSelectedObjects();
if (selected!=null && (selected.length>0)) { if (selected != null && (selected.length > 0)) {
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser();
fc.setName("Select a directory to save jobs to..."); fc.setName("Select a directory to save jobs to...");
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = fc.showSaveDialog(parentComponent); int returnVal = fc.showSaveDialog(parentComponent);
if (returnVal==JFileChooser.APPROVE_OPTION) { if (returnVal == JFileChooser.APPROVE_OPTION) {
File sFile = fc.getSelectedFile(); File sFile = fc.getSelectedFile();
if (sFile.exists()) { if (sFile.exists()) {
for (EvAJob job : selected) { for (EvAJob job : selected) {
if (job!=null) { if (job != null) {
if (!FileTools.saveObjectToFolder(job, sFile, false, parentComponent)) { if (!FileTools.saveObjectToFolder(job, sFile, false, parentComponent)) {
System.err.println("Error on saving jobs..."); System.err.println("Error on saving jobs...");
return false; return false;
} }
} }
} }
} else return false; // invalid folder chosen } else {
} else return false; // user break return false; // invalid folder chosen
}
} else {
return false; // user break
}
} }
return true; return true;
} }
/** /**
* Search for a job in the list which has the given parameter structure assigned. * Search for a job in the list which has the given parameter structure assigned. This is tested
* This is tested by reference, so the exact same instance of InterfaceGOParameters * by reference, so the exact same instance of InterfaceGOParameters must be known. If no
* must be known. If no matching job is found, null is returned. * matching job is found, null is returned.
*
* @param params * @param params
* @return * @return
*/ */
public EvAJob getJobOf(InterfaceGOParameters params) { public EvAJob getJobOf(InterfaceGOParameters params) {
for (EvAJob job : getObjects()) { for (EvAJob job : getObjects()) {
if (job.getGOParams()==params) return job; if (job.getGOParams() == params) {
return job;
}
} }
return null; return null;
} }
@ -153,34 +168,22 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
final GenericArrayEditor genericArrayEditor = new GenericArrayEditor(); final GenericArrayEditor genericArrayEditor = new GenericArrayEditor();
genericArrayEditor.setWithAddButton(false); genericArrayEditor.setWithAddButton(false);
genericArrayEditor.setWithSetButton(false); genericArrayEditor.setWithSetButton(false);
ActionListener al=new ActionListener() { ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// System.out.println("PING!"); EvAStatisticalEvaluation.evaluate((InterfaceTextListener) jobList, jobList.getObjects(), genericArrayEditor.getSelectedIndices(),
// System.out.println(BeanInspector.toString(edi.getSelectedIndices())); (StatsOnSingleDataSetEnum[]) EvAStatisticalEvaluation.statsParams.getOneSampledStats().getSelectedEnum(StatsOnSingleDataSetEnum.values()),
EvAStatisticalEvaluation.evaluate((InterfaceTextListener)jobList, jobList.getObjects(), genericArrayEditor.getSelectedIndices(), (StatsOnTwoSampledDataEnum[]) EvAStatisticalEvaluation.statsParams.getTwoSampledStats().getSelectedEnum(StatsOnTwoSampledDataEnum.values()));
(StatsOnSingleDataSetEnum[])EvAStatisticalEvaluation.statsParams.getOneSampledStats().getSelectedEnum(StatsOnSingleDataSetEnum.values()),
(StatsOnTwoSampledDataEnum[])EvAStatisticalEvaluation.statsParams.getTwoSampledStats().getSelectedEnum(StatsOnTwoSampledDataEnum.values()));
// System.out.println(BeanInspector.toString(EvAStatisticalEvaluation.statsParams.getPairedStats().getSelected()));
} }
// public void actionPerformed(ActionEvent e) {
// if (statsFrame ==null) {
// statsFrame = new JEFrame("EvA2 Statistics Evaluation", true);
// JPanel tmpPan = createStatsPanel(jobList, edi);
// statsFrame.getContentPane().add(tmpPan);
// }
// if (!statsFrame.isVisible()) {
// statsFrame.pack();
// statsFrame.validate();
// statsFrame.setVisible(true);
// } else statsFrame.requestFocus();
// }
}; };
ActionListener sl=new ActionListener() { ActionListener sl = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
genericArrayEditor.selectDeselectAll(); genericArrayEditor.selectDeselectAll();
} }
}; };
ActionListener sal=new ActionListener() { ActionListener sal = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
jobList.saveSelectedJobs(genericArrayEditor); jobList.saveSelectedJobs(genericArrayEditor);
} }
@ -197,26 +200,27 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
return genericArrayEditor; return genericArrayEditor;
} }
private static JPanel createStatsPanel(final EvAJobList jobList, final GenericArrayEditor edi) { private static JComponent createStatsPanel(final EvAJobList jobList, final GenericArrayEditor edi) {
JParaPanel pan = new JParaPanel(EvAStatisticalEvaluation.statsParams, "Statistics"); JParaPanel pan = new JParaPanel(EvAStatisticalEvaluation.statsParams, "Statistics");
JComponent paraPan = pan.makePanel(); JComponent paraPan = pan.makePanel();
JPanel tmpPan = new JPanel(); return paraPan;
tmpPan.add(paraPan);
return tmpPan;
} }
private static ActionListener getReuseActionListener(final Component parent, final EvAJobList jobList) { private static ActionListener getReuseActionListener(final Component parent, final EvAJobList jobList) {
ActionListener al = new ActionListener() { ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
List<EvAJob> jobs = jobList.getSelectedJobs(); List<EvAJob> jobs = jobList.getSelectedJobs();
if (jobs.size()==1) { if (jobs.size() == 1) {
EvAJob job = jobs.get(0); EvAJob job = jobs.get(0);
AbstractGOParameters curParams = (AbstractGOParameters)((AbstractModuleAdapter)jobList.module).getGOParameters(); AbstractGOParameters curParams = (AbstractGOParameters) ((AbstractModuleAdapter) jobList.module).getGOParameters();
curParams.setSameParams((AbstractGOParameters) job.getGOParams()); curParams.setSameParams((AbstractGOParameters) job.getGOParams());
((GenericModuleAdapter)jobList.module).setGOParameters(curParams); ((GenericModuleAdapter) jobList.module).setGOParameters(curParams);
((GenericModuleAdapter)jobList.module).getStatistics().getStatisticsParameter().setMultiRuns(job.getNumRuns()); ((GenericModuleAdapter) jobList.module).getStatistics().getStatisticsParameter().setMultiRuns(job.getNumRuns());
((GenericModuleAdapter)jobList.module).getStatistics().getStatisticsParameter().setFieldSelection(job.getFieldSelection(((GenericModuleAdapter)jobList.module).getStatistics().getStatisticsParameter().getFieldSelection())); ((GenericModuleAdapter) jobList.module).getStatistics().getStatisticsParameter().setFieldSelection(job.getFieldSelection(((GenericModuleAdapter) jobList.module).getStatistics().getStatisticsParameter().getFieldSelection()));
} else JOptionPane.showMessageDialog(parent, "Select exactly one job to reuse!", "Error", JOptionPane.ERROR_MESSAGE); } else {
JOptionPane.showMessageDialog(parent, "Select exactly one job to reuse!", "Error", JOptionPane.ERROR_MESSAGE);
}
} }
}; };
return al; return al;
@ -224,9 +228,12 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
private static ActionListener getClearSelectedActionListener(final Component parent, final EvAJobList jobList) { private static ActionListener getClearSelectedActionListener(final Component parent, final EvAJobList jobList) {
ActionListener al = new ActionListener() { ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
List<EvAJob> jobs = jobList.getSelectedJobs(); List<EvAJob> jobs = jobList.getSelectedJobs();
for (EvAJob j : jobs) j.resetJob(); for (EvAJob j : jobs) {
j.resetJob();
}
} }
}; };
return al; return al;
@ -234,6 +241,7 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
/** /**
* Link a processor to the job list for re-scheduling jobs. * Link a processor to the job list for re-scheduling jobs.
*
* @param processor * @param processor
*/ */
public void setModule(ModuleAdapter mod) { public void setModule(ModuleAdapter mod) {
@ -241,33 +249,41 @@ public class EvAJobList extends PropertySelectableList<EvAJob> implements Serial
} }
public void addTextListener(InterfaceTextListener tListener) { public void addTextListener(InterfaceTextListener tListener) {
if (listeners==null) listeners = new LinkedList<InterfaceTextListener>(); if (listeners == null) {
if (!listeners.contains(tListener)) listeners.add(tListener); listeners = new LinkedList<InterfaceTextListener>();
}
if (!listeners.contains(tListener)) {
listeners.add(tListener);
}
} }
public boolean removeTextListener(InterfaceTextListener tListener) { public boolean removeTextListener(InterfaceTextListener tListener) {
if (listeners!=null) { if (listeners != null) {
return listeners.remove(tListener); return listeners.remove(tListener);
} else return false; } else {
return false;
}
} }
/* /*
* (non-Javadoc) * (non-Javadoc) @see eva2.server.stat.InterfaceTextListener#print(java.lang.String)
* @see eva2.server.stat.InterfaceTextListener#print(java.lang.String)
*/ */
public void print(String str) { public void print(String str) {
if (listeners!=null) for (InterfaceTextListener lst : listeners) { if (listeners != null) {
for (InterfaceTextListener lst : listeners) {
lst.print(str); lst.print(str);
} }
} }
}
/* /*
* (non-Javadoc) * (non-Javadoc) @see eva2.server.stat.InterfaceTextListener#println(java.lang.String)
* @see eva2.server.stat.InterfaceTextListener#println(java.lang.String)
*/ */
public void println(String str) { public void println(String str) {
if (listeners!=null) for (InterfaceTextListener lst : listeners) { if (listeners != null) {
for (InterfaceTextListener lst : listeners) {
lst.println(str); lst.println(str);
} }
} }
}
} }

View File

@ -150,7 +150,9 @@ public class StatisticsWithGUI extends AbstractStatistics implements Serializabl
} }
public void maybeShowProxyPrinter() { public void maybeShowProxyPrinter() {
if (proxyPrinter != null) proxyPrinter.setShow(m_StatsParams.isShowTextOutput()); if (proxyPrinter != null) {
proxyPrinter.setShow(m_StatsParams.isShowTextOutput());
}
} }
protected void initPlots(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informerList) { protected void initPlots(PopulationInterface pop, List<InterfaceAdditionalPopulationInformer> informerList) {

View File

@ -9,50 +9,46 @@ package eva2.tools;
* $Date: 2007-11-15 14:58:12 +0100 (Thu, 15 Nov 2007) $ * $Date: 2007-11-15 14:58:12 +0100 (Thu, 15 Nov 2007) $
* $Author: mkron $ * $Author: mkron $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.io.*; import java.io.*;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Properties; import java.util.Properties;
/** /**
* *
*/ */
public class EVAHELP { public class EVAHELP {
private static long m_TimeStamp; private static long m_TimeStamp;
/**
*
*/
/**
*
*/
/** /**
* *
*/ */
public static String getmyRUP() { public static String getmyRUP() {
String Out= new String(); String Out = new String();
String HostName = ""; String HostName = "";
try { try {
HostName = InetAddress.getLocalHost().getHostName(); HostName = InetAddress.getLocalHost().getHostName();
} } catch (Exception e) {
catch (Exception e) {
System.out.println("ERROR getting HostName EVAHELP " + e.getMessage()); System.out.println("ERROR getting HostName EVAHELP " + e.getMessage());
} }
try { try {
BufferedReader in = null; BufferedReader in = null;
Process pro = null; Process pro = null;
String command = "rup "+HostName; String command = "rup " + HostName;
pro = Runtime.getRuntime().exec(command); pro = Runtime.getRuntime().exec(command);
in = new BufferedReader ( new InputStreamReader (pro.getInputStream())); in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
String line = null; String line = null;
while((line = in.readLine()) != null ) { while ((line = in.readLine()) != null) {
//System.out.println(line); //System.out.println(line);
Out = Out + line; Out = Out + line;
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Error in calling the command:"+e.getMessage()); System.out.println("Error in calling the command:" + e.getMessage());
} }
return Out; return Out;
} }
@ -63,17 +59,19 @@ public class EVAHELP {
public static void setTimeStamp() { public static void setTimeStamp() {
m_TimeStamp = System.currentTimeMillis(); m_TimeStamp = System.currentTimeMillis();
} }
/** /**
* *
*/ */
public static long getTimeStamp() { public static long getTimeStamp() {
return System.currentTimeMillis() - m_TimeStamp; return System.currentTimeMillis() - m_TimeStamp;
} }
/** /**
* *
*/ */
public static void returnForExit() { public static void returnForExit() {
BufferedReader in = new BufferedReader (new InputStreamReader(System.in)); BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("return for exit:"); System.out.println("return for exit:");
try { try {
in.readLine(); in.readLine();
@ -81,6 +79,7 @@ public class EVAHELP {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
} }
/** /**
* *
*/ */
@ -98,6 +97,7 @@ public class EVAHELP {
} }
return sBuf.toString(); return sBuf.toString();
} }
/** /**
* @param longName The FQDN of a class * @param longName The FQDN of a class
* @return Returns the class Name without package. * @return Returns the class Name without package.
@ -110,6 +110,7 @@ public class EVAHELP {
} }
return className; // now is shortName return className; // now is shortName
} }
/** /**
* *
*/ */
@ -126,8 +127,8 @@ public class EVAHELP {
} }
/** /**
* Log a String to a log-file indicated by the file name. * Log a String to a log-file indicated by the file name. If the file
* If the file exists, the String is appended. * exists, the String is appended.
* *
* @param msg * @param msg
* @param fileName * @param fileName
@ -136,8 +137,7 @@ public class EVAHELP {
final File logFile = new File(fileName); final File logFile = new File(fileName);
try { try {
BufferedWriter bW = new BufferedWriter( BufferedWriter bW = new BufferedWriter(
new PrintWriter(new FileOutputStream(logFile, logFile.exists())) new PrintWriter(new FileOutputStream(logFile, logFile.exists())));
);
bW.write(msg); bW.write(msg);
bW.close(); bW.close();
} catch (IOException ex) { } catch (IOException ex) {
@ -146,8 +146,8 @@ public class EVAHELP {
} }
/** /**
* Deletes the given file in the current directory. * Deletes the given file in the current directory. If the file does not
* If the file does not exist nothing happens. * exist nothing happens.
* *
* @param fileName The name of the log file * @param fileName The name of the log file
*/ */

View File

@ -2,9 +2,8 @@ package eva2.tools;
import java.awt.Component; import java.awt.Component;
import javax.swing.Icon; import java.awt.Toolkit;
import javax.swing.JDialog; import javax.swing.*;
import javax.swing.JOptionPane;
/** /**
* Some helper methods connected to the GUI. * Some helper methods connected to the GUI.
@ -50,11 +49,24 @@ public class ToolBoxGui {
jop.setInitialValue(initialVal); // this I expected to work next jop.setInitialValue(initialVal); // this I expected to work next
jop.setInitialSelectionValue(initialVal); // this actually seems to work... jop.setInitialSelectionValue(initialVal); // this actually seems to work...
JDialog dialog = jop.createDialog(parent, title); JDialog dialog = jop.createDialog(parent, title);
dialog.show(); dialog.setVisible(true);
Object value = jop.getValue(); Object value = jop.getValue();
if (value!=null && (value instanceof Integer) && ((Integer)value)==JOptionPane.OK_OPTION) { if (value != null && (value instanceof Integer) && ((Integer) value) == JOptionPane.OK_OPTION) {
String newStr=(String)jop.getInputValue(); return (String) jop.getInputValue();
return newStr; } else {
} else return null; return null;
}
}
public static JButton createIconifiedButton(final String iconSrc, final String title, final boolean withTitle) {
JButton newButton;
byte[] bytes;
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false);
if (bytes == null) {
newButton = new JButton(title);
} else {
newButton = new JButton(title, new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
}
return newButton;
} }
} }

View File

@ -17,15 +17,10 @@ import java.rmi.Naming;
import java.rmi.NotBoundException; import java.rmi.NotBoundException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.rmi.registry.Registry; import java.rmi.registry.Registry;
import java.security.AccessControlException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import eva2.tools.Serializer;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.AccessControlException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;

View File

@ -8,24 +8,15 @@ package eva2.tools.jproxy;
* $Date: 2004/04/15 09:12:29 $ * $Date: 2004/04/15 09:12:29 $
* $Author: ulmerh $ * $Author: ulmerh $
*/ */
/*==========================================================================* import java.io.Serializable;
* IMPORTS
*==========================================================================*/
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.io.Serializable;
import java.util.ArrayList;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
public class JProxyRemoteThread implements InvocationHandler, public class JProxyRemoteThread implements InvocationHandler, Serializable {
Serializable {
private static ComAdapter m_ComAdapter; private static ComAdapter m_ComAdapter;
private Object m_Object; private Object m_Object;
private RMIThreadInvocationHandler m_RMIThreadHandler; private RMIThreadInvocationHandler m_RMIThreadHandler;
@ -33,7 +24,7 @@ public class JProxyRemoteThread implements InvocationHandler,
/** /**
* *
*/ */
public static Object newInstance(Serializable object, String host) throws NO_RMIServerAvailable { public static Object newInstance(Serializable object, String host) throws RMIServerNotAvailableException {
return Proxy.newProxyInstance( return Proxy.newProxyInstance(
object.getClass().getClassLoader(), object.getClass().getClassLoader(),
object.getClass().getInterfaces(), object.getClass().getInterfaces(),
@ -43,7 +34,7 @@ public class JProxyRemoteThread implements InvocationHandler,
/** /**
* *
*/ */
public static Object newInstance(Serializable object) throws NO_RMIServerAvailable { public static Object newInstance(Serializable object) throws RMIServerNotAvailableException {
return Proxy.newProxyInstance( return Proxy.newProxyInstance(
object.getClass().getClassLoader(), object.getClass().getClassLoader(),
object.getClass().getInterfaces(), object.getClass().getInterfaces(),
@ -80,7 +71,7 @@ public class JProxyRemoteThread implements InvocationHandler,
/** /**
* *
*/ */
private JProxyRemoteThread(Serializable object, String host) throws NO_RMIServerAvailable { private JProxyRemoteThread(Serializable object, String host) throws RMIServerNotAvailableException {
if (m_ComAdapter == null) if (m_ComAdapter == null)
m_ComAdapter = ComAdapter.getInstance(); m_ComAdapter = ComAdapter.getInstance();
m_RMIThreadHandler = m_ComAdapter.getRMIThreadHandler(object, host); m_RMIThreadHandler = m_ComAdapter.getRMIThreadHandler(object, host);
@ -89,7 +80,7 @@ public class JProxyRemoteThread implements InvocationHandler,
/** /**
* *
*/ */
private JProxyRemoteThread(Serializable object) throws NO_RMIServerAvailable { private JProxyRemoteThread(Serializable object) throws RMIServerNotAvailableException {
if (m_ComAdapter == null) if (m_ComAdapter == null)
m_ComAdapter = ComAdapter.getInstance(); m_ComAdapter = ComAdapter.getInstance();
m_RMIThreadHandler = m_ComAdapter.getRMIThreadHandler(object); m_RMIThreadHandler = m_ComAdapter.getRMIThreadHandler(object);

View File

@ -8,24 +8,26 @@ package eva2.tools.jproxy;
* $Date: 2004/04/15 09:12:29 $ * $Date: 2004/04/15 09:12:29 $
* $Author: ulmerh $ * $Author: ulmerh $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
public interface MainAdapter { public interface MainAdapter {
public String getExecOutput(String command); public String getExecOutput(String command);
public void setBuf(String s); public void setBuf(String s);
public void killServer(); public void killServer();
public void restartServer(); public void restartServer();
public String getBuf(); public String getBuf();
public RMIInvocationHandler getRMIHandler(Object obj); public RMIInvocationHandler getRMIHandler(Object obj);
public RMIThreadInvocationHandler getRMIThreadHandler(Object obj); public RMIThreadInvocationHandler getRMIThreadHandler(Object obj);
public void setRemoteThis (MainAdapter x);
public void setRemoteThis(MainAdapter x);
} }

View File

@ -8,13 +8,7 @@ package eva2.tools.jproxy;
* $Date: 2004/04/15 09:12:30 $ * $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $ * $Author: ulmerh $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/** /**
* *
*/ */

View File

@ -8,14 +8,8 @@ package eva2.tools.jproxy;
* $Date: 2004/04/15 09:12:30 $ * $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $ * $Author: ulmerh $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.net.InetAddress; import java.net.InetAddress;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* *
*/ */

View File

@ -8,69 +8,60 @@ package eva2.tools.jproxy;
* $Date: 2004/04/15 09:12:30 $ * $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $ * $Author: ulmerh $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* *
*/ */
public class MainAdapterImpl implements MainAdapter { public class MainAdapterImpl implements MainAdapter {
static final public String MAIN_ADAPTER_NAME = "MainRemoteObjectName";
static final public int PORT = 1099; private static final Logger LOGGER = Logger.getLogger(eva2.EvAInfo.defaultLogger);
static public boolean TRACE = false; public static final String MAIN_ADAPTER_NAME = "MainRemoteObjectName";
public static final int PORT = 1099;
private String m_Buf = ""; private String m_Buf = "";
private MainAdapter m_RemoteThis; private MainAdapter remoteThis;
/** /**
* *
*/ */
public MainAdapterImpl() { public MainAdapterImpl() {
if (TRACE) System.out.println("Constructor MainAdapterImpl !!!!!!"); remoteThis = this;
m_RemoteThis = this;
} }
/** /**
* *
*/ */
public void setBuf(String s) { public void setBuf(String s) {
if (TRACE) System.out.println("MainAdapterImpl.setBuf:"+s);
m_Buf = s; m_Buf = s;
} }
/** /**
* *
*/ */
public void restartServer() { public void restartServer() {
System.out.println("Received message to restartServer !!!!"); LOGGER.log(Level.INFO, "Received a Message to restart the server.");
try { try {
String command = "java -cp . eva2.server.EvAServer &"; String command = "java -cp . eva2.server.EvAServer &";
System.out.println("Calling the command:"+"java eva2.server.EvAServer"); LOGGER.log(Level.INFO, "Calling the command:" + "java eva2.server.EvAServer");
Process pro = Runtime.getRuntime().exec(command); Process pro = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader ( new InputStreamReader (pro.getInputStream())); BufferedReader in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
// String line = null; } catch (Exception ex) {
// while((line = in.readLine()) != null ) { LOGGER.log(Level.WARNING, "Error while restarting the server.", ex);
// System.out.println(line);
// Out = Out + line;
// }
System.out.println("command="+command);
} catch (Exception e) {
System.out.println("Error in calling the command:"+e.getMessage());
} }
killServer(); killServer();
} }
/** /**
* *
*/ */
public void killServer() { public void killServer() {
//Mail.SendMail("Received message to kill EvAServer"); LOGGER.log(Level.INFO, "Received a Message to kill the server.");
System.out.println("Received message to kill EvAServer !!!!");
KillThread x = new KillThread(); KillThread x = new KillThread();
x.start(); x.start();
return;
} }
/** /**
@ -79,27 +70,27 @@ public class MainAdapterImpl implements MainAdapter {
public String getBuf() { public String getBuf() {
return m_Buf; return m_Buf;
} }
/** /**
* *
*/ */
public String getExecOutput(String command) { public String getExecOutput(String command) {
String Out= new String(); StringBuffer output = new StringBuffer();
try { try {
BufferedReader in = null; BufferedReader in = null;
Process pro = null; Process pro = null;
if (TRACE) System.out.println("Calling the command:"+command);
pro = Runtime.getRuntime().exec(command); pro = Runtime.getRuntime().exec(command);
in = new BufferedReader ( new InputStreamReader (pro.getInputStream())); in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
String line = null; String line = null;
while((line = in.readLine()) != null ) { while ((line = in.readLine()) != null) {
if (TRACE) System.out.println(line); output.append(line);
Out = Out + line;
} }
} catch (Exception e) { } catch (Exception e) {
System.err.println("Error in calling the command:"+e.getMessage()); System.err.println("Error in calling the command:" + e.getMessage());
} }
return Out; return output.toString();
} }
/** /**
* *
*/ */
@ -108,44 +99,46 @@ public class MainAdapterImpl implements MainAdapter {
RMIInvocationHandler ret = null; RMIInvocationHandler ret = null;
try { try {
ret = new RMIInvocationHandlerImpl(obj); ret = new RMIInvocationHandlerImpl(obj);
} } catch (Exception e) {
catch (Exception e) {
System.out.println("Error: RMIInvokationHandler getRMIHandler"); System.out.println("Error: RMIInvokationHandler getRMIHandler");
} }
return ret; return ret;
} }
/** /**
* *
*/ */
public RMIThreadInvocationHandler getRMIThreadHandler(Object obj) { public RMIThreadInvocationHandler getRMIThreadHandler(Object obj) {
if (TRACE) System.out.println("getRMIThreadHandler");
RMIThreadInvocationHandler ret = null; RMIThreadInvocationHandler ret = null;
try { try {
ret = new RMIThreadInvocationHandlerImpl(obj); ret = new RMIThreadInvocationHandlerImpl(obj);
} } catch (Exception e) {
catch (Exception e) {
System.out.println("Error: RMIThreadInvokationHandler getRMIThreadHandler"); System.out.println("Error: RMIThreadInvokationHandler getRMIThreadHandler");
} }
return ret; return ret;
} }
/** /**
* *
*/ */
public void setRemoteThis (MainAdapter x) { public void setRemoteThis(MainAdapter x) {
m_RemoteThis = x; remoteThis = x;
} }
} }
/** /**
* *
*/ */
class KillThread extends Thread { class KillThread extends Thread {
/** /**
* *
*/ */
public void run() { public void run() {
try {sleep(3000);} try {
catch(Exception e) { sleep(3000);
} catch (Exception e) {
System.out.println("Error in sleep"); System.out.println("Error in sleep");
} }
System.exit(-1); System.exit(-1);

View File

@ -22,22 +22,32 @@ import java.util.logging.Logger;
* *
*/ */
public class RMIServer { public class RMIServer {
/* Version string of the server application. */ /*
* Version string of the server application.
*/
protected static RMIServer instance; protected static RMIServer instance;
/* Name of host on which the server is running. */ /*
* Name of host on which the server is running.
*/
private String myHostName = "undefined"; private String myHostName = "undefined";
/* IP of host on which the server is running. */ /*
* IP of host on which the server is running.
*/
private String myHostIP = "undefined"; private String myHostIP = "undefined";
/* MainAdapterImp object. This is need for the first /*
connection between the server and the client program. */ * MainAdapterImp object. This is need for the first connection between the server and the
* client program.
*/
protected MainAdapter mainRemoteObject; protected MainAdapter mainRemoteObject;
/* String describing the properties of the enviroment. */ /*
* String describing the properties of the enviroment.
*/
// private ComAdapter m_ComAdapter; // private ComAdapter m_ComAdapter;
protected static String userName; protected static String userName;
protected static int numberOfVM = 0; protected static int numberOfVM = 0;
private Registry myRegistry = null; private Registry myRegistry = null;
protected static final Logger LOGGER = Logger.getLogger(EvAInfo.defaultLogger);
protected static final Logger logger = Logger.getLogger(EvAInfo.defaultLogger);
/** /**
* *
@ -48,9 +58,9 @@ public class RMIServer {
} }
return instance; return instance;
} }
/** /**
* Constructor of EvAServer. * Constructor of EvAServer. Calls RMIConnection().
* Calls RMIConnection().
*/ */
protected RMIServer() { protected RMIServer() {
userName = System.getProperty("user.name"); userName = System.getProperty("user.name");
@ -58,18 +68,17 @@ public class RMIServer {
} }
/** /**
* Main method of this class. * Main method of this class. Is the starting point of the server application.
* Is the starting point of the server application.
*/ */
public static void main(String[] args) { public static void main(String[] args) {
logger.log(Level.INFO, "Start RMIServer !"); LOGGER.log(Level.INFO, "Start RMIServer !");
RMIServer application = RMIServer.getInstance(); RMIServer application = RMIServer.getInstance();
} }
/** /**
* Launches the RMIRegistry and makes the registration * Launches the RMIRegistry and makes the registration of the MainAdapterImpl class at the
* of the MainAdapterImpl class at the rmiregistry. * rmiregistry.
*
* @param * @param
*/ */
private void initConnection() { private void initConnection() {
@ -80,33 +89,33 @@ public class RMIServer {
myHostIP = InetAddress.getLocalHost().getHostAddress(); myHostIP = InetAddress.getLocalHost().getHostAddress();
myHostName = InetAddress.getLocalHost().getHostName(); myHostName = InetAddress.getLocalHost().getHostName();
} catch (Exception e) { } catch (Exception e) {
logger.log(Level.SEVERE, "Error getting HostName " + e.getMessage(), e); LOGGER.log(Level.SEVERE, "Error getting HostName " + e.getMessage(), e);
} }
logger.log(Level.INFO, "Start of EvA RMI-Server on host " + myHostName + " = " + myHostIP); LOGGER.log(Level.INFO, "Start of EvA RMI-Server on host " + myHostName + " = " + myHostIP);
try { try {
String[] list = Naming.list("rmi://localhost:" + MainAdapterImpl.PORT); String[] list = Naming.list("rmi://localhost:" + MainAdapterImpl.PORT);
numberOfVM = getNumberOfVM(list); numberOfVM = getNumberOfVM(list);
} catch (RemoteException e) { } catch (RemoteException e) {
logger.log(Level.WARNING, "No RMI registry available yet"); LOGGER.log(Level.WARNING, "No RMI registry available yet");
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
logger.log(Level.SEVERE, "MalformedURLException: Error while looking up " + ex.getMessage(), ex); LOGGER.log(Level.SEVERE, "MalformedURLException: Error while looking up " + ex.getMessage(), ex);
} }
createMainRemoteObject(mainAdapterName); createMainRemoteObject(mainAdapterName);
logger.log(Level.INFO, "End of RMI-Server Initialisation"); LOGGER.log(Level.INFO, "End of RMI-Server Initialisation");
logger.log(Level.INFO, "Host: " + myHostName + " = " + myHostIP + ", adapter name is " + mainAdapterName); LOGGER.log(Level.INFO, "Host: " + myHostName + " = " + myHostIP + ", adapter name is " + mainAdapterName);
logger.log(Level.INFO, "Waiting for a client."); LOGGER.log(Level.INFO, "Waiting for a client.");
} }
protected void createMainRemoteObject(String mainAdapterName) { protected void createMainRemoteObject(String mainAdapterName) {
try { try {
mainRemoteObject = new MainAdapterImpl(); mainRemoteObject = new MainAdapterImpl();
mainRemoteObject = mainRemoteObject =
(MainAdapter) RMIProxyLocal.newInstance(mainRemoteObject,mainAdapterName + "_" + numberOfVM); (MainAdapter) RMIProxyLocal.newInstance(mainRemoteObject, mainAdapterName + "_" + numberOfVM);
mainRemoteObject.setRemoteThis(mainRemoteObject); mainRemoteObject.setRemoteThis(mainRemoteObject);
} catch (Exception ex) { } catch (Exception ex) {
logger.log(Level.WARNING, "Could not create main remote object!", ex); LOGGER.log(Level.WARNING, "Could not create main remote object!", ex);
} }
} }
@ -123,11 +132,11 @@ public class RMIServer {
private void launchRMIRegistry() { private void launchRMIRegistry() {
try { try {
myRegistry = java.rmi.registry.LocateRegistry.createRegistry(MainAdapterImpl.PORT); myRegistry = java.rmi.registry.LocateRegistry.createRegistry(MainAdapterImpl.PORT);
} catch (Throwable e) { } catch (Exception ex) {
myRegistry = null; myRegistry = null;
} }
if (myRegistry == null) { if (myRegistry == null) {
logger.log(Level.INFO, "Try to get registry with getRegistry on port " + MainAdapterImpl.PORT); LOGGER.log(Level.INFO, "Try to get registry with getRegistry on port " + MainAdapterImpl.PORT);
try { try {
myRegistry = java.rmi.registry.LocateRegistry.getRegistry(MainAdapterImpl.PORT); myRegistry = java.rmi.registry.LocateRegistry.getRegistry(MainAdapterImpl.PORT);
} catch (RemoteException e) { } catch (RemoteException e) {
@ -135,7 +144,7 @@ public class RMIServer {
} }
} }
if (myRegistry == null) { if (myRegistry == null) {
logger.log(Level.WARNING, "Got no RMIREGISTRY"); LOGGER.log(Level.WARNING, "Got no RMIREGISTRY");
} }
} }
@ -145,11 +154,10 @@ public class RMIServer {
private int getNumberOfVM(String[] list) { private int getNumberOfVM(String[] list) {
int ret = 0; int ret = 0;
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
if (list[i].indexOf(MainAdapterImpl.MAIN_ADAPTER_NAME) != -1) if (list[i].indexOf(MainAdapterImpl.MAIN_ADAPTER_NAME) != -1) {
ret++; ret++;
} }
}
return ret; return ret;
} }
} }

View File

@ -8,17 +8,15 @@ package eva2.tools.jproxy;
* $Date: 2004/04/15 09:12:30 $ * $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $ * $Author: ulmerh $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/** /**
* This exception will be thrown when no * This exception will be thrown when no
* RMIServer con be found by the ComAdapter. * RMIServer can be found by the ComAdapter.
*/ */
public class NO_RMIServerAvailable extends Exception { public final class RMIServerNotAvailableException extends Exception {
NO_RMIServerAvailable() {
printStackTrace();
}
@Override
public String getMessage() {
return "There is no RMI Server available.";
}
} }

View File

@ -8,14 +8,8 @@ package eva2.tools.jproxy;
* $Date: 2004/04/15 09:12:31 $ * $Date: 2004/04/15 09:12:31 $
* $Author: ulmerh $ * $Author: ulmerh $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.rmi.Remote; import java.rmi.Remote;
import java.rmi.RemoteException; import java.rmi.RemoteException;
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/** /**
* *
*/ */

View File

@ -8,13 +8,6 @@ package eva2.tools.jproxy;
* $Date: 2004/04/15 09:12:30 $ * $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $ * $Author: ulmerh $
*/ */
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/** /**
* *