AbstractSchemeActions<InspectionProfileModifiableModel> () { return new DescriptionAwareSchemeActions<>(this) { @Nullable @Override public String getDescription(@NotNull InspectionProfileModifiableModel scheme) { SingleInspectionProfilePanel inspectionProfile = ((InspectionProfileSchemesModel)getModel()).getProfilePanel(scheme); return inspectionProfile == null ? null : inspectionProfile.getProfile().getDescription(); } @Override protected void setDescription(@NotNull InspectionProfileModifiableModel scheme, @NlsContexts.DetailedDescription @NotNull String newDescription) { InspectionProfileModifiableModel inspectionProfile = InspectionProfileSchemesPanel.this.getModel().getProfilePanel(scheme).getProfile(); if (!Comparing.strEqual(newDescription, inspectionProfile.getDescription())) { inspectionProfile.setDescription(newDescription); inspectionProfile.setModified(true); } } @Override protected void importScheme(@NotNull String importerName) { final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public boolean isFileSelectable(@Nullable VirtualFile file) { return file != null && FileTypeRegistry.getInstance().isFileOfType(file, StdFileTypes.XML); } }; descriptor.setDescription(AnalysisBundle.message("inspections.settings.profile.file.chooser.description")); FileChooser.chooseFile(descriptor, myProject, null, file -> { if (file != null) { try { InspectionProfileImpl profile = importInspectionProfile(JDOMUtil.load(file.getInputStream()), myAppProfileManager, myProject); if (profile == null) { Messages.showErrorDialog(myProject, AnalysisBundle.message("inspections.settings.invalid.format.warning", file.getName()), CommonBundle.getErrorTitle()); return; } final SingleInspectionProfilePanel existed = InspectionProfileSchemesPanel.this.getModel().getProfilePanel(profile); if (existed != null) { if (Messages.showOkCancelDialog(myProject, AnalysisBundle .message("inspections.settings.profile.already.exists.dialog.message", profile.getName()), AnalysisBundle.message("inspections.settings.overwrite.warning.title"), AnalysisBundle.message("inspections.settings.overwrite.action.text"), CommonBundle.getCancelButtonText(), Messages.getInformationIcon()) != Messages.OK) { return; } getModel().removeScheme(existed.getProfile()); } InspectionProfileModifiableModel model = new InspectionProfileModifiableModel(profile); model.setModified(true); addProfile(model); selectScheme(model); } catch (JDOMException | InvalidDataException | IOException e) { LOG.error(e); } } }); } @Override protected void resetScheme(@NotNull InspectionProfileModifiableModel scheme) { final SingleInspectionProfilePanel panel = InspectionProfileSchemesPanel.this.getModel().getProfilePanel(scheme); panel.performProfileReset(); } @Override protected void duplicateScheme(@NotNull InspectionProfileModifiableModel scheme, @NotNull String newName) { final InspectionProfileModifiableModel newProfile = copyToNewProfile(scheme, myProject, newName, false); addProfile(newProfile); myConfigurable.selectProfile(newProfile); selectScheme(newProfile); } @Override protected void onSchemeChanged(@Nullable InspectionProfileModifiableModel scheme) { super.onSchemeChanged(scheme); if (scheme != null) { myConfigurable.selectProfile(scheme); } } @Override protected void renameScheme(@NotNull InspectionProfileModifiableModel scheme, @NotNull String newName) { scheme.setName(newName); } @Override protected void copyToProject(@NotNull InspectionProfileModifiableModel scheme) { copyToAnotherLevel(scheme, true); } @Override protected void copyToIDE(@NotNull InspectionProfileModifiableModel scheme) { copyToAnotherLevel(scheme, false); } @NotNull @Override protected Class<InspectionProfileModifiableModel> getSchemeType() { return InspectionProfileModifiableModel.class; } private void copyToAnotherLevel(@NotNull InspectionProfileModifiableModel profile, boolean copyToProject) { getSchemesPanel().editNewSchemeName( profile.getName(), copyToProject, newName -> { final InspectionProfileModifiableModel newProfile = copyToNewProfile(profile, myProject, newName, true); addProfile(newProfile); selectScheme(newProfile); }); } }; }