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.BoxLayout;
30import javax.swing.JButton;
31import javax.swing.JLabel;
32import javax.swing.JOptionPane;
33import javax.swing.JPanel;
34import javax.swing.JTabbedPane;
35import javax.swing.JTextField;
36import javax.swing.SwingConstants;
37import javax.swing.UIManager;
39import denoptim.constants.DENOPTIMConstants;
40import denoptim.exception.DENOPTIMException;
41import denoptim.files.FileFormat;
42import denoptim.files.FileUtils;
43import denoptim.main.Main.RunType;
44import denoptim.programs.combinatorial.FragSpaceExplorer;
45import denoptim.programs.denovo.GARunner;
46import denoptim.programs.fitnessevaluator.FitnessRunner;
47import denoptim.task.ProgramTask;
48import denoptim.task.StaticTaskManager;
82 super.setLayout(
new BorderLayout());
83 this.allParams =
new ArrayList<IParametersForm>();
99 super.add(commandsPane, BorderLayout.SOUTH);
101 JButton btnLoadParams =
new JButton(
"Load Parameters");
107 btnLoadParams.setToolTipText(
"<html>Reads a DENOPTIM parameter file,"
108 +
"<br>and imports parameters into the form.</html>");
109 btnLoadParams.addActionListener(
new ActionListener() {
110 public void actionPerformed(ActionEvent e) {
112 if (inFile ==
null || inFile.getAbsolutePath().equals(
""))
121 p.setUnsavedChanges(
false);
125 commandsPane.
add(btnLoadParams);
127 JButton btnSaveParams =
new JButton(
"Save Parameters");
133 btnSaveParams.setToolTipText(
"<html>Write all parameters to file."
134 +
"<br>This will produce a DENOPTIM parameter file.</html>");
135 btnSaveParams.addActionListener(
new ActionListener() {
136 public void actionPerformed(ActionEvent e) {
143 commandsPane.
add(btnSaveParams);
159 JButton btnRun =
new JButton(
"Run now...");
164 btnRun.addActionListener(
new ActionListener() {
165 public void actionPerformed(ActionEvent e) {
166 String msg =
"<html><body width='%1s'><p>Running a DENOPTIM "
167 +
"experiment from the graphical user interface "
168 +
"(GUI) makes it dependent on "
169 +
"the GUI itself. Therefore, if the GUI is closed "
171 +
"the experiment will be terminated as well.</p>"
172 +
"<p>To avoid this, consider running your experiment "
173 +
"as a batch process disconnected from the GUI.</p>"
176 msg = msg +
"<p>Continue?</p></body></html>";
178 String[] options =
new String[]{
"Yes",
"Cancel"};
179 int res = JOptionPane.showOptionDialog(btnRun,
180 String.format(msg, 450),
182 JOptionPane.DEFAULT_OPTION,
183 JOptionPane.QUESTION_MESSAGE,
184 UIManager.getIcon(
"OptionPane.warningIcon"),
190 String location =
"unknownLocation";
201 +
"parameter file '" + paramFile +
"'");
203 location = wrkSpace.getAbsolutePath();
205 JOptionPane.showMessageDialog(btnRun,
206 "Could not start task. " + e1.getMessage()
207 +
". " + e1.getCause().getMessage(),
209 JOptionPane.ERROR_MESSAGE);
213 JOptionPane.showMessageDialog(btnRun,
214 "<html>Experiment submitted!<br>"
215 +
"See under " + location+
"<br>"
216 +
"or 'File -> Open Recent'</html>",
218 JOptionPane.INFORMATION_MESSAGE);
226 commandsPane.
add(btnRun);
229 JButton btnCanc =
new JButton(
"Close Tab");
235 btnCanc.setToolTipText(
"Closes this tab.");
237 commandsPane.
add(btnCanc);
239 JButton btnHelp =
new JButton(
"?");
240 btnHelp.setToolTipText(
"Help");
241 btnHelp.addActionListener(
new ActionListener() {
242 public void actionPerformed(ActionEvent e) {
243 String txt =
"<html><body width='%1s'>"
244 +
"<p>This tab allows to create, inspect, and edit "
245 +
"parameter used as input for DENOPTIM experiments. "
246 +
"These parameters are then collected into an input "
247 +
"file for DENOPTIM.</p>"
249 +
"<p>Hover over buttons and parameter fields to get "
250 +
"informations on a specific parameter.</p></html>";
251 JOptionPane.showMessageDialog(btnHelp,
252 String.format(txt, 350),
254 JOptionPane.PLAIN_MESSAGE);
257 commandsPane.
add(btnHelp);
274 throw new IllegalArgumentException(
"BUG: GUIPrepare"
276 +
"declare what kind of recent file to store. "
277 +
"Current declaration is not valid. Report this "
278 +
"to the development team.");
289 throw new IllegalArgumentException(
"BUG: GUIPrepare"
291 +
"declare what kind of recent file to store. "
292 +
"Current declaration is not valid. Report this "
293 +
"to the development team.");
304 throw new IllegalArgumentException(
"BUG: GUIPrepare"
306 +
"declare what kind of recent file to store. "
307 +
"Current declaration is not valid. Report this "
308 +
"to the development team.");
337 File paramFile =
new File (wrkSpace.getAbsolutePath()
338 + System.getProperty(
"file.separator") + baseName);
351 StringBuilder sb =
new StringBuilder();
356 p.putParametersToString(sb);
360 JOptionPane.showMessageDialog(
this,
363 JOptionPane.ERROR_MESSAGE,
364 UIManager.getIcon(
"OptionPane.errorIcon"));
378 FileWriter fw =
new FileWriter(outFile);
379 fw.write(sb.toString());
384 p.setUnsavedChanges(
false);
387 catch (IOException io)
389 JOptionPane.showMessageDialog(
this,
390 "Could not write to '" + outFile +
"'!.",
392 JOptionPane.PLAIN_MESSAGE,
393 UIManager.getIcon(
"OptionPane.errorIcon"));
414 task =
new GARunner(configFile, workDir);
443 p.importParametersFromDenoptimParamsFile(
444 file.getAbsolutePath());
448 if (e1.getMessage().equals(
"")
449 || e1.getMessage() ==
null)
451 e1.printStackTrace();
452 JOptionPane.showMessageDialog(
this,
453 "<html>Exception occurred while importing"
454 +
"parameters.<br>Please, report this to "
455 +
"the DENOPTIM team.</html>",
457 JOptionPane.ERROR_MESSAGE,
458 UIManager.getIcon(
"OptionPane.errorIcon"));
462 JOptionPane.showMessageDialog(
this,
465 JOptionPane.ERROR_MESSAGE,
466 UIManager.getIcon(
"OptionPane.errorIcon"));
485 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.