react to node name changes
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 24 May 2008 20:36:29 +0000 (22:36 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 24 May 2008 20:36:29 +0000 (22:36 +0200)
src/net/pterodactylus/jsite/gui/MainWindow.java
src/net/pterodactylus/jsite/gui/NodeLabel.java
src/net/pterodactylus/jsite/gui/SwingInterface.java

index 28554c8..61a61c6 100644 (file)
@@ -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());
+                       }
                }
        }
 
index ca3bbfd..46e8be1 100644 (file)
@@ -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()));
                }
        }
 
index e316ab1..d77920b 100644 (file)
@@ -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). */
        }
 
 }