private void fillList() { DefaultListModel model = new DefaultListModel(); model.removeAllElements(); final List<String> scopes = new ArrayList<String>(); for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) { for (final NamedScope scope : holder.getScopes()) { if (!(scope instanceof NonProjectFilesScope)) { scopes.add(scope.getName()); } } } scopes.remove(CustomScopesProviderEx.getAllScope().getName()); Collections.sort(scopes, new ScopeOrderComparator(myInspectionProfile)); for (String scopeName : scopes) { model.addElement(scopeName); } myOptionsList.setModel(model); myOptionsList.setSelectedIndex(0); }
public DefaultScopesProvider(@NotNull Project project) { myProject = project; final NamedScope projectScope = new ProjectFilesScope(); final NamedScope nonProjectScope = new NonProjectFilesScope(); final String text = FilePatternPackageSet.SCOPE_FILE + ":*//*"; myProblemsScope = new NamedScope(IdeBundle.message("predefined.scope.problems.name"), new AbstractPackageSet(text) { @Override public boolean contains(VirtualFile file, @NotNull NamedScopesHolder holder) { return contains(file, holder.getProject(), holder); } @Override public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) { return project == myProject && WolfTheProblemSolver.getInstance(myProject).isProblemFile(file); } }); myScopes = Arrays.asList(projectScope, getProblemsScope(), getAllScope(), nonProjectScope); }
private void addDisabledFileColors(Project project) { final FileColorManager manager = FileColorManager.getInstance(project); manager.addScopeColor(NonProjectFilesScope.NAME, MTOceanicTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTDarkerTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTLighterTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTPalenightTheme.DISABLED, false); Notify.show(project, "", MaterialThemeBundle.message("mt.fileColorsInstalled"), NotificationType.INFORMATION, new NotificationListener.Adapter() { @Override protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { ApplicationManager.getApplication().invokeLater(() -> ShowSettingsUtil.getInstance().showSettingsDialog( project, "File Colors"), ModalityState.NON_MODAL); } }); }
private void rebuildModel(Project project, String scopeName) { final ArrayList<ScopeWrapper> scopes = new ArrayList<ScopeWrapper>(); final DependencyValidationManager manager = DependencyValidationManager.getInstance(project); scopes.add(new ScopeWrapper("Predefined Scopes")); List<NamedScope> predefinedScopesList = manager.getPredefinedScopes(); NamedScope[] predefinedScopes = predefinedScopesList.toArray(new NamedScope[predefinedScopesList.size()]); predefinedScopes = NonProjectFilesScope.removeFromList(predefinedScopes); for (NamedScope predefinedScope : predefinedScopes) { scopes.add(new ScopeWrapper(predefinedScope)); } collectEditableScopes(scopes, manager, "Custom Project Scopes"); collectEditableScopes(scopes, NamedScopeManager.getInstance(project), "Custom Local Scopes"); myScopes.setModel(new DefaultComboBoxModel(scopes.toArray(new ScopeWrapper[scopes.size()]))); setSelection(scopeName, scopes); }
Color getFrameBgColor(XStackFrame stackFrame) { VirtualFile virtualFile = getFile(stackFrame); if (virtualFile != null) { // handle null value if (myFileColors.containsKey(virtualFile)) { return myFileColors.get(virtualFile); } else if (virtualFile.isValid()) { Color color = myColorsManager.getFileColor(virtualFile); myFileColors.put(virtualFile, color); return color; } } else { return myColorsManager.getScopeColor(NonProjectFilesScope.NAME); } return null; }
@NotNull @Override public DefaultActionGroup createPopupActionGroup(final JComponent component) { final DefaultActionGroup group = new DefaultActionGroup(); final List<NamedScope> predefinedScopes = new ArrayList<NamedScope>(); final List<NamedScope> customScopes = new ArrayList<NamedScope>(); for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) { Collections.addAll(customScopes, holder.getEditableScopes()); predefinedScopes.addAll(holder.getPredefinedScopes()); } predefinedScopes.remove(CustomScopesProviderEx.getAllScope()); for (NamedScope predefinedScope : predefinedScopes) { if (predefinedScope instanceof NonProjectFilesScope) { predefinedScopes.remove(predefinedScope); break; } } fillActionGroup(group, predefinedScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames); group.addSeparator(); fillActionGroup(group, customScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames); group.addSeparator(); group.add(new DumbAwareAction("Edit Scopes Order...") { @Override public void actionPerformed(final AnActionEvent e) { final ScopesOrderDialog dlg = new ScopesOrderDialog(component, myInspectionProfile, myProject); if (dlg.showAndGet()) { onScopesOrderChanged(); } } }); return group; }
@NotNull private static Collection<NamedScope> getShownScopes(DependencyValidationManager dependencyValidationManager, NamedScopeManager namedScopeManager) { List<NamedScope> list = ContainerUtil.newArrayList(); for (NamedScope scope : ContainerUtil.concat(dependencyValidationManager.getScopes(), namedScopeManager.getScopes())) { if (scope instanceof NonProjectFilesScope) continue; if (scope == CustomScopesProviderEx.getAllScope()) continue; list.add(scope); } return list; }
@Nullable @Override public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile file) { if (JSGraphQLSchemaLanguageProjectService.isProjectSchemaFile(file)) { FileColorManager colorManager = FileColorManager.getInstance(project); if (colorManager.isEnabledForTabs()) { return colorManager.getScopeColor(NonProjectFilesScope.NAME); } } return null; }
/** * At start, check if Material Theme File Colors are added, otherwise add them * Note: If the scope has changed somehow (by changing the name or the color), it will add a duplicate. */ private void addDisabledFileColors() { final FileColorManager manager = FileColorManager.getInstance(myProject); manager.addScopeColor(NonProjectFilesScope.NAME, MTOceanicTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTDarkerTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTLighterTheme.DISABLED, false); manager.addScopeColor(NonProjectFilesScope.NAME, MTPalenightTheme.DISABLED, false); }
private NamedScope[] getShownScopes() { NamedScope[] scopes = myDependencyValidationManager.getScopes(); scopes = ArrayUtil.mergeArrays(scopes, myNamedScopeManager.getScopes()); scopes = NonProjectFilesScope.removeFromList(scopes); scopes = ArrayUtil.remove(scopes, CustomScopesProviderEx.getAllScope()); return scopes; }
@Nonnull @Override public DefaultActionGroup createPopupActionGroup(final JComponent component) { final DefaultActionGroup group = new DefaultActionGroup(); final List<NamedScope> predefinedScopes = new ArrayList<NamedScope>(); final List<NamedScope> customScopes = new ArrayList<NamedScope>(); for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) { Collections.addAll(customScopes, holder.getEditableScopes()); predefinedScopes.addAll(holder.getPredefinedScopes()); } predefinedScopes.remove(CustomScopesProviderEx.getAllScope()); for (NamedScope predefinedScope : predefinedScopes) { if (predefinedScope instanceof NonProjectFilesScope) { predefinedScopes.remove(predefinedScope); break; } } fillActionGroup(group, predefinedScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames); group.addSeparator(); fillActionGroup(group, customScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames); group.addSeparator(); group.add(new DumbAwareAction("Edit Scopes Order...") { @Override public void actionPerformed(final AnActionEvent e) { final ScopesOrderDialog dlg = new ScopesOrderDialog(component, myInspectionProfile, myProject); if (dlg.showAndGet()) { onScopesOrderChanged(); } } }); return group; }
public DefaultScopesProvider(Project project) { myProject = project; final NamedScope projectScope = new ProjectFilesScope(); final NamedScope nonProjectScope = new NonProjectFilesScope(); final String text = FilePatternPackageSet.SCOPE_FILE + ":*//*"; myProblemsScope = new NamedScope(IdeBundle.message("predefined.scope.problems.name"), new AbstractPackageSet(text) { @Override public boolean contains(VirtualFile file, NamedScopesHolder holder) { return holder.getProject() == myProject && WolfTheProblemSolver.getInstance(myProject).isProblemFile(file); } }); myScopes = Arrays.asList(projectScope, getProblemsScope(), getAllScope(), nonProjectScope); }
@Override @Nonnull public String[] getSubIds() { NamedScope[] scopes = myDependencyValidationManager.getScopes(); scopes = ArrayUtil.mergeArrays(scopes, myNamedScopeManager.getScopes()); scopes = NonProjectFilesScope.removeFromList(scopes); String[] ids = new String[scopes.length]; for (int i = 0; i < scopes.length; i++) { final NamedScope scope = scopes[i]; ids[i] = scope.getName(); } return ids; }