mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -79,6 +79,8 @@ public class ExternalizablePropertyContainer extends AbstractProperty.AbstractPr
|
||||
}
|
||||
|
||||
public void readExternal(@NotNull Element element) {
|
||||
myValues.clear();
|
||||
|
||||
Map<String, AbstractProperty> propertyByName = new THashMap<String, AbstractProperty>();
|
||||
for (AbstractProperty abstractProperty : myExternalizers.keySet()) {
|
||||
propertyByName.put(abstractProperty.getName(), abstractProperty);
|
||||
|
||||
@@ -173,32 +173,32 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis
|
||||
try {
|
||||
final Element state = new Element("state");
|
||||
getProperties().writeExternal(state);
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
for (final AntBuildFileBase buildFile : getBuildFiles()) {
|
||||
final Element element = new Element(BUILD_FILE);
|
||||
element.setAttribute(URL, buildFile.getVirtualFile().getUrl());
|
||||
buildFile.writeProperties(element);
|
||||
saveEvents(element, buildFile);
|
||||
state.addContent(element);
|
||||
}
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
for (final AntBuildFileBase buildFile : getBuildFiles()) {
|
||||
final Element element = new Element(BUILD_FILE);
|
||||
element.setAttribute(URL, buildFile.getVirtualFile().getUrl());
|
||||
buildFile.writeProperties(element);
|
||||
saveEvents(element, buildFile);
|
||||
state.addContent(element);
|
||||
}
|
||||
|
||||
final List<VirtualFile> files = new ArrayList<VirtualFile>(myAntFileToContextFileMap.keySet());
|
||||
// sort in order to minimize changes
|
||||
Collections.sort(files, (o1, o2) -> o1.getUrl().compareTo(o2.getUrl()));
|
||||
for (VirtualFile file : files) {
|
||||
final Element element = new Element(CONTEXT_MAPPING);
|
||||
final VirtualFile contextFile = myAntFileToContextFileMap.get(file);
|
||||
element.setAttribute(URL, file.getUrl());
|
||||
element.setAttribute(CONTEXT, contextFile.getUrl());
|
||||
state.addContent(element);
|
||||
}
|
||||
});
|
||||
final List<VirtualFile> files = new ArrayList<VirtualFile>(myAntFileToContextFileMap.keySet());
|
||||
// sort in order to minimize changes
|
||||
Collections.sort(files, (o1, o2) -> o1.getUrl().compareTo(o2.getUrl()));
|
||||
for (VirtualFile file : files) {
|
||||
final Element element = new Element(CONTEXT_MAPPING);
|
||||
final VirtualFile contextFile = myAntFileToContextFileMap.get(file);
|
||||
element.setAttribute(URL, file.getUrl());
|
||||
element.setAttribute(CONTEXT, contextFile.getUrl());
|
||||
state.addContent(element);
|
||||
}
|
||||
});
|
||||
return state;
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void loadState(Element state) {
|
||||
@@ -624,8 +624,7 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis
|
||||
private void loadBuildFileProjectProperties(final Element parentNode) {
|
||||
final List<Pair<Element, String>> files = new ArrayList<Pair<Element, String>>();
|
||||
final VirtualFileManager vfManager = VirtualFileManager.getInstance();
|
||||
for (final Object o : parentNode.getChildren(BUILD_FILE)) {
|
||||
final Element element = (Element)o;
|
||||
for (final Element element : parentNode.getChildren(BUILD_FILE)) {
|
||||
final String url = element.getAttributeValue(URL);
|
||||
if (url != null) {
|
||||
files.add(Pair.create(element, url));
|
||||
@@ -634,8 +633,7 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis
|
||||
|
||||
// contexts
|
||||
myAntFileToContextFileMap.clear();
|
||||
for (final Object o : parentNode.getChildren(CONTEXT_MAPPING)) {
|
||||
final Element element = (Element)o;
|
||||
for (final Element element : parentNode.getChildren(CONTEXT_MAPPING)) {
|
||||
final String url = element.getAttributeValue(URL);
|
||||
final String contextUrl = element.getAttributeValue(CONTEXT);
|
||||
final VirtualFile file = vfManager.findFileByUrl(url);
|
||||
|
||||
@@ -29,12 +29,12 @@ import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@State(name = "antWorkspaceConfiguration", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
|
||||
public class AntWorkspaceConfiguration implements PersistentStateComponent<Element> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.lang.ant.config.impl.AntWorkspaceConfiguration");
|
||||
|
||||
private final Project myProject;
|
||||
@NonNls private static final String BUILD_FILE = "buildFile";
|
||||
@NonNls private static final String URL = "url";
|
||||
@@ -68,9 +68,6 @@ public class AntWorkspaceConfiguration implements PersistentStateComponent<Eleme
|
||||
}
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
public void readExternal(Element parentNode) throws InvalidDataException {
|
||||
loadGlobalSettings(parentNode);
|
||||
myProperties.set(parentNode);
|
||||
@@ -114,10 +111,10 @@ public class AntWorkspaceConfiguration implements PersistentStateComponent<Eleme
|
||||
|
||||
@Nullable
|
||||
private static Element findChildByUrl(Element parentNode, String url) {
|
||||
List children = parentNode.getChildren(BUILD_FILE);
|
||||
for (final Object aChildren : children) {
|
||||
Element element = (Element)aChildren;
|
||||
if (Comparing.equal(element.getAttributeValue(URL), url)) return element;
|
||||
for (Element element : parentNode.getChildren(BUILD_FILE)) {
|
||||
if (Comparing.equal(element.getAttributeValue(URL), url)) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user