📄 delaytermtablemodel.java
字号:
package collector.gui.model;
import java.util.*;
import javax.swing.table.*;
import collector.common.*;
import pbs.service.defineobject.*;
import pbs.service.vo.*;
public class DelayTermTableModel
extends AbstractTableModel {
String[] columnNames = new String[8];
Object[][] data = new Object[5][8];
ArrayList m_terminallist = new ArrayList();
terminalDefine tDefine = new terminalDefine();
public DelayTermTableModel() {
}
public DelayTermTableModel(int debug) {
super();
data[0][0] = new Boolean(false);
data[0][1] = "898989";
data[0][2] = new Long(1234567890);
int status = 0;
switch (status) {
case 0:
data[0][3] = "正常";
break;
case 1:
data[0][3] = "延时";
break;
case 2:
data[0][3] = "故障";
break;
default:
data[0][3] = "未知";
break;
}
data[0][4] = "";
data[0][5] = "";
data[0][6] = "";
data[0][7] = "";
}
public DelayTermTableModel(ArrayList terminallist) {
//必须是已经更新过的terminal,里面的meter已经fetch过了
//
super();
if (terminallist == null || terminallist.size() <= 0) {
//System.out.println("terminallist == null || terminallist.size() <= 0");
return;
}
else {
Object[] term_array = terminallist.toArray();
data = new Object[term_array.length][8];
//System.out.println("term_array.length = " + term_array.length);
if (term_array.length > 0) {
for (int i = 0; i < term_array.length; i++) {
Object obj = term_array[i];
//System.out.println("obj.getClass().getName() = " +obj.getClass().getName());
if (obj instanceof terminal) {
terminal term = (terminal) (term_array[i]);
data[i][0] = new Boolean(false);
data[i][1] = term.getTerminalName();
data[i][2] = new Long(term.getTerminalId());
int status = collector.common.CFunction.adjustTermStatus(term,
collector.common.CollectorDefine.ONTIME_TASK);
//System.out.println("the status of terminal: " +term.getTerminalName() +" = " + status);
switch (status) {
case 0:
data[i][3] = "正常";
break;
case 1:
data[i][3] = "延时";
break;
case 2:
data[i][3] = "故障";
break;
default:
data[i][3] = "未知";
break;
}
long fac_id = term.getFacId();
factory fac = (factory) (CollectorDefine.m_HashFactory.get(new Long(
fac_id)));
if (fac != null) {
data[i][6] = fac.getFacName();
long area_id = fac.getAreaId();
area area1 = (area) (CollectorDefine.m_HashArea.get(new Long(
area_id)));
if (area1 != null) {
data[i][7] = area1.getAreaName();
}
else {
data[i][7] = " ";
}
}
else {
data[i][6] = " ";
data[i][7] = " ";
}
Collection meter_col = term.getMeters();
if (meter_col == null || meter_col.size() <= 0) {
data[i][4] = " ";
data[i][5] = " ";
continue;
}
Object[] meter_array = meter_col.toArray();
long min_add_time_tag = 0;
long min_base_time_tag = 0;
for (int j = 0; j < meter_array.length; j++) {
meter meter1 = (meter) (meter_array[j]);
long add_time_tag = meter1.getAddTimeTag();
long base_time_tag = meter1.getBaseSendTimeTag();
if (j == 0) {
min_add_time_tag = add_time_tag;
min_base_time_tag = base_time_tag;
}
else {
if (add_time_tag < min_add_time_tag) {
min_add_time_tag = add_time_tag;
}
if (base_time_tag < min_base_time_tag) {
min_base_time_tag = base_time_tag;
}
}
}
data[i][4] = pbs.service.function.commonFunc.getTimeString(
min_add_time_tag);
data[i][5] = pbs.service.function.commonFunc.getTimeString(
min_base_time_tag);
}
}
}
}
}
public Class getColumnClass(int c) {
//System.out.println("Column = "+c);
//System.out.println("*********** the class of column "+c+" is "+getValueAt(0, c).getClass().getName());
return getValueAt(0, c).getClass();
}
public int getRowCount() {
return data.length;
}
public int getColumnCount() {
return 8;
}
public Object getValueAt(int rowIndex, int columnIndex) {
return data[rowIndex][columnIndex];
}
public String getColumnName(int column) {
if (column == 0) {
return "选中";
}
if (column == 1) {
return "计量单元名";
}
if (column == 2) {
return "计量单元ID";
}
if (column == 3) {
return "采集状态";
}
if (column == 4) {
return "最后增量采集时标";
}
if (column == 5) {
return "最后底码采集时标";
}
if (column == 6) {
return "所属厂站";
}
if (column == 7) {
return "所属地区";
}
else {
return "";
}
}
public boolean isCellEditable(int row, int col) {
if (col == 0) {
//System.out.println("the column : "+col+" is Editable");
return true;
}
else {
//System.out.println("the column : "+col+" is not Editable");
return false;
}
}
public void setValueAt(Object value, int row, int col) {
data[row][col] = value;
fireTableCellUpdated(row, col);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -