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.NbBundle; 31 import org.openide.util.RequestProcessor; 32 import org.openide.util.HelpCtx; 33 34 37 public class OverviewMultiViewElement extends ToolBarMultiViewElement implements java.beans.PropertyChangeListener { 38 private SectionView view; 39 private ToolBarDesignEditor comp; 40 private DDDataObject dObj; 41 private WebApp webApp; 42 private OverviewFactory factory; 43 private boolean needInit=true; 44 private int index; 45 private RequestProcessor.Task repaintingTask; 46 private static final String OVERVIEW_MV_ID=DDDataObject.DD_MULTIVIEW_PREFIX+DDDataObject.MULTIVIEW_OVERVIEW; 47 private static final String HELP_ID_PREFIX=DDDataObject.HELP_ID_PREFIX_OVERVIEW; 48 49 50 public OverviewMultiViewElement(final DDDataObject dObj, int index) { 51 super(dObj); 52 this.dObj=dObj; 53 this.index=index; 54 comp = new ToolBarDesignEditor(); 55 factory = new OverviewFactory(comp, dObj); 56 setVisualEditor(comp); 57 repaintingTask = RequestProcessor.getDefault().create(new Runnable () { 58 public void run() { 59 javax.swing.SwingUtilities.invokeLater(new Runnable () { 60 public void run() { 61 repaintView(); 62 } 63 }); 64 } 65 }); 66 } 67 68 public SectionView getSectionView() { 69 return view; 70 } 71 72 public void componentShowing() { 73 super.componentShowing(); 74 dObj.setLastOpenView(index); 75 if (needInit || !dObj.isDocumentParseable()) { 76 repaintView(); 77 needInit=false; 78 } 79 } 80 81 private void repaintView() { 82 webApp = dObj.getWebApp(); 83 view =new OverView(webApp); 84 comp.setContentView(view); 85 Object lastActive = comp.getLastActive(); 86 if (lastActive!=null) { 87 ((SectionView)view).openPanel(lastActive); 88 } else { 89 ((SectionView)view).openPanel("overview"); } 91 view.checkValidity(); 92 dObj.checkParseable(); 93 } 94 95 public void componentOpened() { 96 super.componentOpened(); 97 dObj.getWebApp().addPropertyChangeListener(this); 98 } 99 100 public void componentClosed() { 101 super.componentClosed(); 102 dObj.getWebApp().removePropertyChangeListener(this); 103 } 104 105 public void propertyChange(java.beans.PropertyChangeEvent evt) { 106 if (!dObj.isChangedFromUI()) { 107 String name = evt.getPropertyName(); 108 if ( name.indexOf("/WebApp/DisplayName")>=0 || name.indexOf("/WebApp/Description")>=0 || name.indexOf("Distributable")>0 || name.indexOf("ContextParam")>0 || name.indexOf("Listener")>0 || name.indexOf("SessionConfig")>0 ) { if (OVERVIEW_MV_ID.equals(dObj.getSelectedPerspective().preferredID())) { 116 repaintingTask.schedule(100); 117 } else { 118 needInit=true; 119 } 120 } 121 } 122 } 123 124 class OverView extends SectionView { 125 private Node overviewNode, contextParamsNode, listenersNode; 126 OverView(WebApp webApp) { 127 super(factory); 128 overviewNode = new OverviewNode(); 129 addSection(new SectionPanel(this,overviewNode,"overview")); 131 contextParamsNode = new ContextParamsNode(); 132 addSection(new SectionPanel(this,contextParamsNode,"context_params")); 134 listenersNode = new ListenersNode(); 135 addSection(new SectionPanel(this,listenersNode,"listeners")); 137 Children rootChildren = new Children.Array(); 138 rootChildren.add(new Node[]{overviewNode,contextParamsNode,listenersNode}); 139 AbstractNode root = new AbstractNode(rootChildren); 140 setRoot(root); 141 } 142 143 Node getOverviewNode() { 144 return overviewNode; 145 } 146 147 Node getContextParamsNode() { 148 return contextParamsNode; 149 } 150 151 Node getListenersNode(){ 152 return listenersNode; 153 } 154 } 155 156 private class OverviewNode extends org.openide.nodes.AbstractNode { 157 OverviewNode() { 158 super(org.openide.nodes.Children.LEAF); 159 setDisplayName(NbBundle.getMessage(PagesMultiViewElement.class,"TTL_Overview")); 160 setIconBaseWithExtension("org/netbeans/modules/j2ee/ddloaders/web/multiview/resources/class.gif"); } 162 public HelpCtx getHelpCtx() { 163 return new HelpCtx(HELP_ID_PREFIX+"overviewNode"); } 165 } 166 167 private class ContextParamsNode extends org.openide.nodes.AbstractNode { 168 ContextParamsNode() { 169 super(org.openide.nodes.Children.LEAF); 170 setDisplayName(NbBundle.getMessage(PagesMultiViewElement.class,"TTL_ContextParams")); 171 setIconBaseWithExtension("org/netbeans/modules/j2ee/ddloaders/web/multiview/resources/paramsNode.gif"); } 173 public HelpCtx getHelpCtx() { 174 return new HelpCtx(HELP_ID_PREFIX+"contextParamsNode"); } 176 } 177 178 private class ListenersNode extends org.openide.nodes.AbstractNode { 179 ListenersNode() { 180 super(org.openide.nodes.Children.LEAF); 181 setDisplayName(NbBundle.getMessage(PagesMultiViewElement.class,"TTL_Listeners")); 182 setIconBaseWithExtension("org/netbeans/modules/j2ee/ddloaders/web/multiview/resources/class.gif"); } 184 public HelpCtx getHelpCtx() { 185 return new HelpCtx(HELP_ID_PREFIX+"listenersNode"); } 187 } 188 } 189 | Popular Tags |