Inspections UI: removing nonexistence scope throws exception fixed

This commit is contained in:
Dmitry Batkovich
2014-09-10 16:14:13 +04:00
parent 2df232b0be
commit 6602c533b5
3 changed files with 20 additions and 16 deletions
@@ -885,13 +885,13 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
getTools(toolId, project).removeScope(scopeIdx);
}
public void removeScope(@NotNull String toolId, @NotNull NamedScope scope, Project project) {
getTools(toolId, project).removeScope(scope);
public void removeScope(@NotNull String toolId, @NotNull String scopeName, Project project) {
getTools(toolId, project).removeScope(scopeName);
}
public void removeScopes(@NotNull List<String> toolIds, @NotNull NamedScope scope, Project project) {
public void removeScopes(@NotNull List<String> toolIds, @NotNull String scopeName, Project project) {
for (final String toolId : toolIds) {
removeScope(toolId, scope, project);
removeScope(toolId, scopeName, project);
}
}
@@ -267,25 +267,26 @@ public class ToolsImpl implements Tools {
public void removeScope(int scopeIdx) {
if (myTools != null && scopeIdx >= 0 && myTools.size() > scopeIdx) {
myTools.remove(scopeIdx);
if (myTools.isEmpty()) {
myTools = null;
setEnabled(myDefaultState.isEnabled());
}
checkToolsIsEmpty();
}
}
public void removeScope(final NamedScope scope) {
public void removeScope(final @NotNull String scopeName) {
if (myTools != null) {
for (final ScopeToolState tool : myTools) {
if (Comparing.equal(tool.getScopeName(), scope.getName())) {
for (ScopeToolState tool : myTools) {
if (scopeName.equals(tool.getScopeName())) {
myTools.remove(tool);
break;
}
}
if (myTools.isEmpty()) {
myTools = null;
setEnabled(myDefaultState.isEnabled());
}
checkToolsIsEmpty();
}
}
private void checkToolsIsEmpty() {
if (myTools.isEmpty()) {
myTools = null;
setEnabled(myDefaultState.isEnabled());
}
}
@@ -357,6 +357,9 @@ public class ScopesAndSeveritiesTable extends JBTable {
}
else if (columnIndex == SCOPE_ENABLED_COLUMN) {
final NamedScope scope = getScope(rowIndex);
if (scope == null) {
return;
}
if ((Boolean)value) {
if (rowIndex == lastRowIndex()) {
myInspectionProfile.enableToolsByDefault(myKeyNames, myProject);
@@ -381,7 +384,7 @@ public class ScopesAndSeveritiesTable extends JBTable {
@Override
public void removeRow(final int idx) {
if (idx != lastRowIndex()) {
myInspectionProfile.removeScopes(myKeyNames, getScope(idx), myProject);
myInspectionProfile.removeScopes(myKeyNames, getScopeName(idx), myProject);
refreshAggregatedScopes();
myTableSettings.onScopeRemoved(getRowCount());
}