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 * ComponentAfterVisitor.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; 31 import org.netbeans.modules.xml.schema.abe.ABEBaseDropPanel; 32 import org.netbeans.modules.xml.schema.abe.AttributePanel; 33 import org.netbeans.modules.xml.schema.abe.CompositorPanel; 34 import org.netbeans.modules.xml.schema.abe.GlobalComplextypeContainerPanel; 35 import org.netbeans.modules.xml.schema.abe.GlobalElementsContainerPanel; 36 import org.netbeans.modules.xml.schema.abe.NamespacePanel; 37 import org.netbeans.modules.xml.schema.abe.StartTagPanel; 38 39 /** 40 * 41 * @author girix 42 */ 43 public class UpTraversalVisitor extends TraversalVisitor{ 44 ABEBaseDropPanel currentComponent; 45 ABEBaseDropPanel result; 46 47 /** Creates a new instance of ComponentAfterVisitor */ 48 public UpTraversalVisitor(ABEBaseDropPanel currentComponent) { 49 this.currentComponent = currentComponent; 50 } 51 52 public ABEBaseDropPanel getResult(){ 53 return result; 54 } 55 56 public void visit(GlobalComplextypeContainerPanel panel) { 57 super.visit(panel); 58 } 59 60 public void visit(AttributePanel panel) { 61 visit((StartTagPanel)panel.getParent()); 62 } 63 64 public void visit(GlobalElementsContainerPanel panel) { 65 super.visit(panel); 66 } 67 68 public void visit(StartTagPanel panel) { 69 List<AttributePanel> list = panel.getAttributePanels(); 70 if(currentComponent instanceof AttributePanel){ 71 //already an attr selected so select next 72 int i = list.indexOf(currentComponent); 73 if( (i+1) < list.size()){ 74 result = list.get(i+1); 75 return; 76 } 77 }else if(currentComponent instanceof StartTagPanel){ 78 //select the first attr 79 if(list.size() > 0){ 80 result = list.get(0); 81 return; 82 } 83 } 84 result = panel; 85 } 86 87 public void visit(NamespacePanel panel) { 88 super.visit(panel); 89 } 90 91 public void visit(CompositorPanel panel) { 92 super.visit(panel); 93 } 94 95 96 } 97