use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class ScopeToolState method equalTo.
public boolean equalTo(@NotNull ScopeToolState state2) {
if (isEnabled() != state2.isEnabled())
return false;
if (getLevel() != state2.getLevel())
return false;
InspectionToolWrapper toolWrapper = getTool();
InspectionToolWrapper toolWrapper2 = state2.getTool();
if (!toolWrapper.isInitialized() && !toolWrapper2.isInitialized())
return true;
try {
@NonNls String tempRoot = "root";
Element oldToolSettings = new Element(tempRoot);
toolWrapper.getTool().writeSettings(oldToolSettings);
Element newToolSettings = new Element(tempRoot);
toolWrapper2.getTool().writeSettings(newToolSettings);
return JDOMUtil.areElementsEqual(oldToolSettings, newToolSettings);
} catch (WriteExternalException e) {
LOG.error(e);
}
return false;
}
use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class ClasspathStorage method getSerializedState.
@Nullable
@Override
public Element getSerializedState(@NotNull Boolean storageData, Object component, @NotNull String componentName, boolean archive) {
if (storageData) {
return null;
}
Element element = new Element("component");
ModifiableRootModel model = null;
AccessToken token = ReadAction.start();
try {
model = ((ModuleRootManagerImpl) component).getModifiableModel();
// IDEA-137969 Eclipse integration: external remove of classpathentry is not synchronized
model.clear();
try {
myConverter.readClasspath(model);
} catch (IOException e) {
throw new RuntimeException(e);
}
((RootModelImpl) model).writeExternal(element);
} catch (WriteExternalException e) {
LOG.error(e);
} finally {
try {
token.finish();
} finally {
if (model != null) {
model.dispose();
}
}
}
if (myPathMacroSubstitutor != null) {
myPathMacroSubstitutor.expandPaths(element);
myPathMacroSubstitutor.addUnknownMacros("NewModuleRootManager", PathMacrosCollector.getMacroNames(element));
}
getStorageDataRef().set(true);
return element;
}
use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class RunConfigurationExtensionsManager method writeExternal.
public void writeExternal(@NotNull U configuration, @NotNull Element parentNode) {
final TreeMap<String, Element> map = ContainerUtil.newTreeMap();
final List<Element> elements = configuration.getCopyableUserData(RUN_EXTENSIONS);
if (elements != null) {
for (Element element : elements) {
map.put(element.getAttributeValue(getIdAttrName()), element.clone());
}
}
for (T extension : getApplicableExtensions(configuration)) {
Element element = new Element(getExtensionRootAttr());
element.setAttribute(getIdAttrName(), extension.getSerializationId());
try {
extension.writeExternal(configuration, element);
} catch (WriteExternalException ignored) {
continue;
}
if (!element.getContent().isEmpty() || element.getAttributes().size() > 1) {
map.put(extension.getSerializationId(), element);
}
}
for (Element values : map.values()) {
parentNode.addContent(values);
}
}
use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class ModuleBasedConfiguration method clone.
@Override
public ModuleBasedConfiguration clone() {
final Element element = new Element(TO_CLONE_ELEMENT_NAME);
try {
writeExternal(element);
RunConfiguration configuration = getFactory().createTemplateConfiguration(getProject());
configuration.setName(getName());
configuration.readExternal(element);
return (ModuleBasedConfiguration) configuration;
} catch (InvalidDataException | WriteExternalException e) {
LOG.error(e);
return null;
}
}
use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class LogConsolePreferences method getState.
@Override
public Element getState() {
@NonNls Element element = new Element("LogFilters");
try {
for (LogFilter filter : myRegisteredLogFilters.keySet()) {
Element filterElement = new Element(FILTER);
filterElement.setAttribute(IS_ACTIVE, myRegisteredLogFilters.get(filter).toString());
filter.writeExternal(filterElement);
element.addContent(filterElement);
}
DefaultJDOMExternalizer.writeExternal(this, element);
} catch (WriteExternalException e) {
LOG.error(e);
}
return element;
}
Aggregations