Package org.apache.tools.ant.gui.xml

Examples of org.apache.tools.ant.gui.xml.DOMNode


        if (option == JOptionPane.YES_OPTION) {
            // Find the element to remove
            ACSElement[] vals = getContext().getSelectionManager().
                getSelectedElements();
            if(vals != null && vals.length > 0) {
                DOMNode item = vals[vals.length - 1];
               
                // Find the parent and remove the element.
                DOMNode parent = item.getParentNode();
                parent.removeChild(item);

                // Notify the tree the element was removed.
                DeleteElementEvent event = new DeleteElementEvent(
                    getContext(), (ACSElement) parent);
                getContext().getEventBus().postEvent(event);
View Full Code Here


        List retval = new ArrayList(length);
        for(int i = 0; i < length; i++) {
            // XXX This is where we will eventually add dynamic filtering
            // capabilities.
            DOMNode n = children.item(i);
            if(n instanceof ACSTreeNodeElement) {
                retval.add(n);
            }
        }
View Full Code Here

     * @param   parent  a node in the tree, obtained from this data source
     * @return  the child of <I>parent</I> at index <I>index</I>
     */
    public Object getChild(Object parent, int index) {
        if(parent instanceof DOMNode) {
            DOMNode n = (DOMNode) parent;
            List children = getChildren(n);
            return children.get(index);
        }
        else {
            return null;
View Full Code Here

     * @param   parent  a node in the tree, obtained from this data source
     * @return  the number of children of the node <I>parent</I>
     */
    public int getChildCount(Object parent) {
        if(parent instanceof DOMNode) {
            DOMNode n = (DOMNode) parent;
            return getChildren(n).size();
        }
        else {
            return 0;
        }
View Full Code Here

     * @param   node    a node in the tree, obtained from this data source
     * @return  true if <I>node</I> is a leaf
     */
    public boolean isLeaf(Object node) {
        if(node instanceof DOMNode) {
            DOMNode n = (DOMNode) node;
            return getChildren(n).size() == 0;
        }
        else {
            return true;
        }
View Full Code Here

    /**
     * Returns the index of child in parent.
     */
    public int getIndexOfChild(Object parent, Object child) {
        if(parent instanceof DOMNode && child instanceof DOMNode) {
            DOMNode n = (DOMNode) parent;
            List children = getChildren(n);
            int count = children.size();
            for(int i = 0; i < count; i++) {
                if(children.get(i) == child) return i;
            }
View Full Code Here

     * Fire a node change event.
     *
     * @param node Node that changed.
     */
    public void fireNodeAdded(DOMNode node) {
        DOMNode parent = node.getParentNode();
        TreeModelEvent event = null;
        if(parent == null) {
            event = new TreeModelEvent(this, getPathToRoot(node));
        }
        else {
            DOMNode[] path = getPathToRoot(parent);
            int[] indicies = null;
            DOMNode[] children = new DOMNode[] { node };

            // XXX Right now we assume that the node was added at the end.
            // This may not be the case in the future.
            if(parent.getLastChild() == node) {
                List filteredChildren = getChildren(parent);
                indicies = new int[] { filteredChildren.indexOf(node) };
            }
            else {
                throw new UnsupportedOperationException(
View Full Code Here

     * Fire the node deleted event.
     *
     * @param node Node that changed.
     */
    public void fireNodeDeleted(DOMNode node) {
        DOMNode parent = node.getParentNode();
        TreeModelEvent event = new TreeModelEvent(this, getPathToRoot(node));
       
        // XXX This doen't support modifying the list during dispatch...
        Iterator it = _listeners.iterator();
        while(it.hasNext()) {
View Full Code Here

    public String getDisplayName() {
        String name = getTagName();
       
        // Is there only one attribute?
        if (getAttributes().getLength() == 1) {
            DOMNode onlyNode = getAttributes().item(0);
           
            // Display the only attribute
            name += ": " + onlyNode.getNodeValue();
        } else {
           
            // Display one of these attributes
            // if they are present.
            final String[] DISPLAY_ATTRIBUTES = {
                "name",
                "id",
                "property"
            };
           
            for(int i = 0; i < DISPLAY_ATTRIBUTES.length; i++) {
                DOMNode testNode =
                getAttributes().getNamedItem(DISPLAY_ATTRIBUTES[i]);
                if (testNode != null) {
                    name += ": " + testNode.getNodeValue();
                    break;
                }
            }
        }
       
View Full Code Here

        Map m = ACSFactory.getInstance().getClassInfo(getTagName(), (this instanceof ACSTargetElement))._attributes;
        DOMAttributes d = new DOMAttributes(m);

        NamedDOMNodeMap attribs = getAttributes();
        for(int i = 0, len = attribs.getLength(); i < len; i++) {
            DOMNode n = attribs.item(i);
            d.setProperty(n.getNodeName(), n.getNodeValue());
        }
        return d;
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.gui.xml.DOMNode

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.