1 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 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 source, String propertyName, Object oldValue, Object newValue) { 49 if (oldValue instanceof EnterpriseBeans || newValue instanceof EnterpriseBeans || 50 propertyName.indexOf("MethodPermission") > 0 || propertyName.indexOf("SecurityIdentity") > 0) { 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 |