List of usage examples for com.google.gwt.user.client.ui Label getText
public String getText()
From source file:strat.mining.multipool.stats.client.mvp.view.waffle.component.AddressChartPanel.java
License:Open Source License
public Widget createLastStatsPanel(AddressStatsDTO lastStats) { HtmlLayoutContainerTemplate templates = GWT.create(HtmlLayoutContainerTemplate.class); HtmlLayoutContainer htmlLayout = new HtmlLayoutContainer(templates.getTemplate()); final DateTimeFormat dtf = DateTimeFormat.getFormat("EEE d MMM HH:mm:ss"); // Name labels Label balanceLabel = new Label("Balance: "); Label unexchangedLabel = new Label("Unexchanged: "); Label totalLabel = new Label("Total: "); Label paidoutLabel = new Label("Paid out: "); Label acceptedMegaHashLabel = new Label("Total MH/s: "); Label lastUpdateTimeLabel = new Label("Last update: "); Label warningLabel = new Label("Worker warning: "); // Values label Label balanceValue = new Label(lastStats != null ? formatBTCValue(lastStats.getBalance()) : ""); Label unexchangedValue = new Label(lastStats != null ? formatBTCValue(lastStats.getUnexchanged()) : ""); paidoutAnchor = new Anchor(lastStats != null ? formatBTCValue(lastStats.getPaidOut()) : ""); Label totalValue = new Label( lastStats != null ? formatBTCValue(lastStats.getBalance() + lastStats.getUnexchanged()) : ""); Label acceptedMegaHashValue = new Label( lastStats != null ? formatPowerValue(lastStats.getMegaHashesPerSeconds()) : ""); Label lastUpdateTimeValue = new Label(lastStats != null ? dtf.format(lastStats.getRefreshTime()) : ""); HTML warningValue = new HTML("<i style=\"margin-left: 15px;\">None</i>"); warningValue.addStyleName("warningValue"); htmlLayout.add(balanceLabel, new HtmlData(".label1")); htmlLayout.add(unexchangedLabel, new HtmlData(".label2")); htmlLayout.add(totalLabel, new HtmlData(".label3")); htmlLayout.add(paidoutLabel, new HtmlData(".label4")); htmlLayout.add(acceptedMegaHashLabel, new HtmlData(".label5")); htmlLayout.add(lastUpdateTimeLabel, new HtmlData(".label6")); htmlLayout.add(warningLabel, new HtmlData(".warningLabel")); htmlLayout.add(balanceValue, new HtmlData(".value1")); htmlLayout.add(unexchangedValue, new HtmlData(".value2")); htmlLayout.add(totalValue, new HtmlData(".value3")); htmlLayout.add(paidoutAnchor, new HtmlData(".value4")); htmlLayout.add(acceptedMegaHashValue, new HtmlData(".value5")); htmlLayout.add(lastUpdateTimeValue, new HtmlData(".value6")); htmlLayout.add(warningValue, new HtmlData(".warningValue")); tableContainer.setWidget(htmlLayout); workerStore.clear();// w ww. j a v a 2 s . com if (lastStats.getWorkerStats() != null) { workerStore.addAll(lastStats.getWorkerStats()); } for (int i = 0; i < columnModel.getColumnCount(); i++) { if (gridView.getHeader() != null) { @SuppressWarnings("rawtypes") final Head head = gridView.getHeader().getHead(i); head.getElement().getStyle().setHeight(25, Unit.PX); head.addDomHandler(new MouseOverHandler() { public void onMouseOver(MouseOverEvent event) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { head.getElement().getStyle().setHeight(25, Unit.PX); } }); } }, MouseOverEvent.getType()); } } ToolTipConfig config = new ToolTipConfig(); String tooltip = "<b>" + balanceLabel.getText() + "</b>" + balanceValue.getText(); tooltip += "<br/><b>" + unexchangedLabel.getText() + "</b>" + unexchangedValue.getText(); tooltip += "<br/><b>" + totalLabel.getText() + "</b>" + totalValue.getText(); tooltip += "<br/><b>" + paidoutLabel.getText() + "</b>" + paidoutAnchor.getText(); tooltip += "<br/><b>" + acceptedMegaHashLabel.getText() + "</b>" + acceptedMegaHashValue.getText(); tooltip += "<br/><b>" + lastUpdateTimeLabel.getText() + "</b>" + lastUpdateTimeValue.getText(); if (lastStats.getWorkerStats() != null) { String warning = "<ul class=\"warningList\">"; boolean isWarning = false; for (WorkerStatsDTO workerStats : lastStats.getWorkerStats()) { if (workerStats.getStaleRate() > WARNING_STALERATE_THRESHOLD || workerStats.getHashrate() < WARNING_HASHRATE_THRESHOLD) { tooltip += "<span style=\"color: red;\">"; } tooltip += "<br/><b>" + formatUsername(workerStats.getUsername()) + ":</b> " + formatPowerValue(workerStats.getHashrate()) + " MH/s, " + workerStats.getStaleRate() + "% Staled"; if (workerStats.getStaleRate() > WARNING_STALERATE_THRESHOLD || workerStats.getHashrate() < WARNING_HASHRATE_THRESHOLD) { tooltip += "</span>"; warning += getWarning(workerStats); isWarning = true; } } warning += "</ul>"; if (isWarning) { warningValue.setHTML(warning); } } config.setBodyHtml(tooltip); config.setTrackMouse(true); config.setDismissDelay(0); config.setHideDelay(0); htmlLayout.setToolTipConfig(config); lastStatsPanelContainer.setWidget(lastStatsPanel); return lastStatsPanel; }
From source file:strat.mining.multipool.stats.client.mvp.view.waffle.component.GlobalChartPanel.java
License:Open Source License
public Widget createLastStatsPanel(GlobalStatsDTO lastStats) { HtmlLayoutContainerTemplate templates = GWT.create(HtmlLayoutContainerTemplate.class); // Remove the last panel if (lastStatsPanel != null) { contentPanel.remove(lastStatsPanel); }//from w w w. j a v a2 s.c om lastStatsPanel = new HtmlLayoutContainer(templates.getTemplate()); lastStatsPanel.setWidth(500); final DateTimeFormat dtf = DateTimeFormat.getFormat("EEE d MMM HH:mm:ss"); // Name labels Label balanceLabel = new Label("Balance: "); Label unexchangedLabel = new Label("Unexchanged: "); Label totalLabel = new Label("Total: "); Label paidoutLabel = new Label("Paid out: "); Label acceptedMegaHashLabel = new Label("MH/s: "); Label nbOfMinersLabel = new Label("Number of miners: "); Label currentMiningCoinLabel = new Label("Mining coin: "); Label lastUpdateTimeLabel = new Label("Last update: "); // Values label Label balanceValue = new Label(lastStats != null ? formatBTCValue(lastStats.getTotalBalance()) : ""); Label unexchangedValue = new Label( lastStats != null ? formatBTCValue(lastStats.getTotalUnexchangedBalance()) : ""); Label totalValue = new Label(lastStats != null ? formatBTCValue(lastStats.getTotalUnexchangedBalance() + lastStats.getTotalUnexchangedBalance()) : ""); Label paidoutValue = new Label(lastStats != null ? formatBTCValue(lastStats.getTotalPaidOut()) : ""); Label acceptedMegaHashValue = new Label( lastStats != null ? formatPowerValue(lastStats.getTotalMegahashesPerSecond()) : ""); Label nbOfMinersValue = new Label(lastStats != null ? lastStats.getNbMiners().toString() : ""); Label currentMiningCoinValue = new Label(lastStats != null ? lastStats.getCurrentMiningCoin() : ""); Label lastUpdateTimeValue = new Label(lastStats != null ? dtf.format(lastStats.getRefreshTime()) : ""); lastStatsPanel.add(balanceLabel, new HtmlData(".label1")); lastStatsPanel.add(unexchangedLabel, new HtmlData(".label2")); lastStatsPanel.add(totalLabel, new HtmlData(".label3")); lastStatsPanel.add(paidoutLabel, new HtmlData(".label4")); lastStatsPanel.add(acceptedMegaHashLabel, new HtmlData(".label6")); lastStatsPanel.add(nbOfMinersLabel, new HtmlData(".label7")); lastStatsPanel.add(currentMiningCoinLabel, new HtmlData(".label8")); lastStatsPanel.add(lastUpdateTimeLabel, new HtmlData(".label9")); lastStatsPanel.add(balanceValue, new HtmlData(".value1")); lastStatsPanel.add(unexchangedValue, new HtmlData(".value2")); lastStatsPanel.add(totalValue, new HtmlData(".value3")); lastStatsPanel.add(paidoutValue, new HtmlData(".value4")); lastStatsPanel.add(acceptedMegaHashValue, new HtmlData(".value6")); lastStatsPanel.add(nbOfMinersValue, new HtmlData(".value7")); lastStatsPanel.add(currentMiningCoinValue, new HtmlData(".value8")); lastStatsPanel.add(lastUpdateTimeValue, new HtmlData(".value9")); ToolTipConfig config = new ToolTipConfig(); String tooltip = "<b>" + balanceLabel.getText() + "</b>" + balanceValue.getText(); tooltip += "<br/><b>" + unexchangedLabel.getText() + "</b>" + unexchangedValue.getText(); tooltip += "<br/><b>" + totalLabel.getText() + "</b>" + totalValue.getText(); tooltip += "<br/><b>" + paidoutLabel.getText() + "</b>" + paidoutValue.getText(); tooltip += "<br/><b>" + acceptedMegaHashLabel.getText() + "</b>" + acceptedMegaHashValue.getText(); tooltip += "<br/><b>" + nbOfMinersLabel.getText() + "</b>" + nbOfMinersValue.getText(); tooltip += "<br/><b>" + currentMiningCoinLabel.getText() + "</b>" + currentMiningCoinValue.getText(); tooltip += "<br/><b>" + lastUpdateTimeLabel.getText() + "</b>" + lastUpdateTimeValue.getText(); config.setBodyHtml(tooltip); config.setTrackMouse(true); config.setDismissDelay(0); config.setHideDelay(0); lastStatsPanel.setToolTipConfig(config); return lastStatsPanel; }