RefactoringElementListener (final PsiElement element) { if (element instanceof PsiClass) { final String qualifiedName = ((PsiClass)element).getQualifiedName(); return new RefactoringElementListener() { @Override public void elementMoved(@NotNull PsiElement newElement) { renameElement(qualifiedName, newElement); } @Override public void elementRenamed(@NotNull PsiElement newElement) { renameElement(qualifiedName, newElement); } private void renameElement(String oldClassName, PsiElement newElement) { if (newElement instanceof PsiClass) { final String newClassName = ((PsiClass)newElement).getQualifiedName(); final DRootElement rootElement = DynamicManager.getInstance(myProject).getRootElement(); final DClassElement oldClassElement = rootElement.getClassElement(oldClassName); final TreeNode oldClassNode = TreeUtil.findNodeWithObject((DefaultMutableTreeNode)myTreeRoot, oldClassElement); DynamicManager.getInstance(myProject).replaceClassName(oldClassElement, newClassName); myTreeTableModel.nodeChanged(oldClassNode); } } }; } return null; }