本文整理汇总了Java中com.google.gwt.user.client.ui.FlexTable.getFlexCellFormatter方法的典型用法代码示例。如果您正苦于以下问题:Java FlexTable.getFlexCellFormatter方法的具体用法?Java FlexTable.getFlexCellFormatter怎么用?Java FlexTable.getFlexCellFormatter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.ui.FlexTable
的用法示例。
在下文中一共展示了FlexTable.getFlexCellFormatter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRender
import com.google.gwt.user.client.ui.FlexTable; //导入方法依赖的package包/类
@Override
public void onRender(int width, int height, List<DataValuePairContainer> data) {
FlexTable grid = (FlexTable)getWidget();
int colWidth = (int)Math.round((double)width / cols);
int rowHeight = (int)Math.round((double)height / rows);
for (int i=0; i<rows; i++) {
for (int j=0; j<cols; j++) {
CellData cellData = cellDataArr[i][j];
if (cellData != null) {
if (!cellData.ignore) {
FlexCellFormatter formatter = grid.getFlexCellFormatter();
int cellWidth = cellData.colSpan * colWidth;
int cellHeight = cellData.rowSpan * rowHeight;
formatter.setRowSpan(i, j, cellData.rowSpan);
formatter.setColSpan(i, j, cellData.colSpan);
formatter.setHeight(i, j, cellHeight + "px");
formatter.setWidth(i, j, cellWidth + "px");
formatter.setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER);
formatter.setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE);
Widget widget = grid.getWidget(i, j);
if (widget != null) {
ConsoleComponent component = (ConsoleComponent)widget;
if (component != null) {
component.onAdd(cellWidth, cellHeight);
}
} else {
// Just add an empty cell
this.setComponent(i, j, null);
}
}
}
}
}
}
示例2: addElementsToTable
import com.google.gwt.user.client.ui.FlexTable; //导入方法依赖的package包/类
/**
* Allows to add a chat message entry to the flex table
* @param table the table to add the message to
* @param avatars the array of registered avatar widgets to be appended
* with the newly added avatar or null if we do not want
* to keep trak of avatars.
* @param numberOfRows the current number of rows in the flex table
* @param avatarWidget the avatar widget
* @param messageWidget the message widget
* @param isLeftMessage true if this is a left message, false for the right one
* @return the current number of wors in the table
*/
private static int addElementsToTable( final FlexTable table, List<Widget> avatars,
final int numberOfRows, final Widget avatarWidget,
final Widget messageWidget, final boolean isLeftMessage ) {
//Insert a new row
final int newRowIndex = numberOfRows;
table.insertRow( newRowIndex );
//Get the cell formatter
FlexCellFormatter cellFormatter = table.getFlexCellFormatter();
//Determine the avatar's row and column index and span
//the avatar's cell across the rows, if possible
final int avatarRowIdx, avatarColIdx, emptyColIdx, messageColIdx;
if( newRowIndex > 0 ) {
avatarRowIdx = newRowIndex - 1;
if( isLeftMessage ) {
avatarColIdx = FIRST_COLUMN_IDX;
messageColIdx = FIRST_COLUMN_IDX;
emptyColIdx = SECOND_COLUM_IDX;
cellFormatter.setRowSpan(avatarRowIdx, avatarColIdx, 2);
table.insertCell( newRowIndex, messageColIdx );
table.insertCell( newRowIndex, emptyColIdx );
} else {
avatarColIdx = ( newRowIndex == 1 ) ? THIRD_COLUMN_IDX : SECOND_COLUM_IDX;
messageColIdx = SECOND_COLUM_IDX;
emptyColIdx = FIRST_COLUMN_IDX;
table.insertCell( newRowIndex, emptyColIdx );
table.insertCell( newRowIndex, messageColIdx );
cellFormatter.setRowSpan(avatarRowIdx, avatarColIdx, 2);
}
} else {
avatarRowIdx = newRowIndex;
messageColIdx = SECOND_COLUM_IDX;
if( isLeftMessage ) {
avatarColIdx = FIRST_COLUMN_IDX;
emptyColIdx = THIRD_COLUMN_IDX;
} else {
avatarColIdx = THIRD_COLUMN_IDX;
emptyColIdx = FIRST_COLUMN_IDX;
}
table.insertCell( newRowIndex, FIRST_COLUMN_IDX );
table.insertCell( newRowIndex, SECOND_COLUM_IDX );
table.insertCell( newRowIndex, THIRD_COLUMN_IDX );
}
//Insert the avatar and the chat message itself with the proper styles
final String messageStyle;
final String avatarStyle;
if( isLeftMessage ) {
messageStyle = CommonResourcesContainer.CHAT_ENTRY_MESSAGE_LEFT_STYLE;
avatarStyle = CommonResourcesContainer.CHAT_ENTRY_AVATAR_LEFT_STYLE;
} else {
messageStyle = CommonResourcesContainer.CHAT_ENTRY_MESSAGE_RIGHT_STYLE;
avatarStyle = CommonResourcesContainer.CHAT_ENTRY_AVATAR_RIGHT_STYLE;
}
table.setWidget( newRowIndex, emptyColIdx, new HTML(" ") );
cellFormatter.setStyleName( newRowIndex, messageColIdx, messageStyle );
table.setWidget( newRowIndex, messageColIdx, messageWidget );
cellFormatter.setStyleName( avatarRowIdx, avatarColIdx, avatarStyle );
table.setWidget( avatarRowIdx, avatarColIdx, avatarWidget );
//Add the new avatar to the avatars list, if it not null
if( avatars != null ) {
avatars.add( avatarWidget );
}
return numberOfRows + 1;
}