本文整理匯總了Java中com.smartgwt.client.widgets.grid.CellFormatter類的典型用法代碼示例。如果您正苦於以下問題:Java CellFormatter類的具體用法?Java CellFormatter怎麽用?Java CellFormatter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CellFormatter類屬於com.smartgwt.client.widgets.grid包,在下文中一共展示了CellFormatter類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildListGridField
import com.smartgwt.client.widgets.grid.CellFormatter; //導入依賴的package包/類
protected Map<GridColumns, ListGridField> buildListGridField() {
Map<GridColumns, ListGridField> fields = super.buildListGridField();
ListGridField idField = fields.get(TasksColumnsFactory.ID_ATTR);
idField.setType(ListGridFieldType.INTEGER);
alignCells(fields);
ListGridField execDuration = fields.get(EXEC_DURATION_ATTR);
execDuration.setCellFormatter(new CellFormatter() {
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
if (value != null) {
return Job.formatDuration(value.toString());
} else {
return "";
}
}
});
return fields;
}
示例2: createList
import com.smartgwt.client.widgets.grid.CellFormatter; //導入依賴的package包/類
private ListGrid createList() {
final ListGrid grid = new ListGrid();
grid.addDataArrivedHandler(new DataArrivedHandler() {
@Override
public void onDataArrived(DataArrivedEvent event) {
int startRow = event.getStartRow();
int endRow = event.getEndRow();
if (startRow == 0 && endRow >= 0) {
grid.focus();
grid.selectSingleRecord(0);
} else if (endRow < 0) {
grid.deselectAllRecords();
}
}
});
grid.setSelectionType(SelectionStyle.SINGLE);
grid.setCanSort(false);
grid.setDataSource(SearchDataSource.getInstance());
ListGridField label = new ListGridField(SearchDataSource.FIELD_LABEL,
i18n.DigitalObjectSearchView_ListHeaderLabel_Title());
ListGridField model = new ListGridField(SearchDataSource.FIELD_MODEL,
i18n.DigitalObjectSearchView_ListHeaderModel_Title(), 150);
model.setAlign(Alignment.CENTER);
ListGridField pid = new ListGridField(SearchDataSource.FIELD_PID,
i18n.DigitalObjectSearchView_ListHeaderPid_Title(), 100);
pid.setAlign(Alignment.CENTER);
ListGridField created = new ListGridField(SearchDataSource.FIELD_CREATED,
i18n.DigitalObjectSearchView_ListHeaderCreated_Title(), 100);
created.setAlign(Alignment.CENTER);
ListGridField modified = new ListGridField(SearchDataSource.FIELD_MODIFIED,
i18n.DigitalObjectSearchView_ListHeaderModified_Title(), 100);
modified.setAlign(Alignment.CENTER);
ListGridField owner = new ListGridField(SearchDataSource.FIELD_OWNER,
i18n.DigitalObjectSearchView_ListHeaderOwner_Title(), 100);
ListGridField state = new ListGridField(SearchDataSource.FIELD_STATE,
i18n.DigitalObjectSearchView_ListHeaderState_Title(), 100);
state.setHidden(true);
ListGridField export = new ListGridField(SearchDataSource.FIELD_EXPORT,
i18n.DigitalObjectSearchView_ListHeaderExport_Title(), 100);
export.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
return value == null || "0".equals(value)
? i18nSmartGwt.dialog_NoButtonTitle()
: i18nSmartGwt.dialog_YesButtonTitle();
}
});
grid.setFields(label, model, pid, created, modified, owner, state, export);
grid.setContextMenu(Actions.createMenu());
grid.addSelectionUpdatedHandler((event) -> {
selectionCache.setSelection();
});
return grid;
}
示例3: createTreeSelector
import com.smartgwt.client.widgets.grid.CellFormatter; //導入依賴的package包/類
private TreeGrid createTreeSelector() {
TreeGrid treeGrid = new TreeGrid();
treeGrid.setCanSort(false);
treeGrid.setDataSource(RelationDataSource.getInstance());
TreeGridField parentId = new TreeGridField(RelationDataSource.FIELD_PARENT);
TreeGridField label = new TreeGridField(RelationDataSource.FIELD_LABEL,
i18n.DigitalObjectSearchView_ListHeaderLabel_Title());
TreeGridField model = new TreeGridField(RelationDataSource.FIELD_MODEL,
i18n.DigitalObjectSearchView_ListHeaderModel_Title(), 150);
model.setAlign(Alignment.CENTER);
TreeGridField pid = new TreeGridField(RelationDataSource.FIELD_PID,
i18n.DigitalObjectSearchView_ListHeaderPid_Title(), 100);
pid.setAlign(Alignment.CENTER);
TreeGridField created = new TreeGridField(RelationDataSource.FIELD_CREATED,
i18n.DigitalObjectSearchView_ListHeaderCreated_Title(), 100);
created.setAlign(Alignment.CENTER);
TreeGridField modified = new TreeGridField(RelationDataSource.FIELD_MODIFIED,
i18n.DigitalObjectSearchView_ListHeaderModified_Title(), 100);
modified.setAlign(Alignment.CENTER);
TreeGridField owner = new TreeGridField(RelationDataSource.FIELD_OWNER,
i18n.DigitalObjectSearchView_ListHeaderOwner_Title(), 100);
TreeGridField export = new TreeGridField(SearchDataSource.FIELD_EXPORT,
i18n.DigitalObjectSearchView_ListHeaderExport_Title(), 100);
export.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
return value == null || "0".equals(value)
? i18nSmartGwt.dialog_NoButtonTitle()
: i18nSmartGwt.dialog_YesButtonTitle();
}
});
treeGrid.setFields(parentId, label, model, pid, created, modified, owner, export);
treeGrid.setTitleField(RelationDataSource.FIELD_LABEL);
treeGrid.setShowConnectors(true);
treeGrid.setEmptyMessage(i18n.DigitalObjectTreeView_EmptySelection_Msg());
treeGrid.setAlternateRecordStyles(true);
treeGrid.setSelectionType(SelectionStyle.SINGLE);
treeGrid.setContextMenu(Actions.createMenu());
treeGrid.addDataArrivedHandler(new DataArrivedHandler() {
@Override
public void onDataArrived(DataArrivedEvent event) {
selectAndExpandRootNode(event);
}
});
return treeGrid;
}
示例4: NewsListGrid
import com.smartgwt.client.widgets.grid.CellFormatter; //導入依賴的package包/類
public NewsListGrid() {
super();
i_newsXmlDS = NewsXmlDS.getInstance();
setWidth100();
setHeight100();
setShowAllRecords(true);
setDataSource(i_newsXmlDS);
// This will show the delete icon.
setCanRemoveRecords(true);
setWarnOnRemoval(true);
setWarnOnRemovalMessage("Are you sure you want to remove this news item? This cannot be undone.");
setAnimateRemoveRecord(true);
ListGridField idField = new ListGridField(NewsColumns.ID.colName(), "ID");
// Don't allow the id to be edited.
idField.setCanEdit(false);
idField.setWidth(40);
idField.setHidden(true);
ListGridField dateField = new ListGridField(NewsColumns.DATE.colName(), "Date");
// dateField.setWidth(100);
dateField.setAlign(Alignment.LEFT);
dateField.setType(ListGridFieldType.DATE);
// format the display of the date
final DateTimeFormat dateFormatter = DateTimeFormat.getFormat("MMMM dd, yyyy");
dateField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
if (value != null) {
try {
Date dateValue = new Date(Date.parse((String) value));
return dateFormatter.format(dateValue);
} catch (Exception e) {
return value.toString();
}
} else {
return "";
}
}
});
ListGridField infoField = new ListGridField(NewsColumns.INFO.colName(), "Information");
infoField.setWidth("*"); // take the remaining width.
setFields(idField, dateField, infoField);
setAutoFetchData(true);
setCanEdit(true);
setEditEvent(ListGridEditEvent.DOUBLECLICK);
setModalEditing(true);
}
示例5: NewsListGrid
import com.smartgwt.client.widgets.grid.CellFormatter; //導入依賴的package包/類
public NewsListGrid() {
super();
i_newsXmlDS = NewsXmlDS.getInstance();
setWidth100();
setHeight("30%");
setShowAllRecords(true);
setDataSource(i_newsXmlDS);
setShowEmptyMessage(false);
setWrapCells(true);
ListGridField dateField = new ListGridField(NewsColumns.DATE.colName(), "Date");
dateField.setAlign(Alignment.LEFT);
dateField.setType(ListGridFieldType.DATE);
dateField.setWrap(false);
// format the display of the date
final DateTimeFormat dateFormatter = DateTimeFormat.getFormat("MMMM dd, yyyy");
dateField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
if (value != null) {
try {
Date dateValue = new Date(Date.parse((String) value));
return dateFormatter.format(dateValue);
} catch (Exception e) {
return value.toString();
}
} else {
return "";
}
}
});
ListGridField infoField = new ListGridField(NewsColumns.INFO.colName(), "News");
dateField.setWidth("35%");
infoField.setWidth("*");
setFields(dateField, infoField);
// set the initial sort
SortSpecifier[] sortspec = new SortSpecifier[1];
sortspec[0] = new SortSpecifier(NewsColumns.DATE.colName(), SortDirection.DESCENDING);
setInitialSort(sortspec);
setAutoFetchData(true);
setCanEdit(false);
setCanHover(true);
setShowHover(true);
setShowHoverComponents(true);
}