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;
}
Aggregations