From bb1eccdace92539e122c9e4b3b8bd1486615d688 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 9 Jun 2011 21:33:04 +0200 Subject: [PATCH] Prevent deletion of the last node. This fixes #183. --- src/de/todesbaum/jsite/gui/NodeManagerPage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/de/todesbaum/jsite/gui/NodeManagerPage.java b/src/de/todesbaum/jsite/gui/NodeManagerPage.java index 951a912..0f38a55 100644 --- a/src/de/todesbaum/jsite/gui/NodeManagerPage.java +++ b/src/de/todesbaum/jsite/gui/NodeManagerPage.java @@ -331,6 +331,7 @@ public class NodeManagerPage extends TWizardPage implements ListSelectionListene private void addNode() { Node node = new Node("localhost", 9481, I18n.getMessage("jsite.node-manager.new-node")); nodeListModel.addElement(node); + deleteNodeAction.setEnabled(nodeListModel.size() > 1); wizard.setNextEnabled(true); fireNodesUpdated(getNodes()); } @@ -349,6 +350,7 @@ public class NodeManagerPage extends TWizardPage implements ListSelectionListene nodeListModel.removeElement(node); nodeList.repaint(); fireNodesUpdated(getNodes()); + deleteNodeAction.setEnabled(nodeListModel.size() > 1); wizard.setNextEnabled(nodeListModel.size() > 0); } @@ -370,7 +372,7 @@ public class NodeManagerPage extends TWizardPage implements ListSelectionListene nodeNameTextField.setEnabled(enabled); nodeHostnameTextField.setEnabled(enabled); nodePortSpinner.setEnabled(enabled); - deleteNodeAction.setEnabled(enabled); + deleteNodeAction.setEnabled(enabled && (nodeListModel.size() > 1)); if (enabled) { nodeNameTextField.setText(node.getName()); nodeHostnameTextField.setText(node.getHostname()); -- 2.7.4