在GWT中的CellTable的列中添加图标 [英] Add Icon in a Column of CellTable in GWT
问题描述
我想添加图片单元格。
我不想使用Gwt-Ext或Smart客户端。
我的代码
private CellTable< FDocument> getDocumentTable(){
if(documentTable == null){
documentTable = new CellTable< FDocument>();
documentTable.setSize(600px,300px);
documentTable.addColumn(nameColumnD,NAME);
documentTable.addColumn(sizeColumnD,SIZE);
documentTable.addColumn(modified_by_ColumnD,MODIFIED BY);
documentTable.addColumn(dateColumnD,MODIFIED ON);
documentTable.addColumn(majorVersion,Major Version);
}
返回documentTable;
}
TextColumn< FDocument> nameColumnD = new TextColumn< FDocument>(){
@Override
public String getValue(FDocument object){
return object.getName();
}
};
TextColumn< FDocument> sizeColumnD = new TextColumn< FDocument>(){
@Override
public String getValue(FDocument object){
return object.getSize();
}
};
.. //同样所有的颜色。
我想添加到图片单元格。如何操作。
编辑
ImageCell imageCell = new ImageCell();
Column< FDocument,String> iconColumn = new Column< FDocument,String>(imageCell){
@Override
public String getValue(FDocument object){
// TODO自动生成方法存根
返回object.getImageUrl(object);
}
};
在FDocument类中
public String getImageUrl (FilenetDocument对象){
if(object.getMimeType()。equals(text / plain)){
返回url(Txt16.gif);
} else {
if(object.getMimeType()==application / x-filenet-publishtemplate){
returnurl(PublishTemplate16.gif);
} else {
if(object.getMimeType()==application / x-filenet-filetype-msg){
returnurl(Msg16.gif);
} else {
if(object.getMimeType()==application / x-filenet-workflowdefinition){
returnurl(WorkflowDefinition16.gif);
} else {
if(object.getMimeType()==application / msword){
returnurl(Doc16.gif);
} else {
returnurl(Txt16.gif);
}
}
}
}
}
getImageUrl()
中,return是一种css风格,不是路径到图像... 因此,要么实现一个新的Cell,它可以使用您提供的样式进行渲染,也可以使用 ImageResourceCell 和你的静态图标,或者尝试渲染方法由 Hardik Mishra 提供,但更新 getImageUrl()
以返回PATH到图片。
With all the values in textcoloumn.
I want to add image cell.
I don't want use Gwt-Ext or Smart client.
My code
private CellTable<FDocument> getDocumentTable() {
if (documentTable == null) {
documentTable = new CellTable<FDocument>();
documentTable.setSize("600px", "300px");
documentTable.addColumn(nameColumnD, "NAME");
documentTable.addColumn(sizeColumnD, "SIZE");
documentTable.addColumn(modified_by_ColumnD, "MODIFIED BY");
documentTable.addColumn(dateColumnD, "MODIFIED ON");
documentTable.addColumn(majorVersion, "Major Version");
}
return documentTable;
}
TextColumn<FDocument> nameColumnD = new TextColumn<FDocument>() {
@Override
public String getValue(FDocument object) {
return object.getName();
}
};
TextColumn<FDocument> sizeColumnD = new TextColumn<FDocument>() {
@Override
public String getValue(FDocument object) {
return object.getSize();
}
};
..// similarly all the coloumn.
I want to add to image Cell. How to do it.
edited
ImageCell imageCell=new ImageCell();
Column<FDocument,String> iconColumn = new Column<FDocument, String>(imageCell){
@Override
public String getValue(FDocument object) {
// TODO Auto-generated method stub
return object.getImageUrl(object);
}
};
in FDocument Class
public String getImageUrl(FilenetDocument object){
if(object.getMimeType().equals("text/plain")){
return "url(Txt16.gif)";
}else{
if(object.getMimeType()=="application/x-filenet-publishtemplate"){
return "url(PublishTemplate16.gif)";
}else{
if(object.getMimeType()=="application/x-filenet-filetype-msg"){
return "url(Msg16.gif)";
}else{
if(object.getMimeType()=="application/x-filenet-workflowdefinition"){
return "url(WorkflowDefinition16.gif)";
}else{
if(object.getMimeType()=="application/msword"){
return "url(Doc16.gif)";
}else{
return "url(Txt16.gif)";
}
}
}
}
}
In your function getImageUrl()
, the return is a css style, not path to an image...
So either implement a new Cell which render with the style you provide, or use a ImageResourceCell with your static icons, or try the render method provided by Hardik Mishra but update getImageUrl()
to return a PATH to an image.
这篇关于在GWT中的CellTable的列中添加图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!