mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-133779 Inspection settings: changing Share + Rename is processed not consistently
This commit is contained in:
+2
-2
@@ -42,7 +42,7 @@ public class SingleInspectionProfilePanelTest extends LightIdeaTestCase {
|
||||
|
||||
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
|
||||
assertEquals(0, InspectionProfileTest.countInitializedTools(model));
|
||||
SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model);
|
||||
SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model, profile);
|
||||
panel.setVisible(true);
|
||||
panel.reset();
|
||||
assertEquals(InspectionProfileTest.getInitializedTools(model).toString(), 0, InspectionProfileTest.countInitializedTools(model));
|
||||
@@ -70,7 +70,7 @@ public class SingleInspectionProfilePanelTest extends LightIdeaTestCase {
|
||||
|
||||
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
|
||||
|
||||
SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model);
|
||||
SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model, profile);
|
||||
panel.setVisible(true);
|
||||
panel.reset();
|
||||
assertEquals(InspectionProfileTest.getInitializedTools(model).toString(), 1, InspectionProfileTest.countInitializedTools(model));
|
||||
|
||||
+16
-44
@@ -49,6 +49,7 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.profile.ApplicationProfileManager;
|
||||
import com.intellij.profile.DefaultProjectProfileManager;
|
||||
import com.intellij.profile.Profile;
|
||||
import com.intellij.profile.ProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
@@ -111,6 +112,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
private final Alarm myAlarm = new Alarm();
|
||||
private final StorageAccessors myProperties = StorageAccessors.createGlobal("SingleInspectionProfilePanel");
|
||||
private final InspectionProjectProfileManager myProjectProfileManager;
|
||||
@NotNull private Profile myOriginal;
|
||||
private InspectionProfileImpl mySelectedProfile;
|
||||
private JEditorPane myBrowser;
|
||||
private JPanel myOptionsPanel;
|
||||
@@ -140,9 +142,11 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
|
||||
public SingleInspectionProfilePanel(@NotNull InspectionProjectProfileManager projectProfileManager,
|
||||
@NotNull String inspectionProfileName,
|
||||
@NotNull ModifiableModel profile) {
|
||||
@NotNull ModifiableModel profile,
|
||||
@NotNull Profile original) {
|
||||
super(new BorderLayout());
|
||||
myProjectProfileManager = projectProfileManager;
|
||||
myOriginal = original;
|
||||
mySelectedProfile = (InspectionProfileImpl)profile;
|
||||
myCurrentProfileName = inspectionProfileName;
|
||||
myShareProfile = profile.getProfileManager() == projectProfileManager;
|
||||
@@ -158,43 +162,6 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ModifiableModel createNewProfile(final int initValue,
|
||||
ModifiableModel selectedProfile,
|
||||
JPanel parent,
|
||||
String profileName,
|
||||
Set<String> existingProfileNames,
|
||||
@NotNull Project project) {
|
||||
profileName = Messages.showInputDialog(parent, profileName, "Create New Inspection Profile", Messages.getQuestionIcon());
|
||||
if (profileName == null) return null;
|
||||
final ProfileManager profileManager = selectedProfile.getProfileManager();
|
||||
if (existingProfileNames.contains(profileName)) {
|
||||
Messages.showErrorDialog(InspectionsBundle.message("inspection.unable.to.create.profile.message", profileName),
|
||||
InspectionsBundle.message("inspection.unable.to.create.profile.dialog.title"));
|
||||
return null;
|
||||
}
|
||||
InspectionProfileImpl inspectionProfile = new InspectionProfileImpl(profileName, InspectionToolRegistrar.getInstance(), profileManager);
|
||||
if (initValue == -1) {
|
||||
inspectionProfile.initInspectionTools(project);
|
||||
ModifiableModel profileModifiableModel = inspectionProfile.getModifiableModel();
|
||||
final InspectionToolWrapper[] profileEntries = profileModifiableModel.getInspectionTools(null);
|
||||
for (InspectionToolWrapper toolWrapper : profileEntries) {
|
||||
profileModifiableModel.disableTool(toolWrapper.getShortName(), null, project);
|
||||
}
|
||||
profileModifiableModel.setProjectLevel(false);
|
||||
profileModifiableModel.setModified(true);
|
||||
return profileModifiableModel;
|
||||
}
|
||||
else if (initValue == 0) {
|
||||
inspectionProfile.copyFrom(selectedProfile);
|
||||
inspectionProfile.setName(profileName);
|
||||
inspectionProfile.initInspectionTools(project);
|
||||
inspectionProfile.setModified(true);
|
||||
return inspectionProfile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static InspectionConfigTreeNode findNodeByKey(String name, InspectionConfigTreeNode root) {
|
||||
for (int i = 0; i < root.getChildCount(); i++) {
|
||||
@@ -1174,19 +1141,23 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
}
|
||||
final ModifiableModel selectedProfile = getSelectedProfile();
|
||||
|
||||
if (!Comparing.equal(myCurrentProfileName, selectedProfile.getName())) {
|
||||
selectedProfile.getProfileManager().deleteProfile(selectedProfile.getName());
|
||||
selectedProfile.setName(myCurrentProfileName);
|
||||
selectedProfile.getProfileManager().updateProfile(selectedProfile);
|
||||
}
|
||||
ProfileManager profileManager = myShareProfile ? myProjectProfileManager : InspectionProfileManager.getInstance();
|
||||
selectedProfile.setProjectLevel(myShareProfile);
|
||||
if (selectedProfile.getProfileManager() != profileManager) {
|
||||
if (selectedProfile.getProfileManager().getProfile(selectedProfile.getName(), false) != null) {
|
||||
if (selectedProfile.getProfileManager().getProfile(selectedProfile.getName(), false) == myOriginal) {
|
||||
selectedProfile.getProfileManager().deleteProfile(selectedProfile.getName());
|
||||
}
|
||||
selectedProfile.setName(myCurrentProfileName);
|
||||
copyUsedSeveritiesIfUndefined(selectedProfile, profileManager);
|
||||
selectedProfile.setProfileManager(profileManager);
|
||||
} else {
|
||||
if (!Comparing.equal(myCurrentProfileName, selectedProfile.getName())) {
|
||||
if (selectedProfile.getProfileManager().getProfile(selectedProfile.getName(), false) == myOriginal) {
|
||||
selectedProfile.getProfileManager().deleteProfile(selectedProfile.getName());
|
||||
}
|
||||
selectedProfile.setName(myCurrentProfileName);
|
||||
selectedProfile.getProfileManager().updateProfile(selectedProfile);
|
||||
}
|
||||
}
|
||||
|
||||
final InspectionProfile parentProfile = selectedProfile.getParentProfile();
|
||||
@@ -1199,6 +1170,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
setSelectedProfile(parentProfile.getModifiableModel());
|
||||
setSelectedProfileModified(false);
|
||||
myModified = false;
|
||||
myOriginal = selectedProfile.getProfileManager().getProfile(selectedProfile.getName());
|
||||
}
|
||||
|
||||
private boolean descriptorsAreChanged() {
|
||||
|
||||
+7
-7
@@ -160,7 +160,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
final InspectionProfileImpl modifiableModel = (InspectionProfileImpl)newProfile.getModifiableModel();
|
||||
modifiableModel.setModified(true);
|
||||
modifiableModel.setProjectLevel(false);
|
||||
addProfile(modifiableModel);
|
||||
addProfile(modifiableModel, newProfile);
|
||||
rename(modifiableModel);
|
||||
}
|
||||
}
|
||||
@@ -337,7 +337,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
}
|
||||
final ModifiableModel model = profile.getModifiableModel();
|
||||
model.setModified(true);
|
||||
addProfile((InspectionProfileImpl)model);
|
||||
addProfile((InspectionProfileImpl)model, profile);
|
||||
|
||||
//TODO myDeletedProfiles ? really need this
|
||||
myDeletedProfiles.remove(profile);
|
||||
@@ -418,9 +418,9 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
return inspectionProfile;
|
||||
}
|
||||
|
||||
private void addProfile(InspectionProfileImpl model) {
|
||||
private void addProfile(InspectionProfileImpl model, InspectionProfileImpl profile) {
|
||||
final String modelName = model.getName();
|
||||
final SingleInspectionProfilePanel panel = createPanel(model, modelName);
|
||||
final SingleInspectionProfilePanel panel = createPanel(model, profile, modelName);
|
||||
myPanel.add(getCardName(model), panel);
|
||||
|
||||
myProfiles.getModel().addElement(model);
|
||||
@@ -541,7 +541,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
final ModifiableModel modifiableProfile = ((InspectionProfileImpl)profile).getModifiableModel();
|
||||
modifiableProfiles.add(modifiableProfile);
|
||||
final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)modifiableProfile;
|
||||
final SingleInspectionProfilePanel panel = createPanel(inspectionProfile, profileName);
|
||||
final SingleInspectionProfilePanel panel = createPanel(inspectionProfile, profile, profileName);
|
||||
putProfile(modifiableProfile, panel);
|
||||
myPanel.add(getCardName(inspectionProfile), panel);
|
||||
}
|
||||
@@ -575,8 +575,8 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
return (inspectionProfile.isProjectLevel() ? "s" : "a") + inspectionProfile.getName();
|
||||
}
|
||||
|
||||
private SingleInspectionProfilePanel createPanel(InspectionProfileImpl profile, String profileName) {
|
||||
return new SingleInspectionProfilePanel(myProjectProfileManager, profileName, profile) {
|
||||
private SingleInspectionProfilePanel createPanel(InspectionProfileImpl profile, Profile original, String profileName) {
|
||||
return new SingleInspectionProfilePanel(myProjectProfileManager, profileName, profile, original) {
|
||||
@Override
|
||||
protected boolean accept(InspectionToolWrapper entry) {
|
||||
return super.accept(entry) && acceptTool(entry);
|
||||
|
||||
Reference in New Issue
Block a user