From 7403a08d06153ecc3869efc0204064c37e67dc37 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 25 May 2008 14:26:51 +0200 Subject: [PATCH] update node labels when connecting or disconnecting --- src/net/pterodactylus/jsite/gui/MainWindow.java | 30 ++++++++++++++++++++++ .../pterodactylus/jsite/gui/SwingInterface.java | 3 +++ 2 files changed, 33 insertions(+) diff --git a/src/net/pterodactylus/jsite/gui/MainWindow.java b/src/net/pterodactylus/jsite/gui/MainWindow.java index d09c352..654f548 100644 --- a/src/net/pterodactylus/jsite/gui/MainWindow.java +++ b/src/net/pterodactylus/jsite/gui/MainWindow.java @@ -215,6 +215,36 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop return null; } + /** + * Sets the given node to the “online” state. + * + * @param node + * The node to set online + */ + public void setOnline(Node node) { + nodeLabels.get(node).setOnline(); + } + + /** + * Sets the given node to the “offline” state in the status bar. + * + * @param node + * The node to set offline + */ + public void setOffline(Node node) { + nodeLabels.get(node).setOffline(); + } + + /** + * Sets the given node to the “error” state in the status bar. + * + * @param node + * The node to set the error state for + */ + public void setError(Node node) { + nodeLabels.get(node).setError(); + } + // // ACTIONS // diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index 084215c..2f13df6 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -953,6 +953,7 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh public void nodeConnected(Node node) { nodeDisconnectActions.get(node).setEnabled(true); mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.connectedToNode", node.getName(), node.getHostname(), node.getPort())); + mainWindow.setOnline(node); } /** @@ -963,6 +964,7 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh nodeEditActions.get(node).setEnabled(true); nodeDeleteActions.get(node).setEnabled(true); mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.connectionToNodeFailed", node.getName(), node.getHostname(), node.getPort(), (cause != null) ? cause.getMessage() : "no reason given")); + mainWindow.setError(node); JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.error.nodeConnectionFailed.message", node.getName(), node.getHostname(), node.getPort(), (cause != null) ? cause.getMessage() : "no reason given"), I18n.get("mainWindow.error.nodeConnectionFailed.title"), JOptionPane.ERROR_MESSAGE); } @@ -975,6 +977,7 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh nodeEditActions.get(node).setEnabled(true); nodeDeleteActions.get(node).setEnabled(true); mainWindow.setStatusBarText(I18n.get("mainWindow.statusBar.disconnectedFromNode", node.getName(), node.getHostname(), node.getPort())); + mainWindow.setOffline(node); } /** -- 2.7.4