Added schedule button

This commit is contained in:
Marcel Kronfeld 2011-05-05 13:16:37 +00:00
parent 1b4f07edb3
commit 69272b4918
3 changed files with 59 additions and 50 deletions

View File

@ -20,17 +20,11 @@ import java.net.InetAddress;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import eva2.server.go.InterfaceGOParameters;
import eva2.server.go.individuals.AbstractEAIndividual;
import eva2.server.go.populations.Population;
import eva2.server.go.problems.InterfaceOptimizationProblem;
import eva2.server.go.strategies.InterfaceOptimizer;
import eva2.server.modules.AbstractModuleAdapter;
import eva2.server.modules.ModuleAdapter;
import eva2.server.stat.EvAJob;
import eva2.tools.jproxy.RMIProxyLocal;
import eva2.tools.jproxy.RemoteStateListener;
@ -44,10 +38,11 @@ public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializa
private boolean m_StateRunning;
private JButton m_RunButton;
private JButton m_PPButton;
private JButton m_actStop;
private JButton m_StopButton;
private JButton m_ScheduleButton;
// private JButton m_actExitMod;
private JButton m_JHelpButton;
private JButton m_ShowSolButton;
// private JButton m_ShowSolButton;
private JPanel m_Panel;
private String m_HelperFileName;
@ -97,9 +92,9 @@ public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializa
// m_Panel.setBorder(BorderFactory.createTitledBorder("general action buttons"));
//////////////////////////////////////////////////////////////
m_actStop= new JButton("Stop");
m_actStop.setToolTipText("Stop the current optimization run.");
m_actStop.addActionListener(new ActionListener() {
m_StopButton= new JButton("Stop");
m_StopButton.setToolTipText("Stop the current optimization run.");
m_StopButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
try {
m_Adapter.stopOpt(); // this means user break
@ -111,8 +106,8 @@ public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializa
// m_RestartButton.setEnabled(false);
// else
// m_RestartButton.setEnabled(true);
m_actStop.setEnabled(m_StateRunning);
m_Panel.add(m_actStop);
m_StopButton.setEnabled(m_StateRunning);
m_Panel.add(m_StopButton);
// //////////////////////////////////////////////////////////////
m_PPButton= new JButton("Post Process");
m_PPButton.setToolTipText("Start post processing according to available parameters.");
@ -131,36 +126,50 @@ public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializa
);
m_PPButton.setEnabled(m_StateRunning && m_Adapter.hasPostProcessing());
m_Panel.add(m_PPButton);
// //////////////////////////////////////////////////////////////
m_ScheduleButton= new JButton("Schedule");
m_ScheduleButton.setToolTipText("Schedule the currently configured optimization as a job.");
m_ScheduleButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
EvAJob job = m_Adapter.scheduleJob();
if (job==null) {
System.err.println("Something went wrong on scheduling!");
}
}
}
);
m_ScheduleButton.setEnabled(true);
m_Panel.add(m_ScheduleButton);
makeHelpButton();
if (m_Adapter instanceof AbstractModuleAdapter && (m_Adapter != null)) {
/** This action listener, called by the "show" button will show the
* currently best solution in a frame.
*/
m_ShowSolButton = new JButton("Show Solution");
m_ShowSolButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
InterfaceGOParameters goParams = ((AbstractModuleAdapter)m_Adapter).getGOParameters();
InterfaceOptimizationProblem goProblem = goParams.getProblem();
InterfaceOptimizer opt = goParams.getOptimizer();
AbstractEAIndividual indy = opt.getPopulation().getBestEAIndividual();
if (indy != null) {
JFrame frame = new JFrame();
frame.setTitle("The current best solution for "+goProblem.getName());
frame.setSize(400, 300);
frame.setLocation(450, 250);
Population pop = opt.getPopulation();
frame.getContentPane().add(goProblem.drawIndividual(pop.getGeneration(), pop.getFunctionCalls(), indy));
frame.validate();
frame.setVisible(true);
} else System.out.println("No current solution available.");
}
}
);
m_ShowSolButton.setEnabled(false);
m_Panel.add(m_ShowSolButton);
}
// if (m_Adapter instanceof AbstractModuleAdapter && (m_Adapter != null)) {
// /** This action listener, called by the "show" button will show the
// * currently best solution in a frame.
// */
// m_ShowSolButton = new JButton("Show Solution");
// m_ShowSolButton.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent event) {
// InterfaceGOParameters goParams = ((AbstractModuleAdapter)m_Adapter).getGOParameters();
// InterfaceOptimizationProblem goProblem = goParams.getProblem();
// InterfaceOptimizer opt = goParams.getOptimizer();
// AbstractEAIndividual indy = opt.getPopulation().getBestEAIndividual();
// if (indy != null) {
// JFrame frame = new JFrame();
// frame.setTitle("The current best solution for "+goProblem.getName());
// frame.setSize(400, 300);
// frame.setLocation(450, 250);
// Population pop = opt.getPopulation();
// frame.getContentPane().add(goProblem.drawIndividual(pop.getGeneration(), pop.getFunctionCalls(), indy));
// frame.validate();
// frame.setVisible(true);
// } else System.out.println("No current solution available.");
// }
// }
// );
// m_ShowSolButton.setEnabled(false);
// m_Panel.add(m_ShowSolButton);
// }
// m_actExitMod = new JButton("Exit Module");
// m_actExitMod.setToolTipText("todo !!.");// TODO
@ -170,7 +179,7 @@ public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializa
public void onUserStart() {
try {
m_Adapter.startOpt();
m_actStop.setEnabled(true);
m_StopButton.setEnabled(true);
m_RunButton.setEnabled(false);
m_PPButton.setEnabled(false);
// m_RestartButton.setEnabled(false);
@ -214,12 +223,12 @@ public class EvAModuleButtonPanelMaker implements RemoteStateListener, Serializa
m_RunButton.setEnabled(true);
m_PPButton.setEnabled(true);
m_RunButton.repaint();
m_actStop.setEnabled(false);
m_StopButton.setEnabled(false);
m_Panel.repaint();
}
public void performedStart(String infoString) {
m_ShowSolButton.setEnabled(true);
// m_ShowSolButton.setEnabled(true);
}

View File

@ -16,13 +16,8 @@ import java.io.Serializable;
import java.net.InetAddress;
import java.util.Vector;
import eva2.gui.EvATabbedFrameMaker;
import eva2.gui.LogPanel;
import eva2.server.go.InterfaceGOParameters;
import eva2.server.go.InterfaceProcessor;
/*==========================================================================*
* ABSTRACT CLASS DECLARATION
*==========================================================================*/
import eva2.tools.jproxy.MainAdapterClient;
import eva2.tools.jproxy.RemoteStateListener;
@ -43,7 +38,6 @@ abstract public class AbstractModuleAdapter implements ModuleAdapter, Serializab
protected boolean m_RMI = true;
protected MainAdapterClient m_MainAdapterClient; // connection to client
private Vector<RemoteStateListener> m_RemoteStateListeners;
protected LogPanel logPanel = null;
protected AbstractModuleAdapter(MainAdapterClient Client) {
if (TRACE) System.out.println("AbstractModuleAdapter.AbstractModuleAdapter()");

View File

@ -13,6 +13,7 @@ package eva2.server.modules;
* IMPORTS
*==========================================================================*/
import eva2.gui.EvATabbedFrameMaker;
import eva2.server.stat.EvAJob;
import eva2.tools.jproxy.RemoteStateListener;
/*==========================================================================*
* INTERFACE DECLARATION
@ -23,6 +24,11 @@ import eva2.tools.jproxy.RemoteStateListener;
public interface ModuleAdapter extends RemoteStateListener {
public EvATabbedFrameMaker getModuleFrame();
public void startOpt(); // called from client
/**
* Schedule a certain job to a job list.
*/
public EvAJob scheduleJob();
public void restartOpt();
public void stopOpt();
public void runScript();