X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FManageNodesDialog.java;fp=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FManageNodesDialog.java;h=9d993a0180a2d76e8f9db43d3b3f24e68e3b4d1f;hb=d1bf7681d79cf88ee860b6f5fa1732714cbd5055;hp=c2d6adfe2bb912924565963600f7391f3bfdd3dd;hpb=708351fe5e8c91e5bc6e6a257997b660cba51415;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java b/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java index c2d6adf..9d993a0 100644 --- a/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java +++ b/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java @@ -32,7 +32,6 @@ import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JDialog; -import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -41,6 +40,7 @@ import javax.swing.border.EtchedBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import net.pterodactylus.jsite.core.Core; import net.pterodactylus.jsite.core.Node; import net.pterodactylus.jsite.i18n.I18n; import net.pterodactylus.jsite.main.Version; @@ -54,6 +54,9 @@ import net.pterodactylus.util.swing.SwingUtils; */ public class ManageNodesDialog extends JDialog implements ListSelectionListener { + /** The core. */ + private final Core core; + /** The original list of nodes. */ private List originalNodeList; @@ -84,11 +87,12 @@ public class ManageNodesDialog extends JDialog implements ListSelectionListener /** * Creates a new node manager dialog. * - * @param parentFrame - * The parent frame of the dialog + * @param swingInterface + * The Swing interface */ - public ManageNodesDialog(JFrame parentFrame) { - super(parentFrame, I18n.get("manageNodesDialog.title") + " – jSite " + Version.getVersion(), true); + public ManageNodesDialog(SwingInterface swingInterface) { + super(swingInterface.getMainWindow(), I18n.get("manageNodesDialog.title") + " – jSite " + Version.getVersion(), true); + this.core = swingInterface.getCore(); initActions(); initComponents(); initDialogs(); @@ -271,7 +275,16 @@ public class ManageNodesDialog extends JDialog implements ListSelectionListener private void deleteNodes() { Object[] selectedNodes = nodeList.getSelectedValues(); for (Object node: selectedNodes) { - nodeListModel.removeNode((Node) node); + Node selectedNode = (Node) node; + if (core.isNodeConnected(selectedNode)) { + int response = JOptionPane.showConfirmDialog(this, I18n.get("manageNodesDialog.error.nodeConnected.message", selectedNode.getName()), I18n.get("manageNodesDialog.error.nodeConnected.title"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); + if (response == JOptionPane.CANCEL_OPTION) { + break; + } else if (response == JOptionPane.NO_OPTION) { + continue; + } + } + nodeListModel.removeNode(selectedNode); } nodeList.clearSelection(); }