Search in sources :

Example 11 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class ToolsProcessor method readScheme.

@NotNull
@Override
public ToolsGroup<T> readScheme(@NotNull Element root, boolean duringLoad) throws InvalidDataException, IOException, JDOMException {
    if (!TOOL_SET.equals(root.getName())) {
        throw new InvalidDataException();
    }
    String attrName = root.getAttributeValue(ATTRIBUTE_NAME);
    String groupName = StringUtil.isEmpty(attrName) ? Tool.DEFAULT_GROUP_NAME : attrName;
    ToolsGroup<T> result = createToolsGroup(groupName);
    final PathMacroManager macroManager = PathMacroManager.getInstance(ApplicationManager.getApplication());
    for (Element element : root.getChildren(TOOL)) {
        T tool = createTool();
        readToolAttributes(element, tool);
        Element exec = element.getChild(EXEC);
        if (exec != null) {
            for (final Object o1 : exec.getChildren(ELEMENT_OPTION)) {
                Element optionElement = (Element) o1;
                String name = optionElement.getAttributeValue(ATTRIBUTE_NAME);
                String value = optionElement.getAttributeValue(ATTRIBUTE_VALUE);
                if (WORKING_DIRECTORY.equals(name)) {
                    if (value != null) {
                        final String replace = macroManager.expandPath(value).replace('/', File.separatorChar);
                        tool.setWorkingDirectory(replace);
                    }
                }
                if (COMMAND.equals(name)) {
                    tool.setProgram(macroManager.expandPath(BaseToolManager.convertString(value)));
                }
                if (PARAMETERS.equals(name)) {
                    tool.setParameters(macroManager.expandPath(BaseToolManager.convertString(value)));
                }
            }
        }
        for (final Object o2 : element.getChildren(FILTER)) {
            Element childNode = (Element) o2;
            FilterInfo filterInfo = new FilterInfo();
            filterInfo.readExternal(childNode);
            tool.addOutputFilter(filterInfo);
        }
        tool.setGroup(groupName);
        result.addElement(tool);
    }
    return result;
}
Also used : Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException) PathMacroManager(com.intellij.openapi.components.PathMacroManager) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class ConfigFileInfoSetImpl method readExternal.

public void readExternal(final Element element) throws InvalidDataException {
    myConfigFiles.clear();
    List<Element> children = element.getChildren(ELEMENT_NAME);
    for (Element child : children) {
        final String id = child.getAttributeValue(ID_ATTRIBUTE);
        if (id != null) {
            final ConfigFileMetaData metaData = myMetaDataProvider.findMetaData(id);
            if (metaData != null) {
                final String url = child.getAttributeValue(URL_ATTRIBUTE);
                if (url == null)
                    throw new InvalidDataException(URL_ATTRIBUTE + " attribute not specified for " + id + " descriptor");
                myConfigFiles.put(metaData, new ConfigFileInfo(metaData, url));
            }
        }
    }
    onChange();
}
Also used : Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 13 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class MigrationMapSet method loadMaps.

private void loadMaps() {
    myMaps = new ArrayList<>();
    File dir = getMapDirectory();
    copyPredefinedMaps(dir);
    File[] files = getMapFiles(dir);
    for (int i = 0; i < files.length; i++) {
        try {
            MigrationMap map = readMap(files[i]);
            if (map != null) {
                map.setFileName(FileUtil.getNameWithoutExtension(files[i]));
                myMaps.add(map);
            }
        } catch (InvalidDataException | JDOMException e) {
            LOG.error("Invalid data in file: " + files[i].getAbsolutePath());
        } catch (IOException e) {
            LOG.error(e);
        }
    }
}
Also used : InvalidDataException(com.intellij.openapi.util.InvalidDataException) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException) File(java.io.File)

Example 14 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class ContentEntryImpl method getUrlFrom.

private static String getUrlFrom(@NotNull Element e) throws InvalidDataException {
    LOG.assertTrue(ELEMENT_NAME.equals(e.getName()));
    String url = e.getAttributeValue(URL_ATTRIBUTE);
    if (url == null)
        throw new InvalidDataException();
    return url;
}
Also used : InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 15 with InvalidDataException

use of com.intellij.openapi.util.InvalidDataException in project intellij-community by JetBrains.

the class ProjectLevelVcsManagerSerialization method readExternalUtil.

public void readExternalUtil(final Element element, final OptionsAndConfirmations optionsAndConfirmations) throws InvalidDataException {
    final Map<String, VcsShowOptionsSettingImpl> options = optionsAndConfirmations.getOptions();
    for (Element subElement : element.getChildren(OPTIONS_SETTING)) {
        final String id = subElement.getAttributeValue(ID_ATTRIBUTE);
        final String value = subElement.getAttributeValue(VALUE_ATTTIBUTE);
        if (id != null && value != null) {
            try {
                getOrCreateOption(options, id).setValue(Boolean.parseBoolean(value));
            } catch (Exception ignored) {
            }
        }
    }
    myReadValue.clear();
    for (Element subElement : element.getChildren(CONFIRMATIONS_SETTING)) {
        final String id = subElement.getAttributeValue(ID_ATTRIBUTE);
        final String value = subElement.getAttributeValue(VALUE_ATTTIBUTE);
        if (id != null && value != null) {
            try {
                myReadValue.put(id, VcsShowConfirmationOption.Value.fromString(value));
            } catch (Exception ignored) {
            }
        }
    }
}
Also used : Element(org.jdom.Element) VcsShowOptionsSettingImpl(com.intellij.openapi.vcs.VcsShowOptionsSettingImpl) InvalidDataException(com.intellij.openapi.util.InvalidDataException) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Aggregations

InvalidDataException (com.intellij.openapi.util.InvalidDataException)36 Element (org.jdom.Element)24 WriteExternalException (com.intellij.openapi.util.WriteExternalException)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 JDOMException (org.jdom.JDOMException)5 NotNull (org.jetbrains.annotations.NotNull)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 File (java.io.File)4 List (java.util.List)4 TreeState (com.intellij.ide.util.treeView.TreeState)3 Nullable (org.jetbrains.annotations.Nullable)3 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 DescriptionAwareSchemeActions (com.intellij.application.options.schemes.DescriptionAwareSchemeActions)1 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)1 InspectionProfileModifiableModel (com.intellij.codeInspection.ex.InspectionProfileModifiableModel)1 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)1 UnsupportedExpressionException (com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException)1 ExecutionException (com.intellij.execution.ExecutionException)1