1 19 20 package org.netbeans.modules.j2ee.ddloaders.web.multiview; 21 22 import org.netbeans.core.spi.multiview.*; 23 import org.openide.nodes.*; 24 import org.netbeans.modules.j2ee.dd.api.web.*; 25 import org.netbeans.modules.j2ee.ddloaders.web.*; 26 import org.netbeans.modules.xml.multiview.ui.*; 27 import org.netbeans.modules.xml.multiview.ToolBarMultiViewElement; 28 import org.netbeans.modules.xml.multiview.Error; 29 import org.openide.util.NbBundle; 30 import org.openide.util.RequestProcessor; 31 import org.openide.util.HelpCtx; 32 33 43 public class ReferencesMultiViewElement extends ToolBarMultiViewElement implements java.beans.PropertyChangeListener { 44 private SectionView view; 45 private ToolBarDesignEditor comp; 46 private DDDataObject dObj; 47 private WebApp webApp; 48 private ReferencesFactory factory; 49 private javax.swing.Action addAction, removeAction; 50 private boolean needInit=true; 51 private int index; 52 private RequestProcessor.Task repaintingTask; 53 private static final String REFERENCES_MV_ID=DDDataObject.DD_MULTIVIEW_PREFIX+DDDataObject.MULTIVIEW_REFERENCES; 54 private static final String HELP_ID_PREFIX=DDDataObject.HELP_ID_PREFIX_REFERENCES; 55 56 57 public ReferencesMultiViewElement(final DDDataObject dObj, int index) { 58 super(dObj); 59 this.dObj=dObj; 60 this.index=index; 61 comp = new ToolBarDesignEditor(); 62 factory = new ReferencesFactory(comp, dObj); 63 setVisualEditor(comp); 64 repaintingTask = RequestProcessor.getDefault().create(new Runnable () { 65 public void run() { 66 javax.swing.SwingUtilities.invokeLater(new Runnable () { 67 public void run() { 68 repaintView(); 69 } 70 }); 71 } 72 }); 73 } 74 75 public SectionView getSectionView() { 76 return view; 77 } 78 79 public void componentShowing() { 80 super.componentShowing(); 81 dObj.setLastOpenView(index); 82 if (needInit || !dObj.isDocumentParseable()) { 83 repaintView(); 84 needInit=false; 85 } 86 } 87 88 private void repaintView() { 89 webApp = dObj.getWebApp(); 90 view = new ReferencesView(webApp); 91 comp.setContentView(view); 92 Object lastActive = comp.getLastActive(); 93 if (lastActive!=null) { 94 ((SectionView)view).openPanel(lastActive); 95 } else { 96 ReferencesView referencesView = (ReferencesView)view; 97 Node initialNode = referencesView.getResRefsNode(); 98 Children ch = initialNode.getChildren(); 99 if (ch.getNodesCount()>0) 100 initialNode = ch.getNodes()[0]; 101 referencesView.selectNode(initialNode); 102 } 103 view.checkValidity(); 104 dObj.checkParseable(); 105 106 } 107 108 public void componentOpened() { 109 super.componentOpened(); 110 dObj.getWebApp().addPropertyChangeListener(this); 111 } 112 113 public void componentClosed() { 114 super.componentClosed(); 115 dObj.getWebApp().removePropertyChangeListener(this); 116 } 117 118 public void propertyChange(java.beans.PropertyChangeEvent evt) { 119 if (!dObj.isChangedFromUI()) { 120 String name = evt.getPropertyName(); 121 if ( name.indexOf("Ref")>0 || name.indexOf("EnvEntry")>0) { if (REFERENCES_MV_ID.equals(dObj.getSelectedPerspective().preferredID())) { 124 repaintingTask.schedule(100); 125 } else { 126 needInit=true; 127 } 128 } 129 } 130 } 131 132 class ReferencesView extends SectionView { 133 private SectionContainer serviceRefCont; 134 private Node envEntriesNode, resRefsNode, resEnvRefsNode, ejbRefsNode, messageDestRefsNode; 135 private SectionPanel filterMappingSectionPanel; 136 137 ReferencesView (WebApp webApp) { 138 super(factory); 139 envEntriesNode = new EnvEntriesNode(); 140 addSection(new SectionPanel(this,envEntriesNode,"env_entries")); 142 resRefsNode = new ResRefsNode(); 143 addSection(new SectionPanel(this,resRefsNode,"res_refs")); 145 resEnvRefsNode = new ResEnvRefsNode(); 146 addSection(new SectionPanel(this,resEnvRefsNode,"res_env_refs")); 148 ejbRefsNode = new EjbRefsNode(); 149 addSection(new SectionPanel(this,ejbRefsNode,"ejb_refs")); 151 messageDestRefsNode = new MessageDestRefsNode(); 152 addSection(new SectionPanel(this,messageDestRefsNode,"message_dest_refs")); 154 Children rootChildren = new Children.Array(); 155 rootChildren.add(new Node[]{envEntriesNode,resRefsNode,resEnvRefsNode,ejbRefsNode,messageDestRefsNode}); 156 AbstractNode root = new AbstractNode(rootChildren); 157 setRoot(root); 158 } 159 160 Node getEnvEntriesNode() { 161 return envEntriesNode; 162 } 163 164 Node getResRefsNode() { 165 return resRefsNode; 166 } 167 168 Node getResEnvRefsNode(){ 169 return resEnvRefsNode; 170 } 171 172 Node getEjbRefsNode() { 173 return ejbRefsNode; 174 } 175 176 Node getMessageDestRefsNode() { 177 return messageDestRefsNode; 178 } 179 } 180 181 private class EnvEntriesNode extends org.openide.nodes.AbstractNode { 182 EnvEntriesNode() { 183 super(org.openide.nodes.Children.LEAF); 184 setDisplayName(NbBundle.getMessage(ReferencesMultiViewElement.class,"TTL_EnvEntries")); 185 setIconBaseWithExtension("org/netbeans/modules/j2ee/ddloaders/web/multiview/resources/paramNode.gif"); } 187 public HelpCtx getHelpCtx() { 188 return new HelpCtx(HELP_ID_PREFIX+"envEntriesNode"); } 190 } 191 192 private class ResRefsNode extends org.openide.nodes.AbstractNode { 193 ResRefsNode() { 194 super(org.openide.nodes.Children.LEAF); 195 setDisplayName(NbBundle.getMessage(ReferencesMultiViewElement.class,"TTL_ResRefs")); 196 setIconBaseWithExtension("org/netbeans/modules/j2ee/ddloaders/web/multiview/resources/paramNode.gif"); } 198 public HelpCtx getHelpCtx() { 199 return new HelpCtx(HELP_ID_PREFIX+"resRefsNode"); } 201 } 202 203 private class ResEnvRefsNode extends org.openide.nodes.AbstractNode { 204 ResEnvRefsNode() { 205 super(org.openide.nodes.Children.LEAF); 206 setDisplayName(NbBundle.getMessage(ReferencesMultiViewElement.class,"TTL_ResEnvRefs")); 207 setIconBaseWithExtension("org/netbeans/modules/j2ee/ddloaders/web/multiview/resources/paramNode.gif"); } 209 public HelpCtx getHelpCtx() { 210 return new HelpCtx(HELP_ID_PREFIX+"resEnvRefsNode"); } 212 } 213 214 private class EjbRefsNode extends org.openide.nodes.AbstractNode { 215 EjbRefsNode() { 216 super(org.openide.nodes.Children.LEAF); 217 setDisplayName(NbBundle.getMessage(ReferencesMultiViewElement.class,"TTL_EjbRefs")); 218 setIconBaseWithExtension("org/netbeans/modules/j2ee/ddloaders/web/multiview/resources/paramNode.gif"); } 220 public HelpCtx getHelpCtx() { 221 return new HelpCtx(HELP_ID_PREFIX+"ejbRefsNode"); } 223 } 224 225 private class MessageDestRefsNode extends org.openide.nodes.AbstractNode { 226 MessageDestRefsNode() { 227 super(org.openide.nodes.Children.LEAF); 228 setDisplayName(NbBundle.getMessage(ReferencesMultiViewElement.class,"TTL_MessageDestRefs")); 229 setIconBaseWithExtension("org/netbeans/modules/j2ee/ddloaders/web/multiview/resources/paramNode.gif"); } 231 public HelpCtx getHelpCtx() { 232 return new HelpCtx(HELP_ID_PREFIX+"messageDestRefsNode"); } 234 } 235 } 236 | Popular Tags |