Refactoring and proper naming for all the things \o/
This commit is contained in:
parent
77e0e3ae73
commit
2c82732428
@ -1,30 +1,22 @@
|
||||
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.optimization.EvAMainAdapter;
|
||||
import eva2.optimization.EvAMainAdapterImpl;
|
||||
import eva2.optimization.go.InterfaceOptimizationParameters;
|
||||
import eva2.optimization.modules.ModuleAdapter;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EvAComAdapter {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(EvAComAdapter.class.getName());
|
||||
private LoggingPanel loggingPanel;
|
||||
private EvAMainAdapterImpl localMainAdapter;
|
||||
private boolean runLocally = false;
|
||||
private static EvAComAdapter m_instance;
|
||||
private static EvAComAdapter instance;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -37,14 +29,14 @@ public class EvAComAdapter {
|
||||
*
|
||||
*/
|
||||
public static EvAComAdapter getInstance() {
|
||||
if (m_instance == null) {
|
||||
m_instance = new EvAComAdapter();
|
||||
if (instance == null) {
|
||||
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
|
||||
*/
|
||||
@ -72,15 +64,13 @@ public class EvAComAdapter {
|
||||
* @return
|
||||
*/
|
||||
public String[] getModuleNameList() {
|
||||
String[] list;
|
||||
list = getLocalMainAdapter().getModuleNameList();
|
||||
if (loggingPanel != null) {
|
||||
loggingPanel.logMessage("List of modules available:");
|
||||
}
|
||||
String[] list = getLocalMainAdapter().getModuleNameList();
|
||||
LOGGER.info("List of modules available:");
|
||||
|
||||
if (list != null) {
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if ((String) list[i] != null && loggingPanel != null) {
|
||||
loggingPanel.logMessage((String) list[i]);
|
||||
for (String item : list) {
|
||||
if (!item.isEmpty() && loggingPanel != null) {
|
||||
LOGGER.info(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
|
||||
EvATreeNode leafNode = (EvATreeNode) tp.getLastPathComponent();
|
||||
// goe.setValue(leafNode.getUserObject());
|
||||
Component editComp = goe.getCustomEditor();
|
||||
if (editComp instanceof GOEPanel) {
|
||||
// update the object in the main GOEPanel
|
||||
((GOEPanel) editComp).setTarget(leafNode.getUserObject());
|
||||
if (editComp instanceof OptimizationEditorPanel) {
|
||||
// update the object in the main OptimizationEditorPanel
|
||||
((OptimizationEditorPanel) editComp).setTarget(leafNode.getUserObject());
|
||||
} 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());
|
||||
|
||||
// Hosts:
|
||||
// Configurable module:
|
||||
private ModuleAdapter currentModuleAdapter = null;
|
||||
|
||||
// Help:
|
||||
@ -104,7 +104,6 @@ public class Main extends JFrame implements OptimizationStateListener {
|
||||
* @param paramsFile
|
||||
* @param autorun
|
||||
* @param nosplash
|
||||
* @see #EvAClient(String, java.awt.Window, String, boolean, boolean, boolean)
|
||||
*/
|
||||
public Main(final String hostName, final String paramsFile, boolean autorun, boolean nosplash) {
|
||||
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;
|
||||
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();
|
||||
}
|
||||
|
||||
private void loadSpecificModule(String selectedModule, InterfaceOptimizationParameters goParams) {
|
||||
private void loadSpecificModule(String selectedModule, InterfaceOptimizationParameters optimizationParameters) {
|
||||
ModuleAdapter newModuleAdapter = null;
|
||||
//
|
||||
try {
|
||||
newModuleAdapter = comAdapter.getModuleAdapter(selectedModule, goParams, withGUI ? null : "EvA2");
|
||||
newModuleAdapter = comAdapter.getModuleAdapter(selectedModule, optimizationParameters, withGUI ? null : "EvA2");
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.SEVERE, "Error loading module.", e);
|
||||
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);
|
||||
ReflectPackage.resetDynCP();
|
||||
comAdapter.updateLocalMainAdapter();
|
||||
loadSpecificModule(selectedModule, goParams); // end recursive call! handle with care!
|
||||
loadSpecificModule(selectedModule, optimizationParameters); // end recursive call! handle with care!
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -5,7 +5,6 @@ import eva2.optimization.tools.FileTools;
|
||||
import eva2.tools.BasicResourceLoader;
|
||||
import eva2.tools.EVAHELP;
|
||||
import eva2.tools.SerializedObject;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
@ -27,8 +26,8 @@ import javax.swing.plaf.basic.BasicComboBoxRenderer;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class GOEPanel extends JPanel implements ItemListener {
|
||||
private static final Logger LOGGER = Logger.getLogger(GOEPanel.class.getName());
|
||||
public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
||||
private static final Logger LOGGER = Logger.getLogger(OptimizationEditorPanel.class.getName());
|
||||
|
||||
private Object backupObject;
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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;
|
||||
backupObject = backup;
|
||||
propChangeSupport = support;
|
||||
@ -91,7 +90,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
} catch (OutOfMemoryError err) {
|
||||
backupObject = null;
|
||||
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]);
|
||||
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.
|
||||
*/
|
||||
Container container = GOEPanel.this.getParent();
|
||||
Container container = OptimizationEditorPanel.this.getParent();
|
||||
while (!(container instanceof JDialog)) {
|
||||
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.
|
||||
*/
|
||||
Container container = GOEPanel.this.getParent();
|
||||
Container container = OptimizationEditorPanel.this.getParent();
|
||||
while (!(container instanceof JDialog)) {
|
||||
container = container.getParent();
|
||||
}
|
||||
@ -312,7 +311,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
List<String> classesLongNames;
|
||||
ArrayList<Class<?>> instances = new ArrayList<Class<?>>(5);
|
||||
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) {
|
||||
classNameMap = new HashMap<String, String>();
|
||||
for (String className : classesLongNames) {
|
@ -90,7 +90,7 @@ public class GOEPanel extends JPanel implements ItemListener {
|
||||
} catch (OutOfMemoryError err) {
|
||||
backupObject = null;
|
||||
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]);
|
||||
objectChooser = new JComboBox(comboBoxModel);
|
||||
|
@ -6,7 +6,7 @@ package eva2.gui.editor;
|
||||
*/
|
||||
|
||||
import eva2.EvAInfo;
|
||||
import eva2.gui.GOEPanel;
|
||||
import eva2.gui.OptimizationEditorPanel;
|
||||
import eva2.tools.ReflectPackage;
|
||||
|
||||
import java.awt.Component;
|
||||
@ -36,7 +36,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
private Object m_Backup;
|
||||
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
private Class<?> classType;
|
||||
private GOEPanel editorComponent;
|
||||
private OptimizationEditorPanel editorComponent;
|
||||
private boolean isEnabled = true;
|
||||
|
||||
/**
|
||||
@ -473,7 +473,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
@Override
|
||||
public Component getCustomEditor() {
|
||||
if (editorComponent == null) {
|
||||
editorComponent = new GOEPanel(m_Object, m_Backup, propertyChangeSupport, this);
|
||||
editorComponent = new OptimizationEditorPanel(m_Object, m_Backup, propertyChangeSupport, this);
|
||||
}
|
||||
return editorComponent;
|
||||
}
|
||||
@ -483,7 +483,7 @@ public class GenericObjectEditor implements PropertyEditor {
|
||||
*/
|
||||
public void disableOKCancel() {
|
||||
if (editorComponent == null) {
|
||||
editorComponent = new GOEPanel(m_Object, m_Backup,
|
||||
editorComponent = new OptimizationEditorPanel(m_Object, m_Backup,
|
||||
propertyChangeSupport, this);
|
||||
}
|
||||
editorComponent.setEnabledOkCancelButtons(false);
|
||||
|
@ -1,16 +1,5 @@
|
||||
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.modules.GOModuleAdapter;
|
||||
import eva2.optimization.modules.ModuleAdapter;
|
||||
@ -107,7 +96,7 @@ public class ModuleServer {
|
||||
*
|
||||
* @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++;
|
||||
String adapterName = "ERROR MODULADAPTER !!";
|
||||
String moduleName = null;
|
||||
@ -132,8 +121,8 @@ public class ModuleServer {
|
||||
/* create a module instance */
|
||||
int constrIndex = 0;
|
||||
|
||||
if ((goParams == null && noGuiLogFile == null) || !module.equals(GOModuleAdapter.class)) {
|
||||
if (goParams != null) {
|
||||
if ((optimizationParameters == null && noGuiLogFile == null) || !module.equals(GOModuleAdapter.class)) {
|
||||
if (optimizationParameters != null) {
|
||||
System.err.println("Cant set params - no matching constructor found for " + adapterName + " (ModuleServer)");
|
||||
}
|
||||
if (noGuiLogFile != null) {
|
||||
@ -148,21 +137,20 @@ public class ModuleServer {
|
||||
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(Para);
|
||||
} else {
|
||||
Object[] param = new Object[4];
|
||||
param[0] = (String) adapterName;
|
||||
param[1] = (InterfaceOptimizationParameters) goParams;
|
||||
param[2] = (String) noGuiLogFile;
|
||||
param[0] = adapterName;
|
||||
param[1] = optimizationParameters;
|
||||
param[2] = noGuiLogFile;
|
||||
while ((constructorArr[constrIndex].getParameterTypes().length != 4) && (constrIndex < constructorArr.length)) {
|
||||
constrIndex++;
|
||||
}
|
||||
moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(param);
|
||||
}
|
||||
// m_RunnungModules.add(m_ModuleAdapter);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error in RMI-Moduladapter initialization", ex);
|
||||
EVAERROR.EXIT("Error in RMI-Moduladapter initialization: " + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
return (ModuleAdapter) moduleAdapter;
|
||||
return moduleAdapter;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user