Package org.erlide.tracing.core.mvc.model.treenodes

Examples of org.erlide.tracing.core.mvc.model.treenodes.ITreeNode


    // functions creating nodes

    private ITreeNode processDropTrace(final OtpErlangTuple tuple) {
        final OtpErlangLong amount = (OtpErlangLong) tuple.elementAt(1);
        final ITreeNode node = new TreeNode("Dropped traces: " + amount.longValue(),
                Activator.getImage(Images.DROP_NODE));
        return node;
    }
View Full Code Here


    }

    private ITreeNode createProcessNode(final String label,
            final OtpErlangObject erlangObject) {
        final StringBuilder builder = new StringBuilder();
        ITreeNode functionNode = null;
        ITreeNode nameNode = null;
        ITreeNode pidNode = null;
        ITreeNode processNodeNode = null;

        if (erlangObject instanceof OtpErlangTuple) {
            // tuple: {Pid(), Initial_call()|Registered_name(), Node()} |
            // {Registered_name, Node()}
            final OtpErlangTuple processTuple = (OtpErlangTuple) erlangObject;
            int index = 0;

            // pid
            OtpErlangPid pid = null;
            if (processTuple.arity() == 3) {
                // {Pid(), Initial_call()|Registered_name(), Node()}
                pid = (OtpErlangPid) processTuple.elementAt(INDEX_PROCESS_PID);
                pidNode = new TreeNode("pid: " + pid2Str(pid),
                        Activator.getImage(Images.INFO_NODE));
            } else {
                index = 1;// tuple doesn't contain Pid element
            }

            final OtpErlangObject info = processTuple.elementAt(INDEX_PROCESS_INFO
                    - index);

            // process node
            final OtpErlangObject processNode = processTuple.elementAt(INDEX_PROCESS_NODE
                    - index);
            processNodeNode = new TreeNode("node: " + processNode,
                    Activator.getImage(Images.INFO_NODE));

            if (info instanceof OtpErlangTuple) {
                // initial call
                functionNode = createFunctionNode("initial call:", info);
                functionNode.setImage(Activator.getImage(Images.INFO_NODE));
                if (pid != null) {
                    builder.append(pid2Str(pid));
                } else {
                    builder.append(lastFunctionDescription);
                }
            } else {
                // registered name
                nameNode = new TreeNode("name: " + info,
                        Activator.getImage(Images.INFO_NODE));
                builder.append(info.toString());
            }
            builder.append(" (").append(processNode).append(")");
        } else if (erlangObject instanceof OtpErlangPid) {
            // Pid
            final OtpErlangPid pid = (OtpErlangPid) erlangObject;
            pidNode = new TreeNode("pid: " + pid2Str(pid),
                    Activator.getImage(Images.INFO_NODE));
            processNodeNode = new TreeNode("node: " + pid.node(),
                    Activator.getImage(Images.INFO_NODE));
            builder.append(pid2Str(pid)).append(" (").append(pid.node()).append(")");
        } else {
            // Atom (registered name)
            nameNode = new TreeNode("name: " + erlangObject,
                    Activator.getImage(Images.INFO_NODE));
            builder.append(erlangObject.toString());
        }

        final ITreeNode node = new TreeNode();
        if (pidNode != null) {
            node.addChildren(pidNode);
        }
        if (nameNode != null) {
            node.addChildren(nameNode);
        }
        if (processNodeNode != null) {
            node.addChildren(processNodeNode);
        }
        if (functionNode != null) {
            node.addChildren(functionNode);
        }

        lastProcessDescription = builder.toString();
        node.setLabel(label + lastProcessDescription);

        return node;
    }
View Full Code Here

        return node;
    }

    private ITreeNode createFunctionNode(final String label,
            final OtpErlangObject erlangObject) {
        final ITreeNode node = new TreeNode();
        if (erlangObject instanceof OtpErlangTuple) {
            final OtpErlangTuple functionTuple = (OtpErlangTuple) erlangObject;
            final OtpErlangAtom moduleName = (OtpErlangAtom) functionTuple
                    .elementAt(INDEX_FUNCTION_MODULE);
            final OtpErlangAtom functionName = (OtpErlangAtom) functionTuple
                    .elementAt(INDEX_FUNCTION_NAME);

            // args or arity node
            final TreeNode argsNode = new TreeNode();
            argsNode.setImage(Activator.getImage(Images.INFO_NODE));
            final OtpErlangObject arityOrArgs = functionTuple
                    .elementAt(INDEX_FUNCTION_ARGS);
            int arityValue = -1;
            if (arityOrArgs instanceof OtpErlangList) {
                // last element is a list of arguments
                final OtpErlangList arguments = (OtpErlangList) arityOrArgs;
                final StringBuilder builder = new StringBuilder("arguments: ");
                for (int i = 1; i < arguments.arity(); i++) {
                    builder.append(arguments.elementAt(i)).append(", ");
                }
                arityValue = arguments.arity() - 1;
                argsNode.setLabel(builder.substring(0, builder.length() - 2));
            } else {
                // last element is arity
                try {
                    if (functionTuple.elementAt(INDEX_FUNCTION_ARGS) instanceof OtpErlangInt) {
                        arityValue = ((OtpErlangInt) functionTuple
                                .elementAt(INDEX_FUNCTION_ARGS)).intValue();
                    } else {
                        arityValue = (int) ((OtpErlangLong) functionTuple
                                .elementAt(INDEX_FUNCTION_ARGS)).longValue();
                    }
                    argsNode.setLabel("arity: " + arityValue);
                } catch (final OtpErlangRangeException e) {
                    ErlLogger.error(e);
                }
            }

            // module name node
            final TreeNode moduleNameNode = new ModuleNode(moduleName.atomValue());
            moduleNameNode.setLabel("module: " + moduleName);

            // function name node
            final TreeNode functionNameNode = new FunctionNode(moduleName.atomValue(),
                    functionName.atomValue(), arityValue);
            functionNameNode.setLabel("function: " + functionName);

            node.addChildren(moduleNameNode, functionNameNode, argsNode);
            lastFunctionDescription = label + moduleName + ":" + functionName + "/"
                    + arityValue;

        } else {
            lastFunctionDescription = "unknown";
        }
        node.setLabel(lastFunctionDescription);
        return node;
    }
View Full Code Here

        node.setLabel(lastFunctionDescription);
        return node;
    }

    private ITreeNode createMessageNode(final OtpErlangObject message) {
        final ITreeNode node = new TreeNode(message.toString(),
                Activator.getImage(Images.MESSAGE_NODE));
        return node;
    }
View Full Code Here

    private ITreeNode processGcTrace(final String label, final Images image,
            final OtpErlangTuple tuple) {
        final StringBuilder labelBuilder = new StringBuilder(label).append(": ");

        final ITreeNode processNode = createProcessNode("process: ",
                tuple.elementAt(INDEX_PROCESS));
        processNode.setImage(Activator.getImage(Images.PROCESS_NODE));
        labelBuilder.append(lastProcessDescription);

        final ITreeNode node = new TreeNode(createNodeLabel(labelBuilder.toString()),
                Activator.getImage(image));
        node.addChildren(processNode);

        final OtpErlangList list = (OtpErlangList) tuple.elementAt(INDEX_INFO);
        for (final OtpErlangObject otpErlangObject : list) {
            final OtpErlangTuple infoTuple = (OtpErlangTuple) otpErlangObject;
            final OtpErlangObject key = infoTuple.elementAt(0);
            final OtpErlangObject value = infoTuple.elementAt(1);
            final TreeNode treeNode = new TreeNode(key.toString() + ": "
                    + value.toString());
            treeNode.setImage(Activator.getImage(Images.INFO_NODE));
            node.addChildren(treeNode);
        }
        return node;
    }
View Full Code Here

                    finishLoading(firstTrace ? TracingStatus.EMPTY : TracingStatus.OK);
                } else if ((errorReason = dataHandler.getErrorReson(message)) != null) {
                    errorObject = errorReason;
                    finishLoading(TracingStatus.ERROR);
                } else {
                    final ITreeNode newNode = dataHandler.getData(message);
                    if (newNode != null) {
                        firstTrace = false;
                        if (!loadingFileInfo) {
                            TraceCollections.getTracesList().add(newNode);
                        } else {
View Full Code Here

    }

    private ITreeNode processSpawnTrace(final String label, final OtpErlangTuple tuple) {
        final StringBuilder labelBuilder = new StringBuilder(label).append(": ");

        final ITreeNode processNode = createProcessNode("process: ",
                tuple.elementAt(INDEX_PROCESS));
        processNode.setImage(Activator.getImage(Images.PROCESS_NODE));
        labelBuilder.append(lastProcessDescription).append("->");

        final ITreeNode processNode2 = createProcessNode("new process: ",
                tuple.elementAt(INDEX_PROCESS2));
        processNode2.setImage(Activator.getImage(Images.NEW_PROCESS_NODE));
        labelBuilder.append(lastProcessDescription);

        final ITreeNode functionNode = createFunctionNode("function: ",
                tuple.elementAt(INDEX_SPAWN_FUNCTION));
        functionNode.setImage(Activator.getImage(Images.FUNCTION_NODE));

        final ITreeNode node = new TreeNode(createNodeLabel(labelBuilder.toString()),
                Activator.getImage(Images.SPAWN_NODE));
        node.addChildren(processNode, processNode2, functionNode);
        return node;
    }
View Full Code Here

    }

    private ITreeNode processExceptionFrom(final String label, final OtpErlangTuple tuple) {
        final StringBuilder labelBuilder = new StringBuilder(label).append(": ");

        final ITreeNode processNode = createProcessNode("process: ",
                tuple.elementAt(INDEX_PROCESS));
        processNode.setImage(Activator.getImage(Images.PROCESS_NODE));

        final OtpErlangTuple exceptionTuple = (OtpErlangTuple) tuple
                .elementAt(INDEX_EXCEPTION);
        final OtpErlangObject exceptionClass = exceptionTuple
                .elementAt(INDEX_EXCEPTION_CLASS);
        final OtpErlangObject exceptionValue = exceptionTuple
                .elementAt(INDEX_EXCEPTION_VALUE);
        labelBuilder.append(exceptionClass.toString());

        final ITreeNode exceptionClassNode = new TreeNode(exceptionClass.toString(),
                Activator.getImage(Images.INFO_NODE));
        exceptionClassNode.addChildren(new TreeNode(exceptionValue.toString()));

        final ITreeNode node = processReturnTrace(labelBuilder.toString(),
                Images.EXCEPTION_NODE, tuple, false);
        node.addChildren(processNode, exceptionClassNode);
        return node;
    }
View Full Code Here

    private ITreeNode processReturnTrace(final String label, final Images image,
            final OtpErlangTuple tuple, final boolean showRetValue) {
        final StringBuilder labelBuilder = new StringBuilder(label).append(": ");

        final ITreeNode processNode = createProcessNode("process: ",
                tuple.elementAt(INDEX_PROCESS));
        processNode.setImage(Activator.getImage(Images.PROCESS_NODE));

        final ITreeNode functionNode = createFunctionNode("function: ",
                tuple.elementAt(INDEX_FUNCTION));
        functionNode.setImage(Activator.getImage(Images.FUNCTION_NODE));
        labelBuilder.append(lastFunctionDescription);

        final ITreeNode node = new TreeNode();
        node.addChildren(processNode, functionNode);

        if (showRetValue) {
            final ITreeNode returnValueNode = new TreeNode("return value: "
                    + tuple.elementAt(INDEX_RETURN_VALUE));
            returnValueNode.setImage(Activator.getImage(Images.INFO_NODE));
            labelBuilder.append("->").append(tuple.elementAt(INDEX_RETURN_VALUE));
            node.addChildren(returnValueNode);
        }

        node.setLabel(createNodeLabel(labelBuilder.toString()));
View Full Code Here

    private ITreeNode processInOutTrace(final String label, final Images image,
            final OtpErlangTuple tuple) {
        final StringBuilder labelBuilder = new StringBuilder(label).append(": ");

        final ITreeNode processNode = createProcessNode("process: ",
                tuple.elementAt(INDEX_PROCESS));
        processNode.setImage(Activator.getImage(Images.PROCESS_NODE));
        labelBuilder.append(lastProcessDescription);

        final ITreeNode functionNode = createFunctionNode("function: ",
                tuple.elementAt(INDEX_FUNCTION));
        functionNode.setImage(Activator.getImage(Images.FUNCTION_NODE));

        final ITreeNode node = new TreeNode(createNodeLabel(labelBuilder.toString()),
                Activator.getImage(image));
        node.addChildren(processNode, functionNode);
        return node;
    }
View Full Code Here

TOP

Related Classes of org.erlide.tracing.core.mvc.model.treenodes.ITreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.