void (@Nullable final String selectedName) { assert mySchemesModel != null; EditScopesDialog scopesDialog = EditScopesDialog.showDialog(getScopeHolderProject(), selectedName); if (scopesDialog.isOK()) { NamedScope scope = scopesDialog.getSelectedScope(); if (scope != null) { String newName = scope.getScopeId(); FileSetDescriptor newDesciptor = null; if (selectedName == null) { newDesciptor = findDescriptor(newName); if (newDesciptor == null) { newDesciptor = new NamedScopeDescriptor(scope); myModel.addElement(newDesciptor); } } else { FileSetDescriptor oldDescriptor = findDescriptor(selectedName); if (!selectedName.equals(newName)) { int index = myModel.indexOf(oldDescriptor); myModel.removeElement(oldDescriptor); newDesciptor = findDescriptor(newName); if (newDesciptor == null) { newDesciptor = new NamedScopeDescriptor(scope); myModel.add(index, newDesciptor); } } else if (oldDescriptor != null) { PackageSet fileSet = scope.getValue(); oldDescriptor.setPattern(fileSet != null ? fileSet.getText() : null); } } if (newDesciptor != null) { setSelectedValue(newDesciptor, true); } } } }