当前位置: 首页>>代码示例>>Java>>正文


Java FlexTable.getFlexCellFormatter方法代码示例

本文整理汇总了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);
					}
				}
			}
		}
	}
}
 
开发者ID:openremote,项目名称:WebConsole,代码行数:37,代码来源:GridPanelComponent.java

示例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("&nbsp;") );
	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;
}
 
开发者ID:ivan-zapreev,项目名称:x-cure-chat,代码行数:81,代码来源:ChatMessagesPanelUI.java


注:本文中的com.google.gwt.user.client.ui.FlexTable.getFlexCellFormatter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。