Java Code Examples for com.google.gwt.user.client.ui.Anchor#setTitle()

The following examples show how to use com.google.gwt.user.client.ui.Anchor#setTitle() . 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 File: AnchorBuilder.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Build the Anchor with target="_blank"
 * 
 * @return Anchor
 */
public Anchor build() {
	final Anchor anchor = new Anchor();

	if (image != null) {
		anchor.getElement().appendChild(image.getElement());
	}
	if (text != null) {
		anchor.setText(text);
	}
	if (title != null) {
		anchor.setTitle(title);
	}
	if (bottomBorderOnMouseOver) {
		anchor.addMouseOverHandler(getMouseOverhandler(anchor));
		anchor.addMouseOutHandler(getMouseOutHandler(anchor));
	}
	anchor.setHref(href);
	anchor.setTarget("_blank");

	return anchor;
}
 
Example 2
Source File: AnchorBuilder.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
public Anchor buildClick() {
	Anchor anchor = new Anchor();

	if (image != null) {
		anchor.getElement().appendChild(image.getElement());
	}
	if (text != null) {
		anchor.setText(text);
	}
	if (title != null) {
		anchor.setTitle(title);
	}
	if (clickHandler != null) {
		anchor.addClickHandler(clickHandler);
	}

	return anchor;
}
 
Example 3
Source File: UniTimeDialogBox.java    From unitime with Apache License 2.0 6 votes vote down vote up
public UniTimeDialogBox(boolean autoHide, boolean modal) {
      super(autoHide, modal);
      
setAnimationEnabled(true);
setGlassEnabled(true);
	
      iContainer = new FlowPanel();
      iContainer.addStyleName("dialogContainer");
      
      iClose = new Anchor();
  	iClose.setTitle(MESSAGES.hintCloseDialog());
      iClose.setStyleName("close");
      iClose.addClickHandler(new ClickHandler() {
      	@Override
          public void onClick(ClickEvent event) {
              onCloseClick(event);
          }
      });
      iClose.setVisible(autoHide);

      iControls = new FlowPanel();
      iControls.setStyleName("dialogControls");        
      iControls.add(iClose);
  }
 
Example 4
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Refresh proposed query row
 *
 * @param propose
 */
private void refreshProposedQueryRow(final GWTProposedQueryReceived propose, int row) {
	boolean seen = (propose.getSeenDate() == null);
	// Sets folder object
	data.put(new Integer(dataTable.getHTML(row, 5)), propose);

	if (propose.isAccepted()) {
		dataTable.setWidget(row, 0, new Image(OKMBundleResources.INSTANCE.yes()));
	} else {
		dataTable.setHTML(row, 0, "");
	}

	dataTable.setHTML(row, 1, UtilComunicator.getTextAsBoldHTML(propose.getFrom(), seen));
	String queryType = "";

	if (!propose.getParams().isDashboard()) {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.query");
	} else {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.user.query");
	}

	dataTable.setHTML(row, 2, UtilComunicator.getTextAsBoldHTML(queryType, seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(row, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(propose.getSentDate()), seen));
	Anchor anchor = new Anchor();
	String queryName = propose.getParams().getQueryName();
	anchor.setHTML(UtilComunicator.getTextAsBoldHTML(queryName, seen));
	anchor.setTitle(queryName);
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			WorkspaceComunicator.changeSelectedTab(UIDockPanelConstants.SEARCH);
			SearchComunicator.setSavedSearch(propose.getParams());
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(row, 4, anchor);
}
 
Example 5
Source File: FileStatsPage.java    From sc2gears with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and returns a link with the text being the specified google account and which when clicked
 * opens the complete file stats of the specified account.
 * @param googleAccount google account to create a link for
 * @return the created new link
 */
public static Anchor createLinkForOpenGoogleAccount( final String googleAccount ) {
	final Anchor googleAccountAnchor = new Anchor( googleAccount );
	
	googleAccountAnchor.setTitle( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER.toString() );
	googleAccountAnchor.addClickHandler( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER );
	
	return googleAccountAnchor;
}
 
Example 6
Source File: ApiCallStatsPage.java    From sc2gears with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and returns a link with the text being the specified google account and which when clicked
 * opens the complete API call stats of the specified account.
 * @param googleAccount google account to create a link for
 * @return the created new link
 */
public static Anchor createLinkForOpenGoogleAccount( final String googleAccount ) {
	final Anchor googleAccountAnchor = new Anchor( googleAccount );
	
	googleAccountAnchor.setTitle( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER.toString() );
	googleAccountAnchor.addClickHandler( OPEN_GOOGLE_ACCOUNT_CLICK_HANDLER );
	
	return googleAccountAnchor;
}
 
Example 7
Source File: WebTable.java    From unitime with Apache License 2.0 5 votes vote down vote up
public InstructorCell(ArrayList<String> names, ArrayList<String> emails, String separator) {
	super(null, separator);
	if (names != null && !names.isEmpty()) {
		separator = separator.replace(" ", "&nbsp;");
		for (int i = 0; i < names.size(); i++) {
			String text = names.get(i) + (i + 1 < names.size() ? separator : "");
			String email = (emails != null && i < emails.size() ? emails.get(i) : null);
			if (email != null && !email.isEmpty()) {
				iText += text;
				HorizontalPanel p = new HorizontalPanel();
				p.setStyleName("instructor");
				Anchor a = new Anchor();
				a.setHref("mailto:" + email);
				a.setHTML(new Image(RESOURCES.email()).getElement().getString());
				a.setTitle(MESSAGES.sendEmail(names.get(i)));
				a.setStyleName("unitime-SimpleLink");
				a.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						event.stopPropagation();
					}
				});
				p.add(a);
				p.setCellVerticalAlignment(a, HasVerticalAlignment.ALIGN_MIDDLE);
				HTML h = new HTML(text, false);
				h.getElement().getStyle().setMarginLeft(2, Unit.PX);
				p.add(h);
				iPanel.add(p);
				iContent.add(h);
			} else
				add(text);
		}
	} else {
		add("&nbsp;");
	}
}
 
Example 8
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adding proposed subscription received row
 *
 * @param propose
 */
private void addProposedSubscriptionReceivedRow(final GWTProposedSubscriptionReceived propose) {
	int rows = dataTable.getRowCount();
	boolean seen = (propose.getSeenDate() == null);
	dataTable.insertRow(rows);

	// Sets folder object
	data.put(new Integer(dataIndexValue), propose);

	if (propose.isAccepted()) {
		dataTable.setWidget(rows, 0, new Image(OKMBundleResources.INSTANCE.yes()));
	} else {
		dataTable.setHTML(rows, 0, "");
	}

	dataTable.setHTML(rows, 1, UtilComunicator.getTextAsBoldHTML(propose.getFrom(), seen));
	String docType = "";
	if (propose.getType().equals(GWTFolder.TYPE)) {

		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.folder");
	} else {
		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.document");
	}
	dataTable.setHTML(rows, 2, UtilComunicator.getTextAsBoldHTML(docType, seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(rows, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(propose.getSentDate()), seen));

	Anchor anchor = new Anchor();
	String path = propose.getPath().substring(propose.getPath().lastIndexOf("/") + 1);
	anchor.setHTML(UtilComunicator.getTextAsBoldHTML(path, seen));
	anchor.setTitle(propose.getPath());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			if (propose.getType().equals(GWTFolder.TYPE)) {
				GeneralComunicator.openPath(propose.getPath(), null);
			} else if (propose.getType().equals(GWTDocument.TYPE)) {
				String fldPath = propose.getPath().substring(0, propose.getPath().lastIndexOf("/"));
				GeneralComunicator.openPath(fldPath, propose.getPath());
			}
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(rows, 4, anchor);
	dataTable.setHTML(rows, 5, "" + (dataIndexValue++));

	// Format
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 4, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVisible(rows, 5, false);

	for (int i = 0; i < 5; i++) {
		dataTable.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect");
	}
}
 
Example 9
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adding proposed subscription sent row
 *
 * @param propose
 */
private void addProposedSubscriptionSentRow(final GWTProposedSubscriptionSent propose) {
	int rows = dataTable.getRowCount();
	dataTable.insertRow(rows);
	// Sets folder object
	data.put(new Integer(dataIndexValue), propose);

	dataTable.setHTML(rows, 0, "");
	dataTable.setHTML(rows, 1, propose.getFrom());
	String docType = "";

	if (propose.getType().equals(GWTFolder.TYPE)) {
		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.folder");
	} else {
		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.document");
	}

	dataTable.setHTML(rows, 2, docType);
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(rows, 3, dtf.format(propose.getSentDate()));

	Anchor anchor = new Anchor();
	String path = propose.getPath().substring(propose.getPath().lastIndexOf("/") + 1);
	anchor.setHTML(path);
	anchor.setTitle(propose.getPath());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			if (propose.getType().equals(GWTFolder.TYPE)) {
				GeneralComunicator.openPath(propose.getPath(), null);
			} else if (propose.getType().equals(GWTDocument.TYPE)) {
				String fldPath = propose.getPath().substring(0, propose.getPath().lastIndexOf("/"));
				GeneralComunicator.openPath(fldPath, propose.getPath());
			}
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(rows, 4, anchor);
	dataTable.setHTML(rows, 5, "" + (dataIndexValue++));

	// Format
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 4, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVisible(rows, 5, false);

	for (int i = 0; i < 5; i++) {
		dataTable.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect");
	}
}
 
Example 10
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Refresh proposed subscription row
 *
 * @param propose
 */
private void refreshProposedSubscriptionRow(final GWTProposedSubscriptionReceived propose, int row) {
	boolean seen = (propose.getSeenDate() == null);
	// Sets folder object
	data.put(new Integer(dataTable.getHTML(row, 5)), propose);

	if (propose.isAccepted()) {
		dataTable.setWidget(row, 0, new Image(OKMBundleResources.INSTANCE.yes()));
	} else {
		dataTable.setHTML(row, 0, "");
	}

	dataTable.setHTML(row, 1, UtilComunicator.getTextAsBoldHTML(propose.getFrom(), seen));
	String docType = "";

	if (propose.getType().equals(GWTFolder.TYPE)) {
		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.folder");
	} else {
		docType = GeneralComunicator.i18nExtension("messaging.message.type.propose.document");
	}

	dataTable.setHTML(row, 2, UtilComunicator.getTextAsBoldHTML(docType, seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(row, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(propose.getSentDate()), seen));
	Anchor anchor = new Anchor();
	String path = propose.getPath().substring(propose.getPath().lastIndexOf("/") + 1);
	anchor.setHTML(UtilComunicator.getTextAsBoldHTML(path, seen));
	anchor.setTitle(propose.getPath());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			if (propose.getType().equals(GWTFolder.TYPE)) {
				GeneralComunicator.openPath(propose.getPath(), null);
			} else if (propose.getType().equals(GWTDocument.TYPE)) {
				String fldPath = propose.getPath().substring(0, propose.getPath().lastIndexOf("/"));
				GeneralComunicator.openPath(fldPath, propose.getPath());
			}
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(row, 4, anchor);
}
 
Example 11
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adding proposed query row
 *
 * @param propose
 */
private void addProposedQueryReceivedRow(final GWTProposedQueryReceived propose) {
	int rows = dataTable.getRowCount();
	boolean seen = (propose.getSeenDate() == null);
	dataTable.insertRow(rows);
	// Sets folder object
	data.put(new Integer(dataIndexValue), propose);

	if (propose.isAccepted()) {
		dataTable.setWidget(rows, 0, new Image(OKMBundleResources.INSTANCE.yes()));
	} else {
		dataTable.setHTML(rows, 0, "");
	}

	dataTable.setHTML(rows, 1, UtilComunicator.getTextAsBoldHTML(propose.getFrom(), seen));
	String queryType = "";

	if (!propose.getParams().isDashboard()) {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.query");
	} else {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.user.query");
	}

	dataTable.setHTML(rows, 2, UtilComunicator.getTextAsBoldHTML(queryType, seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(rows, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(propose.getSentDate()), seen));
	Anchor anchor = new Anchor();
	String queryName = propose.getParams().getQueryName();
	anchor.setHTML(UtilComunicator.getTextAsBoldHTML(queryName, seen));
	anchor.setTitle(queryName);
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			WorkspaceComunicator.changeSelectedTab(UIDockPanelConstants.SEARCH);
			SearchComunicator.setSavedSearch(propose.getParams());
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(rows, 4, anchor);
	dataTable.setHTML(rows, 5, "" + (dataIndexValue++));

	// Format
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 4, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVisible(rows, 5, false);

	for (int i = 0; i < 5; i++) {
		dataTable.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect");
	}
}
 
Example 12
Source File: ExtendedScrollTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adding proposed query sent row
 *
 * @param propose
 */
private void addProposedQuerySentRow(final GWTProposedQuerySent propose) {
	int rows = dataTable.getRowCount();
	dataTable.insertRow(rows);
	// Sets folder object
	data.put(new Integer(dataIndexValue), propose);

	dataTable.setHTML(rows, 0, "");
	dataTable.setHTML(rows, 1, propose.getFrom());
	String queryType = "";

	if (!propose.getParams().isDashboard()) {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.query");
	} else {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.user.query");
	}

	dataTable.setHTML(rows, 2, queryType);
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(rows, 3, dtf.format(propose.getSentDate()));
	Anchor anchor = new Anchor();
	String queryName = propose.getParams().getQueryName();
	anchor.setHTML(queryName);
	anchor.setTitle(queryName);
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			WorkspaceComunicator.changeSelectedTab(UIDockPanelConstants.SEARCH);
			SearchComunicator.setSavedSearch(propose.getParams());
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(rows, 4, anchor);
	dataTable.setHTML(rows, 5, "" + (dataIndexValue++));

	// Format
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 4, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVisible(rows, 5, false);

	for (int i = 0; i < 5; i++) {
		dataTable.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect");
	}
}
 
Example 13
Source File: HasFileStatInfoTablePage.java    From sc2gears with 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 14
Source File: HasApiCallStatInfoTablePage.java    From sc2gears with 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" );
	}
}