Search in sources :

Example 6 with WriteExternalException

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;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) Element(org.jdom.Element) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Example 7 with WriteExternalException

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;
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) RootModelImpl(com.intellij.openapi.roots.impl.RootModelImpl) AccessToken(com.intellij.openapi.application.AccessToken) Element(org.jdom.Element) WriteExternalException(com.intellij.openapi.util.WriteExternalException) IOException(java.io.IOException) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with WriteExternalException

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);
    }
}
Also used : Element(org.jdom.Element) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Example 9 with WriteExternalException

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;
    }
}
Also used : Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Example 10 with WriteExternalException

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;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) Element(org.jdom.Element) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Aggregations

WriteExternalException (com.intellij.openapi.util.WriteExternalException)27 Element (org.jdom.Element)27 InvalidDataException (com.intellij.openapi.util.InvalidDataException)7 Nullable (org.jetbrains.annotations.Nullable)5 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)2 PsiElement (com.intellij.psi.PsiElement)2 NonNls (org.jetbrains.annotations.NonNls)2 NotNull (org.jetbrains.annotations.NotNull)2 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)1 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)1 LocatableConfiguration (com.intellij.execution.configurations.LocatableConfiguration)1 LocatableConfigurationBase (com.intellij.execution.configurations.LocatableConfigurationBase)1 RunProfileState (com.intellij.execution.configurations.RunProfileState)1 RuntimeConfigurationException (com.intellij.execution.configurations.RuntimeConfigurationException)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1