?? terminalinfotablemodel.java
字號(hào):
package jp.co.ntl.swing.ext.terminal;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;
import jp.co.ntl.printer.PrinterInfo2;
public class TerminalInfoTableModel extends AbstractTableModel {
/**
*
*/
private static final long serialVersionUID = 1L;
private final String columnPrinter;
private final String[] columnNames;
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 mod start
private static final String TABLE_COL1_NAME = " ";
//private final Vector vcPrinterInfo;
private Vector vcPrinterInfo;
private Vector vcCheckBox;
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 mod end
public TerminalInfoTableModel(Vector vcPrinterInfo) {
this.vcPrinterInfo = vcPrinterInfo;
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 mod start
// this.columnPrinter = "";
// columnNames = new String[] {
// this.columnPrinter
// };
this.columnPrinter = Resource.getString(Resource.LIST_PRINTER);
columnNames = new String[] {
TABLE_COL1_NAME,
this.columnPrinter
};
vcCheckBox = new Vector();
for (int i = 0; i < vcPrinterInfo.size(); i ++) {
vcCheckBox.add(Boolean.FALSE);
}
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 mod end
}
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 add start
public synchronized void refreshInfos(Vector vcInfo) {
this.vcPrinterInfo = vcInfo;
vcCheckBox.clear();
for (int i = 0; i < vcPrinterInfo.size(); i ++) {
vcCheckBox.add(Boolean.FALSE);
}
fireTableDataChanged();
}
public synchronized void setCheckBox(int row, boolean flag) {
if (vcCheckBox == null) {
return;
}
if (row >= vcCheckBox.size()) {
return;
}
Object obj = flag ? Boolean.TRUE : Boolean.FALSE;
vcCheckBox.setElementAt(obj, row);
fireTableDataChanged();
}
public synchronized boolean getCheckBox(int row) {
if (vcCheckBox == null || vcCheckBox.size() <= row) {
return false;
}
Boolean bflag = (Boolean)vcCheckBox.get(row);
return bflag.booleanValue();
}
// public boolean isCellEditable(int row, int column){
// if(column == 0){
// return true;
// }else{
// return false;
// }
// }
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 add end
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 del start
// public synchronized void addPrinterInfo(PrinterInfo2 printerInfo) {
// vcPrinterInfo.add(printerInfo);
// fireTableDataChanged();
// }
//
// public synchronized void addPrinterInfos(PrinterInfo2[] printerInfos) {
// for (int i = 0; i < printerInfos.length; i++) {
// vcPrinterInfo.add(printerInfos[i]);
// }
// fireTableDataChanged();
// }
//
// public synchronized void deletePrinterInfo(int row) {
// if (row >= vcPrinterInfo.size()) {
// return;
// }
//
// vcPrinterInfo.remove(row);
// fireTableDataChanged();
// }
//
// public synchronized void deleteAllPrinterInfos() {
// vcPrinterInfo.clear();
// fireTableDataChanged();
// }
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 del end
public synchronized PrinterInfo2 getSelectedPrinterInfo(int selectedRow) {
if (vcPrinterInfo == null || selectedRow >= vcPrinterInfo.size()) {
return null;
}
return (PrinterInfo2)vcPrinterInfo.elementAt(selectedRow);
}
public synchronized PrinterInfo2[] getAllPrinterInfos() {
return (PrinterInfo2[])vcPrinterInfo.toArray(new PrinterInfo2[0]);
}
public synchronized void setPrinterInfo(int row, PrinterInfo2 printerInfo) {
if (row >= vcPrinterInfo.size()) {
return;
}
vcPrinterInfo.set(row, printerInfo);
fireTableDataChanged();
}
public String getColumnName(int column) {
if (columnNames == null) {
return null;
}
if (column >= columnNames.length) {
return null;
}
return columnNames[column];
}
public int getColumnCount() {
if (columnNames == null) {
return 0;
}
return columnNames.length;
}
public int getRowCount() {
if (vcPrinterInfo == null) {
return 0;
}
return vcPrinterInfo.size();
}
public Object getValueAt(int row, int column) {
if (vcPrinterInfo == null) {
return null;
}
if (row >= vcPrinterInfo.size()) {
return null;
}
if (column >= columnNames.length) {
return null;
}
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 mod begin
// PrinterInfo2 printerInfo = (PrinterInfo2)vcPrinterInfo.get(row);
if (column == 0) {
return (Boolean)vcCheckBox.get(row);
} else {
String name = columnNames[column];
if (name.equals(columnPrinter)) {
PrinterInfo2 printerInfo = (PrinterInfo2)vcPrinterInfo.get(row);
return printerInfo.getName();
}
}
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 mod end
return "";
}
public Class getColumnClass(int column) {
if (columnNames == null) {
return String.class;
}
if (column >= columnNames.length) {
return String.class;
}
String name = columnNames[column];
if (name.equals(columnPrinter)) {
return String.class;
}
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 add start
else if (column == 0) {
Object o = getValueAt(0, column);
return o == null ? Object.class : o.getClass();
}
// 2007.10.22 lium 暋悢僾儕儞僞懳墳 add end
return String.class;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -