Search in sources :

Example 1 with InvalidDataException

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

the class MavenProjectsNavigator method scheduleStructureRequest.

private void scheduleStructureRequest(final Runnable r) {
    if (isUnitTestMode()) {
        if (myStructure != null) {
            r.run();
        }
        return;
    }
    if (myToolWindow == null)
        return;
    MavenUtil.invokeLater(myProject, () -> {
        if (!myToolWindow.isVisible())
            return;
        boolean shouldCreate = myStructure == null;
        if (shouldCreate) {
            initStructure();
        }
        r.run();
        if (shouldCreate) {
            if (myState.treeState != null) {
                TreeState treeState = new TreeState();
                try {
                    treeState.readExternal(myState.treeState);
                    treeState.applyTo(myTree);
                } catch (InvalidDataException e) {
                    MavenLog.LOG.info(e);
                }
            }
        }
    });
}
Also used : TreeState(com.intellij.ide.util.treeView.TreeState) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 2 with InvalidDataException

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

the class Breakpoint method readExternal.

public void readExternal(Element parentNode) throws InvalidDataException {
    FilteredRequestorImpl requestor = new FilteredRequestorImpl(myProject);
    requestor.readTo(parentNode, this);
    try {
        setEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "ENABLED")));
    } catch (Exception ignored) {
    }
    try {
        setLogEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_ENABLED")));
    } catch (Exception ignored) {
    }
    try {
        String logMessage = JDOMExternalizerUtil.readField(parentNode, LOG_MESSAGE_OPTION_NAME);
        if (logMessage != null && !logMessage.isEmpty()) {
            XExpressionImpl expression = XExpressionImpl.fromText(logMessage);
            XDebuggerHistoryManager.getInstance(myProject).addRecentExpression(XBreakpointActionsPanel.LOG_EXPRESSION_HISTORY_ID, expression);
            myXBreakpoint.setLogExpressionObject(expression);
            ((XBreakpointBase) myXBreakpoint).setLogExpressionEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_EXPRESSION_ENABLED")));
        }
    } catch (Exception ignored) {
    }
    try {
        setRemoveAfterHit(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "REMOVE_AFTER_HIT")));
    } catch (Exception ignored) {
    }
}
Also used : XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl) XBreakpointBase(com.intellij.xdebugger.impl.breakpoints.XBreakpointBase) UnsupportedExpressionException(com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 3 with InvalidDataException

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

the class BreakpointManager method createXLineBreakpoint.

private <B extends XBreakpoint<?>> XLineBreakpoint createXLineBreakpoint(Class<? extends XBreakpointType<B, ?>> typeCls, Element breakpointNode) throws InvalidDataException {
    final String url = breakpointNode.getAttributeValue("url");
    VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
    if (vFile == null) {
        throw new InvalidDataException(DebuggerBundle.message("error.breakpoint.file.not.found", url));
    }
    final Document doc = FileDocumentManager.getInstance().getDocument(vFile);
    if (doc == null) {
        throw new InvalidDataException(DebuggerBundle.message("error.cannot.load.breakpoint.file", url));
    }
    final int line;
    try {
        //noinspection HardCodedStringLiteral
        line = Integer.parseInt(breakpointNode.getAttributeValue("line"));
    } catch (Exception e) {
        throw new InvalidDataException("Line number is invalid for breakpoint");
    }
    return addXLineBreakpoint(typeCls, doc, line);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) InvalidDataException(com.intellij.openapi.util.InvalidDataException) Document(com.intellij.openapi.editor.Document) InvalidDataException(com.intellij.openapi.util.InvalidDataException) InvalidRequestStateException(com.sun.jdi.request.InvalidRequestStateException) InternalException(com.sun.jdi.InternalException)

Example 4 with InvalidDataException

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

the class ExternalProjectsViewImpl method restoreTreeState.

private void restoreTreeState() {
    if (myState.treeState != null) {
        TreeState treeState = new TreeState();
        try {
            treeState.readExternal(myState.treeState);
            treeState.applyTo(myTree);
        } catch (InvalidDataException e) {
            LOG.info(e);
        }
    }
}
Also used : TreeState(com.intellij.ide.util.treeView.TreeState) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 5 with InvalidDataException

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

the class PackageEntryTable method readExternal.

@Override
public void readExternal(Element element) throws InvalidDataException {
    myEntries.clear();
    List children = element.getChildren();
    for (final Object aChildren : children) {
        @NonNls Element e = (Element) aChildren;
        @NonNls String name = e.getName();
        if ("package".equals(name)) {
            String packageName = e.getAttributeValue("name");
            boolean isStatic = Boolean.parseBoolean(e.getAttributeValue("static"));
            boolean withSubpackages = Boolean.parseBoolean(e.getAttributeValue("withSubpackages"));
            if (packageName == null) {
                throw new InvalidDataException();
            }
            PackageEntry entry;
            if (packageName.isEmpty()) {
                entry = isStatic ? PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY : PackageEntry.ALL_OTHER_IMPORTS_ENTRY;
            } else {
                entry = new PackageEntry(isStatic, packageName, withSubpackages);
            }
            myEntries.add(entry);
        } else {
            if ("emptyLine".equals(name)) {
                myEntries.add(PackageEntry.BLANK_LINE_ENTRY);
            }
        }
    }
}
Also used : NonNls(org.jetbrains.annotations.NonNls) Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException) List(java.util.List) ArrayList(java.util.ArrayList)

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