DefaultMutableTreeNode selNode = (DefaultMutableTreeNode)tree.getSelectionPath().getLastPathComponent(); ModifiableComponent society = (ModifiableComponent)nodeToComponent.get(selNode);
if (society instanceof ComplexRecipeComponent) { while (name.equals(society.getFullName().toString())) { if (log.isInfoEnabled()) log.info("Cant add agent to Complex recipe with same name as recipe: " + name); name = (String)JOptionPane.showInputDialog(this, "Enter Agent Name different from Recipe name", "Agent Name", JOptionPane.QUESTION_MESSAGE, null, null, name); if (name == null) return;  name = name.trim(); if (name.equals("")) return; } }
  private void addAgent() {    String name =       (String)JOptionPane.showInputDialog(this, "Enter Agent Name",                                           "Agent Name",                                          JOptionPane.QUESTION_MESSAGE,                                          null, null, "");    if (name == null) return;    name = name.trim();    if (name.equals(""))      return;    DefaultMutableTreeNode selNode =      (DefaultMutableTreeNode)tree.getSelectionPath().getLastPathComponent();    ModifiableComponent society =       (ModifiableComponent)nodeToComponent.get(selNode);    AgentComponent agentComponent =       (AgentComponent)new AgentUIComponent(name);    // put the node in the tree before adding properties to it    society.addChild(agentComponent);    PropertyTreeNode agentNode = createTreeNode(agentComponent, selNode);    agentComponent.initProperties();    tree.setSelectionPath(tree.getSelectionPath().pathByAddingChild(agentNode));    addContainerComponent(agentNode, agentComponent, "Other Components");    addContainerComponent(agentNode, agentComponent, "Binders");    addContainerComponent(agentNode, agentComponent, "Plugins");    AssetComponent asset = (AssetComponent)new AssetUIComponent();    agentComponent.addChild(asset);    PropertyTreeNode assetNode = createTreeNode(asset, agentNode);    asset.initProperties();    addContainerComponent(assetNode, asset, "Property Groups");    addContainerComponent(assetNode, asset, "Relationships");  }