1 19 24 25 package org.netbeans.swing.tabcontrol; 26 27 import org.netbeans.swing.tabcontrol.event.TabActionEvent; 28 29 import javax.swing.*; 30 import javax.swing.plaf.ComponentUI ; 31 import java.awt.*; 32 import java.awt.event.MouseEvent ; 33 34 42 public abstract class TabDisplayerUI extends ComponentUI { 43 protected SingleSelectionModel selectionModel = null; 44 protected final TabDisplayer displayer; 45 46 49 protected TabDisplayerUI(TabDisplayer displayer) { 50 this.displayer = displayer; 51 } 52 53 54 public void installUI(JComponent c) { 55 assert c == displayer; 56 selectionModel = displayer.getSelectionModel(); 57 58 if (selectionModel == null) { 61 selectionModel = createSelectionModel(); 62 } 63 64 installSelectionModel(); 65 } 66 67 public void uninstallUI(JComponent c) { 68 assert c == displayer; 69 } 70 71 80 public abstract Polygon getExactTabIndication(int index); 81 82 95 public abstract Polygon getInsertTabIndication(int index); 96 97 103 public abstract int tabForCoordinate(Point p); 104 105 109 public abstract Rectangle getTabRect(int index, 110 final Rectangle destination); 111 112 119 public Image createImageOfTab(int index) { 120 return null; 121 } 122 123 128 protected abstract SingleSelectionModel createSelectionModel(); 129 130 147 protected final boolean shouldPerformAction(String command, int tab, 148 MouseEvent event) { 149 TabActionEvent evt = new TabActionEvent(displayer, command, tab, event); 150 displayer.postActionEvent(evt); 151 return !evt.isConsumed(); 152 } 153 154 163 public void makeTabVisible(int index) { 164 } 166 167 171 private void installSelectionModel() { 172 displayer.setSelectionModel(selectionModel); 173 } 174 175 181 public abstract int dropIndexOfPoint (Point p); 182 183 public abstract void registerShortcuts (JComponent comp); 184 185 public abstract void unregisterShortcuts (JComponent comp); 186 187 188 protected abstract void requestAttention (int tab); 189 190 protected abstract void cancelRequestAttention (int tab); 191 192 public abstract Icon getButtonIcon( int buttonId, int buttonState ); 193 194 public void postTabAction( TabActionEvent e ) { 195 if( shouldPerformAction( e.getActionCommand(), e.getTabIndex(), e.getMouseEvent() ) ) { 196 197 } 199 } 200 } 201 | Popular Tags |