1 26 27 package org.objectweb.util.browser.core.panel; 28 29 import java.awt.BorderLayout ; 30 import java.awt.Color ; 31 32 import javax.swing.BorderFactory ; 34 import javax.swing.JPanel ; 35 37 import org.objectweb.util.browser.api.Panel; 38 import org.objectweb.util.browser.api.Table; 39 import org.objectweb.util.browser.api.TreeView; 40 import org.objectweb.util.browser.core.api.Decoder; 41 import org.objectweb.util.browser.core.common.AdminCustomization; 42 import org.objectweb.util.browser.core.common.DynamicTable; 43 44 52 public class DefaultTablePanel 53 implements Panel { 54 55 61 protected JPanel panel_; 62 63 protected Table table_; 64 65 protected AdminCustomization custom_; 66 67 protected Decoder decoder_; 68 69 75 public DefaultTablePanel(Table table, AdminCustomization custom, Decoder currentDecoder){ 76 panel_ = new JPanel (); 77 panel_.setBackground(Color.white); 78 panel_.setBorder(BorderFactory.createLineBorder(Color.black)); 79 table_ = table; 80 decoder_ = currentDecoder; 81 custom_ = custom; 82 panel_.setLayout(new BorderLayout ()); 84 } 85 86 public DefaultTablePanel(Table table, AdminCustomization custom){ 87 this(table, custom, null); 88 } 89 90 96 102 public void selected(TreeView treeView) { 103 if(table_!=null){ 104 DynamicTable dynamicTable = null; 105 if(decoder_!=null) 106 dynamicTable = new DynamicTable(decoder_); 107 else 108 dynamicTable = new DynamicTable(); 109 dynamicTable.setAdminCustomization(custom_); 110 String [] headers = table_.getHeaders(treeView); 111 Object [][] values = table_.getRows(treeView); 112 if(values!=null && values.length>0){ 113 dynamicTable.setData(headers,values); 114 panel_.add(dynamicTable.getTableHeader(),BorderLayout.NORTH); 116 panel_.add(dynamicTable,BorderLayout.CENTER); 117 } 118 } 119 } 120 121 public JPanel getPanel() { 122 return panel_; 123 } 124 125 public void unselected(TreeView treeview) { 126 } 128 129 } 130 131 | Popular Tags |