private void checkForEmptyAndDuplicatedNames( MyNode rootNode, String prefix, String title, Class<? extends NamedConfigurable> configurableClass, boolean recursively) throws ConfigurationException { final Set<String> names = new HashSet<String>(); for (int i = 0; i < rootNode.getChildCount(); i++) { final MyNode node = (MyNode) rootNode.getChildAt(i); final NamedConfigurable scopeConfigurable = node.getConfigurable(); if (configurableClass.isInstance(scopeConfigurable)) { final String name = scopeConfigurable.getDisplayName(); if (name.trim().length() == 0) { selectNodeInTree(node); throw new ConfigurationException("Name should contain non-space characters"); } if (names.contains(name)) { final NamedConfigurable selectedConfigurable = getSelectedConfigurable(); if (selectedConfigurable == null || !Comparing.strEqual(selectedConfigurable.getDisplayName(), name)) { selectNodeInTree(node); } throw new ConfigurationException( CommonBundle.message("smth.already.exist.error.message", prefix, name), title); } names.add(name); } if (recursively) { checkForEmptyAndDuplicatedNames(node, prefix, title, configurableClass, true); } } }
protected final void checkForEmptyAndDuplicatedNames( String prefix, String title, Class<? extends NamedConfigurable> configurableClass) throws ConfigurationException { checkForEmptyAndDuplicatedNames(myRoot, prefix, title, configurableClass, true); }
/** @deprecated use {@link #checkForEmptyAndDuplicatedNames(String, String, Class} instead */ protected void checkApply(Set<MyNode> rootNodes, String prefix, String title) throws ConfigurationException { for (MyNode rootNode : rootNodes) { checkForEmptyAndDuplicatedNames(rootNode, prefix, title, NamedConfigurable.class, false); } }