1 19 package org.netbeans.modules.openide.explorer; 20 21 import javax.swing.*; 22 import javax.swing.event.ChangeListener ; 23 24 import java.awt.*; 25 26 37 public class TrivialTabbedContainerBridgeImpl extends TabbedContainerBridge { 38 public TrivialTabbedContainerBridgeImpl() { 39 40 } 41 42 public JComponent createTabbedContainer() { 43 JPanel result = new JPanel(); 44 result.setLayout (new BorderLayout()); 45 result.putClientProperty ("titles", new String [0]); 46 result.putClientProperty ("items", new Object [0]); 47 return result; 48 } 49 50 public void setInnerComponent(JComponent container, JComponent inner) { 51 if (container.getComponentCount() > 0) { 52 container.removeAll(); 53 } 54 container.add (inner, BorderLayout.CENTER); 55 } 56 57 public JComponent getInnerComponent(JComponent jc) { 58 JComponent result = null; 59 if (jc.getComponentCount() > 0 && jc.getComponent(0) instanceof JComponent) { 60 result = (JComponent) jc.getComponent(0); 61 } 62 return result; 63 } 64 65 public Object [] getItems(JComponent jc) { 66 return new Object [0]; 67 } 68 69 public void setItems(JComponent jc, Object [] objects, String [] titles) { 70 jc.putClientProperty ("items", objects); 71 jc.putClientProperty ("titles", titles); 72 } 73 74 public void attachSelectionListener(JComponent jc, ChangeListener listener) { 75 } 77 78 public void detachSelectionListener(JComponent jc, ChangeListener listener) { 79 } 81 82 public Object getSelectedItem(JComponent jc) { 83 Object [] items = (Object []) jc.getClientProperty ("items"); 84 if (items != null && items.length > 0) { 85 return items[0]; 86 } 87 return null; 88 } 89 90 public void setSelectedItem(JComponent jc, Object selection) { 91 } 93 94 public boolean setSelectionByName(JComponent jc, String tabname) { 95 return false; 96 } 97 98 public String getCurrentSelectedTabName(JComponent jc) { 99 String [] titles = (String []) jc.getClientProperty("titles"); 100 if (titles != null && titles.length > 0) { 101 return titles[0]; 102 } 103 return ""; } 105 } 106 | Popular Tags |