$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
19
package
denoptim.gui;
20
21
import
java.awt.event.ActionEvent;
22
import
java.awt.event.ActionListener;
23
24
import
javax.swing.JOptionPane;
25
import
javax.swing.JPanel;
26
import
javax.swing.UIManager;
27
33
public
class
GUICardPanel
extends
JPanel
34
{
38
private
static
final
long
serialVersionUID
= -1640517890155875184L;
39
43
protected
GUIMainPanel
mainPanel
;
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
{
84
private
GUICardPanel
parentPanel
;
85
86
public
removeCardActionListener
(
GUICardPanel
panel)
87
{
88
this.parentPanel = panel;
89
}
90
91
@Override
92
public
void
actionPerformed
(ActionEvent e)
93
{
94
if
(
hasUnsavedChanges
())
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
{
108
mainPanel
.
removeCard
(
parentPanel
);
109
}
110
}
111
else
112
{
113
mainPanel
.
removeCard
(
parentPanel
);
114
}
115
}
116
}
117
118
//-----------------------------------------------------------------------------
119
120
}
denoptim.gui.GUICardPanel.removeCardActionListener
Remove the card from the deck of cards and takes care of removing also the entry in the list of activ...
Definition:
GUICardPanel.java:83
denoptim.gui.GUICardPanel.removeCardActionListener.removeCardActionListener
removeCardActionListener(GUICardPanel panel)
Definition:
GUICardPanel.java:86
denoptim.gui.GUICardPanel.removeCardActionListener.parentPanel
GUICardPanel parentPanel
Definition:
GUICardPanel.java:84
denoptim.gui.GUICardPanel.removeCardActionListener.actionPerformed
void actionPerformed(ActionEvent e)
Definition:
GUICardPanel.java:92
denoptim.gui.GUICardPanel
Class of GUI panels meant to occupy one card in the deck-of-cards layout of the main panel.
Definition:
GUICardPanel.java:34
denoptim.gui.GUICardPanel.GUICardPanel
GUICardPanel(GUIMainPanel mainPanel, String newPanelName)
Constructor for JPanel meant to be a single "card" in the deck of cards.
Definition:
GUICardPanel.java:50
denoptim.gui.GUICardPanel.serialVersionUID
static final long serialVersionUID
Version.
Definition:
GUICardPanel.java:38
denoptim.gui.GUICardPanel.hasUnsavedChanges
boolean hasUnsavedChanges()
Check for unsaved changes in the components included in this card.
Definition:
GUICardPanel.java:61
denoptim.gui.GUICardPanel.mainPanel
GUIMainPanel mainPanel
The main panel (cards deck)
Definition:
GUICardPanel.java:43
denoptim.gui.GUIMainPanel
The main panel is a deck of cards that occupies all the GUI frame.
Definition:
GUIMainPanel.java:33
denoptim.gui.GUIMainPanel.removeCard
void removeCard(Component comp)
Remove a panel (i.e., a card) from the pile of cards (i.e., card deck)
Definition:
GUIMainPanel.java:84
denoptim.gui.GUIPrepare
Class representing the general structure of a form including a specific set of parameter collections.
Definition:
GUIPrepare.java:59
denoptim.gui.GUIVertexInspector
A panel with a viewer capable of visualising DENOPTIM fragments and allows to create and edit fragmen...
Definition:
GUIVertexInspector.java:93
src
main
java
denoptim
gui
GUICardPanel.java
Generated by
1.9.4