Refactoring and proper naming for all the things \o/
This commit is contained in:
@@ -1,30 +1,22 @@
|
|||||||
package eva2.client;
|
package eva2.client;
|
||||||
|
|
||||||
/*
|
|
||||||
* Title: EvA2
|
|
||||||
* Description:
|
|
||||||
* Copyright: Copyright (c) 2003
|
|
||||||
* 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 $
|
|
||||||
*/
|
|
||||||
import eva2.gui.LoggingPanel;
|
import eva2.gui.LoggingPanel;
|
||||||
import eva2.optimization.EvAMainAdapter;
|
import eva2.optimization.EvAMainAdapter;
|
||||||
import eva2.optimization.EvAMainAdapterImpl;
|
import eva2.optimization.EvAMainAdapterImpl;
|
||||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||||
import eva2.optimization.modules.ModuleAdapter;
|
import eva2.optimization.modules.ModuleAdapter;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EvAComAdapter {
|
public class EvAComAdapter {
|
||||||
|
private final static Logger LOGGER = Logger.getLogger(EvAComAdapter.class.getName());
|
||||||
private LoggingPanel loggingPanel;
|
private LoggingPanel loggingPanel;
|
||||||
private EvAMainAdapterImpl localMainAdapter;
|
private EvAMainAdapterImpl localMainAdapter;
|
||||||
private boolean runLocally = false;
|
private static EvAComAdapter instance;
|
||||||
private static EvAComAdapter m_instance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -37,14 +29,14 @@ public class EvAComAdapter {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static EvAComAdapter getInstance() {
|
public static EvAComAdapter getInstance() {
|
||||||
if (m_instance == null) {
|
if (instance == null) {
|
||||||
m_instance = new EvAComAdapter();
|
instance = new EvAComAdapter();
|
||||||
}
|
}
|
||||||
return (EvAComAdapter) m_instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the ModulAdapters RMI Object on the server
|
* Creates the ModuleAdapters RMI Object on the server
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -72,15 +64,13 @@ public class EvAComAdapter {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String[] getModuleNameList() {
|
public String[] getModuleNameList() {
|
||||||
String[] list;
|
String[] list = getLocalMainAdapter().getModuleNameList();
|
||||||
list = getLocalMainAdapter().getModuleNameList();
|
LOGGER.info("List of modules available:");
|
||||||
if (loggingPanel != null) {
|
|
||||||
loggingPanel.logMessage("List of modules available:");
|
|
||||||
}
|
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (String item : list) {
|
||||||
if ((String) list[i] != null && loggingPanel != null) {
|
if (!item.isEmpty() && loggingPanel != null) {
|
||||||
loggingPanel.logMessage((String) list[i]);
|
LOGGER.info(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -59,11 +59,11 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
|
|||||||
EvATreeNode leafNode = (EvATreeNode) tp.getLastPathComponent();
|
EvATreeNode leafNode = (EvATreeNode) tp.getLastPathComponent();
|
||||||
// goe.setValue(leafNode.getUserObject());
|
// goe.setValue(leafNode.getUserObject());
|
||||||
Component editComp = goe.getCustomEditor();
|
Component editComp = goe.getCustomEditor();
|
||||||
if (editComp instanceof GOEPanel) {
|
if (editComp instanceof OptimizationEditorPanel) {
|
||||||
// update the object in the main GOEPanel
|
// update the object in the main OptimizationEditorPanel
|
||||||
((GOEPanel) editComp).setTarget(leafNode.getUserObject());
|
((OptimizationEditorPanel) editComp).setTarget(leafNode.getUserObject());
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected GOEPanel (EvATreeSelectionListener)");
|
System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected OptimizationEditorPanel (EvATreeSelectionListener)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
|
||||||
|
|
||||||
// Hosts:
|
// Configurable module:
|
||||||
private ModuleAdapter currentModuleAdapter = null;
|
private ModuleAdapter currentModuleAdapter = null;
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@@ -104,7 +104,6 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
* @param paramsFile
|
* @param paramsFile
|
||||||
* @param autorun
|
* @param autorun
|
||||||
* @param nosplash
|
* @param nosplash
|
||||||
* @see #EvAClient(String, java.awt.Window, String, boolean, boolean, boolean)
|
|
||||||
*/
|
*/
|
||||||
public Main(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) {
|
public Main(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) {
|
||||||
this(hostName, null, paramsFile, null, autorun, nosplash, false, false);
|
this(hostName, null, paramsFile, null, autorun, nosplash, false, false);
|
||||||
@@ -207,7 +206,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
comAdapter = EvAComAdapter.getInstance();
|
this.comAdapter = EvAComAdapter.getInstance();
|
||||||
|
|
||||||
splashScreenTime = 2500;
|
splashScreenTime = 2500;
|
||||||
SwingUtilities.invokeLater(initRunnable = new Runnable() {
|
SwingUtilities.invokeLater(initRunnable = new Runnable() {
|
||||||
@@ -789,11 +788,11 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
return (currentModuleAdapter != null) && (currentModuleAdapter instanceof AbstractModuleAdapter) && ((AbstractModuleAdapter) currentModuleAdapter).isOptRunning();
|
return (currentModuleAdapter != null) && (currentModuleAdapter instanceof AbstractModuleAdapter) && ((AbstractModuleAdapter) currentModuleAdapter).isOptRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSpecificModule(String selectedModule, InterfaceOptimizationParameters goParams) {
|
private void loadSpecificModule(String selectedModule, InterfaceOptimizationParameters optimizationParameters) {
|
||||||
ModuleAdapter newModuleAdapter = null;
|
ModuleAdapter newModuleAdapter = null;
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
newModuleAdapter = comAdapter.getModuleAdapter(selectedModule, goParams, withGUI ? null : "EvA2");
|
newModuleAdapter = comAdapter.getModuleAdapter(selectedModule, optimizationParameters, withGUI ? null : "EvA2");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.log(Level.SEVERE, "Error loading module.", e);
|
LOGGER.log(Level.SEVERE, "Error loading module.", e);
|
||||||
EVAERROR.EXIT("Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage());
|
EVAERROR.EXIT("Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage());
|
||||||
@@ -811,7 +810,7 @@ public class Main extends JFrame implements OptimizationStateListener {
|
|||||||
System.setProperty("java.class.path", cp + System.getProperty("path.separator") + dir);
|
System.setProperty("java.class.path", cp + System.getProperty("path.separator") + dir);
|
||||||
ReflectPackage.resetDynCP();
|
ReflectPackage.resetDynCP();
|
||||||
comAdapter.updateLocalMainAdapter();
|
comAdapter.updateLocalMainAdapter();
|
||||||
loadSpecificModule(selectedModule, goParams); // end recursive call! handle with care!
|
loadSpecificModule(selectedModule, optimizationParameters); // end recursive call! handle with care!
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -5,7 +5,6 @@ import eva2.optimization.tools.FileTools;
|
|||||||
import eva2.tools.BasicResourceLoader;
|
import eva2.tools.BasicResourceLoader;
|
||||||
import eva2.tools.EVAHELP;
|
import eva2.tools.EVAHELP;
|
||||||
import eva2.tools.SerializedObject;
|
import eva2.tools.SerializedObject;
|
||||||
import org.reflections.Reflections;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@@ -27,8 +26,8 @@ import javax.swing.plaf.basic.BasicComboBoxRenderer;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GOEPanel extends JPanel implements ItemListener {
|
public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
||||||
private static final Logger LOGGER = Logger.getLogger(GOEPanel.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(OptimizationEditorPanel.class.getName());
|
||||||
|
|
||||||
private Object backupObject;
|
private Object backupObject;
|
||||||
private PropertyChangeSupport propChangeSupport;
|
private PropertyChangeSupport propChangeSupport;
|
||||||
@@ -71,14 +70,14 @@ public class GOEPanel extends JPanel implements ItemListener {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public GOEPanel(Object target, Object backup, PropertyChangeSupport support, GenericObjectEditor goe) {
|
public OptimizationEditorPanel(Object target, Object backup, PropertyChangeSupport support, GenericObjectEditor goe) {
|
||||||
this(target, backup, support, goe, false);
|
this(target, backup, support, goe, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public GOEPanel(Object target, Object backup, PropertyChangeSupport support, GenericObjectEditor goe, boolean withCancel) {
|
public OptimizationEditorPanel(Object target, Object backup, PropertyChangeSupport support, GenericObjectEditor goe, boolean withCancel) {
|
||||||
Object m_Object = target;
|
Object m_Object = target;
|
||||||
backupObject = backup;
|
backupObject = backup;
|
||||||
propChangeSupport = support;
|
propChangeSupport = support;
|
||||||
@@ -91,7 +90,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
|||||||
} catch (OutOfMemoryError err) {
|
} catch (OutOfMemoryError err) {
|
||||||
backupObject = null;
|
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 (OptimizationEditorPanel backup of " + m_Object + ")");
|
||||||
}
|
}
|
||||||
comboBoxModel = new DefaultComboBoxModel(new String[0]);
|
comboBoxModel = new DefaultComboBoxModel(new String[0]);
|
||||||
objectChooser = new JComboBox(comboBoxModel);
|
objectChooser = new JComboBox(comboBoxModel);
|
||||||
@@ -145,7 +144,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
|||||||
/*
|
/*
|
||||||
* ToDo: This is really ugly. Find a way to make this better.
|
* ToDo: This is really ugly. Find a way to make this better.
|
||||||
*/
|
*/
|
||||||
Container container = GOEPanel.this.getParent();
|
Container container = OptimizationEditorPanel.this.getParent();
|
||||||
while (!(container instanceof JDialog)) {
|
while (!(container instanceof JDialog)) {
|
||||||
container = container.getParent();
|
container = container.getParent();
|
||||||
}
|
}
|
||||||
@@ -168,7 +167,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
|||||||
/*
|
/*
|
||||||
* ToDo: This is really ugly. Find a way to make this better.
|
* ToDo: This is really ugly. Find a way to make this better.
|
||||||
*/
|
*/
|
||||||
Container container = GOEPanel.this.getParent();
|
Container container = OptimizationEditorPanel.this.getParent();
|
||||||
while (!(container instanceof JDialog)) {
|
while (!(container instanceof JDialog)) {
|
||||||
container = container.getParent();
|
container = container.getParent();
|
||||||
}
|
}
|
||||||
@@ -312,7 +311,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
|||||||
List<String> classesLongNames;
|
List<String> classesLongNames;
|
||||||
ArrayList<Class<?>> instances = new ArrayList<Class<?>>(5);
|
ArrayList<Class<?>> instances = new ArrayList<Class<?>>(5);
|
||||||
classesLongNames = GenericObjectEditor.getClassesFromProperties(genericObjectEditor.getClassType().getName(), instances);
|
classesLongNames = GenericObjectEditor.getClassesFromProperties(genericObjectEditor.getClassType().getName(), instances);
|
||||||
LOGGER.finest("Selected type for GOEPanel: " + genericObjectEditor.getClassType().getName());
|
LOGGER.finest("Selected type for OptimizationEditorPanel: " + genericObjectEditor.getClassType().getName());
|
||||||
if (classesLongNames.size() > 1) {
|
if (classesLongNames.size() > 1) {
|
||||||
classNameMap = new HashMap<String, String>();
|
classNameMap = new HashMap<String, String>();
|
||||||
for (String className : classesLongNames) {
|
for (String className : classesLongNames) {
|
@@ -90,7 +90,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
|||||||
} catch (OutOfMemoryError err) {
|
} catch (OutOfMemoryError err) {
|
||||||
backupObject = null;
|
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 (OptimizationEditorPanel backup of " + m_Object + ")");
|
||||||
}
|
}
|
||||||
comboBoxModel = new DefaultComboBoxModel(new String[0]);
|
comboBoxModel = new DefaultComboBoxModel(new String[0]);
|
||||||
objectChooser = new JComboBox(comboBoxModel);
|
objectChooser = new JComboBox(comboBoxModel);
|
||||||
|
@@ -6,7 +6,7 @@ package eva2.gui.editor;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import eva2.EvAInfo;
|
import eva2.EvAInfo;
|
||||||
import eva2.gui.GOEPanel;
|
import eva2.gui.OptimizationEditorPanel;
|
||||||
import eva2.tools.ReflectPackage;
|
import eva2.tools.ReflectPackage;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
@@ -36,7 +36,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
|||||||
private Object m_Backup;
|
private Object m_Backup;
|
||||||
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
||||||
private Class<?> classType;
|
private Class<?> classType;
|
||||||
private GOEPanel editorComponent;
|
private OptimizationEditorPanel editorComponent;
|
||||||
private boolean isEnabled = true;
|
private boolean isEnabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -473,7 +473,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
|||||||
@Override
|
@Override
|
||||||
public Component getCustomEditor() {
|
public Component getCustomEditor() {
|
||||||
if (editorComponent == null) {
|
if (editorComponent == null) {
|
||||||
editorComponent = new GOEPanel(m_Object, m_Backup, propertyChangeSupport, this);
|
editorComponent = new OptimizationEditorPanel(m_Object, m_Backup, propertyChangeSupport, this);
|
||||||
}
|
}
|
||||||
return editorComponent;
|
return editorComponent;
|
||||||
}
|
}
|
||||||
@@ -483,7 +483,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
|||||||
*/
|
*/
|
||||||
public void disableOKCancel() {
|
public void disableOKCancel() {
|
||||||
if (editorComponent == null) {
|
if (editorComponent == null) {
|
||||||
editorComponent = new GOEPanel(m_Object, m_Backup,
|
editorComponent = new OptimizationEditorPanel(m_Object, m_Backup,
|
||||||
propertyChangeSupport, this);
|
propertyChangeSupport, this);
|
||||||
}
|
}
|
||||||
editorComponent.setEnabledOkCancelButtons(false);
|
editorComponent.setEnabledOkCancelButtons(false);
|
||||||
|
@@ -1,16 +1,5 @@
|
|||||||
package eva2.optimization;
|
package eva2.optimization;
|
||||||
|
|
||||||
/*
|
|
||||||
* Title: EvA2
|
|
||||||
* Description:
|
|
||||||
* Copyright: Copyright (c) 2003
|
|
||||||
* 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 $
|
|
||||||
*/
|
|
||||||
|
|
||||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||||
import eva2.optimization.modules.GOModuleAdapter;
|
import eva2.optimization.modules.GOModuleAdapter;
|
||||||
import eva2.optimization.modules.ModuleAdapter;
|
import eva2.optimization.modules.ModuleAdapter;
|
||||||
@@ -107,7 +96,7 @@ public class ModuleServer {
|
|||||||
*
|
*
|
||||||
* @return the loaded module adapter instance
|
* @return the loaded module adapter instance
|
||||||
*/
|
*/
|
||||||
public ModuleAdapter createModuleAdapter(String selectedModuleName, InterfaceOptimizationParameters goParams, String noGuiLogFile) {
|
public ModuleAdapter createModuleAdapter(String selectedModuleName, InterfaceOptimizationParameters optimizationParameters, String noGuiLogFile) {
|
||||||
moduleAdapterCounter++;
|
moduleAdapterCounter++;
|
||||||
String adapterName = "ERROR MODULADAPTER !!";
|
String adapterName = "ERROR MODULADAPTER !!";
|
||||||
String moduleName = null;
|
String moduleName = null;
|
||||||
@@ -132,8 +121,8 @@ public class ModuleServer {
|
|||||||
/* create a module instance */
|
/* create a module instance */
|
||||||
int constrIndex = 0;
|
int constrIndex = 0;
|
||||||
|
|
||||||
if ((goParams == null && noGuiLogFile == null) || !module.equals(GOModuleAdapter.class)) {
|
if ((optimizationParameters == null && noGuiLogFile == null) || !module.equals(GOModuleAdapter.class)) {
|
||||||
if (goParams != null) {
|
if (optimizationParameters != null) {
|
||||||
System.err.println("Cant set params - no matching constructor found for " + adapterName + " (ModuleServer)");
|
System.err.println("Cant set params - no matching constructor found for " + adapterName + " (ModuleServer)");
|
||||||
}
|
}
|
||||||
if (noGuiLogFile != null) {
|
if (noGuiLogFile != null) {
|
||||||
@@ -148,21 +137,20 @@ 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] = adapterName;
|
||||||
param[1] = (InterfaceOptimizationParameters) goParams;
|
param[1] = optimizationParameters;
|
||||||
param[2] = (String) noGuiLogFile;
|
param[2] = noGuiLogFile;
|
||||||
while ((constructorArr[constrIndex].getParameterTypes().length != 4) && (constrIndex < constructorArr.length)) {
|
while ((constructorArr[constrIndex].getParameterTypes().length != 4) && (constrIndex < constructorArr.length)) {
|
||||||
constrIndex++;
|
constrIndex++;
|
||||||
}
|
}
|
||||||
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(param);
|
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(param);
|
||||||
}
|
}
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
return (ModuleAdapter) moduleAdapter;
|
return moduleAdapter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user