1 19 20 package org.netbeans.core.spi.multiview; 21 22 import javax.swing.JComponent ; 23 import javax.swing.JToolBar ; 24 import javax.swing.text.Document ; 25 import org.openide.text.CloneableEditor; 26 import org.openide.text.CloneableEditorSupport; 27 import org.openide.text.NbDocument; 28 29 32 abstract class MultiViewCloneableEditor extends CloneableEditor implements MultiViewElement { 33 34 private static final long serialVersionUID =-3126744316644172415L; 35 36 private transient MultiViewElementCallback multiViewObserver; 37 private transient JToolBar bar; 38 39 40 public MultiViewCloneableEditor() { 41 this(null); 42 } 43 44 public MultiViewCloneableEditor(CloneableEditorSupport support) { 45 super(support); 46 } 47 48 public JComponent getToolbarRepresentation() { 49 Document doc = getEditorPane().getDocument(); 50 if (doc instanceof NbDocument.CustomToolbar) { 51 if (bar == null) { 52 bar = ((NbDocument.CustomToolbar)doc).createToolbar(getEditorPane()); 53 } 54 return bar; 55 } 56 return null; 57 } 58 59 public javax.swing.JComponent getVisualRepresentation() { 60 return this; 61 } 62 63 public final void setMultiViewCallback(MultiViewElementCallback callback) { 64 multiViewObserver = callback; 65 } 66 67 protected final MultiViewElementCallback getElementObserver() { 68 return multiViewObserver; 69 } 70 71 public void componentActivated() { 72 super.componentActivated(); 73 } 74 75 public void componentClosed() { 76 super.componentClosed(); 77 } 78 79 public void componentDeactivated() { 80 super.componentDeactivated(); 81 } 82 83 public void componentHidden() { 84 super.componentHidden(); 85 } 86 87 public void componentOpened() { 88 super.componentOpened(); 89 } 90 91 public void componentShowing() { 92 if (multiViewObserver != null) { 93 updateName(); 94 } 95 super.componentShowing(); 96 } 97 98 public javax.swing.Action [] getActions() { 99 return super.getActions(); 100 } 101 102 public org.openide.util.Lookup getLookup() { 103 return super.getLookup(); 104 } 105 106 public String preferredID() { 107 return super.preferredID(); 108 } 109 110 111 public void requestVisible() { 112 if (multiViewObserver != null) { 113 multiViewObserver.requestVisible(); 114 } else { 115 super.requestVisible(); 116 } 117 } 118 119 public void requestActive() { 120 if (multiViewObserver != null) { 121 multiViewObserver.requestActive(); 122 } else { 123 super.requestActive(); 124 } 125 } 126 127 128 public void updateName() { 129 super.updateName(); 130 if (multiViewObserver != null) { 131 multiViewObserver.updateTitle(getDisplayName()); 132 } 133 } 134 135 public void open() { 136 if (multiViewObserver != null) { 137 multiViewObserver.requestVisible(); 138 } else { 139 super.open(); 140 } 141 142 } 143 144 public CloseOperationState canCloseElement() { 145 throw new IllegalStateException ("Not implemented yet."); 146 } 148 149 } 150 | Popular Tags |