mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not save default usage.statistics.xml
This commit is contained in:
@@ -27,18 +27,21 @@ class DoNotSaveDefaultsTest {
|
||||
val app = ApplicationManager.getApplication() as ApplicationImpl
|
||||
val directory = app.stateStore.stateStorageManager.expandMacros(APP_CONFIG)
|
||||
val dirPath = Paths.get(directory)
|
||||
val useModCountOldValue = System.getProperty("store.save.use.modificationCount")
|
||||
try {
|
||||
System.setProperty("store.save.use.modificationCount", "false")
|
||||
app.doNotSave(false)
|
||||
runInEdtAndWait {
|
||||
app.saveAll()
|
||||
}
|
||||
}
|
||||
finally {
|
||||
System.setProperty("store.save.use.modificationCount", useModCountOldValue ?: "false")
|
||||
app.doNotSave(true)
|
||||
}
|
||||
|
||||
println(directory)
|
||||
println(printDirectoryTree(dirPath.toFile()))
|
||||
println(printDirectoryTree(dirPath))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.intellij.configurationStore
|
||||
|
||||
import java.io.File
|
||||
import com.intellij.util.io.directoryStreamIfExists
|
||||
import com.intellij.util.io.isDirectory
|
||||
import java.nio.file.Path
|
||||
|
||||
fun printDirectoryTree(folder: File): String {
|
||||
if (!folder.isDirectory) {
|
||||
fun printDirectoryTree(folder: Path): String {
|
||||
if (!folder.isDirectory()) {
|
||||
throw IllegalArgumentException("folder is not a Directory")
|
||||
}
|
||||
val indent = 0
|
||||
@@ -12,17 +14,17 @@ fun printDirectoryTree(folder: File): String {
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
private fun printDirectoryTree(folder: File, indent: Int, sb: StringBuilder) {
|
||||
if (!folder.isDirectory) {
|
||||
private fun printDirectoryTree(dir: Path, indent: Int, sb: StringBuilder) {
|
||||
if (!dir.isDirectory()) {
|
||||
throw IllegalArgumentException("folder is not a Directory")
|
||||
}
|
||||
getIndentString(indent, sb)
|
||||
sb.append("\u251c\u2500\u2500")
|
||||
sb.append(folder.name)
|
||||
sb.append(dir.fileName.toString())
|
||||
sb.append("/")
|
||||
sb.append("\n")
|
||||
for (file in folder.listFiles()!!) {
|
||||
if (file.isDirectory) {
|
||||
for (file in dir.directoryStreamIfExists { it.map { it } }!!) {
|
||||
if (file.isDirectory()) {
|
||||
printDirectoryTree(file, indent + 1, sb)
|
||||
}
|
||||
else {
|
||||
@@ -31,10 +33,10 @@ private fun printDirectoryTree(folder: File, indent: Int, sb: StringBuilder) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun printFile(file: File, indent: Int, sb: StringBuilder) {
|
||||
private fun printFile(file: Path, indent: Int, sb: StringBuilder) {
|
||||
getIndentString(indent, sb)
|
||||
sb.append("\u251c\u2500\u2500")
|
||||
sb.append(file.name)
|
||||
sb.append(file.fileName.toString())
|
||||
sb.append("\n")
|
||||
}
|
||||
|
||||
|
||||
+19
-12
@@ -29,7 +29,6 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -66,9 +65,7 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste
|
||||
|
||||
@Override
|
||||
public void loadState(final Element element) {
|
||||
List groupsList = element.getChildren(GROUP_TAG);
|
||||
for (Object project : groupsList) {
|
||||
Element groupElement = (Element)project;
|
||||
for (Element groupElement : element.getChildren(GROUP_TAG)) {
|
||||
String groupId = groupElement.getAttributeValue(GROUP_ID_ATTR);
|
||||
double groupPriority = getPriority(groupElement.getAttributeValue(GROUP_PRIORITY_ATTR));
|
||||
|
||||
@@ -76,14 +73,15 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste
|
||||
if (!StringUtil.isEmptyOrSpaces(groupId) && !StringUtil.isEmptyOrSpaces(valueData)) {
|
||||
try {
|
||||
getSentUsages().putAll(ConvertUsagesUtil.convertValueString(GroupDescriptor.create(groupId, groupPriority), valueData));
|
||||
} catch (AssertionError e) {
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
//don't load incorrect groups
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
setSentTime(Long.parseLong(element.getAttributeValue(LAST_TIME_ATTR)));
|
||||
setSentTime(Long.parseLong(element.getAttributeValue(LAST_TIME_ATTR, "0")));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
setSentTime(0);
|
||||
@@ -102,8 +100,7 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste
|
||||
public Element getState() {
|
||||
Element element = new Element("state");
|
||||
|
||||
for (Map.Entry<GroupDescriptor, Set<UsageDescriptor>> entry : ConvertUsagesUtil.sortDescriptorsByPriority(getSentUsages())
|
||||
.entrySet()) {
|
||||
for (Map.Entry<GroupDescriptor, Set<UsageDescriptor>> entry : ConvertUsagesUtil.sortDescriptorsByPriority(getSentUsages()).entrySet()) {
|
||||
Element projectElement = new Element(GROUP_TAG);
|
||||
projectElement.setAttribute(GROUP_ID_ATTR, entry.getKey().getId());
|
||||
projectElement.setAttribute(GROUP_PRIORITY_ATTR, Double.toString(entry.getKey().getPriority()));
|
||||
@@ -112,10 +109,20 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste
|
||||
element.addContent(projectElement);
|
||||
}
|
||||
|
||||
element.setAttribute(LAST_TIME_ATTR, String.valueOf(getLastTimeSent()));
|
||||
element.setAttribute(IS_ALLOWED_ATTR, String.valueOf(isAllowed()));
|
||||
element.setAttribute(SHOW_NOTIFICATION_ATTR, String.valueOf(isShowNotification()));
|
||||
element.setAttribute(PERIOD_ATTR, myPeriod.getName());
|
||||
long lastTimeSent = getLastTimeSent();
|
||||
if (lastTimeSent > 0) {
|
||||
element.setAttribute(LAST_TIME_ATTR, String.valueOf(lastTimeSent));
|
||||
}
|
||||
|
||||
if (isAllowed()) {
|
||||
element.setAttribute(IS_ALLOWED_ATTR, "true");
|
||||
}
|
||||
if (isShowNotification()) {
|
||||
element.setAttribute(SHOW_NOTIFICATION_ATTR, "true");
|
||||
}
|
||||
if (myPeriod != SendPeriod.WEEKLY) {
|
||||
element.setAttribute(PERIOD_ATTR, myPeriod.getName());
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user