1 package net.matuschek.jobo; 2 3 import java.util.Vector ; 4 import javax.swing.table.AbstractTableModel ; 5 import net.matuschek.spider.RegExpRule; 6 9 10 11 12 18 public class RegExpRuleTableModel 19 extends AbstractTableModel 20 { 21 22 private static final long serialVersionUID = -2211969715108211170L; 23 24 final static String [] columns = { "Allow","Pattern" }; 25 26 30 public RegExpRuleTableModel(Vector rules) { 31 super(); 32 this.rules = rules; 33 } 34 35 public int getColumnCount() { 36 return columns.length; 37 } 38 39 public int getRowCount() { 40 return rules.size(); 41 } 42 43 public String getColumnName(int col) { 44 return columns[col]; 45 } 46 47 public Object getValueAt(int row, int col) { 48 RegExpRule rule = (RegExpRule)rules.elementAt(row); 49 if (col == 0) { 50 return new Boolean (rule.getAllow()); 51 } else if (col == 1) { 52 return rule.getPattern(); 53 } else { 54 return null; 55 } 56 } 57 58 public Class <?> getColumnClass(int col) { 59 if (col == 0) { 60 return Boolean .class; 61 } else if (col == 1) { 62 return String .class; 63 } else { 64 return null; 65 } 66 } 67 68 71 public boolean isCellEditable(int row, int column) { 72 return true; 73 } 74 75 76 78 public void setValueAt(Object value, int row, int col) { 79 RegExpRule rule = (RegExpRule)rules.elementAt(row); 80 81 if (col == 0) { 82 rule.setAllow(((Boolean )value).booleanValue()); 84 } else if (col == 1) { 85 try { 86 rule.setPattern((String )value); 87 } catch (org.apache.regexp.RESyntaxException e) { 88 } 90 } else { 91 return; 93 } 94 95 } 96 97 98 100 Vector rules = null; 101 102 } | Popular Tags |