21import java.awt.BorderLayout;
22import java.awt.event.ActionEvent;
23import java.awt.event.ActionListener;
25import java.io.FileWriter;
26import java.io.IOException;
27import java.util.ArrayList;
29import javax.swing.JButton;
30import javax.swing.JOptionPane;
31import javax.swing.JTabbedPane;
32import javax.swing.UIManager;
33import denoptim.exception.DENOPTIMException;
34import denoptim.files.FileFormat;
35import denoptim.files.FileUtils;
36import denoptim.main.Main.RunType;
37import denoptim.programs.combinatorial.FragSpaceExplorer;
38import denoptim.programs.denovo.GARunner;
39import denoptim.programs.fitnessevaluator.FitnessRunner;
40import denoptim.task.ProgramTask;
41import denoptim.task.StaticTaskManager;
75 super.setLayout(
new BorderLayout());
76 this.allParams =
new ArrayList<IParametersForm>();
92 super.add(commandsPane, BorderLayout.SOUTH);
94 JButton btnLoadParams =
new JButton(
"Load Parameters");
100 btnLoadParams.setToolTipText(
"<html>Reads a DENOPTIM parameter file,"
101 +
"<br>and imports parameters into the form.</html>");
102 btnLoadParams.addActionListener(
new ActionListener() {
103 public void actionPerformed(ActionEvent e) {
105 if (inFile ==
null || inFile.getAbsolutePath().equals(
""))
114 p.setUnsavedChanges(
false);
118 commandsPane.
add(btnLoadParams);
120 JButton btnSaveParams =
new JButton(
"Save Parameters");
126 btnSaveParams.setToolTipText(
"<html>Write all parameters to file."
127 +
"<br>This will produce a DENOPTIM parameter file.</html>");
128 btnSaveParams.addActionListener(
new ActionListener() {
129 public void actionPerformed(ActionEvent e) {
136 commandsPane.
add(btnSaveParams);
152 JButton btnRun =
new JButton(
"Run now...");
157 btnRun.addActionListener(
new ActionListener() {
158 public void actionPerformed(ActionEvent e) {
159 String msg =
"<html><body width='%1s'><p>Running a DENOPTIM "
160 +
"experiment from the graphical user interface "
161 +
"(GUI) makes it dependent on "
162 +
"the GUI itself. Therefore, if the GUI is closed "
164 +
"the experiment will be terminated as well.</p>"
165 +
"<p>To avoid this, consider running your experiment "
166 +
"as a batch process disconnected from the GUI.</p>"
169 msg = msg +
"<p>Continue?</p></body></html>";
171 String[] options =
new String[]{
"Yes",
"Cancel"};
172 int res = JOptionPane.showOptionDialog(btnRun,
173 String.format(msg, 450),
175 JOptionPane.DEFAULT_OPTION,
176 JOptionPane.QUESTION_MESSAGE,
177 UIManager.getIcon(
"OptionPane.warningIcon"),
183 String location =
"unknownLocation";
194 +
"parameter file '" + paramFile +
"'");
196 location = wrkSpace.getAbsolutePath();
198 JOptionPane.showMessageDialog(btnRun,
199 "Could not start task. " + e1.getMessage()
200 +
". " + e1.getCause().getMessage(),
202 JOptionPane.ERROR_MESSAGE);
206 JOptionPane.showMessageDialog(btnRun,
207 "<html>Experiment submitted!<br>"
208 +
"See under " + location+
"<br>"
209 +
"or 'File -> Open Recent'</html>",
211 JOptionPane.INFORMATION_MESSAGE);
219 commandsPane.
add(btnRun);
222 JButton btnCanc =
new JButton(
"Close Tab");
228 btnCanc.setToolTipText(
"Closes this tab.");
230 commandsPane.
add(btnCanc);
232 JButton btnHelp =
new JButton(
"?");
233 btnHelp.setToolTipText(
"Help");
234 btnHelp.addActionListener(
new ActionListener() {
235 public void actionPerformed(ActionEvent e) {
236 String txt =
"<html><body width='%1s'>"
237 +
"<p>This tab allows to create, inspect, and edit "
238 +
"parameter used as input for DENOPTIM experiments. "
239 +
"These parameters are then collected into an input "
240 +
"file for DENOPTIM.</p>"
242 +
"<p>Hover over buttons and parameter fields to get "
243 +
"informations on a specific parameter.</p></html>";
244 JOptionPane.showMessageDialog(btnHelp,
245 String.format(txt, 350),
247 JOptionPane.PLAIN_MESSAGE);
250 commandsPane.
add(btnHelp);
267 throw new IllegalArgumentException(
"BUG: GUIPrepare"
269 +
"declare what kind of recent file to store. "
270 +
"Current declaration is not valid. Report this "
271 +
"to the development team.");
282 throw new IllegalArgumentException(
"BUG: GUIPrepare"
284 +
"declare what kind of recent file to store. "
285 +
"Current declaration is not valid. Report this "
286 +
"to the development team.");
297 throw new IllegalArgumentException(
"BUG: GUIPrepare"
299 +
"declare what kind of recent file to store. "
300 +
"Current declaration is not valid. Report this "
301 +
"to the development team.");
330 File paramFile =
new File (wrkSpace.getAbsolutePath()
331 + System.getProperty(
"file.separator") + baseName);
344 StringBuilder sb =
new StringBuilder();
349 p.putParametersToString(sb);
353 JOptionPane.showMessageDialog(
this,
356 JOptionPane.ERROR_MESSAGE,
357 UIManager.getIcon(
"OptionPane.errorIcon"));
371 FileWriter fw =
new FileWriter(outFile);
372 fw.write(sb.toString());
377 p.setUnsavedChanges(
false);
380 catch (IOException io)
382 JOptionPane.showMessageDialog(
this,
383 "Could not write to '" + outFile +
"'!.",
385 JOptionPane.PLAIN_MESSAGE,
386 UIManager.getIcon(
"OptionPane.errorIcon"));
407 task =
new GARunner(configFile, workDir);
436 p.importParametersFromDenoptimParamsFile(
437 file.getAbsolutePath());
441 if (e1.getMessage().equals(
"")
442 || e1.getMessage() ==
null)
444 e1.printStackTrace();
445 JOptionPane.showMessageDialog(
this,
446 "<html>Exception occurred while importing"
447 +
"parameters.<br>Please, report this to "
448 +
"the DENOPTIM team.</html>",
450 JOptionPane.ERROR_MESSAGE,
451 UIManager.getIcon(
"OptionPane.errorIcon"));
455 JOptionPane.showMessageDialog(
this,
458 JOptionPane.ERROR_MESSAGE,
459 UIManager.getIcon(
"OptionPane.errorIcon"));
478 if (p.hasUnsavedChanges())
static File getAvailableFileName(File parent, String baseName)
Define a filename that can be used, i.e., is still available, because no other file with the same pat...
static boolean createDirectory(String fileName)
Creates a directory.
static void addToRecentFiles(String fileName, FileFormat ff)
Appends an entry to the list of recent files.
Remove the card from the deck of cards and takes care of removing also the entry in the list of activ...
Class of GUI panels meant to occupy one card in the deck-of-cards layout of the main panel.
GUIMainPanel mainPanel
The main panel (cards deck)
File opener for DENOPTIM GUI.
static File pickFile(Component parent)
static File pickFileForSaving(Component parent)
The main panel is a deck of cards that occupies all the GUI frame.
The collection of tunable preferences.
static String tmpSpace
Readable/writable space for tmp files.
Master form containing all sub-forms that need to be filled to define the input parameters for FragSp...
Form that allows to test the configuration of a fitness provider.
Master form containing all sub-forms that need to be filled to define the input parameters for Denopt...
Class representing the general structure of a form including a specific set of parameter collections.
FileFormat getFileFormat(String string)
RunType getAchronimFromClass()
void importParametersFromDenoptimParamsFile(File file)
GUIPrepare(GUIMainPanel mainPanel, String newPanelName)
Constructor.
boolean hasUnsavedChanges()
Check whether any of the parameter forms (i.e., a tab) in this list of tabs has unsaved changes.
static final long serialVersionUID
Version UID.
void initialize()
Initialize the panel with tabbedPane and buttons.
File instantiateParametersFile(File wrkSpace)
ProgramTask buildProgramTask(File configFile, File workDir)
The type of main to run is determined by which subclass calls this method.
JTabbedPane tabbedPane
Parameters for the various components are divided in TABs.
ArrayList< IParametersForm > allParams
Storage of parameters.
boolean printAllParamsToFile(File outFile)
Combinatorial exploration of the fragment space.
Programs that runs de novo design by a genetic algorithm.
Stand-alone fitness provider.
Task structure for any of the main programs in the denoptim project, such as genetic algorithm and co...
Manager for tasks submitted by the GUI.
static void submit(Task task)
static String getQueueSnapshot()
Types of runs that can be requested to the DENOPTIM Main class.
GA
Run the genetic algorithm with DenoptimGA.
FIT
stand-alone fitness evaluation
FSE
Run a combinatorial generation of candidates with FragSpaceExplorer.