mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -15,10 +15,12 @@
|
||||
*/
|
||||
package com.intellij.openapi.util.registry;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.components.StoragePathMacros;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
@@ -28,7 +30,7 @@ import java.util.TreeMap;
|
||||
name = "Registry",
|
||||
storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml")
|
||||
)
|
||||
public class RegistryState implements BaseComponent, PersistentStateComponent<Element> {
|
||||
public class RegistryState implements PersistentStateComponent<Element> {
|
||||
private static final Logger LOG = Logger.getInstance(RegistryState.class);
|
||||
|
||||
@Override
|
||||
@@ -48,18 +50,4 @@ public class RegistryState implements BaseComponent, PersistentStateComponent<El
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "Registry";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -35,7 +35,6 @@ public class Registry {
|
||||
public static final String REGISTRY_BUNDLE = "misc.registry";
|
||||
|
||||
private final Map<String, String> myUserProperties = new LinkedHashMap<String, String>();
|
||||
private final Map<String, String> myLoadedUserProperties = new HashMap<String, String>();
|
||||
private final Map<String, RegistryValue> myValues = new ConcurrentHashMap<String, RegistryValue>();
|
||||
|
||||
private static final Registry ourInstance = new Registry();
|
||||
@@ -119,20 +118,18 @@ public class Registry {
|
||||
}
|
||||
|
||||
public void loadState(@NotNull Element state) {
|
||||
final List entries = state.getChildren("entry");
|
||||
for (Object each : entries) {
|
||||
final Element eachEntry = (Element) each;
|
||||
final String eachKey = eachEntry.getAttributeValue("key");
|
||||
final String eachValue = eachEntry.getAttributeValue("value");
|
||||
if (eachKey != null && eachValue != null) {
|
||||
myUserProperties.put(eachKey, eachValue);
|
||||
myUserProperties.clear();
|
||||
for (Element eachEntry : state.getChildren("entry")) {
|
||||
String key = eachEntry.getAttributeValue("key");
|
||||
String value = eachEntry.getAttributeValue("value");
|
||||
if (key != null && value != null) {
|
||||
RegistryValue registryValue = get(key);
|
||||
if (registryValue.isChangedFromDefault(value)) {
|
||||
myUserProperties.put(key, value);
|
||||
registryValue.resetCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
myLoadedUserProperties.putAll(myUserProperties);
|
||||
|
||||
for (RegistryValue each : myValues.values()) {
|
||||
each.resetCache();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -165,11 +162,11 @@ public class Registry {
|
||||
}
|
||||
|
||||
public boolean isInDefaultState() {
|
||||
return getUserProperties().isEmpty();
|
||||
return myUserProperties.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isRestartNeeded() {
|
||||
return isRestartNeeded(myUserProperties) || isRestartNeeded(myLoadedUserProperties);
|
||||
return isRestartNeeded(myUserProperties);
|
||||
}
|
||||
|
||||
private static boolean isRestartNeeded(@NotNull Map<String, String> map) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -109,7 +109,11 @@ public class RegistryValue {
|
||||
}
|
||||
|
||||
public boolean isChangedFromDefault() {
|
||||
return !asString().equals(getBundleValue(myKey, false));
|
||||
return isChangedFromDefault(asString());
|
||||
}
|
||||
|
||||
boolean isChangedFromDefault(@NotNull String newValue) {
|
||||
return !newValue.equals(getBundleValue(myKey, false));
|
||||
}
|
||||
|
||||
private String get(@NotNull String key, String defaultValue, boolean isValue) throws MissingResourceException {
|
||||
|
||||
Reference in New Issue
Block a user