mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
isLocal() is not clear flag — isProjectLevel is much more clear
don't write defaults
This commit is contained in:
@@ -141,7 +141,7 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
myProfiles.clear();
|
||||
XmlSerializer.deserializeInto(this, state);
|
||||
for (Element o : state.getChildren(PROFILE)) {
|
||||
final Profile profile = myApplicationProfileManager.createProfile();
|
||||
Profile profile = myApplicationProfileManager.createProfile();
|
||||
profile.setProfileManager(this);
|
||||
try {
|
||||
profile.readExternal(o);
|
||||
@@ -149,11 +149,8 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
catch (InvalidDataException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
final String name = profile.getName();
|
||||
if (myApplicationProfileManager.getProfile(name) != null) { //override ide profile
|
||||
// myApplicationProfileManager.deleteProfile(name);
|
||||
}
|
||||
myProfiles.put(name, profile);
|
||||
profile.setProjectLevel(true);
|
||||
myProfiles.put(profile.getName(), profile);
|
||||
}
|
||||
if (state.getChild("version") == null || !Comparing.strEqual(state.getChild("version").getAttributeValue("value"), VERSION)) {
|
||||
boolean toConvert = true;
|
||||
@@ -231,7 +228,7 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
setProjectProfile(PROJECT_DEFAULT_PROFILE_NAME);
|
||||
final Profile projectProfile = myApplicationProfileManager.createProfile();
|
||||
projectProfile.copyFrom(myApplicationProfileManager.getRootProfile());
|
||||
projectProfile.setLocal(false);
|
||||
projectProfile.setProjectLevel(true);
|
||||
projectProfile.setName(PROJECT_DEFAULT_PROFILE_NAME);
|
||||
myProfiles.put(PROJECT_DEFAULT_PROFILE_NAME, projectProfile);
|
||||
}
|
||||
|
||||
@@ -24,18 +24,28 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Date: 20-Nov-2005
|
||||
*/
|
||||
public interface Profile extends JDOMExternalizable, Comparable, Scheme {
|
||||
|
||||
void copyFrom(@NotNull Profile profile);
|
||||
|
||||
void setLocal(boolean isLocal);
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* @deprecated Use !{@link #isProjectLevel()}
|
||||
*/
|
||||
boolean isLocal();
|
||||
|
||||
boolean isProjectLevel();
|
||||
|
||||
void setProjectLevel(boolean isProjectLevel);
|
||||
|
||||
void setName(@NotNull String name);
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
void setProfileManager(@NotNull ProfileManager profileManager);
|
||||
|
||||
@NotNull
|
||||
ProfileManager getProfileManager();
|
||||
}
|
||||
|
||||
+20
-30
@@ -47,6 +47,9 @@ import com.intellij.util.containers.StringInterner;
|
||||
import com.intellij.util.graph.CachingSemiGraph;
|
||||
import com.intellij.util.graph.DFSTBuilder;
|
||||
import com.intellij.util.graph.GraphGenerator;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -67,8 +70,6 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
@NonNls private static final String VALID_VERSION = "1.0";
|
||||
@NonNls private static final String VERSION_TAG = "version";
|
||||
@NonNls private static final String USED_LEVELS = "used_levels";
|
||||
@NonNls private static final String IS_LOCKED = "is_locked";
|
||||
@NonNls private static final String DESCRIPTION = "description";
|
||||
@TestOnly
|
||||
public static boolean INIT_INSPECTIONS = false;
|
||||
private static Map<String, InspectionElementsMerger> ourMergers = null;
|
||||
@@ -79,12 +80,13 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
protected InspectionProfileImpl mySource;
|
||||
private Map<String, ToolsImpl> myTools = new THashMap<String, ToolsImpl>();
|
||||
private Map<String, Boolean> myDisplayLevelMap;
|
||||
private boolean myLockedProfile = false;
|
||||
@Attribute("is_locked")
|
||||
private boolean myLockedProfile;
|
||||
private InspectionProfileImpl myBaseProfile = null;
|
||||
private String myEnabledTool = null;
|
||||
private String[] myScopesOrder = null;
|
||||
private String[] myScopesOrder;
|
||||
private String myDescription;
|
||||
private boolean myModified = false;
|
||||
private boolean myModified;
|
||||
private volatile boolean myInitialized;
|
||||
|
||||
InspectionProfileImpl(@NotNull InspectionProfileImpl inspectionProfile) {
|
||||
@@ -94,7 +96,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
myUninstalledInspectionsSettings = new LinkedHashMap<String, Element>(inspectionProfile.myUninstalledInspectionsSettings);
|
||||
|
||||
myBaseProfile = inspectionProfile.myBaseProfile;
|
||||
myLocal = inspectionProfile.myLocal;
|
||||
setProjectLevel(inspectionProfile.isProjectLevel());
|
||||
myLockedProfile = inspectionProfile.myLockedProfile;
|
||||
mySource = inspectionProfile;
|
||||
setProfileManager(inspectionProfile.getProfileManager());
|
||||
@@ -249,10 +251,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
@Override
|
||||
public void readExternal(@NotNull Element element) throws InvalidDataException {
|
||||
super.readExternal(element);
|
||||
final String locked = element.getAttributeValue(IS_LOCKED);
|
||||
if (locked != null) {
|
||||
myLockedProfile = Boolean.parseBoolean(locked);
|
||||
}
|
||||
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode() || myBaseProfile == null) {
|
||||
// todo remove this strange side effect
|
||||
myBaseProfile = getDefaultProfile();
|
||||
@@ -263,7 +262,8 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
}
|
||||
|
||||
final Element highlightElement = element.getChild(USED_LEVELS);
|
||||
if (highlightElement != null) { //from old profiles
|
||||
if (highlightElement != null) {
|
||||
// from old profiles
|
||||
((SeverityProvider)getProfileManager()).getOwnSeverityRegistrar().readExternal(highlightElement);
|
||||
}
|
||||
|
||||
@@ -274,11 +274,6 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
JDOMUtil.internElement(toolElement, interner);
|
||||
myUninstalledInspectionsSettings.put(toolElement.getAttributeValue(CLASS_TAG), toolElement);
|
||||
}
|
||||
|
||||
final Element descriptionElement = element.getChild(DESCRIPTION);
|
||||
if (descriptionElement != null) {
|
||||
myDescription = descriptionElement.getText();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -295,12 +290,10 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
|
||||
@Override
|
||||
public void writeExternal(@NotNull Element element) throws WriteExternalException {
|
||||
super.writeExternal(element);
|
||||
// must be first - compatibility
|
||||
element.setAttribute(VERSION_TAG, VALID_VERSION);
|
||||
element.setAttribute(IS_LOCKED, String.valueOf(myLockedProfile));
|
||||
if (myDescription != null) {
|
||||
element.addContent(new Element(DESCRIPTION).addContent(myDescription));
|
||||
}
|
||||
|
||||
super.writeExternal(element);
|
||||
synchronized (myExternalInfo) {
|
||||
if (!myInitialized) {
|
||||
for (Element el : myUninstalledInspectionsSettings.values()) {
|
||||
@@ -471,6 +464,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transient
|
||||
public boolean isProfileLocked() {
|
||||
return myLockedProfile;
|
||||
}
|
||||
@@ -621,6 +615,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Transient
|
||||
public String[] getScopesOrder() {
|
||||
return myScopesOrder;
|
||||
}
|
||||
@@ -640,6 +635,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
}
|
||||
});
|
||||
}
|
||||
//noinspection TestOnlyProblems
|
||||
return myRegistrar.createTools();
|
||||
}
|
||||
|
||||
@@ -786,7 +782,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
private void commit(@NotNull InspectionProfileImpl inspectionProfile) {
|
||||
setName(inspectionProfile.getName());
|
||||
setDescription(inspectionProfile.getDescription());
|
||||
myLocal = inspectionProfile.myLocal;
|
||||
setProjectLevel(inspectionProfile.isProjectLevel());
|
||||
myLockedProfile = inspectionProfile.myLockedProfile;
|
||||
myDisplayLevelMap = inspectionProfile.myDisplayLevelMap;
|
||||
myBaseProfile = inspectionProfile.myBaseProfile;
|
||||
@@ -798,6 +794,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
InspectionProfileManager.getInstance().fireProfileChanged(inspectionProfile);
|
||||
}
|
||||
|
||||
@Tag
|
||||
public String getDescription() {
|
||||
return myDescription;
|
||||
}
|
||||
@@ -920,14 +917,6 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAllScopes(@NotNull String toolId, Project project) {
|
||||
getTools(toolId, project).removeAllScopes();
|
||||
}
|
||||
|
||||
public void moveScope(@NotNull String toolId, int idx, int dir, Project project) {
|
||||
getTools(toolId, project).moveScope(idx, dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null if it has no base profile
|
||||
*/
|
||||
@@ -950,6 +939,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Transient
|
||||
public HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, NamedScope scope, Project project) {
|
||||
final ToolsImpl tools = getTools(key.toString(), project);
|
||||
return tools != null ? tools.getLevel(scope, project) : HighlightDisplayLevel.WARNING;
|
||||
|
||||
@@ -17,9 +17,11 @@ package com.intellij.profile;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.util.xmlb.SmartSerializer;
|
||||
import com.intellij.util.xmlb.annotations.OptionTag;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -33,18 +35,33 @@ public abstract class ProfileEx implements Profile {
|
||||
public static final String SCOPE = "scope";
|
||||
public static final String NAME = "name";
|
||||
|
||||
// public for JDOMExternalizable
|
||||
private final SmartSerializer mySerializer;
|
||||
|
||||
@NotNull
|
||||
public String myName;
|
||||
public boolean myLocal = true;
|
||||
protected String myName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@OptionTag
|
||||
// exists only to preserve compatibility
|
||||
private boolean myLocal;
|
||||
|
||||
protected ProfileManager myProfileManager;
|
||||
|
||||
private boolean myIsProjectLevel;
|
||||
|
||||
public ProfileEx(@NotNull String name) {
|
||||
setName(name);
|
||||
this(name, SmartSerializer.skipEmptySerializer());
|
||||
}
|
||||
|
||||
protected ProfileEx(@NotNull String name, @NotNull SmartSerializer serializer) {
|
||||
myName = name;
|
||||
mySerializer = serializer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
// ugly name to preserve compatibility
|
||||
@OptionTag("myName")
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
@@ -65,13 +82,25 @@ public abstract class ProfileEx implements Profile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocal(boolean isLocal) {
|
||||
myLocal = isLocal;
|
||||
@Transient
|
||||
public boolean isLocal() {
|
||||
return !myIsProjectLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return myLocal;
|
||||
@Transient
|
||||
public boolean isProjectLevel() {
|
||||
return myIsProjectLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectLevel(boolean isProjectLevel) {
|
||||
myIsProjectLevel = isProjectLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocal(boolean isLocal) {
|
||||
myIsProjectLevel = !isLocal;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,38 +108,33 @@ public abstract class ProfileEx implements Profile {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfileManager(@NotNull ProfileManager profileManager) {
|
||||
myProfileManager = profileManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@Transient
|
||||
public ProfileManager getProfileManager() {
|
||||
return myProfileManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfileManager(@NotNull ProfileManager profileManager) {
|
||||
myProfileManager = profileManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
DefaultJDOMExternalizer.readExternal(this, element);
|
||||
mySerializer.readExternal(this, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
DefaultJDOMExternalizer.writeExternal(this, element);
|
||||
mySerializer.writeExternal(this, element, isProjectLevel());
|
||||
}
|
||||
|
||||
public void profileChanged() {}
|
||||
public void profileChanged() {
|
||||
}
|
||||
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ProfileEx)) return false;
|
||||
|
||||
final ProfileEx profileEx = (ProfileEx)o;
|
||||
|
||||
if (!myName.equals(profileEx.myName)) return false;
|
||||
|
||||
return true;
|
||||
public boolean equals(Object o) {
|
||||
return this == o || o instanceof ProfileEx && myName.equals(((ProfileEx)o).myName);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
@@ -118,12 +142,13 @@ public abstract class ProfileEx implements Profile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final Object o) {
|
||||
public int compareTo(@NotNull Object o) {
|
||||
if (o instanceof Profile) {
|
||||
return getName().compareToIgnoreCase(((Profile)o).getName());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void convert(@NotNull Element element, @NotNull Project project) {}
|
||||
public void convert(@NotNull Element element, @NotNull Project project) {
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -102,9 +102,9 @@ public class CodeInspectionAction extends BaseAnalysisAction {
|
||||
@Override
|
||||
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value instanceof Profile) {
|
||||
final Profile profile = (Profile)value;
|
||||
Profile profile = (Profile)value;
|
||||
setText(profile.getName());
|
||||
setIcon(profile.isLocal() ? AllIcons.General.Settings : AllIcons.General.ProjectSettings);
|
||||
setIcon(profile.isProjectLevel() ? AllIcons.General.ProjectSettings : AllIcons.General.Settings);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -107,13 +107,13 @@ public class InspectionProfileManagerImpl extends InspectionProfileManager imple
|
||||
|
||||
@Override
|
||||
public boolean shouldBeSaved(@NotNull InspectionProfileImpl scheme) {
|
||||
return !scheme.isLocal() && scheme.wasInitialized();
|
||||
return !scheme.isProjectLevel() && scheme.wasInitialized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element writeScheme(@NotNull InspectionProfileImpl scheme) throws WriteExternalException {
|
||||
Element root = new Element("inspections");
|
||||
root.setAttribute("profile_name", scheme.myName);
|
||||
root.setAttribute("profile_name", scheme.getName());
|
||||
scheme.writeExternal(root);
|
||||
return root;
|
||||
}
|
||||
|
||||
+14
-9
@@ -23,12 +23,14 @@ import com.intellij.codeInspection.ex.InspectionToolRegistrar;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.profile.ApplicationProfileManager;
|
||||
import com.intellij.profile.Profile;
|
||||
import com.intellij.profile.ProfileManager;
|
||||
import com.intellij.profile.ProjectProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -62,7 +64,7 @@ public class ProfilesComboBox extends JComboBox {
|
||||
if (value instanceof Profile) {
|
||||
final Profile profile = (Profile)value;
|
||||
setText(profile.getName());
|
||||
setIcon(profile.isLocal() ? AllIcons.General.Settings : AllIcons.General.ProjectSettings);
|
||||
setIcon(profile.isProjectLevel() ? AllIcons.General.ProjectSettings : AllIcons.General.Settings);
|
||||
}
|
||||
else if (value instanceof String) {
|
||||
setText((String)value);
|
||||
@@ -74,11 +76,14 @@ public class ProfilesComboBox extends JComboBox {
|
||||
private Object myDeselectedItem = null;
|
||||
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (myFrozenProfilesCombo) return; //do not update during reloading
|
||||
if (ItemEvent.SELECTED == e.getStateChange()) {
|
||||
public void itemStateChanged(@NotNull ItemEvent e) {
|
||||
if (myFrozenProfilesCombo) {
|
||||
// do not update during reloading
|
||||
return;
|
||||
}
|
||||
else if (ItemEvent.SELECTED == e.getStateChange()) {
|
||||
final Object item = e.getItem();
|
||||
if (profileManager instanceof ProjectProfileManager && item instanceof Profile && ((Profile)item).isLocal()) {
|
||||
if (profileManager instanceof ProjectProfileManager && item instanceof Profile && !((Profile)item).isProjectLevel()) {
|
||||
if (Messages.showOkCancelDialog(InspectionsBundle.message("inspection.new.profile.ide.to.project.warning.message"),
|
||||
InspectionsBundle.message("inspection.new.profile.ide.to.project.warning.title"),
|
||||
Messages.getErrorIcon()) == Messages.OK) {
|
||||
@@ -86,7 +91,7 @@ public class ProfilesComboBox extends JComboBox {
|
||||
InspectionsBundle.message("inspection.new.profile.dialog.title"),
|
||||
Messages.getInformationIcon());
|
||||
final Object selectedItem = getSelectedItem();
|
||||
if (newName != null && newName.length() > 0 && selectedItem instanceof Profile) {
|
||||
if (!StringUtil.isEmpty(newName) && selectedItem instanceof Profile) {
|
||||
if (ArrayUtil.find(profileManager.getAvailableProfileNames(), newName) == -1 &&
|
||||
ArrayUtil.find(InspectionProfileManager.getInstance().getAvailableProfileNames(), newName) == -1) {
|
||||
saveNewProjectProfile(newName, (Profile)selectedItem, profileManager);
|
||||
@@ -112,7 +117,7 @@ public class ProfilesComboBox extends JComboBox {
|
||||
InspectionProfileImpl inspectionProfile = new InspectionProfileImpl(newName, InspectionToolRegistrar.getInstance(), profileManager);
|
||||
final ModifiableModel profileModifiableModel = inspectionProfile.getModifiableModel();
|
||||
profileModifiableModel.copyFrom(profile);
|
||||
profileModifiableModel.setLocal(false);
|
||||
profileModifiableModel.setProjectLevel(true);
|
||||
profileModifiableModel.setName(newName);
|
||||
((DefaultComboBoxModel)getModel()).addElement(profileModifiableModel);
|
||||
setSelectedItem(profileModifiableModel);
|
||||
@@ -138,8 +143,8 @@ public class ProfilesComboBox extends JComboBox {
|
||||
for (Profile profile : availableProfiles) {
|
||||
model.addElement(profile);
|
||||
}
|
||||
if (selectedProfile != null && ((selectedProfile.isLocal() && profileManager instanceof ApplicationProfileManager) ||
|
||||
(!selectedProfile.isLocal() && profileManager instanceof ProjectProfileManager))) {
|
||||
if (selectedProfile != null && ((!selectedProfile.isProjectLevel() && profileManager instanceof ApplicationProfileManager) ||
|
||||
(selectedProfile.isProjectLevel() && profileManager instanceof ProjectProfileManager))) {
|
||||
setSelectedItem(selectedProfile);
|
||||
}
|
||||
else {
|
||||
|
||||
+21
-22
@@ -172,26 +172,26 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
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.setLocal(true);
|
||||
profileModifiableModel.setModified(true);
|
||||
return profileModifiableModel;
|
||||
} else if (initValue == 0) {
|
||||
inspectionProfile.copyFrom(selectedProfile);
|
||||
inspectionProfile.setName(profileName);
|
||||
inspectionProfile.initInspectionTools(project);
|
||||
inspectionProfile.setModified(true);
|
||||
return inspectionProfile;
|
||||
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);
|
||||
}
|
||||
return null;
|
||||
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
|
||||
@@ -1142,9 +1142,8 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
return;
|
||||
}
|
||||
final ModifiableModel selectedProfile = getSelectedProfile();
|
||||
final ProfileManager profileManager =
|
||||
myShareProfile ? myProjectProfileManager : InspectionProfileManager.getInstance();
|
||||
selectedProfile.setLocal(!myShareProfile);
|
||||
ProfileManager profileManager = myShareProfile ? myProjectProfileManager : InspectionProfileManager.getInstance();
|
||||
selectedProfile.setProjectLevel(myShareProfile);
|
||||
if (selectedProfile.getProfileManager() != profileManager) {
|
||||
if (selectedProfile.getProfileManager().getProfile(selectedProfile.getName(), false) != null) {
|
||||
selectedProfile.getProfileManager().deleteProfile(selectedProfile.getName());
|
||||
|
||||
+11
-5
@@ -26,7 +26,10 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
|
||||
import com.intellij.codeInspection.InspectionManager;
|
||||
import com.intellij.codeInspection.ModifiableModel;
|
||||
import com.intellij.codeInspection.ex.*;
|
||||
import com.intellij.codeInspection.ex.InspectionManagerEx;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
|
||||
import com.intellij.codeInspection.ex.InspectionToolWrapper;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -54,7 +57,10 @@ import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.profile.codeInspection.ui.ErrorsConfigurable;
|
||||
import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jdom.Document;
|
||||
@@ -145,7 +151,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
if (newProfile != null) {
|
||||
final InspectionProfileImpl modifiableModel = (InspectionProfileImpl)newProfile.getModifiableModel();
|
||||
modifiableModel.setModified(true);
|
||||
modifiableModel.setLocal(true);
|
||||
modifiableModel.setProjectLevel(false);
|
||||
addProfile(modifiableModel);
|
||||
rename(modifiableModel);
|
||||
}
|
||||
@@ -300,7 +306,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
}
|
||||
}
|
||||
profile.readExternal(rootElement);
|
||||
profile.setLocal(true);
|
||||
profile.setProjectLevel(false);
|
||||
profile.initInspectionTools(getProject());
|
||||
if (getProfilePanel(profile) != null) {
|
||||
if (Messages.showOkCancelDialog(myWholePanel, "Profile with name \'" +
|
||||
@@ -525,7 +531,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
|
||||
return new SingleInspectionProfilePanel(myProjectProfileManager, profileName, profile) {
|
||||
@Override
|
||||
protected boolean accept(InspectionToolWrapper entry) {
|
||||
return super.accept(entry) && InspectionToolsConfigurable.this.acceptTool(entry);
|
||||
return super.accept(entry) && acceptTool(entry);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -242,7 +242,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
bus.connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter(){
|
||||
@Override
|
||||
public void after(@NotNull List<? extends VFileEvent> events) {
|
||||
Set<VirtualFile> files = ContainerUtil.map2Set(events, new Function<VFileEvent, VirtualFile>() {
|
||||
Collection<VirtualFile> files = ContainerUtil.map2Set(events, new Function<VFileEvent, VirtualFile>() {
|
||||
@Override
|
||||
public VirtualFile fun(VFileEvent event) {
|
||||
VirtualFile file = event instanceof VFileCreateEvent ? null : event.getFile();
|
||||
|
||||
@@ -220,8 +220,7 @@ class BeanBinding extends Binding {
|
||||
|
||||
private static String getTagNameFromAnnotation(Class<?> aClass) {
|
||||
Tag tag = aClass.getAnnotation(Tag.class);
|
||||
if (tag != null && !tag.value().isEmpty()) return tag.value();
|
||||
return null;
|
||||
return tag != null && !tag.value().isEmpty() ? tag.value() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -287,6 +286,7 @@ class BeanBinding extends Binding {
|
||||
field.getAnnotation(Tag.class) != null ||
|
||||
field.getAnnotation(Attribute.class) != null ||
|
||||
field.getAnnotation(Property.class) != null ||
|
||||
field.getAnnotation(Text.class) != null ||
|
||||
(Modifier.isPublic(modifiers) &&
|
||||
!Modifier.isFinal(modifiers) &&
|
||||
!Modifier.isTransient(modifiers) &&
|
||||
@@ -332,7 +332,7 @@ class BeanBinding extends Binding {
|
||||
}
|
||||
|
||||
Tag tag = accessor.getAnnotation(Tag.class);
|
||||
if (tag != null && !tag.value().isEmpty()) {
|
||||
if (tag != null) {
|
||||
return new TagBinding(accessor, tag);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public final class SmartSerializer {
|
||||
private final LinkedHashSet<String> mySerializedAccessorNameTracker;
|
||||
private LinkedHashSet<String> mySerializedAccessorNameTracker;
|
||||
private TObjectFloatHashMap<String> myOrderedBindings;
|
||||
private final SerializationFilter mySerializationFilter;
|
||||
|
||||
@@ -53,6 +53,11 @@ public final class SmartSerializer {
|
||||
this(true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static SmartSerializer skipEmptySerializer() {
|
||||
return new SmartSerializer(true, true);
|
||||
}
|
||||
|
||||
public void readExternal(@NotNull Object bean, @NotNull Element element) {
|
||||
if (mySerializedAccessorNameTracker != null) {
|
||||
mySerializedAccessorNameTracker.clear();
|
||||
@@ -68,11 +73,28 @@ public final class SmartSerializer {
|
||||
}
|
||||
|
||||
public void writeExternal(@NotNull Object bean, @NotNull Element element) {
|
||||
writeExternal(bean, element, true);
|
||||
}
|
||||
|
||||
public void writeExternal(@NotNull Object bean, @NotNull Element element, boolean preserveCompatibility) {
|
||||
BeanBinding binding = getBinding(bean);
|
||||
if (myOrderedBindings != null) {
|
||||
if (preserveCompatibility && myOrderedBindings != null) {
|
||||
binding.sortBindings(myOrderedBindings);
|
||||
}
|
||||
binding.serializeInto(bean, element, mySerializationFilter);
|
||||
|
||||
if (preserveCompatibility || mySerializedAccessorNameTracker == null) {
|
||||
binding.serializeInto(bean, element, mySerializationFilter);
|
||||
}
|
||||
else {
|
||||
LinkedHashSet<String> oldTracker = mySerializedAccessorNameTracker;
|
||||
try {
|
||||
mySerializedAccessorNameTracker = null;
|
||||
binding.serializeInto(bean, element, mySerializationFilter);
|
||||
}
|
||||
finally {
|
||||
mySerializedAccessorNameTracker = oldTracker;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -31,10 +31,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
@@ -151,9 +148,11 @@ public class CopyrightManager extends AbstractProjectComponent implements Persis
|
||||
try {
|
||||
if (!myCopyrights.isEmpty()) {
|
||||
for (CopyrightProfile copyright : myCopyrights.values()) {
|
||||
final Element copyrightElement = new Element(COPYRIGHT);
|
||||
Element copyrightElement = new Element(COPYRIGHT);
|
||||
copyright.writeExternal(copyrightElement);
|
||||
state.addContent(copyrightElement);
|
||||
if (!JDOMUtil.isEmpty(copyrightElement)) {
|
||||
state.addContent(copyrightElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +177,7 @@ public class CopyrightManager extends AbstractProjectComponent implements Persis
|
||||
if (myDefaultCopyright != null) {
|
||||
state.setAttribute(DEFAULT, myDefaultCopyright.getName());
|
||||
}
|
||||
else {
|
||||
else if (!myProject.isDefault()) {
|
||||
// todo we still add empty attribute to avoid annoying change (idea 12 - attribute exists, idea 13 - attribute doesn't exists)
|
||||
// CR-IC-3403#CFR-62470, idea <= 12 compatibility
|
||||
state.setAttribute(DEFAULT, "");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,13 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.copyright;
|
||||
|
||||
import com.intellij.profile.ProfileEx;
|
||||
import com.intellij.util.xmlb.SmartSerializer;
|
||||
import com.maddyhome.idea.copyright.pattern.EntityUtil;
|
||||
|
||||
public class CopyrightProfile extends ProfileEx {
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public static final String DEFAULT_COPYRIGHT_NOTICE =
|
||||
EntityUtil.encode("Copyright (c) $today.year. Lorem ipsum dolor sit amet, consectetur adipiscing elit. \n" +
|
||||
"Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. \n" +
|
||||
@@ -27,17 +28,17 @@ public class CopyrightProfile extends ProfileEx {
|
||||
"Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. \n" +
|
||||
"Vestibulum commodo. Ut rhoncus gravida arcu. ");
|
||||
|
||||
public String notice = DEFAULT_COPYRIGHT_NOTICE;
|
||||
public String keyword = EntityUtil.encode("Copyright");
|
||||
public String allowReplaceKeyword = "";
|
||||
private String notice = DEFAULT_COPYRIGHT_NOTICE;
|
||||
private String keyword = EntityUtil.encode("Copyright");
|
||||
private String allowReplaceKeyword = "";
|
||||
|
||||
//read external
|
||||
public CopyrightProfile() {
|
||||
super("");
|
||||
super("", new SmartSerializer());
|
||||
}
|
||||
|
||||
public CopyrightProfile(String profileName) {
|
||||
super(profileName);
|
||||
super(profileName, new SmartSerializer());
|
||||
}
|
||||
|
||||
public String getNotice() {
|
||||
|
||||
@@ -150,7 +150,7 @@ public abstract class UpdatePsiFileCopyright extends AbstractUpdateCopyright {
|
||||
String oldComment = doc.getCharsSequence()
|
||||
.subSequence(range.getFirst().getTextRange().getStartOffset(), range.getLast().getTextRange().getEndOffset()).toString().trim();
|
||||
if (!StringUtil.isEmptyOrSpaces(myOptions.getAllowReplaceKeyword()) &&
|
||||
!oldComment.contains(myOptions.allowReplaceKeyword)) {
|
||||
!oldComment.contains(myOptions.getAllowReplaceKeyword())) {
|
||||
return;
|
||||
}
|
||||
if (newComment.trim().equals(oldComment)) {
|
||||
|
||||
Reference in New Issue
Block a user