Java 类com.intellij.psi.search.scope.packageSet.NamedScopeManager 实例源码

项目:hybris-integration-intellij-idea-plugin    文件:DefaultSearchScopeConfigurator.java   
private static void addOrReplaceScopes(@NotNull Project project, @NotNull List<NamedScope> newScopes) {
    final Set<String> newScopeNames = newScopes
        .stream()
        .map(NamedScope::getName)
        .collect(Collectors.toSet());

    final NamedScopeManager namedScopeManager = NamedScopeManager.getInstance(project);
    final NamedScope[] existingScopes = namedScopeManager.getEditableScopes();

    final NamedScope[] filteredScopes = Arrays
        .stream(existingScopes)
        .filter(it -> !newScopeNames.contains(it.getName()))
        .toArray(NamedScope[]::new);

    namedScopeManager.setScopes(ArrayUtil.mergeArrays(
        filteredScopes,
        newScopes.toArray(new NamedScope[newScopes.size()])
    ));
}
项目:intellij-ce-playground    文件:AdvHighlightingTest.java   
public void testScopeBased() throws Exception {
  NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
  NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
  NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject());
  scopeManager.addScope(xScope);
  scopeManager.addScope(utilScope);

  EditorColorsManager manager = EditorColorsManager.getInstance();
  EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
  manager.addColorsScheme(scheme);
  EditorColorsManager.getInstance().setGlobalScheme(scheme);
  TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName());
  TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC);
  scheme.setAttributes(xKey, xAttributes);

  TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName());
  TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
  scheme.setAttributes(utilKey, utilAttributes);

  try {
    testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
  }
  finally {
    scopeManager.removeAllSets();
  }
}
项目:tools-idea    文件:AdvHighlightingTest.java   
public void testScopeBased() throws Exception {
  NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
  NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
  NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject());
  scopeManager.addScope(xScope);
  scopeManager.addScope(utilScope);

  EditorColorsManager manager = EditorColorsManager.getInstance();
  EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
  manager.addColorsScheme(scheme);
  EditorColorsManager.getInstance().setGlobalScheme(scheme);
  TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xScope.getName());
  TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC);
  scheme.setAttributes(xKey, xAttributes);

  TextAttributesKey utilKey = ColorAndFontOptions.getScopeTextAttributeKey(utilScope.getName());
  TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
  scheme.setAttributes(utilKey, utilAttributes);

  try {
    testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
  }
  finally {
    scopeManager.removeAllSets();
  }
}
项目:tools-idea    文件:ScopeBasedTodosPanel.java   
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);
}
项目:consulo-java    文件:AdvHighlightingTest.java   
public void testScopeBased() throws Exception {
  NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
  NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
  NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject());
  scopeManager.addScope(xScope);
  scopeManager.addScope(utilScope);

  EditorColorsManager manager = EditorColorsManager.getInstance();
  EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
  manager.addColorsScheme(scheme);
  EditorColorsManager.getInstance().setGlobalScheme(scheme);
  TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName());
  TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC);
  scheme.setAttributes(xKey, xAttributes);

  TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName());
  TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
  scheme.setAttributes(utilKey, utilAttributes);

  try {
    testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
  }
  finally {
    scopeManager.removeAllSets();
  }
}
项目:intellij-ce-playground    文件:InspectionProjectProfileManagerImpl.java   
public InspectionProjectProfileManagerImpl(@NotNull Project project,
                                           @NotNull InspectionProfileManager inspectionProfileManager,
                                           @NotNull DependencyValidationManager holder,
                                           @NotNull NamedScopeManager localScopesHolder) {
  super(project, inspectionProfileManager, holder);
  myLocalScopesHolder = localScopesHolder;
  mySeverityRegistrar = new SeverityRegistrar(project.getMessageBus());
}
项目:intellij-ce-playground    文件:DaemonCodeAnalyzerImpl.java   
public DaemonCodeAnalyzerImpl(@NotNull Project project,
                              @NotNull DaemonCodeAnalyzerSettings daemonCodeAnalyzerSettings,
                              @NotNull EditorTracker editorTracker,
                              @NotNull PsiDocumentManager psiDocumentManager,
                              @SuppressWarnings("UnusedParameters") @NotNull final NamedScopeManager namedScopeManager,
                              @SuppressWarnings("UnusedParameters") @NotNull final DependencyValidationManager dependencyValidationManager) {
  myProject = project;
  mySettings = daemonCodeAnalyzerSettings;
  myEditorTracker = editorTracker;
  myPsiDocumentManager = psiDocumentManager;
  myLastSettings = ((DaemonCodeAnalyzerSettingsImpl)daemonCodeAnalyzerSettings).clone();

  myFileStatusMap = new FileStatusMap(project);
  myPassExecutorService = new PassExecutorService(project);
  Disposer.register(this, myPassExecutorService);
  Disposer.register(this, myFileStatusMap);
  DaemonProgressIndicator.setDebug(LOG.isDebugEnabled());

  assert !myInitialized : "Double Initializing";
  Disposer.register(this, new StatusBarUpdater(project));

  myInitialized = true;
  myDisposed = false;
  myFileStatusMap.markAllFilesDirty("DCAI init");
  Disposer.register(this, new Disposable() {
    @Override
    public void dispose() {
      assert myInitialized : "Disposing not initialized component";
      assert !myDisposed : "Double dispose";

      stopProcess(false, "Dispose");

      myDisposed = true;
      myLastSettings = null;
    }
  });
}
项目:intellij-ce-playground    文件:ScopeChooserCombo.java   
public void init(final Project project,
                 final boolean suggestSearchInLibs,
                 final boolean prevSearchWholeFiles,
                 final String preselect,
                 @Nullable Condition<ScopeDescriptor> scopeFilter) {
  mySuggestSearchInLibs = suggestSearchInLibs;
  myPrevSearchFiles = prevSearchWholeFiles;
  myProject = project;
  myScopeListener = new NamedScopesHolder.ScopeListener() {
    @Override
    public void scopesChanged() {
      final SearchScope selectedScope = getSelectedScope();
      rebuildModel();
      if (selectedScope != null) {
        selectScope(selectedScope.getDisplayName());
      }
    }
  };
  myScopeFilter = scopeFilter;
  myNamedScopeManager = NamedScopeManager.getInstance(project);
  myNamedScopeManager.addScopeListener(myScopeListener);
  myValidationManager = DependencyValidationManager.getInstance(project);
  myValidationManager.addScopeListener(myScopeListener);
  addActionListener(createScopeChooserListener());

  final JComboBox combo = getComboBox();
  combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer());

  rebuildModel();

  selectScope(preselect);
}
项目:tools-idea    文件:InspectionProjectProfileManagerImpl.java   
public InspectionProjectProfileManagerImpl(@NotNull Project project,
                                           @NotNull InspectionProfileManager inspectionProfileManager,
                                           @NotNull DependencyValidationManager holder,
                                           @NotNull NamedScopeManager localScopesHolder) {
  super(project, inspectionProfileManager, holder);
  myLocalScopesHolder = localScopesHolder;
  mySeverityRegistrar = new SeverityRegistrar();
}
项目:tools-idea    文件:DaemonCodeAnalyzerImpl.java   
void reloadScopes(@NotNull DependencyValidationManager dependencyValidationManager, @NotNull NamedScopeManager namedScopeManager) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  List<Pair<NamedScope, NamedScopesHolder>> scopeList = new ArrayList<Pair<NamedScope, NamedScopesHolder>>();
  addScopesToList(scopeList, namedScopeManager);
  addScopesToList(scopeList, dependencyValidationManager);
  myScopes.clear();
  myScopes.addAll(scopeList);
  dependencyValidationManager.reloadRules();
}
项目:tools-idea    文件:FileColorConfiguration.java   
public boolean isValid(Project project) {
  if (myScopeName == null || myScopeName.length() == 0) {
    return false;
  }

  if (myColorName == null) {
    return false;
  }

  if (project != null) {
    return NamedScopeManager.getScope(project, myScopeName) != null;
  } else {
    return true;
  }
}
项目:tools-idea    文件:ScopeChooserCombo.java   
public void init(final Project project, final boolean suggestSearchInLibs, final boolean prevSearchWholeFiles,  final String preselect) {
  mySuggestSearchInLibs = suggestSearchInLibs;
  myPrevSearchFiles = prevSearchWholeFiles;
  myProject = project;
  myScopeListener = new NamedScopesHolder.ScopeListener() {
    @Override
    public void scopesChanged() {
      final SearchScope selectedScope = getSelectedScope();
      rebuildModel();
      if (selectedScope != null) {
        selectScope(selectedScope.getDisplayName());
      }
    }
  };
  myNamedScopeManager = NamedScopeManager.getInstance(project);
  myNamedScopeManager.addScopeListener(myScopeListener);
  myValidationManager = DependencyValidationManager.getInstance(project);
  myValidationManager.addScopeListener(myScopeListener);
  addActionListener(createScopeChooserListener());

  final JComboBox combo = getComboBox();
  combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer(combo.getRenderer()));

  rebuildModel();

  selectScope(preselect);
}
项目:consulo    文件:InspectionProjectProfileManagerImpl.java   
public InspectionProjectProfileManagerImpl(@Nonnull Project project,
                                           @Nonnull InspectionProfileManager inspectionProfileManager,
                                           @Nonnull DependencyValidationManager holder,
                                           @Nonnull NamedScopeManager localScopesHolder) {
  super(project, inspectionProfileManager, holder);
  myLocalScopesHolder = localScopesHolder;
  mySeverityRegistrar = new SeverityRegistrar(project.getMessageBus());
}
项目:consulo    文件:DaemonCodeAnalyzerImpl.java   
public DaemonCodeAnalyzerImpl(@Nonnull Project project,
                              @Nonnull DaemonCodeAnalyzerSettings daemonCodeAnalyzerSettings,
                              @Nonnull EditorTracker editorTracker,
                              @Nonnull PsiDocumentManager psiDocumentManager,
                              @SuppressWarnings("UnusedParameters") @Nonnull final NamedScopeManager namedScopeManager,
                              @SuppressWarnings("UnusedParameters") @Nonnull final DependencyValidationManager dependencyValidationManager) {
  myProject = project;
  mySettings = daemonCodeAnalyzerSettings;
  myEditorTracker = editorTracker;
  myPsiDocumentManager = psiDocumentManager;
  myLastSettings = ((DaemonCodeAnalyzerSettingsImpl)daemonCodeAnalyzerSettings).clone();

  myFileStatusMap = new FileStatusMap(project);
  myPassExecutorService = new PassExecutorService(project);
  Disposer.register(this, myPassExecutorService);
  Disposer.register(this, myFileStatusMap);
  DaemonProgressIndicator.setDebug(LOG.isDebugEnabled());

  assert !myInitialized : "Double Initializing";
  Disposer.register(this, new StatusBarUpdater(project));

  myInitialized = true;
  myDisposed = false;
  myFileStatusMap.markAllFilesDirty("DCAI init");
  myUpdateRunnable = new UpdateRunnable(myProject);
  Disposer.register(this, () -> {
    assert myInitialized : "Disposing not initialized component";
    assert !myDisposed : "Double dispose";
    myUpdateRunnable.clearFieldsOnDispose();

    stopProcess(false, "Dispose");

    myDisposed = true;
    myLastSettings = null;
  });
}
项目:consulo    文件:FileColorConfiguration.java   
public boolean isValid(Project project) {
  if (myScopeName == null || myScopeName.length() == 0) {
    return false;
  }

  if (myColorName == null) {
    return false;
  }

  if (project != null) {
    return NamedScopeManager.getScope(project, myScopeName) != null;
  } else {
    return true;
  }
}
项目:consulo    文件:ScopeChooserCombo.java   
public void init(final Project project,
                 final boolean suggestSearchInLibs,
                 final boolean prevSearchWholeFiles,
                 final String preselect,
                 @Nullable Condition<ScopeDescriptor> scopeFilter) {
  mySuggestSearchInLibs = suggestSearchInLibs;
  myPrevSearchFiles = prevSearchWholeFiles;
  myProject = project;
  myScopeListener = () -> {
    final SearchScope selectedScope = getSelectedScope();
    rebuildModel();
    if (selectedScope != null) {
      selectScope(selectedScope.getDisplayName());
    }
  };
  myScopeFilter = scopeFilter;
  myNamedScopeManager = NamedScopeManager.getInstance(project);
  myNamedScopeManager.addScopeListener(myScopeListener);
  myValidationManager = DependencyValidationManager.getInstance(project);
  myValidationManager.addScopeListener(myScopeListener);
  addActionListener(createScopeChooserListener());

  final ComboBox<ScopeDescriptor> combo = (ComboBox<ScopeDescriptor>)getComboBox();
  combo.setMinimumAndPreferredWidth(JBUI.scale(300));
  combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer());

  rebuildModel();

  selectScope(preselect);
  new ComboboxSpeedSearch(combo) {
    @Override
    protected String getElementText(Object element) {
      if (element instanceof ScopeDescriptor) {
        final ScopeDescriptor descriptor = (ScopeDescriptor)element;
        return descriptor.getDisplay();
      }
      return null;
    }
  };
}
项目:intellij-ce-playground    文件:FileColorConfigurationEditDialog.java   
@Override
protected JComponent createNorthPanel() {
  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();
    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()));
  myScopeComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      updateCustomButton();
      updateOKButton();
    }
  });

  final JLabel pathLabel = new JLabel("Scope:");
  pathLabel.setDisplayedMnemonic('S');
  pathLabel.setLabelFor(myScopeComboBox);
  final JLabel colorLabel = new JLabel("Color:");

  JPanel result = new JPanel(new GridBagLayout());
  GridBagConstraints gbc = new GridBagConstraints();
  gbc.fill = GridBagConstraints.BOTH;
  gbc.insets = JBUI.insets(5);
  gbc.gridx = 0;
  result.add(pathLabel, gbc);
  result.add(colorLabel, gbc);
  gbc.gridx = 1;
  gbc.weightx = 1;
  result.add(myScopeComboBox, gbc);
  result.add(myColorSelectionComponent, gbc);
  return result;
}
项目:intellij-ce-playground    文件:ScopeConfigurable.java   
private NamedScopesHolder getHolder(boolean local) {
  return (NamedScopesHolder)(local
          ? DependencyValidationManager.getInstance(myProject)
          : NamedScopeManager.getInstance(myProject));
}
项目:tools-idea    文件:DaemonCodeAnalyzerImpl.java   
public DaemonCodeAnalyzerImpl(@NotNull Project project,
                              @NotNull DaemonCodeAnalyzerSettings daemonCodeAnalyzerSettings,
                              @NotNull EditorTracker editorTracker,
                              @NotNull final NamedScopeManager namedScopeManager,
                              @NotNull final DependencyValidationManager dependencyValidationManager) {
  myProject = project;

  mySettings = daemonCodeAnalyzerSettings;
  myEditorTracker = editorTracker;
  myLastSettings = ((DaemonCodeAnalyzerSettingsImpl)daemonCodeAnalyzerSettings).clone();

  myFileStatusMap = new FileStatusMap(myProject);
  myPassExecutorService = new PassExecutorService(myProject) {
    @Override
    protected void afterApplyInformationToEditor(final TextEditorHighlightingPass pass,
                                                 @NotNull final FileEditor fileEditor,
                                                 final ProgressIndicator updateProgress) {
      if (fileEditor instanceof TextEditor) {
        log(updateProgress, pass, "Apply ");
        Editor editor = ((TextEditor)fileEditor).getEditor();
        repaintErrorStripeRenderer(editor);
      }
    }

    @Override
    protected boolean isDisposed() {
      return myDisposed || super.isDisposed();
    }
  };
  Disposer.register(project, myPassExecutorService);
  Disposer.register(project, myFileStatusMap);
  DaemonProgressIndicator.setDebug(LOG.isDebugEnabled());

  assert !myInitialized : "Double Initializing";
  Disposer.register(myProject, new StatusBarUpdater(myProject));

  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      reloadScopes(dependencyValidationManager, namedScopeManager);
    }
  }, project.getDisposed());


  myInitialized = true;
  myDisposed = false;
  myFileStatusMap.markAllFilesDirty();
  Disposer.register(project, new Disposable() {
    @Override
    public void dispose() {
      assert myInitialized : "Disposing not initialized component";
      assert !myDisposed : "Double dispose";

      stopProcess(false, "Dispose");

      myDisposed = true;
      myLastSettings = null;
    }
  });
}
项目:tools-idea    文件:FileColorConfigurationEditDialog.java   
@Override
protected JComponent createNorthPanel() {
  final JPanel result = new JPanel();
  result.setLayout(new BoxLayout(result, BoxLayout.Y_AXIS));

  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();
    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()));
  myScopeComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      updateCustomButton();
      updateOKButton();
    }
  });

  final JPanel pathPanel = new JPanel();
  pathPanel.setLayout(new BorderLayout());

  final JLabel pathLabel = new JLabel("Scope:");
  pathLabel.setDisplayedMnemonic('S');
  pathLabel.setLabelFor(myScopeComboBox);
  pathPanel.add(pathLabel, BorderLayout.WEST);
  pathPanel.add(myScopeComboBox, BorderLayout.CENTER);

  /*
  final JButton newScope = new JButton("Add scope...");
  newScope.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      // TBD: refresh scope list
    }
  });
  pathPanel.add(newScope, BorderLayout.EAST);
  */

  result.add(pathPanel);

  final JPanel colorPanel = new JPanel();
  colorPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
  colorPanel.setLayout(new BoxLayout(colorPanel, BoxLayout.X_AXIS));
  final JLabel colorLabel = new JLabel("Color:");
  colorPanel.add(colorLabel);
  colorPanel.add(myColorSelectionComponent);
  colorPanel.add(Box.createHorizontalGlue());
  result.add(colorPanel);

  return result;
}
项目:tools-idea    文件:ScopeBasedTodosPanel.java   
public ScopeBasedTodosPanel(final Project project, TodoPanelSettings settings, Content content){
  super(project,settings,false,content);
  myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, project);
  final String scopeName = PropertiesComponent.getInstance(project).getValue(SELECTED_SCOPE);
  rebuildModel(project, scopeName);

  myScopeListener = new NamedScopesHolder.ScopeListener() {
    @Override
    public void scopesChanged() {
      final ScopeWrapper scope = (ScopeWrapper)myScopes.getSelectedItem();
      rebuildModel(project, scope != null ? scope.getName() : null);
    }
  };

  myNamedScopeManager = NamedScopeManager.getInstance(project);
  myNamedScopeManager.addScopeListener(myScopeListener);

  myValidationManager = DependencyValidationManager.getInstance(project);
  myValidationManager.addScopeListener(myScopeListener);

  myScopes.setRenderer(new ListCellRendererWrapper<ScopeWrapper>(){
    @Override
    public void customize(JList list, ScopeWrapper value, int index, boolean selected, boolean hasFocus) {
      setText(value.getName());
      if (value.isSeparator()) {
        setSeparator();
      }
    }
  });
  myScopes.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      rebuildWithAlarm(ScopeBasedTodosPanel.this.myAlarm);
      final ScopeWrapper selectedItem = (ScopeWrapper)myScopes.getSelectedItem();
      if (selectedItem != null) {
        PropertiesComponent.getInstance(myProject).setValue(SELECTED_SCOPE, selectedItem.getName());
      }
    }
  });
  rebuildWithAlarm(myAlarm);
}
项目:tools-idea    文件:ScopeConfigurable.java   
private NamedScopesHolder getHolder(boolean local) {
  return (NamedScopesHolder)(local
          ? DependencyValidationManager.getInstance(myProject)
          : NamedScopeManager.getInstance(myProject));
}
项目:consulo    文件:FileColorConfigurationEditDialog.java   
@Override
protected JComponent createNorthPanel() {
  final JPanel result = new JPanel();
  result.setLayout(new BoxLayout(result, BoxLayout.Y_AXIS));

  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();
    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()));
  myScopeComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      updateCustomButton();
      updateOKButton();
    }
  });

  final JPanel pathPanel = new JPanel();
  pathPanel.setLayout(new BorderLayout());

  final JLabel pathLabel = new JLabel("Scope:");
  pathLabel.setDisplayedMnemonic('S');
  pathLabel.setLabelFor(myScopeComboBox);
  pathPanel.add(pathLabel, BorderLayout.WEST);
  pathPanel.add(myScopeComboBox, BorderLayout.CENTER);

  /*
  final JButton newScope = new JButton("Add scope...");
  newScope.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      // TBD: refresh scope list
    }
  });
  pathPanel.add(newScope, BorderLayout.EAST);
  */

  result.add(pathPanel);

  final JPanel colorPanel = new JPanel();
  colorPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
  colorPanel.setLayout(new BoxLayout(colorPanel, BoxLayout.X_AXIS));
  final JLabel colorLabel = new JLabel("Color:");
  colorPanel.add(colorLabel);
  colorPanel.add(createColorButtonsPanel(myConfiguration));
  colorPanel.add(Box.createHorizontalGlue());
  result.add(colorPanel);

  return result;
}
项目:consulo    文件:ScopeConfigurable.java   
private NamedScopesHolder getHolder(boolean local) {
  return local
          ? DependencyValidationManager.getInstance(myProject)
          : NamedScopeManager.getInstance(myProject);
}