From 86fee12cd8136a0c768189795f8a7d4916aad26b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 24 May 2008 22:36:29 +0200 Subject: [PATCH] react to node name changes --- src/net/pterodactylus/jsite/gui/MainWindow.java | 7 +++++++ src/net/pterodactylus/jsite/gui/NodeLabel.java | 7 +++++-- src/net/pterodactylus/jsite/gui/SwingInterface.java | 7 +------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/net/pterodactylus/jsite/gui/MainWindow.java b/src/net/pterodactylus/jsite/gui/MainWindow.java index 28554c8..61a61c6 100644 --- a/src/net/pterodactylus/jsite/gui/MainWindow.java +++ b/src/net/pterodactylus/jsite/gui/MainWindow.java @@ -235,6 +235,7 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop NodeLabel nodeLabel = new NodeLabel(swingInterface, node, onlineIcon, offlineIcon, errorIcon); nodeLabels.put(node, nodeLabel); statusBar.addSideComponent(nodeLabel); + node.addPropertyChangeListener(this); } /** @@ -246,6 +247,7 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop void removeNode(Node node) { nodeMenu.remove(nodeMenus.remove(node)); statusBar.removeSideComponent(nodeLabels.remove(node)); + node.removePropertyChangeListener(this); } /** @@ -543,6 +545,11 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop } } } + } else if (eventSource instanceof Node) { + if (propertyName.equals(Node.PROPERTY_NAME)) { + Node changedNode = (Node) eventSource; + nodeMenus.get(changedNode).setText(changedNode.getName()); + } } } diff --git a/src/net/pterodactylus/jsite/gui/NodeLabel.java b/src/net/pterodactylus/jsite/gui/NodeLabel.java index ca3bbfd..46e8be1 100644 --- a/src/net/pterodactylus/jsite/gui/NodeLabel.java +++ b/src/net/pterodactylus/jsite/gui/NodeLabel.java @@ -34,6 +34,7 @@ import javax.swing.SwingConstants; import javax.swing.border.EtchedBorder; import net.pterodactylus.jsite.core.Node; +import net.pterodactylus.jsite.i18n.I18n; import net.pterodactylus.jsite.i18n.I18nable; import net.pterodactylus.jsite.i18n.gui.I18nLabel; @@ -89,6 +90,7 @@ public class NodeLabel extends JLabel implements PropertyChangeListener, MouseLi this.offlineIcon = offlineIcon; this.errorIcon = errorIcon; initComponents(); + node.addPropertyChangeListener(this); } // @@ -161,9 +163,10 @@ public class NodeLabel extends JLabel implements PropertyChangeListener, MouseLi if (propertyChangeEvent.getSource() != node) { return; } - if (propertyChangeEvent.getPropagationId().equals(Node.PROPERTY_NAME)) { + if (propertyChangeEvent.getPropertyName().equals(Node.PROPERTY_NAME)) { setText(node.getName()); - menuLabel.updateI18n(); + /* TODO - find way to get around this hack */ + menuLabel.setText(I18n.get("mainWindow.statusBar.nodeLabel.name", node.getName())); } } diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index e316ab1..d77920b 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -40,7 +40,6 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; -import javax.swing.Action; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -943,11 +942,7 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh * {@inheritDoc} */ public void propertyChange(PropertyChangeEvent propertyChangeEvent) { - if (propertyChangeEvent.getSource() instanceof Node) { - Node changedNode = (Node) propertyChangeEvent.getSource(); - nodeConnectActions.get(changedNode).putValue(Action.NAME, changedNode.getName()); - nodeDisconnectActions.get(changedNode).putValue(Action.NAME, changedNode.getName()); - } + /* do not react to anything (yet). */ } } -- 2.7.4