Search in sources :

Example 1 with SchemesCombo

use of com.intellij.application.options.schemes.SchemesCombo in project intellij-community by JetBrains.

the class CodeInspectionAction method getAdditionalActionSettings.

@Override
protected JComponent getAdditionalActionSettings(@NotNull final Project project, final BaseAnalysisActionDialog dialog) {
    final AdditionalPanel panel = new AdditionalPanel();
    final InspectionManagerEx manager = (InspectionManagerEx) InspectionManager.getInstance(project);
    final SchemesCombo<InspectionProfileImpl> profiles = (SchemesCombo<InspectionProfileImpl>) panel.myBrowseProfilesCombo.getComboBox();
    final InspectionProfileManager profileManager = InspectionProfileManager.getInstance();
    final ProjectInspectionProfileManager projectProfileManager = ProjectInspectionProfileManager.getInstance(project);
    panel.myBrowseProfilesCombo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final ExternalProfilesComboboxAwareInspectionToolsConfigurable errorConfigurable = createConfigurable(projectProfileManager, profiles);
            final MySingleConfigurableEditor editor = new MySingleConfigurableEditor(project, errorConfigurable, manager);
            if (editor.showAndGet()) {
                reloadProfiles(profiles, profileManager, projectProfileManager, project);
                if (errorConfigurable.mySelectedName != null) {
                    final InspectionProfileImpl profile = (errorConfigurable.mySelectedIsProjectProfile ? projectProfileManager : profileManager).getProfile(errorConfigurable.mySelectedName);
                    profiles.selectScheme(profile);
                }
            } else {
                //if profile was disabled and cancel after apply was pressed
                final InspectionProfile profile = profiles.getSelectedScheme();
                final boolean canExecute = profile != null && profile.isExecutable(project);
                dialog.setOKActionEnabled(canExecute);
            }
        }
    });
    profiles.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            myExternalProfile = profiles.getSelectedScheme();
            final boolean canExecute = myExternalProfile != null && myExternalProfile.isExecutable(project);
            dialog.setOKActionEnabled(canExecute);
            if (canExecute) {
                PropertiesComponent.getInstance(project).setValue(LAST_SELECTED_PROFILE_PROP, (myExternalProfile.isProjectLevel() ? 'p' : 'a') + myExternalProfile.getName());
                manager.setProfile(myExternalProfile.getName());
            }
        }
    });
    reloadProfiles(profiles, profileManager, projectProfileManager, project);
    return panel.myAdditionalPanel;
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) InspectionProfile(com.intellij.codeInspection.InspectionProfile) ActionEvent(java.awt.event.ActionEvent) InspectionManagerEx(com.intellij.codeInspection.ex.InspectionManagerEx) ActionListener(java.awt.event.ActionListener) SchemesCombo(com.intellij.application.options.schemes.SchemesCombo) InspectionProfileManager(com.intellij.profile.codeInspection.InspectionProfileManager) ProjectInspectionProfileManager(com.intellij.profile.codeInspection.ProjectInspectionProfileManager) ProjectInspectionProfileManager(com.intellij.profile.codeInspection.ProjectInspectionProfileManager)

Aggregations

SchemesCombo (com.intellij.application.options.schemes.SchemesCombo)1 InspectionProfile (com.intellij.codeInspection.InspectionProfile)1 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)1 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)1 InspectionProfileManager (com.intellij.profile.codeInspection.InspectionProfileManager)1 ProjectInspectionProfileManager (com.intellij.profile.codeInspection.ProjectInspectionProfileManager)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1