+ * Adds a node to the menu.
+ *
+ * @param node
+ * The node to add
+ */
+ void addNode(Node node) {
+ JMenu newNodeMenu = new JMenu(node.getName());
+ nodeMenus.put(node, newNodeMenu);
+ newNodeMenu.add(swingInterface.getNodeConnectAction(node));
+ newNodeMenu.add(swingInterface.getNodeDisconnectAction(node));
+ newNodeMenu.addSeparator();
+ newNodeMenu.add(swingInterface.getNodeEditAction(node));
+ newNodeMenu.add(swingInterface.getNodeDeleteAction(node));
+ nodeMenu.add(newNodeMenu);
+ NodeLabel nodeLabel = new NodeLabel(swingInterface, node, onlineIcon, offlineIcon, errorIcon);
+ nodeLabels.put(node, nodeLabel);
+ statusBar.addSideComponent(nodeLabel);
+ for (int tabIndex = 0, tabCount = projectPane.getTabCount(); tabIndex < tabCount; tabIndex++) {
+ Component tabComponent = projectPane.getComponentAt(tabIndex);
+ if (!(tabComponent instanceof ProjectPanel)) {
+ continue;
+ }
+ ((ProjectPanel) tabComponent).addNode(node);
+ }
+ node.addPropertyChangeListener(this);
+ }
+
+ /**
+ * Removes a node from the menu.
+ *
+ * @param node
+ * The node to remove
+ */
+ void removeNode(Node node) {
+ nodeMenu.remove(nodeMenus.remove(node));
+ statusBar.removeSideComponent(nodeLabels.remove(node));
+ for (int tabIndex = 0, tabCount = projectPane.getTabCount(); tabIndex < tabCount; tabIndex++) {
+ Component tabComponent = projectPane.getComponentAt(tabIndex);
+ if (!(tabComponent instanceof ProjectPanel)) {
+ continue;
+ }
+ ((ProjectPanel) tabComponent).addNode(node);
+ }
+ node.removePropertyChangeListener(this);
+ }
+
+ /**
+ * Adds a project to the project pane.
+ *
+ * @param project
+ * The project to add
+ * @param switchToProject
+ * <code>true</code> to switch to the new panel,
+ * <code>false</code> to not change the current panel