mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
profiles: ignore empty files
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<option name="PROJECT_PROFILE" value="p1" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
<profiles>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
@@ -17,6 +14,9 @@
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</profiles>
|
||||
<option name="PROJECT_PROFILE" value="p1" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
<list size="5">
|
||||
<item index="0" class="java.lang.String" itemvalue="TYPO" />
|
||||
<item index="1" class="java.lang.String" itemvalue="SERVER PROBLEM" />
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<option name="PROJECT_PROFILE" value="p1" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
<profiles>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
@@ -21,6 +18,9 @@
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</profiles>
|
||||
<option name="PROJECT_PROFILE" value="p1" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
<list size="5">
|
||||
<item index="0" class="java.lang.String" itemvalue="TYPO" />
|
||||
<item index="1" class="java.lang.String" itemvalue="SERVER PROBLEM" />
|
||||
|
||||
@@ -115,22 +115,39 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
DefaultJDOMExternalizer.writeExternal(this, element);
|
||||
Element version = new Element("version");
|
||||
version.setAttribute("value", VERSION);
|
||||
element.addContent(version);
|
||||
|
||||
final List<String> sortedProfiles = new ArrayList<String>(myProfiles.keySet());
|
||||
Element profiles = null;
|
||||
Collections.sort(sortedProfiles);
|
||||
final Element profiles = new Element(PROFILES);
|
||||
for (String profile : sortedProfiles) {
|
||||
final Profile projectProfile = myProfiles.get(profile);
|
||||
if (projectProfile != null) {
|
||||
final Element profileElement = new Element(PROFILE);
|
||||
projectProfile.writeExternal(profileElement);
|
||||
boolean hasSmthToSave = sortedProfiles.size() > 1;
|
||||
for (Object child : profileElement.getChildren()) {
|
||||
if (!((Element)child).getName().equals("option")) {
|
||||
hasSmthToSave = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasSmthToSave) continue;
|
||||
|
||||
if (profiles == null) {
|
||||
profiles = new Element(PROFILES);
|
||||
element.addContent(profiles);
|
||||
}
|
||||
|
||||
profiles.addContent(profileElement);
|
||||
}
|
||||
}
|
||||
element.addContent(profiles);
|
||||
|
||||
if (profiles != null) {
|
||||
DefaultJDOMExternalizer.writeExternal(this, element);
|
||||
final Element version = new Element("version");
|
||||
version.setAttribute("value", VERSION);
|
||||
element.addContent(version);
|
||||
}
|
||||
}
|
||||
|
||||
public NamedScopesHolder getScopesManager() {
|
||||
@@ -230,7 +247,7 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
}
|
||||
|
||||
|
||||
result.add(new Pair<Element, String>(e, generator.generateUniqueName("profiles_settings") + ".xml"));
|
||||
if (!e.getContent().isEmpty()) result.add(new Pair<Element, String>(e, generator.generateUniqueName("profiles_settings") + ".xml"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
myOrder.retainAll(knownSeverities);
|
||||
|
||||
if (myOrder.isEmpty()) {
|
||||
initOrder();
|
||||
myOrder.addAll(getDefaultOrder());
|
||||
}
|
||||
//enforce include all known
|
||||
for (int i = 0; i < knownSeverities.size(); i++) {
|
||||
@@ -175,7 +175,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
for (String severity : myOrder) {
|
||||
for (String severity : getOrder()) {
|
||||
Element info = new Element(INFO);
|
||||
final SeverityBasedTextAttributes infoType = ourMap.get(severity);
|
||||
if (infoType != null) {
|
||||
@@ -187,10 +187,12 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
element.addContent(info);
|
||||
}
|
||||
}
|
||||
if (myReadOrder != null) {
|
||||
if (myReadOrder != null && !myReadOrder.isEmpty()) {
|
||||
myReadOrder.writeExternal(element);
|
||||
} else {
|
||||
myOrder.writeExternal(element);
|
||||
if (!getDefaultOrder().equals(getOrder())) {
|
||||
getOrder().writeExternal(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,12 +240,12 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
|
||||
private JDOMExternalizableStringList getOrder() {
|
||||
if (myOrder.isEmpty()) {
|
||||
initOrder();
|
||||
myOrder.addAll(getDefaultOrder());
|
||||
}
|
||||
return myOrder;
|
||||
}
|
||||
|
||||
private void initOrder() {
|
||||
private List<String> getDefaultOrder() {
|
||||
final List<HighlightSeverity> order = new ArrayList<HighlightSeverity>();
|
||||
for (HighlightInfoType type : STANDART_SEVERITIES.values()) {
|
||||
order.add(type.getSeverity(null));
|
||||
@@ -252,9 +254,11 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
|
||||
order.add(attributes.getSeverity());
|
||||
}
|
||||
Collections.sort(order);
|
||||
final List<String> result = new ArrayList<String>();
|
||||
for (HighlightSeverity severity : order) {
|
||||
myOrder.add(severity.toString());
|
||||
result.add(severity.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setOrder(List<String> order) {
|
||||
|
||||
@@ -87,6 +87,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
myRegistrar = inspectionProfile.myRegistrar;
|
||||
myTools = new HashMap<String, ToolsImpl>();
|
||||
myVisibleTreeState = new VisibleTreeState(inspectionProfile.myVisibleTreeState);
|
||||
myDeinstalledInspectionsSettings = new LinkedHashMap<String, Element>(inspectionProfile.myDeinstalledInspectionsSettings);
|
||||
|
||||
myBaseProfile = inspectionProfile.myBaseProfile;
|
||||
myLocal = inspectionProfile.myLocal;
|
||||
|
||||
Reference in New Issue
Block a user