X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FManageNodesDialog.java;h=447618ce3cac053c86fc9bb62bf78cd236cc9777;hb=e5c7a1609ef6d0878f98c3e8c2819bc1430f96f7;hp=c2d6adfe2bb912924565963600f7391f3bfdd3dd;hpb=c303c800fd219b20b2fb60e01f3e99ae983da37b;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java b/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java index c2d6adf..447618c 100644 --- a/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java +++ b/src/net/pterodactylus/jsite/gui/ManageNodesDialog.java @@ -28,11 +28,9 @@ import java.util.Iterator; import java.util.List; import javax.swing.AbstractListModel; -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,8 +39,10 @@ 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.i18n.I18nable; import net.pterodactylus.jsite.main.Version; import net.pterodactylus.util.swing.SwingUtils; @@ -52,25 +52,28 @@ import net.pterodactylus.util.swing.SwingUtils; * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ */ -public class ManageNodesDialog extends JDialog implements ListSelectionListener { +public class ManageNodesDialog extends JDialog implements ListSelectionListener, I18nable { + + /** The core. */ + private final Core core; /** The original list of nodes. */ private List originalNodeList; /** The “add node” action. */ - private Action addNodeAction; + private I18nAction addNodeAction; /** The “edit node” action. */ - private Action editNodeAction; + private I18nAction editNodeAction; /** The “delete node” action. */ - private Action deleteNodeAction; + private I18nAction deleteNodeAction; /** The “okay” action. */ - private Action okayAction; + private I18nAction okayAction; /** The “cancel” action. */ - private Action cancelAction; + private I18nAction cancelAction; /** The “edit node” dialog. */ private EditNodeDialog editNodeDialog; @@ -84,15 +87,17 @@ 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(); pack(); + I18n.registerI18nable(this); SwingUtils.center(this); } @@ -271,7 +276,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(); } @@ -325,6 +339,23 @@ public class ManageNodesDialog extends JDialog implements ListSelectionListener deleteNodeAction.setEnabled(selectCount >= 1); } + // + // INTERFACE I18nable + // + + /** + * {@inheritDoc} + */ + public void updateI18n() { + okayAction.updateI18n(); + cancelAction.updateI18n(); + addNodeAction.updateI18n(); + editNodeAction.updateI18n(); + deleteNodeAction.updateI18n(); + setTitle(I18n.get("manageNodesDialog.title") + " – jSite " + Version.getVersion()); + SwingUtils.repackCentered(this); + } + /** * List model for the {@link ManageNodesDialog#nodeList}. TODO *