package com.vci.client.workflow.editor.ui;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Locale;
|
|
import javax.swing.table.AbstractTableModel;
|
|
import com.vci.client.workflow.commom.ClientHelper;
|
import com.vci.corba.workflow.data.PropertyInfo;
|
|
public class CustomClassTableModel extends AbstractTableModel {
|
|
private static final long serialVersionUID = -655431475234368469L;
|
|
private String[] columns = {"事件名称"};
|
private List<PropertyInfo> data;
|
|
public CustomClassTableModel() {
|
data = new ArrayList<PropertyInfo>();
|
}
|
|
public void setData(List<PropertyInfo> data) {
|
this.data = data;
|
fireTableDataChanged();
|
}
|
|
public void addRow() {
|
if(data.size()==0){
|
data = new ArrayList<PropertyInfo>();
|
}
|
data.add(new PropertyInfo());
|
fireTableDataChanged();
|
}
|
|
public void addRow(PropertyInfo info) {
|
data.add(info);
|
fireTableDataChanged();
|
}
|
|
public void deleteRow(int[] selectedRows) {
|
for (int i = selectedRows.length - 1; i >= 0 ; i--) {
|
data.remove(selectedRows[i]);
|
}
|
fireTableDataChanged();
|
}
|
|
public int getRowCount() {
|
if(data == null) {
|
return 0;
|
}
|
return data.size();
|
}
|
|
public int getColumnCount() {
|
return columns.length;
|
}
|
|
public Object getValueAt(int rowIndex, int columnIndex) {
|
if(data == null) {
|
return null;
|
}
|
PropertyInfo propertyInfo = data.get(rowIndex);
|
if(propertyInfo==null){
|
return null;
|
}
|
if(columnIndex == 0) {
|
return propertyInfo.property;
|
}else{
|
return propertyInfo.value;
|
}
|
// }
|
// return null;
|
}
|
|
@Override
|
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
PropertyInfo propertyInfo = data.get(rowIndex);
|
switch (columnIndex) {
|
case 0:
|
propertyInfo.property = ((PropertyObject)aValue).getValue();
|
break;
|
default:
|
propertyInfo.value = ((PropertyObject)aValue).getValue();
|
break;
|
}
|
}
|
|
@Override
|
public Class<?> getColumnClass(int columnIndex) {
|
return String.class;
|
}
|
|
@Override
|
public String getColumnName(int column) {
|
return columns[column];
|
}
|
|
@Override
|
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
return true;
|
}
|
|
public List<PropertyInfo> getData() {
|
return data;
|
}
|
|
private String getI18nString(String code){
|
return ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + code, Locale.getDefault());
|
}
|
|
}
|