Prevent deletion of the last node.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 9 Jun 2011 19:33:04 +0000 (21:33 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 3 Nov 2011 07:45:18 +0000 (08:45 +0100)
This fixes #183.

src/de/todesbaum/jsite/gui/NodeManagerPage.java

index 951a912..0f38a55 100644 (file)
@@ -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());