1 19 20 package org.netbeans.modules.websvc.design.multiview; 21 22 import java.awt.BorderLayout ; 23 import java.io.IOException ; 24 import java.io.ObjectInput ; 25 import java.io.ObjectOutput ; 26 import javax.swing.JComponent ; 27 import javax.swing.JToolBar ; 28 import org.openide.windows.TopComponent; 29 import org.openide.awt.UndoRedo; 30 import org.netbeans.core.spi.multiview.CloseOperationState; 31 import org.netbeans.core.spi.multiview.MultiViewElement; 32 import org.netbeans.core.spi.multiview.MultiViewElementCallback; 33 import org.netbeans.modules.websvc.api.jaxws.project.config.Service; 34 import org.netbeans.modules.websvc.design.view.DesignView; 35 import org.openide.filesystems.FileObject; 36 import org.openide.util.lookup.Lookups; 37 38 42 public class DesignMultiViewElement extends TopComponent 43 implements MultiViewElement { 44 45 private static final long serialVersionUID = 1L; 46 private transient MultiViewElementCallback multiViewCallback; 47 private transient JToolBar toolbar; 48 private transient DesignView designView; 49 private transient Service service; 50 private transient FileObject implementationClass; 51 52 55 public DesignMultiViewElement() { 56 } 57 58 62 public DesignMultiViewElement(MultiViewSupport mvSupport) { 63 this(); 64 initialize(mvSupport); 65 } 66 67 private void initialize(MultiViewSupport mvSupport) { 68 associateLookup(Lookups.fixed(mvSupport)); 69 service = mvSupport.getService(); 70 implementationClass = mvSupport.getDataObject().getPrimaryFile(); 71 } 72 73 public int getPersistenceType() { 74 return PERSISTENCE_NEVER; 75 } 76 77 public void setMultiViewCallback(MultiViewElementCallback callback) { 78 multiViewCallback = callback; 79 } 80 81 public CloseOperationState canCloseElement() { 82 return CloseOperationState.STATE_OK; 83 } 84 85 86 91 private void initUI() { 92 setLayout(new BorderLayout ()); 93 designView = new DesignView(service,implementationClass); 94 add(designView); 95 } 96 97 98 public void componentActivated() { 99 super.componentActivated(); 100 } 101 102 public void componentDeactivated() { 103 super.componentDeactivated(); 104 } 105 106 public void componentOpened() { 107 super.componentOpened(); 108 initUI(); 110 } 111 112 public void componentClosed() { 113 super.componentClosed(); 114 } 115 116 public void componentShowing() { 117 super.componentShowing(); 118 } 119 120 public void componentHidden() { 121 super.componentHidden(); 122 } 123 124 public JComponent getToolbarRepresentation() { 125 if (toolbar == null) { 127 toolbar = new JToolBar (); 128 toolbar.setFloatable(false); 129 } 130 return toolbar; 131 } 132 133 public UndoRedo getUndoRedo() { 134 return super.getUndoRedo(); 135 } 136 137 public JComponent getVisualRepresentation() { 138 return this; 139 } 140 141 public void writeExternal(ObjectOutput out) throws IOException { 142 super.writeExternal(out); 144 Object obj = getLookup().lookup(MultiViewSupport.class); 145 if(obj!=null) { 146 out.writeObject(obj); 147 } 148 } 149 150 public void readExternal(ObjectInput in) 151 throws IOException , ClassNotFoundException { 152 super.readExternal(in); 153 Object firstObject = in.readObject(); 154 if (firstObject instanceof MultiViewSupport ) { 155 initialize((MultiViewSupport)firstObject); 156 } 157 } 158 159 } 160 | Popular Tags |