/** * The documenttreenode's name is changed. Updates the element and panels. * * @param event the NameChangedEvent * @throws IllegalArgumentException if event is null */ public void treeNodeNameChanged(NameChangedEvent event) { DeployHelper.checkNotNull(event, "event"); DocumentTreeNode treeNode = event.getTreeNode(); DocumentTreeNodeType nodeType = treeNode.getType(); Object object = treeNode.getNodeObject(); List<JComponent> jComponents = new ArrayList<JComponent>(); ModelElement modelElement = null; if (nodeType == DocumentTreeNodeType.MODEL_ELEMENT) { // when the changed node is a model element. modelElement = (ModelElement) object; if (modelElement instanceof AssociationEnd) { jComponents = DeployHelper.getComponent(((AssociationEnd) modelElement).getAssociation(), mainFrame); } else { jComponents = DeployHelper.getComponent(modelElement, mainFrame); } } else if (nodeType == DocumentTreeNodeType.GRAPH_ELEMENT) { if (object instanceof Diagram) { // when the changed node is a diagram. ((Diagram) object).setName(event.getNewName()); /* * BugFix: BUGR-65 Sorting diagrams */ mainFrame.getDocumentTree().updateTree(); mainFrame.getDiagramViewer().openDiagramView((Diagram) object); mainFrame .getDocumentTree() .getCurrentPanel() .getCurrentView() .setSelectedTreeNodes(new DocumentTreeNode[] {treeNode}); } else { // When the changed node is a graph element. modelElement = DeployHelper.getElement((GraphElement) object); jComponents.add(DeployHelper.getComponent((GraphElement) object, mainFrame)); } } else { mainFrame.getDocumentTree().getCurrentPanel().getCurrentView().updateTreeNode(treeNode); } if (modelElement != null) { if (modelElement instanceof ClassImpl) { DeployHelper.changeConstructors( mainFrame, (ClassImpl) modelElement, event.getNewName(), jComponents); } else { ChangeEntityNameAction changeEntityNameAction = new ChangeEntityNameAction( modelElement, event.getNewName(), mainFrame.isAutoGenerateMethods()); mainFrame.handleActionEvent(changeEntityNameAction, jComponents, "change name"); } } }
/** * Sets up environment. * * @throws Exception to Junit */ public void setUp() throws Exception { super.setUp(); diagram = new Diagram(); diagram.setName("Class Diagram"); action = new RemoveClassDiagramAction(diagram); }