1 26 package org.objectweb.util.explorer.swing.panel; 27 28 import java.awt.BorderLayout ; 29 import java.awt.Color ; 30 31 import javax.swing.BorderFactory ; 32 import javax.swing.JPanel ; 33 34 import org.objectweb.util.explorer.api.Panel; 35 import org.objectweb.util.explorer.api.Table; 36 import org.objectweb.util.explorer.api.Tree; 37 import org.objectweb.util.explorer.api.TreeView; 38 import org.objectweb.util.explorer.interpreter.api.DescriptionInterpreter; 39 import org.objectweb.util.explorer.resolver.api.PropertyResolver; 40 import org.objectweb.util.explorer.swing.lib.DynamicTable; 41 42 50 public class BasicTablePanel 51 implements Panel 52 { 53 54 60 protected JPanel panel_; 61 62 protected Table table_; 63 64 protected PropertyResolver propertyResolver_; 65 66 protected DescriptionInterpreter descriptionInterpreter_; 67 68 protected Tree tree_; 69 70 72 74 75 81 97 98 public BasicTablePanel(){ 99 panel_ = new JPanel (); 100 panel_.setBackground(Color.white); 101 panel_.setBorder(BorderFactory.createLineBorder(Color.black)); 102 panel_.setLayout(new BorderLayout ()); 104 } 105 106 112 118 public void setPropertyResolver(PropertyResolver propertyResolver){ 119 propertyResolver_ = propertyResolver; 121 } 122 123 public void setDescriptionInterpreter(DescriptionInterpreter descriptionInterpreter){ 124 descriptionInterpreter_ = descriptionInterpreter; 126 } 127 128 public void setTree(Tree tree){ 129 tree_ = tree; 131 } 132 133 public void setTable(Table table){ 134 table_ = table; 135 } 136 137 143 146 public void selected(TreeView treeView) { 147 if(table_!=null){ 148 DynamicTable dynamicTable = null; 149 dynamicTable = new DynamicTable(); 153 dynamicTable.setPropertyResolver(propertyResolver_); 154 dynamicTable.setDescriptionInterpreter(descriptionInterpreter_); 155 dynamicTable.setTree(tree_); 156 String [] headers = table_.getHeaders(treeView); 158 Object [][] values = table_.getRows(treeView); 159 if(values!=null && values.length>0){ 160 dynamicTable.setData(headers,values); 161 panel_.add(dynamicTable.getTableHeader(),BorderLayout.NORTH); 163 panel_.add(dynamicTable,BorderLayout.CENTER); 164 } 165 } 166 } 167 168 171 public Object getPanel() { 172 return panel_; 173 } 174 175 178 public void unselected(TreeView treeview) { 179 } 181 182 } 183 184 185 | Popular Tags |