Search in sources :

Example 1 with ProjectInspectionProfileManager

use of com.intellij.profile.codeInspection.ProjectInspectionProfileManager in project intellij-community by JetBrains.

the class InspectionProfileTest method testSameNameSharedProfile.

public void testSameNameSharedProfile() throws Exception {
    BaseInspectionProfileManager profileManager = getApplicationProfileManager();
    InspectionProfileImpl localProfile = createProfile();
    updateProfile(profileManager, localProfile);
    ProjectInspectionProfileManager projectProfileManager = ProjectInspectionProfileManager.getInstance(getProject());
    try {
        //normally on open project profile wrappers are init for both managers
        updateProfile(profileManager, localProfile);
        InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager, null);
        updateProfile(projectProfileManager, profile);
        projectProfileManager.setRootProfile(profile.getName());
        assertTrue(projectProfileManager.getCurrentProfile() == profile);
    } finally {
        projectProfileManager.deleteProfile(PROFILE);
    }
}
Also used : BaseInspectionProfileManager(com.intellij.profile.codeInspection.BaseInspectionProfileManager) ProjectInspectionProfileManager(com.intellij.profile.codeInspection.ProjectInspectionProfileManager)

Example 2 with ProjectInspectionProfileManager

use of com.intellij.profile.codeInspection.ProjectInspectionProfileManager in project intellij-community by JetBrains.

the class EditCleanupProfileIntentionAction method invoke.

@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    final ProjectInspectionProfileManager profileManager = ProjectInspectionProfileManager.getInstance(project);
    final ProjectInspectionToolsConfigurable configurable = new ProjectInspectionToolsConfigurable(profileManager) {

        @Override
        protected boolean acceptTool(InspectionToolWrapper entry) {
            return super.acceptTool(entry) && entry.isCleanupTool();
        }

        @Override
        public String getDisplayName() {
            return CodeCleanupAction.CODE_CLEANUP_INSPECTIONS_DISPLAY_NAME;
        }
    };
    ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
}
Also used : ProjectInspectionToolsConfigurable(com.intellij.profile.codeInspection.ui.ProjectInspectionToolsConfigurable) ProjectInspectionProfileManager(com.intellij.profile.codeInspection.ProjectInspectionProfileManager) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 3 with ProjectInspectionProfileManager

use of com.intellij.profile.codeInspection.ProjectInspectionProfileManager in project intellij-community by JetBrains.

the class QuickChangeInspectionProfileAction method fillActions.

@Override
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
    final ProjectInspectionProfileManager projectProfileManager = ProjectInspectionProfileManager.getInstance(project);
    InspectionProfile current = projectProfileManager.getCurrentProfile();
    for (InspectionProfile profile : projectProfileManager.getProfiles()) {
        addScheme(group, projectProfileManager, current, profile);
    }
}
Also used : InspectionProfile(com.intellij.codeInspection.InspectionProfile) ProjectInspectionProfileManager(com.intellij.profile.codeInspection.ProjectInspectionProfileManager)

Example 4 with ProjectInspectionProfileManager

use of com.intellij.profile.codeInspection.ProjectInspectionProfileManager 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)

Example 5 with ProjectInspectionProfileManager

use of com.intellij.profile.codeInspection.ProjectInspectionProfileManager in project intellij-community by JetBrains.

the class GlobalInspectionContextBase method getCurrentProfile.

public InspectionProfileImpl getCurrentProfile() {
    if (myExternalProfile != null) {
        return myExternalProfile;
    }
    String currentProfile = ((InspectionManagerBase) InspectionManager.getInstance(myProject)).getCurrentProfile();
    ProjectInspectionProfileManager profileManager = ProjectInspectionProfileManager.getInstance(myProject);
    InspectionProfileImpl profile = profileManager.getProfile(currentProfile, false);
    if (profile == null) {
        profile = InspectionProfileManager.getInstance().getProfile(currentProfile);
        if (profile != null) {
            return profile;
        }
        final String[] availableProfileNames = profileManager.getAvailableProfileNames();
        if (availableProfileNames.length == 0) {
            //can't be
            return null;
        }
        profile = profileManager.getProfile(availableProfileNames[0], true);
    }
    return profile;
}
Also used : ProjectInspectionProfileManager(com.intellij.profile.codeInspection.ProjectInspectionProfileManager)

Aggregations

ProjectInspectionProfileManager (com.intellij.profile.codeInspection.ProjectInspectionProfileManager)6 InspectionProfile (com.intellij.codeInspection.InspectionProfile)2 SchemesCombo (com.intellij.application.options.schemes.SchemesCombo)1 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)1 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)1 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)1 BaseInspectionProfileManager (com.intellij.profile.codeInspection.BaseInspectionProfileManager)1 InspectionProfileManager (com.intellij.profile.codeInspection.InspectionProfileManager)1 ProjectInspectionToolsConfigurable (com.intellij.profile.codeInspection.ui.ProjectInspectionToolsConfigurable)1 PsiElement (com.intellij.psi.PsiElement)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Element (org.jdom.Element)1 NotNull (org.jetbrains.annotations.NotNull)1