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 34 38 public class MVElem implements MultiViewElement { 39 private StringBuffer log; 40 private Action [] actions; 41 public MultiViewElementCallback observer; 42 private JPanel visualRepre; 43 private transient UndoRedo undoredo; 44 45 MVElem() { 46 this(new Action [0]); 47 } 48 49 MVElem(Action [] actions) { 50 log = new StringBuffer (); 51 this.actions = actions; 52 visualRepre = new JPanel (); 53 } 54 55 public String getLog() { 56 return log.toString(); 57 } 58 59 public void resetLog() { 60 log = new StringBuffer (); 61 } 62 63 public void componentActivated() { 64 log.append("componentActivated-"); 65 66 } 67 68 public void componentClosed() { 69 log.append("componentClosed-"); 70 } 71 72 public void componentDeactivated() { 73 log.append("componentDeactivated-"); 74 } 75 76 public void componentHidden() { 77 log.append("componentHidden-"); 78 } 79 80 public void componentOpened() { 81 log.append("componentOpened-"); 82 } 83 84 public void componentShowing() { 85 log.append("componentShowing-"); 86 } 87 88 public javax.swing.Action [] getActions() { 89 return actions; 90 } 91 92 public org.openide.util.Lookup getLookup() { 93 return Lookups.fixed(new Object [] {this}); 94 } 95 96 public JComponent getToolbarRepresentation() { 97 return new JToolBar (); 98 } 99 100 public javax.swing.JComponent getVisualRepresentation() { 101 return visualRepre; 102 } 103 104 public String preferredID() { 105 return "test"; 106 } 107 108 112 113 public void setMultiViewCallback (MultiViewElementCallback callback) { 114 this.observer = callback; 115 } 116 117 public void doRequestActive() { 118 observer.requestActive(); 119 } 120 121 public void doRequestVisible() { 122 observer.requestVisible(); 123 } 124 125 public void setUndoRedo(UndoRedo redo) { 126 undoredo = redo; 127 } 128 129 public UndoRedo getUndoRedo() { 130 return undoredo; 131 } 132 133 public CloseOperationState canCloseElement() { 134 return CloseOperationState.STATE_OK; 135 } 136 137 } 138 139 | Popular Tags |