00001 package GuiComponents.Inspector; 00002 00003 import GuiComponents.Inspector.TreeTable.*; 00004 00005 class SerializableModel extends AbstractTreeTableModel { 00006 private StreamableRep rep; 00007 00008 // Names of the columns. 00009 static protected String[] cNames = {"Name", "Type", "Value"}; 00010 00011 // Types of the columns. 00012 static protected Class[] cTypes = {TreeTableModel.class, String.class, String.class}; 00013 00014 00015 SerializableModel(StreamableRep rep) { 00016 super(rep); 00017 this.rep = rep; 00018 } 00019 00020 00021 // 00022 // The TreeModel interface 00023 // 00024 00025 public int getChildCount(Object node) { 00026 return ((StreamableRep)node).getChildCount(); 00027 } 00028 00029 public Object getChild(Object node, int i) { 00030 return ((StreamableRep)node).getChild(i); 00031 } 00032 00033 // The superclass's implementation would work, but this is more efficient - also helps with lazy filling of tree. 00034 public boolean isLeaf(Object node) { 00035 return node instanceof PrimitiveRep; 00036 } 00037 00038 // 00039 // The TreeTableNode interface. 00040 // 00041 00042 public int getColumnCount() { 00043 return cNames.length; 00044 } 00045 00046 public String getColumnName(int column) { 00047 return cNames[column]; 00048 } 00049 00050 public Class getColumnClass(int column) { 00051 return cTypes[column]; 00052 } 00053 00054 public Object getValueAt(Object node, int column) { 00055 Rep rep = (Rep)node; 00056 try { 00057 switch(column) { 00058 case 0: 00059 return rep.getName(); 00060 case 1: 00061 return rep.getClassName(); 00062 case 2: 00063 return rep.getValue(); 00064 } 00065 } 00066 catch (SecurityException se) { } 00067 00068 return null; 00069 } 00070 }