You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
package com.fr.plugin.tabledata.modify; |
|
|
|
|
|
import com.fr.data.AbstractDataModel; |
|
import com.fr.general.data.DataModel; |
|
import com.fr.general.data.TableDataException; |
|
import com.fr.json.JSONObject; |
|
|
|
public class DemoDataModel extends AbstractDataModel { |
|
|
|
private DataModel old = null; |
|
private static String[] exCols = new String[]{"user","qnumber","addr"}; |
|
public DemoDataModel( DataModel old ){ |
|
this.old = old; |
|
} |
|
|
|
@Override |
|
public int getColumnCount() throws TableDataException { |
|
return old.getColumnCount()+2; |
|
} |
|
|
|
@Override |
|
public String getColumnName(int i) throws TableDataException { |
|
if(i<5){ |
|
return old.getColumnName(i); |
|
} |
|
if(i<8){ |
|
return exCols[i-5]; |
|
} |
|
return old.getColumnName(i-2); |
|
} |
|
|
|
@Override |
|
public int getRowCount() throws TableDataException { |
|
return old.getRowCount(); |
|
} |
|
|
|
@Override |
|
public Object getValueAt(int r, int c) throws TableDataException { |
|
if( c<5 ){ |
|
return old.getValueAt(r,c); |
|
} |
|
if( c<8 ){ |
|
try{ |
|
String val = (String) old.getValueAt(r,5); |
|
JSONObject item = new JSONObject(val); |
|
return item.opt(exCols[c-5]); |
|
}catch(Exception e){ |
|
return null; |
|
} |
|
} |
|
return old.getValueAt(r,c-2); |
|
} |
|
}
|
|
|