mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-83483: filter out predefined scopes in settings
This commit is contained in:
+23
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package com.intellij.psi.search.scope.packageSet;
|
||||
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -37,4 +40,24 @@ public abstract class CustomScopesProviderEx implements CustomScopesProvider {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isVetoed(NamedScope scope, ScopePlace place) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void filterNoSettingsScopes(Project project, List<NamedScope> scopes) {
|
||||
for (Iterator<NamedScope> iterator = scopes.iterator(); iterator.hasNext(); ) {
|
||||
final NamedScope scope = iterator.next();
|
||||
for (CustomScopesProvider provider : Extensions.getExtensions(CUSTOM_SCOPES_PROVIDER, project)) {
|
||||
if (provider instanceof CustomScopesProviderEx && ((CustomScopesProviderEx)provider).isVetoed(scope, ScopePlace.SETTING)) {
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static enum ScopePlace {
|
||||
SETTING, ACTION
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,15 @@ public class ChangeListsScopesProvider extends CustomScopesProviderEx {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVetoed(NamedScope scope, ScopePlace place) {
|
||||
if (place == ScopePlace.SETTING) {
|
||||
final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
|
||||
return changeListManager.findChangeList(scope.getName()) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static NamedScope createScope(final List<VirtualFile> files, String changeListName) {
|
||||
return new NamedScope(changeListName, new PackageSetBase() {
|
||||
@Override
|
||||
|
||||
+4
@@ -31,6 +31,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.packageDependencies.DefaultScopesProvider;
|
||||
import com.intellij.profile.codeInspection.ui.InspectionConfigTreeNode;
|
||||
import com.intellij.psi.search.scope.packageSet.CustomScopesProviderEx;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
@@ -113,6 +114,9 @@ public abstract class AddScopeAction extends AnAction {
|
||||
Collections.addAll(scopes, holder.getScopes());
|
||||
}
|
||||
scopes.remove(DefaultScopesProvider.getAllScope());
|
||||
|
||||
CustomScopesProviderEx.filterNoSettingsScopes(project, scopes);
|
||||
|
||||
final Set<NamedScope> used = new HashSet<NamedScope>();
|
||||
for (Descriptor descriptor : descriptors) {
|
||||
final List<ScopeToolState> nonDefaultTools = getSelectedProfile().getNonDefaultTools(descriptor.getKey().toString());
|
||||
|
||||
@@ -18,7 +18,9 @@ package com.intellij.ui.tabs;
|
||||
|
||||
import com.intellij.notification.impl.ui.StickyButton;
|
||||
import com.intellij.notification.impl.ui.StickyButtonUI;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.psi.search.scope.packageSet.CustomScopesProviderEx;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopeManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
@@ -34,8 +36,8 @@ import javax.swing.plaf.ButtonUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
@@ -68,12 +70,16 @@ public class FileColorConfigurationEditDialog extends DialogWrapper {
|
||||
final JPanel result = new JPanel();
|
||||
result.setLayout(new BoxLayout(result, BoxLayout.Y_AXIS));
|
||||
|
||||
final NamedScopesHolder[] scopeHolders = NamedScopeManager.getAllNamedScopeHolders(myManager.getProject());
|
||||
final List<NamedScope> scopeList = new ArrayList<NamedScope>();
|
||||
final Project project = myManager.getProject();
|
||||
final NamedScopesHolder[] scopeHolders = NamedScopeManager.getAllNamedScopeHolders(project);
|
||||
for (final NamedScopesHolder scopeHolder : scopeHolders) {
|
||||
final NamedScope[] scopes = scopeHolder.getScopes();
|
||||
for (final NamedScope scope : scopes) {
|
||||
myScopeNames.put(scope.getName(), scope);
|
||||
}
|
||||
Collections.addAll(scopeList, scopes);
|
||||
}
|
||||
CustomScopesProviderEx.filterNoSettingsScopes(project, scopeList);
|
||||
for (final NamedScope scope : scopeList) {
|
||||
myScopeNames.put(scope.getName(), scope);
|
||||
}
|
||||
|
||||
myScopeComboBox = new JComboBox(ArrayUtil.toStringArray(myScopeNames.keySet()));
|
||||
|
||||
Reference in New Issue
Block a user