1 20 21 package org.jacorb.naming.namemanager; 22 23 import java.util.*; 24 import javax.swing.table.*; 25 26 public class NSTable 27 extends javax.swing.JTable 28 { 29 private ContextNode current; 30 private NSTableCellRenderer nsRenderer; 31 32 35 36 public NSTable() 37 { 38 super( new NSTableModel()); 39 setShowGrid(false); 40 setAutoCreateColumnsFromModel(false); 41 setDoubleBuffered(true); 42 setCellSelectionEnabled(false); 43 setColumnSelectionAllowed(false); 44 nsRenderer = new NSTableCellRenderer(); 45 } 46 47 public TableCellRenderer getCellRenderer(int row, int column) 48 { 49 String type = (String )getValueAt(row,2); 50 51 if (type.startsWith("IDL:omg.org/CosNaming/NamingContext")) 52 { 53 return nsRenderer; 54 } 55 else 56 return super.getCellRenderer(row, column); 57 } 58 59 62 public ContextNode currentSource() 63 { 64 return current; 65 } 66 67 71 public void setData(Vector newData, ContextNode currentSource) 72 { 73 current = currentSource; 74 ((NSTableModel)super.getModel()).setDataVector( newData ); 75 } 76 77 80 public synchronized void unbind() 81 { 82 int row = getSelectedRow(); 83 if( row > -1 ) 84 { 85 try 86 { 87 org.omg.CosNaming.NameComponent [] ncs = 88 new org.omg.CosNaming.NameComponent [1]; 89 ncs[0] = 90 new org.omg.CosNaming.NameComponent ( 91 (String )getValueAt(row,0), 92 (String )getValueAt(row,1)); 93 current.unbind(ncs); 94 update(); 95 } 96 catch( Exception e) 97 {} 98 } 99 } 100 103 public void update() 104 { 105 if( current != null ) 106 current.display(); 107 } 108 } 109 110 111 112 113 | Popular Tags |