KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > abe > visitors > DownTraversalVisitor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * LastComponentVisitor.java
21  *
22  * Created on August 30, 2006, 8:27 PM
23  *
24  * To change this template, choose Tools | Template Manager
25  * and open the template in the editor.
26  */

27
28 package org.netbeans.modules.xml.schema.abe.visitors;
29
30 import java.util.List JavaDoc;
31 import org.netbeans.modules.xml.axi.AXIComponent;
32 import org.netbeans.modules.xml.schema.abe.ABEBaseDropPanel;
33 import org.netbeans.modules.xml.schema.abe.AttributePanel;
34 import org.netbeans.modules.xml.schema.abe.CompositorPanel;
35 import org.netbeans.modules.xml.schema.abe.ContainerPanel;
36 import org.netbeans.modules.xml.schema.abe.ElementPanel;
37 import org.netbeans.modules.xml.schema.abe.GlobalComplextypeContainerPanel;
38 import org.netbeans.modules.xml.schema.abe.GlobalElementsContainerPanel;
39 import org.netbeans.modules.xml.schema.abe.NamespacePanel;
40 import org.netbeans.modules.xml.schema.abe.StartTagPanel;
41
42 /**
43  *
44  * @author girix
45  */

46 public class DownTraversalVisitor extends TraversalVisitor{
47     ABEBaseDropPanel currentComponent;
48     ABEBaseDropPanel result;
49     
50     /** Creates a new instance of LastComponentVisitor */
51     public DownTraversalVisitor(ABEBaseDropPanel currentComponent) {
52         this.currentComponent = currentComponent;
53     }
54     
55     public ABEBaseDropPanel getResult(){
56         return result;
57     }
58     
59     public void visit(GlobalComplextypeContainerPanel panel) {
60         super.visit(panel);
61     }
62     
63     public void visit(AttributePanel panel) {
64         super.visit(panel);
65     }
66     
67     public void visit(GlobalElementsContainerPanel panel) {
68         super.visit(panel);
69     }
70     
71     public void visit(StartTagPanel panel) {
72         super.visit(panel);
73     }
74     
75     
76     public void visit(NamespacePanel panel) {
77         super.visit(panel);
78     }
79     
80     public void visit(CompositorPanel panel) {
81         ABEBaseDropPanel abdp = (ABEBaseDropPanel)panel.getParent();
82         TraversalVisitor tv = new DownTraversalVisitor(panel);
83         abdp.accept(tv);
84         result = tv.getResult();
85     }
86     
87     
88     public void visit(ElementPanel elementPanel) {
89         elementPanel.expandChild();
90         if(currentComponent instanceof ContainerPanel){
91             AXIComponent comp = currentComponent.getAXIComponent();
92             List JavaDoc list = elementPanel.getAXIContainer().getChildren(TraversalVisitor.getEnCFilterList());
93             int i = list.indexOf(comp);
94             if( (i >= 0) && (i+1 < list.size()) ){
95                 //next comp
96
result = elementPanel.getChildUIComponentFor((AXIComponent) list.get(i+1));
97                 return;
98             }
99         }else{
100             //put focus on first compositor
101
AXIComponent comp = currentComponent.getAXIComponent();
102             List JavaDoc list = elementPanel.getAXIContainer().getChildren(TraversalVisitor.getEnCFilterList());
103             if(list.size() > 0){
104                 //return first compositor
105
result = elementPanel.getChildUIComponentFor((AXIComponent) list.get(0));
106                 return;
107             }
108         }
109         //has to move to next comp. So, call parents forward
110
TraversalVisitor tv = new FrontTraversalVisitor(elementPanel);
111         elementPanel.getParentContainerPanel().accept(tv);
112         result = tv.getResult();
113     }
114     
115     
116 }
117
Popular Tags