KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > abe > GlobalElementsContainerPanel


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 /*
21  * GlobalElementsContainerPanel.java
22  *
23  * Created on June 6, 2006, 4:12 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.schema.abe;
30
31 import java.awt.dnd.DropTargetDragEvent JavaDoc;
32 import java.awt.dnd.DropTargetDropEvent JavaDoc;
33 import java.awt.dnd.DropTargetEvent JavaDoc;
34 import java.awt.event.MouseAdapter JavaDoc;
35 import java.awt.event.MouseEvent JavaDoc;
36 import java.util.ArrayList JavaDoc;
37 import java.util.List JavaDoc;
38 import org.netbeans.modules.xml.axi.AXIComponent;
39 import org.netbeans.modules.xml.axi.AbstractElement;
40 import org.netbeans.modules.xml.schema.abe.nodes.ABEAbstractNode;
41
42 /**
43  *
44  * @author girix
45  */

46 public class GlobalElementsContainerPanel extends ElementsContainerPanel{
47     private static final long serialVersionUID = 7526472295622776147L;
48     /** Creates a new instance of GlobalElementsContainerPanel */
49     public GlobalElementsContainerPanel(InstanceUIContext context,
50             AXIComponent axiComponent, boolean openByDefault) {
51         super(context, axiComponent, null, openByDefault);
52         //dont draw annotation
53
setDrawAnnotation(false);
54         initMouseListener();
55     }
56     
57     
58     public int getChildrenIndent(){
59         return InstanceDesignConstants.GLOBAL_ELEMENT_PANEL_INDENT;
60     }
61     
62     public List JavaDoc<? extends AXIComponent> getAXIChildren() {
63         ArrayList JavaDoc<AbstractElement> list = new ArrayList JavaDoc<AbstractElement>
64                 (getAXIParent().getChildElements());
65         
66         return getAXIChildrenSorted(list);
67     }
68     
69     protected List JavaDoc<? extends AXIComponent> getAXIChildrenSorted(List JavaDoc<AbstractElement> elementList) {
70         /*Collections.sort(elementList,
71                 new Comparator<AbstractElement>() {
72             public int compare(AbstractElement e1, AbstractElement e2) {
73                 return e1.getName().compareTo(e2.getName());
74             }
75          
76         });*/

77         return elementList;
78     }
79     
80     public ABEBaseDropPanel getUIComponentFor(AXIComponent axiComponent) {
81         ABEBaseDropPanel retValue;
82         retValue = super.getUIComponentFor(axiComponent);
83         return retValue;
84     }
85     
86     public void accept(UIVisitor visitor) {
87         visitor.visit(this);
88     }
89     
90     public ABEAbstractNode getNBNode() {
91         //just return the namespace panel node
92
return context.getNamespacePanel().getNBNode();
93     }
94     
95     
96     
97     protected void initMouseListener(){
98         addMouseListener(new MouseAdapter JavaDoc() {
99             public void mouseReleased(MouseEvent JavaDoc e) {
100                 mouseClickedActionHandler(e);
101             }
102             public void mouseClicked(MouseEvent JavaDoc e){
103                 mouseClickedActionHandler(e);
104             }
105             
106             public void mousePressed(MouseEvent JavaDoc e) {
107                 mouseClickedActionHandler(e);
108             }
109         });
110     }
111     
112     
113     protected void mouseClickedActionHandler(MouseEvent JavaDoc e){
114         if(e.getClickCount() == 1){
115             if(e.isPopupTrigger()){
116                 context.getMultiComponentActionManager().showPopupMenu(e, this);
117                 return;
118             }
119         }
120         //the tag is selected
121
context.getComponentSelectionManager().setSelectedComponent(this);
122     }
123     
124     public void drop(DropTargetDropEvent JavaDoc event) {
125         context.getNamespacePanel().drop(event);
126     }
127     
128     public void dragExit(DropTargetEvent JavaDoc event) {
129         context.getNamespacePanel().dragExit(event);
130     }
131     
132     public void dragOver(DropTargetDragEvent JavaDoc event) {
133         context.getNamespacePanel().dragOver(event);
134     }
135     
136     public void dragEnter(DropTargetDragEvent JavaDoc event) {
137         context.getNamespacePanel().dragEnter(event);
138     }
139     
140     
141 }
142
Popular Tags