1 19 20 package org.netbeans.core.multiview; 21 22 import org.netbeans.core.spi.multiview.MultiViewElementCallback; 23 24 import javax.swing.Action ; 25 import javax.swing.JComponent ; 26 import javax.swing.JPanel ; 27 import javax.swing.JToolBar ; 28 import org.netbeans.core.spi.multiview.CloseOperationState; 29 import org.netbeans.core.spi.multiview.MultiViewElement; 30 import org.netbeans.core.spi.multiview.MultiViewFactory; 31 import org.openide.awt.UndoRedo; 32 import org.openide.util.lookup.Lookups; 33 import org.openide.windows.TopComponent; 34 35 39 public class MVElemTopComponent extends TopComponent implements MultiViewElement { 40 private StringBuffer log; 41 public MultiViewElementCallback observer; 42 private transient UndoRedo undoredo; 43 44 MVElemTopComponent() { 45 resetLog(); 46 } 47 48 49 public String getLog() { 50 return log.toString(); 51 } 52 53 public void resetLog() { 54 log = new StringBuffer (); 55 } 56 57 public void componentActivated() { 58 super.componentActivated(); 59 log.append("componentActivated-"); 60 61 } 62 63 public void componentClosed() { 64 super.componentClosed(); 65 log.append("componentClosed-"); 66 } 67 68 public void componentDeactivated() { 69 super.componentDeactivated(); 70 log.append("componentDeactivated-"); 71 } 72 73 public void componentHidden() { 74 super.componentHidden(); 75 log.append("componentHidden-"); 76 } 77 78 public void componentOpened() { 79 super.componentOpened(); 80 log.append("componentOpened-"); 81 } 82 83 public void componentShowing() { 84 super.componentShowing(); 85 log.append("componentShowing-"); 86 } 87 88 89 public JComponent getToolbarRepresentation() { 90 return new JToolBar (); 91 } 92 93 public javax.swing.JComponent getVisualRepresentation() { 94 return this; 95 } 96 97 public String preferredID() { 98 return super.preferredID(); 99 } 100 101 105 106 public void setMultiViewCallback (MultiViewElementCallback callback) { 107 this.observer = callback; 108 } 109 110 public void doRequestActive() { 111 observer.requestActive(); 112 } 113 114 public void doRequestVisible() { 115 observer.requestVisible(); 116 } 117 118 public void setUndoRedo(UndoRedo redo) { 119 undoredo = redo; 120 } 121 122 126 public CloseOperationState canCloseElement() { 127 return CloseOperationState.STATE_OK; 128 } 129 130 } 131 132 | Popular Tags |