KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ui > logicalview > ejb > entity > EntityChildren


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.entity;
21
22 import java.beans.PropertyChangeEvent JavaDoc;
23 import java.beans.PropertyChangeListener JavaDoc;
24 import java.util.*;
25 import javax.swing.SwingUtilities JavaDoc;
26 import org.netbeans.api.java.classpath.ClassPath;
27 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar;
28 import org.netbeans.modules.j2ee.dd.api.ejb.Entity;
29 import org.openide.filesystems.FileObject;
30 import org.openide.nodes.Children;
31 import org.openide.nodes.Node;
32
33
34 /**
35  * @author Chris Webster
36  * @author Martin Adamek
37  */

38 public final class EntityChildren extends Children.Keys<EntityChildren.KEY> implements PropertyChangeListener JavaDoc {
39     
40     protected enum KEY { REMOTE, LOCAL, CMP_FIELDS }
41     
42     private final Entity model;
43     private final ClassPath srcPath;
44 // private final EntityMethodController controller;
45
// private final EjbJar jar;
46
// private final FileObject ddFile;
47

48     public EntityChildren(Entity model, ClassPath srcPath, EjbJar jar, FileObject ddFile) {
49         this.srcPath = srcPath;
50         this.model = model;
51         //TODO: RETOUCHE
52
// this.jar = jar;
53
// this.ddFile = ddFile;
54
// controller = new EntityMethodController(null, model, jar);
55
}
56     
57     protected void addNotify() {
58         super.addNotify();
59         updateKeys();
60         model.addPropertyChangeListener(this);
61         srcPath.addPropertyChangeListener(this);
62     }
63     
64     private void updateKeys() {
65         SwingUtilities.invokeLater(new Runnable JavaDoc() {
66             public void run() {
67                 List<KEY> keys = new ArrayList<KEY>();
68                 if (model.getRemote() != null) {
69                     keys.add(KEY.REMOTE);
70                 }
71                 if (model.getLocal()!=null) {
72                     keys.add(KEY.LOCAL);
73                 }
74                 if (Entity.PERSISTENCE_TYPE_CONTAINER.equals(model.getPersistenceType())) {
75                     keys.add(KEY.CMP_FIELDS);
76                 }
77                 setKeys(keys);
78             }
79         });
80     }
81     
82     protected void removeNotify() {
83         model.removePropertyChangeListener(this);
84         srcPath.removePropertyChangeListener(this);
85         setKeys(Collections.<KEY>emptySet());
86         super.removeNotify();
87     }
88      
89     protected Node[] createNodes(KEY key) {
90         //TODO: RETOUCHE
91
// if (key == KEY.LOCAL) {
92
// Children c = new MethodChildren(controller, model, controller.getLocalInterfaces(), true, ddFile);
93
// MethodsNode n = new MethodsNode(model, jar, srcPath, c, true);
94
// n.setIconBaseWithExtension("org/netbeans/modules/j2ee/ejbcore/resources/LocalMethodContainerIcon.gif");
95
// n.setDisplayName(NbBundle.getMessage(EjbViewController.class, "LBL_LocalMethods"));
96
// return new Node[] { n };
97
// }
98
// if (key == KEY.REMOTE) {
99
// Children c = new MethodChildren(controller, model, controller.getRemoteInterfaces(), false, ddFile);
100
// MethodsNode n = new MethodsNode(model, jar, srcPath, c, false);
101
// n.setIconBaseWithExtension("org/netbeans/modules/j2ee/ejbcore/resources/RemoteMethodContainerIcon.gif");
102
// n.setDisplayName(NbBundle.getMessage(EjbViewController.class, "LBL_RemoteMethods"));
103
// return new Node[] { n };
104
// }
105
// if (key == KEY.CMP_FIELDS) {
106
// CMPFieldsNode n = new CMPFieldsNode(controller,model,jar, ddFile);
107
// n.setIconBaseWithExtension("org/netbeans/modules/j2ee/ejbcore/resources/CMFieldContainerIcon.gif");
108
// n.setDisplayName(NbBundle.getMessage(EntityChildren.class, "LBL_CMPFields"));
109
// return new Node[] { n };
110
// }
111
return null;
112     }
113     
114     public void propertyChange(PropertyChangeEvent JavaDoc propertyChangeEvent) {
115         //TODO add code for detecting class name changes
116
SwingUtilities.invokeLater(new Runnable JavaDoc() {
117             public void run() {
118                 updateKeys();
119             }
120         });
121     }
122     
123 }
124
Popular Tags