Java Code Examples for com.google.gwt.user.client.ui.HTMLTable.CellFormatter

The following examples show how to use com.google.gwt.user.client.ui.HTMLTable.CellFormatter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: swcv   Source File: WordCloudLatestApp.java    License: MIT License 6 votes vote down vote up
private Grid createStatTable(DBStatistics result)
{
    Grid table = new Grid(3, 2);
    table.addStyleName("stat");

    table.setHTML(0, 0, "the number of clouds <b>in total</b>");
    table.setHTML(1, 0, "the number of clouds constructed <b>last month</b>");
    table.setHTML(2, 0, "the number of clouds constructed <b>last week</b>");

    table.setHTML(0, 1, "" + result.getTotal());
    table.setHTML(1, 1, "" + result.getLastMonth());
    table.setHTML(2, 1, "" + result.getLastWeek());

    CellFormatter cf = table.getCellFormatter();
    cf.setWidth(0, 0, "65%");
    cf.setWidth(0, 1, "35%");
    return table;
}
 
Example 2
Source Project: swcv   Source File: SettingsPanel.java    License: MIT License 6 votes vote down vote up
private void addParseOptions(FlexTable layout, CellFormatter cf)
{
    cf.setStyleName(0, 4, "adv-cell-label");
    layout.setWidget(0, 4, createLabel("Remove Stop Words:"));
    layout.setWidget(0, 5, createCheckboxStopwords());

    cf.setStyleName(1, 4, "adv-cell-label");
    layout.setWidget(1, 4, createLabel("Remove Numbers:"));
    layout.setWidget(1, 5, createCheckboxRemoveNumbers());

    cf.setStyleName(2, 4, "adv-cell-label");
    layout.setWidget(2, 4, createLabel("Group Similar Words:"));
    layout.setWidget(2, 5, createCheckboxStem());

    cf.setStyleName(3, 4, "adv-cell-label");
    layout.setWidget(3, 4, createLabel("Shortest Word:"));
    layout.setWidget(3, 5, createMinLengthField());

}
 
Example 3
/**
 * Set the WordWarp for all the row cells
 *
 * @param row     The row cell
 * @param columns Number of row columns
 */
private void setRowWordWarp(FlexTable table, int row, int columns, boolean wrap) {
	CellFormatter cellFormatter = table.getCellFormatter();

	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, wrap);
	}
}
 
Example 4
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 */
private void setRowWordWarp(FlexTable table, int row, int columns, boolean wrap) {
	CellFormatter cellFormatter = table.getCellFormatter();

	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, wrap);
	}
}
 
Example 5
/**
 * Adds a new row
 *
 * @param search The search value
 */
public void addRow(GWTQueryParams search) {
	int rows = table.getRowCount();

	data.put(dataIndexValue, search);

	if (!search.isShared()) {
		table.setHTML(rows, 0, "&nbsp;");
	} else {
		table.setWidget(rows, 0, new Image(OKMBundleResources.INSTANCE.sharedQuery()));
	}

	table.setHTML(rows, 1, search.getQueryName());
	table.setHTML(rows, 2, "" + dataIndexValue++);
	table.setHTML(rows, 3, "");
	table.getFlexCellFormatter().setVisible(rows, 2, false);

	// The hidden column extends table to 100% width
	CellFormatter cellFormatter = table.getCellFormatter();
	cellFormatter.setWidth(rows, 0, "30px");
	cellFormatter.setHeight(rows, 0, "20px");
	cellFormatter.setHorizontalAlignment(rows, 0, HasAlignment.ALIGN_CENTER);
	cellFormatter.setVerticalAlignment(rows, 0, HasAlignment.ALIGN_MIDDLE);
	cellFormatter.setWidth(rows, 3, "100%");

	table.getRowFormatter().setStyleName(rows, "okm-userNews");
	setRowWordWarp(rows, 4, false);
}
 
Example 6
/**
 * Adds a new row
 *
 * @param search Search parameters to be added.
 */
private void addRow(GWTQueryParams search) {
	int rows = table.getRowCount();

	data.put(new Long(dataIndexValue), search);

	if (!search.isShared()) {
		table.setHTML(rows, 0, "&nbsp;");
	} else {
		table.setWidget(rows, 0, new Image(OKMBundleResources.INSTANCE.sharedQuery()));
	}

	table.setHTML(rows, 1, search.getQueryName());
	table.setHTML(rows, 2, "" + dataIndexValue++);
	table.setHTML(rows, 3, "");
	table.getCellFormatter().setVisible(rows, 2, false);

	// The hidden column extends table to 100% width
	CellFormatter cellFormatter = table.getCellFormatter();
	cellFormatter.setWidth(rows, 0, "30px");
	cellFormatter.setHeight(rows, 0, "20px");
	cellFormatter.setHorizontalAlignment(rows, 0, HasAlignment.ALIGN_CENTER);
	cellFormatter.setVerticalAlignment(rows, 0, HasAlignment.ALIGN_MIDDLE);
	cellFormatter.setWidth(rows, 3, "100%");

	table.getRowFormatter().setStyleName(rows, "okm-SearchSaved");
	setRowWordWarp(rows, 4, false);
}
 
Example 7
Source Project: sc2gears   Source File: ClientUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the horizontal alignment of all cells of the specified table.
 * @param table      table whose cells to be aligned
 * @param hAlignment horizontal alignment to be set
 */
public static void alignTableCells( final HTMLTable table, final HorizontalAlignmentConstant hAlignment ) {
	final CellFormatter cellFormatter = table.getCellFormatter();
	
	for ( int i = table.getRowCount() - 1; i >= 0; i-- )
		for ( int j = table.getCellCount( i ) - 1; j >= 0; j-- )
			cellFormatter.setHorizontalAlignment( i, j, hAlignment );
}
 
Example 8
/**
 * The folder
 */
public Folder() {
	folder = new GWTFolder();
	categoryManager = new CategoryManager(CategoryManager.ORIGIN_FOLDER);
	keywordManager = new KeywordManager(ThesaurusSelectPopup.FOLDER_PROPERTIES);
	table = new FlexTable();
	tableProperties = new FlexTable();
	tableSubscribedUsers = new FlexTable();
	scrollPanel = new ScrollPanel(table);

	tableProperties.setHTML(0, 0, "<b>" + Main.i18n("folder.uuid") + "</b>");
	tableProperties.setHTML(0, 1, "");
	tableProperties.setHTML(1, 0, "<b>" + Main.i18n("folder.name") + "</b>");
	tableProperties.setHTML(1, 1, "");
	tableProperties.setHTML(2, 0, "<b>" + Main.i18n("folder.parent") + "</b>");
	tableProperties.setHTML(2, 1, "");
	tableProperties.setHTML(3, 0, "<b>" + Main.i18n("folder.created") + "</b>");
	tableProperties.setHTML(3, 1, "");
	tableProperties.setHTML(4, 0, "<b>" + Main.i18n("folder.subscribed") + "</b>");
	tableProperties.setHTML(4, 1, "");
	tableProperties.setHTML(5, 0, "<b>" + Main.i18n("folder.number.folders") + "</b>");
	tableProperties.setHTML(5, 1, "");
	tableProperties.setHTML(6, 0, "<b>" + Main.i18n("folder.number.documents") + "</b>");
	tableProperties.setHTML(6, 1, "");
	tableProperties.setHTML(7, 0, "<b>" + Main.i18n("folder.number.mails") + "</b>");
	tableProperties.setHTML(7, 1, "");
	tableProperties.setHTML(8, 0, "<b>" + Main.i18n("folder.keywords") + "</b>");
	tableProperties.setHTML(8, 1, "");
	tableProperties.setHTML(9, 0, "<b>" + Main.i18n("folder.url") + "</b>");
	tableProperties.setWidget(9, 1, new HTML(""));
	tableProperties.setHTML(10, 0, "<b>" + Main.i18n("folder.webdav") + "</b>");
	tableProperties.setWidget(10, 1, new HTML(""));

	tableProperties.getCellFormatter().setVerticalAlignment(8, 0, HasAlignment.ALIGN_TOP);

	// Sets the tagcloud
	keywordManager.getKeywordCloud().setWidth("350px");

	VerticalPanel vPanel2 = new VerticalPanel();

	hPanelSubscribedUsers = new HorizontalPanel();
	subcribedUsersText = new HTML("<b>" + Main.i18n("folder.subscribed.users") + "<b>");
	proposeSubscribeImage = new Image(OKMBundleResources.INSTANCE.proposeSubscription());
	proposeSubscribeImage.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			MessagingToolBarBox.get().executeProposeSubscription(folder.getUuid(), GWTFolder.TYPE);
		}
	});

	hPanelSubscribedUsers.add(subcribedUsersText);
	hPanelSubscribedUsers.add(new HTML("&nbsp;"));
	hPanelSubscribedUsers.setCellVerticalAlignment(subcribedUsersText, HasAlignment.ALIGN_MIDDLE);

	vPanel2.add(hPanelSubscribedUsers);
	vPanel2.add(tableSubscribedUsers);
	HTML space2 = new HTML("");
	vPanel2.add(space2);
	vPanel2.add(keywordManager.getKeywordCloudText());
	vPanel2.add(keywordManager.getKeywordCloud());
	HTML space3 = new HTML("");
	vPanel2.add(space3);
	vPanel2.add(categoryManager.getPanelCategories());
	vPanel2.add(categoryManager.getSubscribedCategoriesTable());

	vPanel2.setCellHeight(space2, "10px");
	vPanel2.setCellHeight(space3, "10px");

	table.setWidget(0, 0, tableProperties);
	table.setHTML(0, 1, "");
	table.setWidget(0, 2, vPanel2);

	// The hidden column extends table to 100% width
	CellFormatter cellFormatter = table.getCellFormatter();
	cellFormatter.setWidth(0, 1, "25px");
	cellFormatter.setVerticalAlignment(0, 0, HasAlignment.ALIGN_TOP);
	cellFormatter.setVerticalAlignment(0, 2, HasAlignment.ALIGN_TOP);

	// Sets wordWrap for al rows
	for (int i = 0; i < 11; i++) {
		setRowWordWarp(i, 0, true, tableProperties);
	}

	setRowWordWarp(0, 0, true, tableSubscribedUsers);

	tableProperties.setStyleName("okm-DisableSelect");
	tableSubscribedUsers.setStyleName("okm-DisableSelect");
	proposeSubscribeImage.addStyleName("okm-Hyperlink");

	initWidget(scrollPanel);
}
 
Example 9
/**
 * Document
 */
public Document() {
	categoryManager = new CategoryManager(CategoryManager.ORIGIN_DOCUMENT);
	keywordManager = new KeywordManager(ThesaurusSelectPopup.DOCUMENT_PROPERTIES);
	document = new GWTDocument();
	table = new FlexTable();
	tableProperties = new FlexTable();
	tableSubscribedUsers = new FlexTable();
	scrollPanel = new ScrollPanel(table);

	tableProperties.setHTML(0, 0, "<b>" + Main.i18n("document.uuid") + "</b>");
	tableProperties.setHTML(0, 1, "");
	tableProperties.setHTML(1, 0, "<b>" + Main.i18n("document.name") + "</b>");
	tableProperties.setHTML(1, 1, "");
	tableProperties.setHTML(2, 0, "<b>" + Main.i18n("document.folder") + "</b>");
	tableProperties.setHTML(3, 1, "");
	tableProperties.setHTML(3, 0, "<b>" + Main.i18n("document.size") + "</b>");
	tableProperties.setHTML(4, 1, "");
	tableProperties.setHTML(4, 0, "<b>" + Main.i18n("document.created") + "</b>");
	tableProperties.setHTML(5, 1, "");
	tableProperties.setHTML(5, 0, "<b>" + Main.i18n("document.lastmodified") + "</b>");
	tableProperties.setHTML(5, 1, "");
	tableProperties.setHTML(6, 0, "<b>" + Main.i18n("document.mimetype") + "</b>");
	tableProperties.setHTML(6, 1, "");
	tableProperties.setHTML(7, 0, "<b>" + Main.i18n("document.keywords") + "</b>");
	tableProperties.setHTML(7, 1, "");
	tableProperties.setHTML(8, 0, "<b>" + Main.i18n("document.status") + "</b>");
	tableProperties.setHTML(8, 1, "");
	tableProperties.setHTML(9, 0, "<b>" + Main.i18n("document.subscribed") + "</b>");
	tableProperties.setHTML(9, 1, "");
	tableProperties.setHTML(10, 0, "<b>" + Main.i18n("document.history.size") + "</b>");
	tableProperties.setHTML(10, 1, "");
	tableProperties.setHTML(11, 0, "<b>" + Main.i18n("document.url") + "</b>");
	tableProperties.setWidget(11, 1, new HTML(""));
	tableProperties.setHTML(12, 0, "<b>" + Main.i18n("document.webdav") + "</b>");
	tableProperties.setWidget(12, 1, new HTML(""));

	tableProperties.getCellFormatter().setVerticalAlignment(7, 0, HasAlignment.ALIGN_TOP);

	// Sets the tagcloud
	keywordManager.getKeywordCloud().setWidth("350px");

	VerticalPanel vPanel2 = new VerticalPanel();

	hPanelSubscribedUsers = new HorizontalPanel();
	subcribedUsersText = new HTML("<b>" + Main.i18n("document.subscribed.users") + "<b>");
	proposeSubscribeImage = new Image(OKMBundleResources.INSTANCE.proposeSubscription());
	proposeSubscribeImage.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			MessagingToolBarBox.get().executeProposeSubscription(document.getUuid(), GWTDocument.TYPE);
		}
	});
	hPanelSubscribedUsers.add(subcribedUsersText);
	hPanelSubscribedUsers.add(new HTML("&nbsp;"));
	hPanelSubscribedUsers.setCellVerticalAlignment(subcribedUsersText, HasAlignment.ALIGN_MIDDLE);

	vPanel2.add(hPanelSubscribedUsers);
	vPanel2.add(tableSubscribedUsers);
	HTML space2 = new HTML("");
	vPanel2.add(space2);
	vPanel2.add(keywordManager.getKeywordCloudText());
	vPanel2.add(keywordManager.getKeywordCloud());
	HTML space3 = new HTML("");
	vPanel2.add(space3);
	vPanel2.add(categoryManager.getPanelCategories());
	vPanel2.add(categoryManager.getSubscribedCategoriesTable());

	vPanel2.setCellHeight(space2, "10px");
	vPanel2.setCellHeight(space3, "10px");

	table.setWidget(0, 0, tableProperties);
	table.setHTML(0, 1, "");
	table.setWidget(0, 2, vPanel2);

	// The hidden column extends table to 100% width
	CellFormatter cellFormatter = table.getCellFormatter();
	cellFormatter.setWidth(0, 1, "25px");
	cellFormatter.setVerticalAlignment(0, 0, HasAlignment.ALIGN_TOP);
	cellFormatter.setVerticalAlignment(0, 2, HasAlignment.ALIGN_TOP);

	// Sets wordWrap for al rows
	for (int i = 0; i < 11; i++) {
		setRowWordWarp(i, 0, true, tableProperties);
	}

	setRowWordWarp(0, 0, true, tableSubscribedUsers);

	tableProperties.setStyleName("okm-DisableSelect");
	tableSubscribedUsers.setStyleName("okm-DisableSelect");
	proposeSubscribeImage.addStyleName("okm-Hyperlink");

	initWidget(scrollPanel);
}
 
Example 10
Source Project: shortyz   Source File: Renderer.java    License: GNU General Public License v3.0 4 votes vote down vote up
public void render(Word w){
    Word currentWord = this.board.getCurrentWord();
    Position currentHighlightLetter = this.board.getHighlightLetter();
    for(int across = 0; across < this.board.getBoxes().length; across++){
        for(int down=0; down < this.board.getBoxes()[across].length; down++){
           CellFormatter formatter = this.table.getCellFormatter();
           Box box = this.board.getBoxes()[across][down];
           if(!currentWord.checkInWord(across, down) && w != null &&  !w.checkInWord(across, down)){
                continue;
            }

            if(box == null){
                continue;
            }

            BoxView view = (BoxView) table.getWidget(down, across);
            view.setValue(box);

            if(box.isCheated()){
                formatter.addStyleName(down, across, resources.css().cheated());
            }

            

            if(currentHighlightLetter.across == across && currentHighlightLetter.down == down){
                formatter.addStyleName(down, across, resources.css().currentLetterHighlight());
            } else {
                formatter.removeStyleName(down, across, resources.css().currentLetterHighlight());
            }
            if(board.isShowErrors() && box.getResponse() != ' ' && box.getResponse() != box.getSolution() ){
                formatter.addStyleName(down, across, resources.css().error());
            } else {
                formatter.removeStyleName(down, across, resources.css().error());
            }

            if(box.getResponder() != null && colorMap.get(box.getResponder()) != null){
                view.getElement().getStyle().setColor(colorMap.get(box.getResponder()));
            }

            if(currentWord.checkInWord(across, down)){
                formatter.addStyleName(down, across, resources.css().currentHighlightWord());
            } else {
                formatter.removeStyleName(down, across, resources.css().currentHighlightWord());
            }
        }
    }
}
 
Example 11
Source Project: sc2gears   Source File: HasFileStatInfoTablePage.java    License: Apache License 2.0 4 votes vote down vote up
private void renderInfoRow( final FileStatInfo info, final FlexTable table, final ClickHandler googleAccountClickHandler ) {
	final CellFormatter cellFormatter = table.getCellFormatter();
	final RowFormatter  rowFormatter  = table.getRowFormatter();
	
	int column = 0;
	
	table.setWidget( row, column++, new Label( userCounter + "." ) );
	cellFormatter.setHorizontalAlignment( row, column-1, HasHorizontalAlignment.ALIGN_RIGHT );
	
	final VerticalPanel userPanel = new VerticalPanel();
	if ( info.getAddressedBy() != null )
		userPanel.add( ClientUtils.styledWidget( new Label( info.getAddressedBy() + ", "
			+ ( info.getCountry() == null ? "-" : info.getCountry() ) ), "explanation" ) );
	if ( googleAccountClickHandler == null || userCounter == 0 )
		userPanel.add( new Label( info.getGoogleAccount() ) );
	else {
		final Anchor googleAccountAnchor = new Anchor( info.getGoogleAccount() );
		googleAccountAnchor.setTitle( googleAccountClickHandler.toString() );
		googleAccountAnchor.addClickHandler( googleAccountClickHandler );
		userPanel.add( googleAccountAnchor );
	}
	userPanel.add( ClientUtils.styledWidget( ClientUtils.createTimestampWidget( "Updated: ", info.getUpdated() ), "explanation" ) );
	userPanel.add( ClientUtils.styledWidget( new Label(
		( info.getAccountCreated() == null ? "" : "Created: " + ClientUtils.DATE_FORMAT.format( info.getAccountCreated() ) + ", " )
		+ "Pkg: " + info.getDbPackageName() + ";" ), "explanation" ) );
	if ( info.getComment() != null ) {
		final Label commentLabel = new Label();
		if ( info.getComment().length() <= 40 )
			commentLabel.setText( info.getComment() );
		else {
			commentLabel.setText( info.getComment().substring( 0, 40 ) + "..." );
			commentLabel.setTitle( info.getComment() );
		}
		userPanel.add( ClientUtils.styledWidget( commentLabel, "explanation" ) );
	}
	table.setWidget( row, column++, userPanel );
	
	final Widget dbPackageWidget = info.getDbPackageIcon() == null ? new Label( info.getDbPackageName() ) : new Image( info.getDbPackageIcon() );
	dbPackageWidget.setTitle( "Available storage: " + NUMBER_FORMAT.format( info.getPaidStorage() ) + " bytes" );
	table.setWidget( row, column++, dbPackageWidget );
	int rowSpan = 1;
	if ( info.getRepCount  () > 0 ) rowSpan++;
	if ( info.getSmpdCount () > 0 ) rowSpan++;
	if ( info.getOtherCount() > 0 ) rowSpan++;
	if ( rowSpan > 1 )
		for ( int i = column - 1; i >= 0; i-- )
			table.getFlexCellFormatter().setRowSpan( row, i, rowSpan );
	userCounter++;
	
	for ( int type = 0; type < 4; type++ ) {
		String fileType = null;
		int    count    = 0;
		long   storage  = 0;
		switch ( type ) {
		case 0 : count = info.getAllCount(); storage = info.getAllStorage(); fileType = "<all>"; break;
		case 1 : if ( ( count = info.getRepCount  () ) == 0 ) continue; storage = info.getRepStorage  (); fileType = "rep"  ; column = 0; break;
		case 2 : if ( ( count = info.getSmpdCount () ) == 0 ) continue; storage = info.getSmpdStorage (); fileType = "smpd" ; column = 0; break;
		case 3 : if ( ( count = info.getOtherCount() ) == 0 ) continue; storage = info.getOtherStorage(); fileType = "other"; column = 0; break;
		}
		table.setWidget( row, column++, new Label( fileType ) );
		final int firstNumberColumn = column;
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( count ) ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( storage ) + " bytes" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( count == 0 ? 0 : storage / count ) + " bytes" ) );
		final int usedPercent = info.getPaidStorage() == 0 ? 0 : (int) ( storage * 100 / info.getPaidStorage() );
		table.setWidget( row, column++, new Label( usedPercent + "%" ) );
		
		for ( int i = column - 1; i >= firstNumberColumn; i-- )
			cellFormatter.setHorizontalAlignment( row, i, HasHorizontalAlignment.ALIGN_RIGHT );
		
		rowFormatter.addStyleName( row, userCounter == 1 ? "gold" : ( userCounter & 0x01 ) == 0 ? "row0" : "row1" );
		
		row++;
	}
}
 
Example 12
Source Project: sc2gears   Source File: HasApiCallStatInfoTablePage.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Builds the API call stat info table.
 * 
 * <p>On first call the table is initialized, on later calls its content is first removed.</p>
 * 
 * @param apiCallStatInfoList       API call stat info list to build the table from
 * @param table                     table to build
 * @param googleAccountClickHandler if provided, google accounts will be rendered as links (@link {@link Anchor}),
 * 		and clicking on them will call this handler; the tool tip of links will be <code>googleAccountClickHandler.toString()</code>
 */
protected void buildApiCallStatInfoTable( final List< ApiCallStatInfo > apiCallStatInfoList, final FlexTable table, final ClickHandler googleAccountClickHandler ) {
	// Build table
	if ( table.getRowCount() == 0 ) {
		// Init table
		table.setBorderWidth( 1 );
		table.setCellSpacing( 0 );
		table.setCellPadding( 3 );
		add( table );
	}
	else
		table.removeAllRows();
	
	final RowFormatter rowFormatter = table.getRowFormatter();
	
	int column = 0;
	table.setWidget( 0, column++, new Label( "#"               ) );
	table.setWidget( 0, column++, new Label( "User"            ) );
	table.setWidget( 0, column++, new Label( "Paid Ops"        ) );
	table.setWidget( 0, column++, new Label( "∑Calls"          ) );
	table.setWidget( 0, column++, new Label( "Used Ops"        ) );
	table.setWidget( 0, column++, new Label( "Avg Time"        ) );
	table.setWidget( 0, column++, new Label( "Denied"          ) );
	table.setWidget( 0, column++, new Label( "Errors"          ) );
	table.setWidget( 0, column++, new Label( "Info"            ) );
	table.setWidget( 0, column++, new Label( "Avg Info T"      ) );
	table.setWidget( 0, column++, new Label( "Map info"        ) );
	table.setWidget( 0, column++, new Label( "Avg Map info T"  ) );
	table.setWidget( 0, column++, new Label( "Parse rep"       ) );
	table.setWidget( 0, column++, new Label( "Avg Parse rep T" ) );
	table.setWidget( 0, column++, new Label( "Prof info"       ) );
	table.setWidget( 0, column++, new Label( "Avg Prof info T" ) );
	table.setWidget( 0, column++, new Label( "Share"           ) );
	rowFormatter.addStyleName( 0, "headerRow" );
	
	final CellFormatter cellFormatter = table.getCellFormatter();
	
	final int rowsCount = apiCallStatInfoList.size();
	int userCounter = 0;
	for ( int row = 1; row <= rowsCount; row++ ) {
		final ApiCallStatInfo info = apiCallStatInfoList.get( row - 1 );
		column = 0;
		
		table.setWidget( row, column++, new Label( userCounter + "." ) );
		cellFormatter.setHorizontalAlignment( row, column-1, HasHorizontalAlignment.ALIGN_RIGHT );
		if ( googleAccountClickHandler == null || userCounter == 0 )
			table.setWidget( row, column++, new Label( info.getGoogleAccount() ) );
		else {
			final Anchor googleAccountAnchor = new Anchor( info.getGoogleAccount() );
			googleAccountAnchor.setTitle( googleAccountClickHandler.toString() );
			googleAccountAnchor.addClickHandler( googleAccountClickHandler );
			table.setWidget( row, column++, googleAccountAnchor );
		}
		userCounter++;
		
		final int firstNumberColumn = column;
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getPaidOps            () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getCalls              () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getUsedOps            () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgExecTime        () ) + " ms" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getDeniedCalls        () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getErrors             () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getInfoCalls          () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgInfoExecTime    () ) + " ms" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getMapInfoCalls       () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgMapInfoExecTime () ) + " ms" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getParseRepCalls      () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgParseRepExecTime() ) + " ms" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getProfInfoCalls      () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgProfInfoExecTime() ) + " ms" ) );
		table.setWidget( row, column++, new Label( ( info.getPaidOps() == 0 ? 0 : 100 * info.getUsedOps() / info.getPaidOps() ) + "%" ) );
		
		for ( int i = column - 1; i >= firstNumberColumn; i-- )
			cellFormatter.setHorizontalAlignment( row, i, HasHorizontalAlignment.ALIGN_RIGHT );
		
		rowFormatter.addStyleName( row, userCounter == 1 ? "gold" : ( userCounter & 0x01 ) == 0 ? "row0" : "row1" );
	}
}
 
Example 13
Source Project: sc2gears   Source File: ClientUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Displays a Details dialog box.<br>
 * Renders a table with 2 columns: name and value pairs.
 * @param caption title of the dialog
 * @param values  values to be displayed; each element is an array (name-value pair) which defines a row
 */
public static void displayDetailsDialog( final String caption, final Object[][] values ) {
	final DialogBox dialogBox = new DialogBox( true );
	dialogBox.setText( caption );
	dialogBox.setGlassEnabled( true );
	
	final VerticalPanel content = new VerticalPanel();
	content.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
	
	final FlexTable table = new FlexTable();
	table.setBorderWidth( 1 );
	table.setCellSpacing( 0 );
	table.setCellPadding( 3 );
	
	
	final CellFormatter cellFormatter = table.getCellFormatter();
	for ( int i = 0; i < values.length; i++ ) {
		// Name
		table.setWidget( i, 0, new Label( values[ i ][ 0 ].toString() ) );
		cellFormatter.addStyleName( i, 0, "headerRow" );
		
		final Object value = values[ i ] [ 1 ];
		
		if ( value == null )
			table.setWidget( i, 1, new Label() );
		else if ( value instanceof Widget ) 
			table.setWidget( i, 1, (Widget) value );
		else if ( value instanceof Date )
			table.setWidget( i, 1, createTimestampWidget( (Date) value ) );
		else {
			String stringValue;
			if ( value instanceof String )
				stringValue = (String) value;
			else if ( value instanceof Number )
				stringValue = NUMBER_FORMAT   .format( (Number) value );
			else
				stringValue = value.toString();
			table.setWidget( i, 1, new Label( stringValue ) );
		}
		cellFormatter.addStyleName( i, 1, "row" + ( i & 0x01 ) );
		cellFormatter.setHorizontalAlignment( i, 1, HasHorizontalAlignment.ALIGN_LEFT );
	}
	
	content.add( table );
	
	content.add( createVerticalEmptyWidget( 8 ) );
	content.add( ClientUtils.createDialogCloseButton( dialogBox, "Close" ) );
	content.add( createVerticalEmptyWidget( 8 ) );
	
	dialogBox.setWidget( content );
	
	dialogBox.center();
}
 
Example 14
Source Project: swcv   Source File: WordCloudLatestApp.java    License: MIT License 4 votes vote down vote up
private Grid createTable(List<WordCloud> clouds, boolean debug)
{
    Grid table = new Grid(clouds.size() + 1, debug ? 4 : 3);
    table.addStyleName("latest");
    CellFormatter cf = table.getCellFormatter();

    table.setHTML(0, 0, "<b>id</b>");
    table.setHTML(0, 1, "<b>creation date</b>");
    table.setHTML(0, 2, "<b>source</b>");
    cf.setWidth(0, 0, "10%");
    cf.setWidth(0, 1, "25%");
    cf.setWidth(0, 2, "65%");
    cf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
    cf.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
    cf.setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);

    if (debug)
    {
        table.setHTML(0, 3, "<b>ip</b>");
        cf.setWidth(0, 1, "20%");
        cf.setWidth(0, 2, "60%");
        cf.setWidth(0, 3, "10%");
        cf.setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
    }

    for (int i = 0; i < clouds.size(); i++)
    {
        WordCloud cloud = clouds.get(i);

        table.setHTML(i + 1, 0, "<a href='/cloud.html?id=" + cloud.getId() + "'>" + cloud.getId() + "</a>");
        Date dt = cloud.getCreationDateAsDate();
        table.setHTML(i + 1, 1, DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(dt));
        table.setWidget(i + 1, 2, createSourceField(cloud, debug));
        cf.setHorizontalAlignment(i + 1, 2, HasHorizontalAlignment.ALIGN_LEFT);

        if (debug)
        {
            table.setHTML(i + 1, 3, cloud.getCreatorIP());
        }
    }

    return table;
}
 
Example 15
Source Project: swcv   Source File: SettingsPanel.java    License: MIT License 4 votes vote down vote up
public CaptionPanel create(WCSettings setting)
{
    this.setting = setting;

    FlexTable layout = new FlexTable();

    CellFormatter cf = layout.getCellFormatter();
    // Add some standard form options
    layout.setWidget(0, 0, createLabel("Number of Words:"));
    layout.setWidget(0, 1, createNumberListBox());
    layout.setWidget(1, 0, createLabel("Layout:"));
    layout.setWidget(1, 1, createLayoutListBox());
    layout.setWidget(2, 0, createLabel("Similarity:"));
    layout.setWidget(2, 1, createSimilarityListBox());

    layout.setWidget(3, 0, createLabel("Ranking:"));
    rankingWidget = createRankingListBox();
    layout.setWidget(3, 1, rankingWidget);

    cf.setStyleName(0, 2, "adv-cell-label");
    layout.setWidget(0, 2, createLabel("Font:"));
    fontWidget = createFontListBox();
    layout.setWidget(0, 3, fontWidget);

    cf.setStyleName(1, 2, "adv-cell-label");
    layout.setWidget(1, 2, createLabel("Color:"));
    colorSchemeWidget = createColorListBox();
    layout.setWidget(1, 3, colorSchemeWidget);

    cf.setStyleName(2, 2, "adv-cell-label");
    layout.setWidget(2, 2, createLabel("Aspect Ratio:"));
    layout.setWidget(2, 3, createAspectRatioListBox());

    cf.setStyleName(3, 2, "adv-cell-label");
    layout.setWidget(3, 2, createLabel("Language:"));
    layout.setWidget(3, 3, createLanguageListBox());

    addParseOptions(layout, cf);

    addTooltips(layout);

    // Wrap the content in a DecoratorPanel
    CaptionPanel panel = new CaptionPanel();
    panel.setCaptionText("advanced options for word cloud generation");
    panel.add(layout);
    return panel;
}
 
Example 16
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 17
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 18
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();

	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 19
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 20
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 21
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();

	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 22
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 23
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 24
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 25
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 */
private void setRowWordWarp(int row, int columns, boolean warp) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, false);
	}
}
 
Example 26
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 27
/**
 * Set the WordWarp for all the row cells
 *
 * @param row     The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table   The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();

	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, false);
	}
}
 
Example 28
/**
 * Set the WordWarp for all the row cells
 *
 * @param row     The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table   The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();

	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 29
/**
 * Set the WordWarp for all the row cells
 *
 * @param row     The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table   The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();

	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}
 
Example 30
/**
 * Set the WordWarp for all the row cells
 *
 * @param row The row cell
 * @param columns Number of row columns
 * @param warp
 * @param table The table to change word wrap
 */
private void setRowWordWarp(int row, int columns, boolean warp, FlexTable table) {
	CellFormatter cellFormatter = table.getCellFormatter();
	for (int i = 0; i < columns; i++) {
		cellFormatter.setWordWrap(row, i, warp);
	}
}