本文整理汇总了Java中com.smartgwt.client.widgets.viewer.DetailFormatter类的典型用法代码示例。如果您正苦于以下问题:Java DetailFormatter类的具体用法?Java DetailFormatter怎么用?Java DetailFormatter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DetailFormatter类属于com.smartgwt.client.widgets.viewer包,在下文中一共展示了DetailFormatter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import com.smartgwt.client.widgets.viewer.DetailFormatter; //导入依赖的package包/类
/**
* @return the Widget to display, ready to be added in a container
*/
public Layout build() {
this.label = new Label(this.emptyMessage);
this.label.setWidth100();
this.label.setAlign(Alignment.CENTER);
this.details = new DetailViewer();
this.details.setWidth100();
this.details.setHeight100();
this.details.setCanSelectText(true);
this.details.hide();
GridColumns[] lines = this.factory.getColumns();
DetailViewerField[] fields = new DetailViewerField[lines.length];
for (int i = 0; i < lines.length; i++) {
fields[i] = new DetailViewerField(lines[i].getName(), lines[i].getTitle());
if (lines[i] == TasksColumnsFactory.EXEC_DURATION_ATTR || lines[i] == JobsColumnsFactory.DURATION_ATTR) {
fields[i].setDetailFormatter(new DetailFormatter() {
@Override
public String format(Object duration, Record record, DetailViewerField detailViewerField) {
if (duration != null) {
return Job.formatDuration(duration.toString());
} else {
return "";
}
}
});
}
}
this.details.setFields(fields);
return getLayout();
}
示例2: createButtons
import com.smartgwt.client.widgets.viewer.DetailFormatter; //导入依赖的package包/类
private void createButtons() {
tileGrid = new TileGrid();
tileGrid.setTileWidth(250);
tileGrid.setTileHeight(250);
tileGrid.setHeight(400);
tileGrid.setWidth(800);
tileGrid.setID("boundList");
tileGrid.setCanReorderTiles(false);
tileGrid.setShowAllRecords(false);
tileGrid.addRecordClickHandler(new RecordClickHandler() {
@Override
public void onRecordClick(RecordClickEvent event) {
switch (event.getRecord().getAttributeAsInt("rec")) {
case 1:
Window.open("/author.html"+LocalSettings.getInstance().getLocateExtension(), "_self", "");
break;
case 2:
Window.open("/resultDisplayRuns.html", "_self", "");
// SC.say("feature not yet implemented");
break;
case 3:
Window.open("/search.html", "_self", "");
break;
default:
break;
}
}
});
// tileGrid.setBorder("1px solid gray");
Record authoring = new Record();
authoring.setAttribute("picture", "author.png");
authoring.setAttribute("commonName", "Authoring");
authoring.setAttribute("rec", 1);
Record results = new Record();
results.setAttribute("picture", "resultsTool.png");
results.setAttribute("commonName", "Results");
results.setAttribute("rec", 2);
Record search = new Record();
search.setAttribute("picture", "searchTool.png");
search.setAttribute("commonName", "Search");
search.setAttribute("rec", 3);
DataSource ds =new DataSource();
ds.setClientOnly(true);
ds.addData(authoring);
ds.addData(results);
ds.addData(search);
tileGrid.setDataSource(ds);
tileGrid.setAutoFetchData(true);
DetailViewerField pictureField = new DetailViewerField("picture");
pictureField.setType("image");
pictureField.setImageHeight(200);
pictureField.setImageWidth(200);
DetailViewerField commonNameField = new DetailViewerField("commonName");
// commonNameField.setCellStyle("commonName");
// DetailViewerField lifeSpanField = new DetailViewerField("lifeSpan");
// lifeSpanField.setCellStyle("lifeSpan");
commonNameField.setDetailFormatter(new DetailFormatter() {
public String format(Object value, Record record, DetailViewerField field) {
return "<h1> " + value +"</h1>";
}
});
DetailViewerField statusField = new DetailViewerField("status");
tileGrid.setFields(pictureField, commonNameField);
}