// File: ActionRenSGraph // Classes: ActionRenSGraph // Author: Kedar Patankar package edu.neu.ccs.demeter.tools.apstudio.graphedit; import java.util.Enumeration; import java.util.Vector; import javax.swing.tree.DefaultMutableTreeNode; public class ActionRenSGraph extends Action { public ActionRenSGraph(Editor e) { super(e); } public String name() { return new String(" Rename strategy name" ); } public void doIt() { DefaultMutableTreeNode node = _editor.getSelectedTreeNode(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); Vector graphNames = ((BehaviorNode)parent.getUserObject()).getGraphNames(); String oldname=node.getUserObject().toString(); SGRenameDialog sgrd = new SGRenameDialog(_editor,"Rename Strategy Graph name",oldname,graphNames); sgrd.setVisible(true); String newname = sgrd.getNewName(); if(!oldname.equals(newname)) { ((Behdata)node.getUserObject()).setName(newname); ((BehaviorNode)parent.getUserObject()).changeGraphName(oldname,newname); ((BehaviorNode)parent.getUserObject()).needsSaving(true); _editor.nodeNameChanged(node); } } public void undoIt() { } }