Package org.apache.geronimo.gshell.layout.model

Examples of org.apache.geronimo.gshell.layout.model.Node


        if (!(start instanceof GroupNode)) {
          throw new NotFoundException(path);
        }
       
        Node node = ((GroupNode)start).find(path);
        if (node == null) {
            throw new NotFoundException(path);
        }
       
        return node;       
View Full Code Here


        String shell = (String) properties.get("shell");
        String[] aliases = properties.get("alias") != null ? properties.get("alias").toString().split(",") : new String[0];

        if (name.equals(shell))
        {
            Node n = gn.find(shell);
            MutableGroupNode g = new MutableGroupNode(shell);
            gn.add(g);
            register(command);
        }
        else
        {
            if (shell != null && shell.length() > 0) {
                Node n = gn.find(shell);
                if (n == null) {
                    MutableGroupNode g = new MutableGroupNode(shell);
                    gn.add(g);
                    register(new GroupCommand(shell, g));
                    gn = g;
View Full Code Here

            name = (String) properties.get("name");
        }
        String shell = (String) properties.get("shell");

        if (name.equals(shell) || shell == null || shell.length() == 0) {
            Node n = layout.find(name);
            layout.removeNode(n);
        } else {
            MutableGroupNode gn = (MutableGroupNode) layout.find(shell);
            Node n = gn.find(name);
            gn.removeNode(n);
            if (gn.size() == 0) {
                layout.removeNode(gn);
            }
        }
View Full Code Here

    public Layout getLayout() {
        return layout;
    }

    public Node findNode(String s) throws NotFoundException {
        Node start = (Node) env.getVariables().get(CURRENT_NODE);
        if (start != null) {
            try {
                return findNode(start, s);
            } catch (NotFoundException e) {
                // Ignore, we need to try at root level
View Full Code Here

                        return n;
                    }
                }
                throw new NotFoundException(s);
            }
            Node n = ((GroupNode) node).find(s);
            if (n == null) {
                throw new NotFoundException(s);
            }
            if (n instanceof GroupNode) {
                return new CommandNode(n.getName(), n.getName());
            }
            return n;
        } else {
            throw new NotFoundException(s);
        }
View Full Code Here

        public Object execute(CommandContext commandContext, Object... objects) throws Exception {
            env.getVariables().set(CURRENT_NODE, gn);
            if (objects.length > 0) {
                try {
                    String cmdId = String.valueOf(objects[0]);
                    Node n = gn.find(cmdId);
                    if (n == null) {
                        n = layout.find(cmdId);
                    }
                    CommandContext ctx = commandContext;
                    Command cmd;
                    if (n instanceof CommandNode) {
                        cmd = lookup(((CommandNode) n).getId());
                    } else if (n instanceof GroupNode) {
                        cmd = new GroupCommand(cmdId, (GroupNode) n);
                    } else if (n instanceof AliasNode) {
                        cmd = lookup(((AliasNode) n).getCommand().substring(ALIAS_PREFIX.length()));
                    } else {
                        throw new IllegalStateException("Unrecognized node type: " + n.getClass().getName());
                    }
                    return cmd.execute(ctx, Arguments.shift(objects));
                } finally {
                    env.getVariables().unset(CURRENT_NODE);
                }
View Full Code Here

        if (!(start instanceof GroupNode)) {
          throw new NotFoundException(path);
        }
       
        Node node = ((GroupNode)start).find(path);
        if (node == null) {
            throw new NotFoundException(path);
        }
       
        return node;       
View Full Code Here

    public String prompt() {
        String userName = shellInfo.getUserName();
        String hostName = shellInfo.getLocalHost().getHostName();

        Node start = (Node) env.getVariables().get(LayoutManager.CURRENT_NODE);
        String path = "";
        if (start != null) {
            path = start.getPath();
            path = path.replace('/', ' ');
        }

        // return renderer.render("@|bold " + userName + "|@" + hostName + ":@|bold " + path + "|> ");
        // I think a simpler prompt would be best.
View Full Code Here

        if (!(start instanceof GroupNode)) {
          throw new NotFoundException(path);
        }
       
        Node node = ((GroupNode)start).find(path);
        if (node == null) {
            throw new NotFoundException(path);
        }
       
        return node;       
View Full Code Here

        public Object execute(CommandContext commandContext, Object... objects) throws Exception {
            env.getVariables().set(CURRENT_NODE, gn);
            if (objects.length > 0) {
                try {
                    String cmdId = String.valueOf(objects[0]);
                    Node n = gn.find(cmdId);
                    if (n == null) {
                        n = layout.find(cmdId);
                    }
                    CommandContext ctx = commandContext;
                    Command cmd;
                    if (n instanceof CommandNode) {
                        cmd = lookup(((CommandNode) n).getId());
                    } else if (n instanceof GroupNode) {
                        cmd = new GroupCommand(cmdId, (GroupNode) n);
                    } else if (n instanceof AliasNode) {
                        cmd = lookup(((AliasNode) n).getCommand().substring(ALIAS_PREFIX.length()));
                    } else {
                        throw new IllegalStateException("Unrecognized node type: " + n.getClass().getName());
                    }
                    return cmd.execute(ctx, Arguments.shift(objects));
                } finally {
                    env.getVariables().unset(CURRENT_NODE);
                }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.gshell.layout.model.Node

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.