📄 modelexampledata.java~38~
字号:
package org.lazybug.skit.example;
import org.lazybug.skit.table.KTableModel;
import org.lazybug.skit.menu.KMenu;
import org.lazybug.skit.menu.KMenuItem;
import org.lazybug.skit.Toolkit;
import org.lazybug.skit.table.KTable;
/**
* <p>Title: Geniux</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author David Lau
* @version 1.0
*/
public class ModelExampleData extends KTableModel
{
public static String HEADERS[] = { "", "列1", "列2", "列3" , "列4", "列5" };
public String header[];
/*数据*/
private Object data[][];
/*弹出菜单*/
private KMenu popMenu;
public ModelExampleData(String header[], Object data[][])
{
super(data.length);
this.data = header;
this.data = data;
popMenu = new KMenu();
popMenu.addComponent(new KMenuItem("查看", "view"));
popMenu.addComponent(new KMenuItem("删除", "delete"));
popMenu.addComponent(new KMenuItem("修改", "modify"));
}
/**
* Returns the number of columns in the model.
*
* @return the number of columns in the model
* @todo Implement this org.lazybug.skit.table.KTableModel method
*/
public int getColumnCount()
{
return HEADERS.length;
}
/**
* Returns the name of the column at <code>col</code>.
*
* @param col the index of the column
* @return the name of the column
* @todo Implement this org.lazybug.skit.table.KTableModel method
*/
public String getColumnName(int col)
{
return HEADERS[col];
}
/**
* Returns the number of rows in the model.
*
* @return the number of rows in the model
* @todo Implement this org.lazybug.skit.table.KTableModel method
*/
public int getRowCount()
{
if( data != null )
{
return data.length;
}
return 0;
}
/**
* Returns the value for the cell at <code>col</code> and
* <code>row</code>.
*
* @param row the row whose value is to be queried
* @param col the column whose value is to be queried
* @return the value Object at the specified cell
* @todo Implement this org.lazybug.skit.table.KTableModel method
*/
public Object getValueAt(int row, int col)
{
Object o;
switch( col )
{
case 0:
o = Toolkit.insertButtonPicked(popMenu);
break;
case 2:
o = Toolkit.insertCellInput(
data[row][col], this.getColStyle(col), this.getColWidth(col));
case 3:
o = Toolkit.insertCellLink("#", data[row][col].toString(), this.getColStyle(col));
break;
case 4:
o = Toolkit.insertCellInput(
data[row][col], this.getColStyle(col), this.getColWidth(col));
break;
case 5:
o = Toolkit.insertCellInput(
data[row][col-1], this.getColStyle(col), this.getColWidth(col));
break;
case 1:
o = Toolkit.insertButtonPicked("abc");
break;
default:
o = null;
break;
}
return o;
}
/**
* Returns the java script tag.
* @return String
*/
public String getScriptTag()
{
StringBuffer sb = new StringBuffer();
for(int i = 0; i < this.popMenu.getComponentCount(); i++ )
{
sb.append(this.popMenu.getComponent(i).getScriptTag());
}
sb.append(Toolkit.insertJsFunction("abc"));
return sb.toString();
}
/**
* 返回弹出菜单标签
* @return String
*/
public String getPopMenuTag()
{
return this.popMenu.toString();
}
public static void main(String args[])
{
String data[][] ={
{"SAMSUNG", "128×160", "GRRS、CSD", "D418","SEC-SGHD418*MDEwMzA2MDA5OTgzMzQ2"},
{"SonyEricsson", "128×160", "GRRS、CSD", "K500i","SonyEricssonK500i/R2AA SEMC-Browser/4.0.2 Profile/MIDP-2.0 Configuration/CLDC-1.1"},
{"SonyEricsson", "128×160", "GRRS、CSD", "P800","SonyEricssonP800/R101 Profile/MIDP-1.0 Configuration/CLDC-1.0"},
{"SAMSUNG", "176×220", "GRRS、CSD", "GSH-D500","SAMSUNG-SGH-D500/1.0Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Browser/6.2.3.3.c.1.101 (GUI) MMP/2."},
{"SAMSUNG", "176×220", "GRRS、CSD", "GSH-E728","SAMSUNG-SGH-E728/TSS 2.5.0/WAP2.0 Profile/MIDP-2.0 Configuration/CLDC-1.0/*MzU1Mjg3MDA1Mjk2MTI"},
{"SAMSUNG", "128×160", "GRRS、CSD", "GSH-X608","SAMSUNG-SGH-X608/1.0*MzUyNjIwMDA1MTU3MDQ0 UP.Browser/6.1.0.6 (GUI) MMP/1.0"},
{"SAMSUNG", "176×220", "GRRS、CSD", "GSH-D500","Samsung-D500/Openwave/6.2.2Profile/MIDP-2.0/CLDC-1.1"},
{"MOTOROLA", "176×220", "CDMA", "A835","A835 MOT-A835/72.32.07. MIB/2.2 Profile/MIDP-1.0 Configuration/CLDC-1.0"},
{"MOTOROLA", "128×160", "GRRS、CSD", "C385","MOT-C385/0B.D1.09R MIB/2.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.0"},
{"MOTOROLA", "128×160", "GRRS、CSD", "MPx220","MOT-MPx220(2004.12.7)/SW./WAP2.0 Profile/MIDP-2.0 Configuration/CLDC-1.1"},
{"MOTOROLA", "240×320", "GRRS、CSD", "A768","MOT-A768/A768_G_00.A9.A1R MIB/2.2 Profile/MIDP-2.0 Configuration/CLDC-1.0"},
{"MOTOROLA", "128×128", "GRRS、CSD", "V188","MOT-V188/0B.D2.2BR MIB/2.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.0"},
{"NOKIA", "320×240", "GRRS、CSD", "6131","Nokia6231/2.0 (03.15) Profile/MIDP-2.0 Configuration/CLDC-1.1"},
{"NOKIA", "240×320", "GRRS、CSD", "7280","Nokia7280/2.0 (03.24) Profile/MIDP-2.0 Configuration/CLDC-1.1"},
{"NOKIA", "128×128", "CDMA", "6220","Nokia6220/2.0 (5.15) Profile/MIDP-1.0 Configuration/CLDC-1.0"},
{"NOKIA", "176×208", "GRRS、CSD", "3230","Nokia3230/2.0 (3.0505.2) SymbianOS/7.0s Series60/2.1 Profile/MIDP-2.0 Configuration/CLDC-1.0"},
{"NOKIA", "128×160", "GRRS、CSD", "3100","Nokia3100/06.01 (UCWEB 3.3B)"},
{"TCL", "128×160", "GRRS、CSD", "E737","TCL-e737/401/WAP-2.0/MIDP-1.0/CLDC-1.0"},
{"SAMSUNG", "176×220", "GRRS、CSD", "P708","LENOVO-P708/(2005.04.12)S268/WAP1.2.1 Profile"},
//{"SAMSUNG", "128×160", "GRRS、CSD", "SGH-E108","1"},
};
ModelExampleData model = new ModelExampleData(data);
model.setColWidth(0, 30);
model.setColWidth(1, 50);
model.setColWidth(2, 100);
model.setColWidth(3, 120);
model.setColWidth(4, 200);
model.setColStyle(4, "font-weight:bold;color:#F39405");
model.setColWidth(5, 350);
model.setColStyle(5, "font-weight:bold;color:#F39405");
KTable table = new KTable(model);
table.setDblClickFunc("dblclk");
table.setHeight(180);
Toolkit.createTableJspFile(
table, "D:/work/project/mste/tomcat/webapps/mste/", "table_example5");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -