void (Project project) { final Object selection = patternTree.getLastSelectedPathComponent(); if (!(selection instanceof DefaultMutableTreeNode node)) { return; } if (!(node.getUserObject() instanceof Configuration configuration)) { return; } if (configuration.isPredefined()) { return; } if (((DefaultMutableTreeNode)selection).isNodeAncestor(myRecentNode)) { return; } final String configurationName = configuration.getName(); outer: for (Configuration otherConfiguration : ConfigurationManager.getInstance(project).getAllConfigurations()) { MatchOptions matchOptions = otherConfiguration.getMatchOptions(); for (String name : matchOptions.getVariableConstraintNames()) { MatchVariableConstraint constraint = matchOptions.getVariableConstraint(name); if (constraint == null) { continue; } if (configurationName.equals(constraint.getWithinConstraint()) || configurationName.equals(constraint.getContainsConstraint()) || configurationName.equals(constraint.getReferenceConstraint())) { if (Messages.CANCEL == Messages.showOkCancelDialog( project, SSRBundle.message("template.in.use.message", configurationName, otherConfiguration.getName()), SSRBundle.message("template.in.use.title", configurationName), CommonBundle.message("button.remove"), Messages.getCancelButton(), AllIcons.General.WarningDialog )) { return; } break outer; } } } DefaultMutableTreeNode sibling = node.getNextSibling(); if (sibling == null) { sibling = node.getPreviousSibling(); } if (sibling == null) { sibling = myUserTemplatesNode; } TreeUtil.selectNode(patternTree, sibling); TreeNode parent = node.getParent(); patternTreeModel.removeNodeFromParent(node); if (parent == myProjectTemplatesNode && parent.getChildCount() == 0) { // hide project-templates node when there are no project templates anymore patternTreeModel.removeNodeFromParent((MutableTreeNode)parent); } ConfigurationManager.getInstance(project).removeConfiguration(configuration, parent == myUserTemplatesNode); }