private void initScopeFilter() { myUseScopeFilteringCb.setSelected(false); myScopeCombo.setEnabled(false); myUseScopeFilteringCb.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myScopeCombo.setEnabled(myUseScopeFilteringCb.isSelected()); } }); }
private void onScopeRadioButtonPressed() { myScopeCombo.setEnabled(myCustomScopeButton.isSelected()); myChangeLists.setEnabled(myUncommitedFilesButton.isSelected()); }
@Override protected JComponent createCenterPanel() { myTitledSeparator.setText(myAnalysisNoon); // include test option myInspectTestSource.setSelected(myAnalysisOptions.ANALYZE_TEST_SOURCES); // module scope if applicable myModuleButton.setText( AnalysisScopeBundle.message("scope.option.module.with.mnemonic", myModuleName)); boolean useModuleScope = false; if (myModuleName != null) { useModuleScope = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.MODULE; myModuleButton.setSelected(myRememberScope && useModuleScope); } myModuleButton.setVisible( myModuleName != null && ModuleManager.getInstance(myProject).getModules().length > 1); boolean useUncommitedFiles = false; final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); final boolean hasVCS = !changeListManager.getAffectedFiles().isEmpty(); if (hasVCS) { useUncommitedFiles = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.UNCOMMITTED_FILES; myUncommitedFilesButton.setSelected(myRememberScope && useUncommitedFiles); } myUncommitedFilesButton.setVisible(hasVCS); DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement(ALL); final List<? extends ChangeList> changeLists = changeListManager.getChangeListsCopy(); for (ChangeList changeList : changeLists) { model.addElement(changeList.getName()); } myChangeLists.setModel(model); myChangeLists.setEnabled(myUncommitedFilesButton.isSelected()); myChangeLists.setVisible(hasVCS); // file/package/directory/module scope if (myFileName != null) { myFileButton.setText(myFileName); myFileButton.setMnemonic(myFileName.charAt(getSelectedScopeMnemonic())); } else { myFileButton.setVisible(false); } VirtualFile file = PsiUtilBase.getVirtualFile(myContext); ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); boolean searchInLib = file != null && (fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file)); String preselect = StringUtil.isEmptyOrSpaces(myAnalysisOptions.CUSTOM_SCOPE_NAME) ? FindSettings.getInstance().getDefaultScopeName() : myAnalysisOptions.CUSTOM_SCOPE_NAME; if (searchInLib && GlobalSearchScope.projectScope(myProject).getDisplayName().equals(preselect)) { preselect = GlobalSearchScope.allScope(myProject).getDisplayName(); } if (GlobalSearchScope.allScope(myProject).getDisplayName().equals(preselect) && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM) { myAnalysisOptions.CUSTOM_SCOPE_NAME = preselect; searchInLib = true; } // custom scope myCustomScopeButton.setSelected( myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM); myScopeCombo.init(myProject, searchInLib, true, preselect); // correct selection myProjectButton.setSelected( myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.PROJECT || myFileName == null); myFileButton.setSelected( myFileName != null && (!myRememberScope || myAnalysisOptions.SCOPE_TYPE != AnalysisScope.PROJECT && !useModuleScope && myAnalysisOptions.SCOPE_TYPE != AnalysisScope.CUSTOM && !useUncommitedFiles)); myScopeCombo.setEnabled(myCustomScopeButton.isSelected()); final ActionListener radioButtonPressed = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onScopeRadioButtonPressed(); } }; final Enumeration<AbstractButton> enumeration = myGroup.getElements(); while (enumeration.hasMoreElements()) { enumeration.nextElement().addActionListener(radioButtonPressed); } // additional panel - inspection profile chooser JPanel wholePanel = new JPanel(new BorderLayout()); wholePanel.add(myPanel, BorderLayout.NORTH); final JComponent additionalPanel = getAdditionalActionSettings(myProject); if (additionalPanel != null) { wholePanel.add(additionalPanel, BorderLayout.CENTER); } new RadioUpDownListener( myProjectButton, myModuleButton, myUncommitedFilesButton, myFileButton, myCustomScopeButton); return wholePanel; }