$darkmode
DENOPTIM
GUICardPanel.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2020 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.gui;
20
21import java.awt.event.ActionEvent;
22import java.awt.event.ActionListener;
23
24import javax.swing.JOptionPane;
25import javax.swing.JPanel;
26import javax.swing.UIManager;
27
33public class GUICardPanel extends JPanel
34{
38 private static final long serialVersionUID = -1640517890155875184L;
39
44
50 public GUICardPanel(GUIMainPanel mainPanel, String newPanelName) {
51 this.mainPanel = mainPanel;
52 this.setName(newPanelName);
53 }
54
55//-----------------------------------------------------------------------------
56
61 public boolean hasUnsavedChanges()
62 {
63 boolean res = false;
64 if (this instanceof GUIPrepare)
65 {
66 res = ((GUIPrepare) this).hasUnsavedChanges();
67 }
68 else if (this instanceof GUIVertexInspector)
69 {
70 res = ((GUIVertexInspector) this).hasUnsavedChanges();
71 }
72
73 return res;
74 }
75
76//-----------------------------------------------------------------------------
77
82 protected class removeCardActionListener implements ActionListener
83 {
85
87 {
88 this.parentPanel = panel;
89 }
90
91 @Override
92 public void actionPerformed(ActionEvent e)
93 {
95 {
96 Object[] options = {"Yes","No"};
97 int res = JOptionPane.showOptionDialog(parentPanel,
98 "<html>Found unsaved edits.<br>"
99 + "Abandon without saving?</html>",
100 "Abandon?",
101 JOptionPane.DEFAULT_OPTION,
102 JOptionPane.QUESTION_MESSAGE,
103 UIManager.getIcon("OptionPane.warningIcon"),
104 options,
105 options[1]);
106 if (res == 0)
107 {
109 }
110 }
111 else
112 {
114 }
115 }
116 }
117
118//-----------------------------------------------------------------------------
119
120}
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.
GUICardPanel(GUIMainPanel mainPanel, String newPanelName)
Constructor for JPanel meant to be a single "card" in the deck of cards.
static final long serialVersionUID
Version.
boolean hasUnsavedChanges()
Check for unsaved changes in the components included in this card.
GUIMainPanel mainPanel
The main panel (cards deck)
The main panel is a deck of cards that occupies all the GUI frame.
void removeCard(Component comp)
Remove a panel (i.e., a card) from the pile of cards (i.e., card deck)
Class representing the general structure of a form including a specific set of parameter collections.
Definition: GUIPrepare.java:59
A panel with a viewer capable of visualising DENOPTIM fragments and allows to create and edit fragmen...