KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ddloaders > multiview > EjbJarView


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 package org.netbeans.modules.j2ee.ddloaders.multiview;
20
21 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar;
22 import org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans;
23 import org.netbeans.modules.xml.multiview.SectionNode;
24 import org.netbeans.modules.xml.multiview.XmlMultiViewDataSynchronizer;
25 import org.netbeans.modules.xml.multiview.ui.SectionNodeView;
26 import org.openide.nodes.Node;
27 import org.openide.nodes.Children;
28
29 /**
30  * @author pfiala
31  */

32 public class EjbJarView extends SectionNodeView {
33
34     protected EnterpriseBeansNode enterpriseBeansNode;
35     protected EnterpriseBeans enterpriseBeans;
36     protected EjbJar ejbJar;
37
38     EjbJarView(EjbJarMultiViewDataObject dataObject) {
39         super(dataObject);
40         EjbSectionNode rootNode = new EjbSectionNode(this, this, Utils.getBundleMessage("LBL_Overview"),
41                 Utils.ICON_BASE_DD_VALID);
42         ejbJar = dataObject.getEjbJar();
43         rootNode.addChild(new EjbJarDetailsNode(this, ejbJar));
44         rootNode.addChild(new EjbJarSecurityRolesNode(this, ejbJar));
45         setRootNode(rootNode);
46     }
47
48     public void dataModelPropertyChange(Object JavaDoc source, String JavaDoc propertyName, Object JavaDoc oldValue, Object JavaDoc newValue) {
49         if (oldValue instanceof EnterpriseBeans || newValue instanceof EnterpriseBeans ||
50                 propertyName.indexOf("MethodPermission") > 0 || propertyName.indexOf("SecurityIdentity") > 0) { //NOI18N
51
scheduleRefreshView();
52         }
53         super.dataModelPropertyChange(source, propertyName, oldValue, newValue);
54     }
55
56     public XmlMultiViewDataSynchronizer getModelSynchronizer() {
57         return ((EjbJarMultiViewDataObject) getDataObject()).getModelSynchronizer();
58     }
59
60     public void refreshView() {
61         checkEnterpriseBeans();
62         super.refreshView();
63     }
64
65     private void checkEnterpriseBeans() {
66         EnterpriseBeans enterpriseBeans = ejbJar.getEnterpriseBeans();
67         if (enterpriseBeans != this.enterpriseBeans) {
68             SectionNode rootNode = getRootNode();
69             final Children children = rootNode.getChildren();
70             final Node[] nodes = children.getNodes();
71             for (int i = 0; i < nodes.length; i++) {
72                 Node node = nodes[i];
73                 if (node instanceof EnterpriseBeansNode) {
74                     children.remove(new Node[]{node});
75                 }
76             }
77             if (enterpriseBeans != null) {
78                 enterpriseBeansNode = new EnterpriseBeansNode(this, enterpriseBeans);
79                 if (rootNode != null) {
80                     rootNode.addChild(enterpriseBeansNode);
81                     rootNode.populateBoxPanel();
82                 }
83             }
84             this.enterpriseBeans = enterpriseBeans;
85         }
86     }
87 }
88
Popular Tags