Package org.apache.tools.ant.gui.acs

Examples of org.apache.tools.ant.gui.acs.ElementTreeModel


                (ACSTreeNodeElement) newChild;
            ACSTreeNodeElement clone =
                (ACSTreeNodeElement) newChildNode.cloneNode(true);
            parentNode.appendChild(clone);
           
            ElementTreeModel model = (ElementTreeModel)_tree.getModel();
            model.fireNodeChanged(parentNode);
           
            return clone;
        }
View Full Code Here


                (ACSTreeNodeElement) newChild;
            ACSTreeNodeElement clone =
                (ACSTreeNodeElement) newChildNode.cloneNode(true);
            parentNode.insertBefore(clone, indexNode);
           
            ElementTreeModel model = (ElementTreeModel)_tree.getModel();
            model.fireNodeChanged(parentNode);
           
            return clone;
        }
View Full Code Here

                (ACSTreeNodeElement) child;
            ACSTreeNodeElement parentNode =
                (ACSTreeNodeElement) childNode.getParentNode();
            parentNode.removeChild(childNode);
           
            ElementTreeModel model = (ElementTreeModel)_tree.getModel();
            model.fireNodeChanged(childNode);
        }
View Full Code Here

         * @param event Event to post.
         * @return true if event should be propogated, false if
         * it should be cancelled.
         */
        public boolean eventPosted(EventObject event) {
            ElementTreeModel model = (ElementTreeModel)_tree.getModel();
            // XXX This crap needs cleaning up. Type switching is lazy...
            if(event instanceof PropertyChangeEvent) {
                // The project node has changed.
                model.fireNodeChanged((ACSElement)event.getSource());
            }
            else if(event instanceof RefreshDisplayEvent && model != null) {
                _tree.validate();
            }
            else if(event instanceof NewElementEvent &&
                    (event instanceof NewProjectEvent == false) &&
                    model != null) {
                ACSElement element = ((NewElementEvent)event).getNewElement();
                model.fireNodeAdded(element);
                TreePath path = new TreePath(model.getPathToRoot(element));
                _selections.setSelectionPath(path);
                _tree.scrollPathToVisible(path);
            }
            else if(event instanceof DeleteElementEvent && model != null) {
                ACSElement element = ((DeleteElementEvent)event).getDeletedElement();
                model.fireNodeDeleted(element);
                _tree.updateUI();
           }
            else {
                ACSProjectElement project = null;
                if(event instanceof ProjectSelectedEvent) {
                    ProjectSelectedEvent e = (ProjectSelectedEvent) event;
                    project = e.getSelectedProject();
                }
               
                if(project == null) {
                    // The project has been closed.
                    // XXX this needs to be tested against
                    // different version of Swing...
                    _tree.setModel(null);
                    _tree.setSelectionModel(null);
                    // Send an empty selection event to notify others that
                    // nothing is selected.
                    ElementSelectionEvent.createEvent(getContext(), null);
                }
                else {
                    boolean updateModel = false;
                    TreeModel testModel = _tree.getModel();
                   
                    // Set the model if's not an ElementTreeModel
                    if (testModel instanceof ElementTreeModel) {
                        ElementTreeModel etm = (ElementTreeModel) testModel;
                        ACSProjectElement currentProject =
                            (ACSProjectElement) etm.getRoot();
                       
                        // Set the model if the project is wrong
                        if (currentProject != project) {
                            updateModel = true;
                        }
                    } else {
                        updateModel = true;
                    }

                    // Should we update the tree model
                    if (updateModel) {
                        _tree.setModel(new ElementTreeModel(project));
                        _tree.getModel().addTreeModelListener(
                            new ChangeHandler());

                        _selections = new ElementTreeSelectionModel();
                        _selections.addTreeSelectionListener(
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.gui.acs.ElementTreeModel

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.