$darkmode
DENOPTIM
GUIMainPanel.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.CardLayout;
22import java.awt.Component;
23
24import javax.swing.JPanel;
25
32public class GUIMainPanel extends JPanel
33{
37 private static final long serialVersionUID = 9090055883771428756L;
38
43
44//-----------------------------------------------------------------------------
45
47 {
48 super(new CardLayout());
49 this.toolBar = toolBar;
50 }
51
52//-----------------------------------------------------------------------------
53
60 @Override
61 public Component add(Component comp)
62 {
63 if (comp instanceof GUICardPanel)
64 {
65 String refName = comp.getName();
66 super.add(comp,refName);
67 ((CardLayout) this.getLayout()).last(this);
69 }
70 else
71 {
72 super.add(comp);
73 }
74 return comp;
75 }
76
77//-----------------------------------------------------------------------------
78
84 public void removeCard(Component comp)
85 {
86 if (comp instanceof GUICardPanel)
87 {
88 if (comp instanceof GUIVertexInspector)
89 {
90 ((GUIVertexInspector) comp).dispose();
91 }
92 if (comp instanceof GUIGraphHandler)
93 {
94 ((GUIGraphHandler) comp).dispose();
95 }
97 super.remove(comp);
98 }
99 else
100 {
101 super.remove(comp);
102 }
103 }
104
105//-----------------------------------------------------------------------------
106
112 public boolean hasUnsavedChanges()
113 {
114 boolean res = false;
115 for (Component c : this.getComponents())
116 {
117 if (c instanceof GUICardPanel)
118 {
120 {
121 res = true;
122 break;
123 }
124 }
125 }
126 return res;
127 }
128
129//-----------------------------------------------------------------------------
130}
Class of GUI panels meant to occupy one card in the deck-of-cards layout of the main panel.
A panel that understands DENOPTIM graphs and allows to create and edit them.
The main panel is a deck of cards that occupies all the GUI frame.
MainToolBar toolBar
Reference to the main tool bar of the GUI.
boolean hasUnsavedChanges()
Checks is any card has unsaved changes.
Component add(Component comp)
Add a component and a reference to such component in the main tool bar.
static final long serialVersionUID
Version.
GUIMainPanel(MainToolBar toolBar)
void removeCard(Component comp)
Remove a panel (i.e., a card) from the pile of cards (i.e., card deck)
A panel with a viewer capable of visualising DENOPTIM fragments and allows to create and edit fragmen...
Main tool bar of the DENOPTIM graphical user interface.
void removeActiveTab(GUICardPanel panel)
Remove the reference to an panel/tab in the menu listing active tabs.
void addActiveTab(GUICardPanel panel)
Add the reference to an active panel/tab in the menu listing active panel/tabs.