21import java.awt.CardLayout;
23import java.awt.Cursor;
24import java.awt.Desktop;
25import java.awt.GridLayout;
26import java.awt.event.ActionEvent;
27import java.awt.event.ActionListener;
28import java.awt.event.MouseAdapter;
29import java.awt.event.MouseEvent;
31import java.io.IOException;
33import java.net.URISyntaxException;
34import java.util.HashMap;
36import java.util.Map.Entry;
38import javax.swing.Box;
39import javax.swing.JComboBox;
40import javax.swing.JLabel;
41import javax.swing.JMenu;
42import javax.swing.JMenuBar;
43import javax.swing.JMenuItem;
44import javax.swing.JOptionPane;
45import javax.swing.JPanel;
46import javax.swing.JProgressBar;
47import javax.swing.UIManager;
48import javax.swing.event.MenuEvent;
49import javax.swing.event.MenuListener;
51import denoptim.files.FileFormat;
52import denoptim.files.FileUtils;
53import denoptim.io.DenoptimIO;
54import denoptim.logging.Version;
55import denoptim.task.StaticTaskManager;
154 JMenuItem prefs =
new JMenuItem(
"Preferences");
155 prefs.addActionListener(
new ActionListener() {
156 public void actionPerformed(ActionEvent e) {
162 prefDialog.setVisible(
true);
167 JMenuItem about =
new JMenuItem(
"About");
168 about.addActionListener(
new ActionListener() {
169 public void actionPerformed(ActionEvent e) {
170 JOptionPane.showMessageDialog(about,
173 JOptionPane.PLAIN_MESSAGE);
176 private JPanel getAboutPanel() {
177 JPanel abtPanel =
new JPanel();
178 abtPanel.setLayout(
new GridLayout(4, 1, 3, 0));
180 JPanel row0 =
new JPanel();
185 JPanel row1 =
new JPanel();
186 JLabel t1 =
new JLabel(
"DENOPTIM is open source software "
187 +
" (Affero GPL-3.0).");
191 JPanel row2 =
new JPanel();
192 JLabel t2 =
new JLabel(
"Get involved at ");
193 JLabel h2 =
new JLabel(
"http://github.com/denoptim-project");
194 h2.setForeground(Color.BLUE.darker());
195 h2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
196 h2.addMouseListener(
new MouseAdapter() {
198 public void mouseClicked(MouseEvent e) {
200 Desktop.getDesktop().browse(
new URI(
201 "http://github.com/denoptim-project"));
202 }
catch (IOException | URISyntaxException e1) {
203 e1.printStackTrace();
211 JPanel row3 =
new JPanel();
212 JLabel t3 =
new JLabel(
"Cite ");
213 JLabel h3 =
new JLabel(
"http://doi.org/10.1021/"
214 +
"acs.jcim.9b00516");
215 h3.setForeground(Color.BLUE.darker());
216 h3.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
217 h3.addMouseListener(
new MouseAdapter() {
219 public void mouseClicked(MouseEvent e) {
221 String url =
"https://doi.org/10.1021/"
222 +
" acs.jcim.9b00516";
223 Desktop.getDesktop().browse(
new URI(url));
224 }
catch (IOException | URISyntaxException e1) {
225 e1.printStackTrace();
240 JMenuItem exit =
new JMenuItem(
"Exit");
241 exit.addActionListener(
new ActionListener() {
242 public void actionPerformed(ActionEvent e) {
251 JMenu newMenu =
new JMenu(
"New");
254 JMenuItem newGA =
new JMenuItem(
"New Evolutionary De Novo Design");
255 newGA.addActionListener(
new ActionListener() {
256 public void actionPerformed(ActionEvent e) {
261 JMenuItem newVS =
new JMenuItem(
"New Virtual Screening");
262 newVS.addActionListener(
new ActionListener() {
263 public void actionPerformed(ActionEvent e) {
268 JMenuItem newFr =
new JMenuItem(
"New Molecular Fragments");
269 newFr.addActionListener(
new ActionListener() {
270 public void actionPerformed(ActionEvent e) {
275 JMenuItem newCPM =
new JMenuItem(
"New Compatibility Matrix");
276 newCPM.addActionListener(
new ActionListener() {
277 public void actionPerformed(ActionEvent e) {
282 JMenuItem newGr =
new JMenuItem(
"New Graphs");
283 newGr.addActionListener(
new ActionListener() {
284 public void actionPerformed(ActionEvent e) {
290 JMenuItem open =
new JMenuItem(
"Open...");
291 open.addActionListener(
new ActionListener() {
292 public void actionPerformed(ActionEvent e) {
297 }
catch (Exception e1) {
298 e1.printStackTrace();
303 String[] options = {
"Abandon",
307 "Compatibility Matrix",
317 JComboBox<String> cmbFiletype =
318 new JComboBox<String>(options);
319 cmbFiletype.setSelectedIndex(0);
320 JLabel msgText =
new JLabel(String.format(
321 "<html><body width='%1s'>"
322 +
"Failed to detect file type automatically."
323 +
"<br>Please, specify how to interpret file "
324 +
"'" + file.getAbsolutePath() +
"'.",270));
325 int res = JOptionPane.showConfirmDialog(open,
326 new Object[] {msgText,cmbFiletype},
328 JOptionPane.OK_CANCEL_OPTION,
329 JOptionPane.ERROR_MESSAGE);
330 if (res != JOptionPane.OK_OPTION)
336 if (cmbFiletype.getSelectedIndex() == 0)
340 openFile(file,ffOpts[cmbFiletype.getSelectedIndex()]);
349 menuFile.addMenuListener(
new MenuListener() {
351 public void menuSelected(MenuEvent e)
356 public void menuDeselected(MenuEvent e) {}
358 public void menuCanceled(MenuEvent e) {}
365 JMenu menuHelp =
new JMenu(
"Help");
368 JMenuItem usrManual =
new JMenuItem(
"DENOPTIM user manual");
369 usrManual.addActionListener(
new ActionListener() {
370 public void actionPerformed(ActionEvent e) {
372 String url =
"http://htmlpreview.github.io/?https://"
373 +
"github.com/denoptim-project/DENOPTIM/blob/"
374 +
"master/doc/user_manual.html";
375 Desktop.getDesktop().browse(
new URI(url));
376 }
catch (IOException | URISyntaxException e1) {
377 JOptionPane.showMessageDialog(usrManual,
378 "Could not launch the browser to open online "
379 +
"version of the manual.",
381 JOptionPane.ERROR_MESSAGE,
382 UIManager.getIcon(
"OptionPane.errorIcon"));
386 menuHelp.add(usrManual);
389 this.add(Box.createGlue());
408 if (recentFiles.size() == 0)
414 for (Entry<File, FileFormat> e : recentFiles.entrySet())
417 item.addActionListener(
new ActionListener() {
418 public void actionPerformed(ActionEvent e) {
428 @SuppressWarnings(
"serial")
434 super(file.getAbsolutePath());
531 JOptionPane.showMessageDialog(
this,
532 "File format '" + fileFormat +
"' not recognized.",
534 JOptionPane.ERROR_MESSAGE,
535 UIManager.getIcon(
"OptionPane.errorIcon"));
539 JOptionPane.showMessageDialog(
this,String.format(
540 "<html><body width='%1s'>"
541 +
"There is no specific visual representation of file"
542 +
" format '" + fileFormat +
"'. If you think there "
543 +
"should be a way to visually inspect this file, "
544 +
"please, write to the development team.",300),
546 JOptionPane.ERROR_MESSAGE,
547 UIManager.getIcon(
"OptionPane.errorIcon"));
575 JMenuItem refToPanel =
new JMenuItem(panel.getName());
576 refToPanel.addActionListener((ActionEvent evt) -> {
577 ((CardLayout)
mainPanel.getLayout()).show(
static FileFormat detectFileFormat(File inFile)
Inspects a file/folder and tries to detect if there is one of the data sources that is recognized by ...
Class of GUI panels meant to occupy one card in the deck-of-cards layout of the main panel.
A panel for handling of compatibility matrix.
void importCPMapFromFile(JComponent parent, File inFile)
File opener for DENOPTIM GUI.
static File pickFileOrFolder(Component parent)
A panel that understands DENOPTIM graphs and allows to create and edit them.
void importGraphsFromFile(File file)
Imports graphs from file.
Graphical User Interface of the DENOPTIM package.
void closeIfAllSaved()
Close GUI is there are no unsaved changes to the open components.
A panel that allows to inspect the output of an combinatorial experiment exploring a fragment space.
void importFSERunData(File folder)
A panel that allows to inspect the output of an artificial evolution experiment.
void importGARunData(File file, JComponent parent)
The main panel is a deck of cards that occupies all the GUI frame.
Component add(Component comp)
Add a component and a reference to such component in the main tool bar.
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...
void importParametersFromDenoptimParamsFile(File file)
A panel that allows to print the content of a text file into a GUI tab.
void displayContent(File file)
Print the content of the given file in this tab's pane.
A panel with a viewer capable of visualising DENOPTIM fragments and allows to create and edit fragmen...
void importVerticesFromFile(File file)
Imports fragments from a file.
RecentFileItem(File file, FileFormat ff)
Main tool bar of the DENOPTIM graphical user interface.
void initialize()
Initialize the contents of the tool bar.
void openFile(File file, FileFormat fileFormat)
Process a file that has a recognized file format and loads a suitable GUI card to visualize the file ...
static final long serialVersionUID
Version.
JProgressBar queueStatusBar
Progress bar indicating the queue of task to complete.
GUI gui
Reference to the GUI window.
JMenu getMainMenu()
Returns the main menu of the tool bar.
MainToolBar()
Constructor that build the tool bar.
JMenu activeTabsMenu
The menu listing the active panels in the deck of cards.
void setRefToMasterGUI(GUI gui)
Sets the reference to master GUI.
void removeActiveTab(GUICardPanel panel)
Remove the reference to an panel/tab in the menu listing active tabs.
Map< GUICardPanel, JMenuItem > activeTabsAndRefs
List of the active panels in the deck of cards.
void updateOpenRecentMenu()
Updated the the list of recent files in the "open Recent" menu.
JMenu menuDenoptim
Main DENOPTIM menu.
void setRefToMainPanel(GUIMainPanel mainPanel)
Sets the reference to main panel for creating functionality of menu items depending on main panel ide...
JMenu openRecent
Menu with list of recent files.
GUIMainPanel mainPanel
Reference to the main panel (cards deck)
void addActiveTab(GUICardPanel panel)
Add the reference to an active panel/tab in the menu listing active panel/tabs.
JMenu menuFile
Main File menu.
Utility methods for input/output.
static Map< File, FileFormat > readRecentFilesMap()
Reads the file defined in DENOPTIMConstants#RECENTFILESLIST and makes a map that contains the pathnam...
Class handling DENOPTIM's version identifier for headers.
static final String VERSION
Version identifier (from pom.xml via Maven properties)
Manager for tasks submitted by the GUI.
static void setLinkToProgressBar(JProgressBar bar)
Adds a reference to the given progress bar.