1 19 package org.netbeans.modules.j2ee.websphere6.dd.loaders.appext; 20 21 import java.io.IOException ; 22 import org.netbeans.modules.j2ee.websphere6.dd.beans.WSAppExt; 23 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject; 24 import org.netbeans.modules.xml.multiview.*; 25 import org.netbeans.modules.xml.multiview.ui.*; 26 import org.openide.nodes.*; 27 import org.openide.util.RequestProcessor; 28 import org.netbeans.modules.xml.multiview.Error; 29 33 public class WSAppExtToolBarMVElement extends ToolBarMultiViewElement implements java.beans.PropertyChangeListener { 34 private ToolBarDesignEditor comp; 35 private SectionView view; 36 private WSAppExtDataObject dObj; 37 private PanelFactory factory; 38 private RequestProcessor.Task repaintingTask; 39 private boolean needInit=true; 40 private static final long serialVersionUID = 76737428339792L; 41 42 private static final String APPEXT_MV_ID = WSMultiViewDataObject.MULTIVIEW_APPEXT + 43 WSMultiViewDataObject.DD_MULTIVIEW_POSTFIX; 44 45 public WSAppExtToolBarMVElement(WSAppExtDataObject dObj) { 46 super(dObj); 47 this.dObj=dObj; 48 comp = new ToolBarDesignEditor(); 49 factory=new PanelFactory(comp,dObj); 50 setVisualEditor(comp); 51 repaintingTask = RequestProcessor.getDefault().create(new Runnable () { 52 public void run() { 53 javax.swing.SwingUtilities.invokeLater(new Runnable () { 54 public void run() { 55 repaintView(); 56 } 57 }); 58 } 59 }); 60 } 61 62 private void repaintView() { 63 view =new WSAppExtView(dObj); 64 comp.setContentView(view); 65 Object lastActive = comp.getLastActive(); 66 if (lastActive!=null) { 67 ((SectionView)view).openPanel(lastActive); 68 } else { 69 70 } 71 view.checkValidity(); 72 73 } 74 75 76 77 public SectionView getSectionView() { 78 return view; 79 } 80 public WSAppExtView getAppExtView() { 81 return (WSAppExtView)view; 82 } 83 84 public void componentShowing() { 85 super.componentShowing(); 86 if (needInit) { 87 repaintView(); 88 needInit=false; 89 } 90 comp.setContentView(view); 92 try { 93 ((SectionView)view).openPanel(dObj.getAppExt()); 94 } catch(java.io.IOException e) { 95 } 96 view.checkValidity(); 97 } 98 99 public void componentOpened() { 100 super.componentOpened(); 101 try { 102 dObj.getAppExt().addPropertyChangeListener(this); 103 } catch(IOException ex) { 104 ex=null; 105 } 106 } 107 108 public void componentClosed() { 109 super.componentClosed(); 110 try { 111 dObj.getAppExt().removePropertyChangeListener(this); 112 } catch(IOException ex) { 113 ex=null; 114 } 115 } 116 public void propertyChange(java.beans.PropertyChangeEvent evt) { 117 if (!dObj.isChangedFromUI()) { 118 String name = evt.getPropertyName(); 119 if ( name.indexOf("ApplicationExt")>0 ) { if (APPEXT_MV_ID.equals(dObj.getSelectedPerspective().preferredID())) { 122 repaintingTask.schedule(100); 123 } else { 124 needInit=true; 125 } 126 } 127 } 128 } 129 130 private class WSAppExtView extends SectionView { 131 132 private WSAppExt appext; 133 134 WSAppExtView(WSAppExtDataObject dObj) { 135 super(factory); 136 137 Children rootChildren = new Children.Array(); 138 Node root = new AbstractNode(rootChildren); 139 try { 140 this.appext=dObj.getAppExt(); 141 rootChildren.add(new Node[]{ 142 createAppExtAttrNode() 143 }); 144 } catch (java.io.IOException ex) { 145 System.out.println("ex="+ex); 146 root.setDisplayName("Invalid AppExt"); 147 } finally { 148 setRoot(root); 149 } 150 151 } 152 153 154 155 private Node createAppExtAttrNode() { 156 Node appextNode = new WSAppExtNode(dObj); 157 addSection(new SectionPanel(this,appextNode,appext)); 159 return appextNode; 160 } 161 } 162 163 164 public Error validateView() { 165 return null; 166 } 167 168 169 public static class WSAppExtNode extends org.openide.nodes.AbstractNode { 170 WSAppExtNode(WSAppExtDataObject appext) { 171 super(org.openide.nodes.Children.LEAF); 172 setDisplayName("Application Extension Deployment Information"); 173 174 } 175 } 176 177 } 178 | Popular Tags |