List of usage examples for com.google.gwt.user.client.ui RadioButton getValue
@Override
public Boolean getValue()
From source file:ar.com.cristal.creditos.client.clientes.busqueda.BusquedaClientesView.java
License:Open Source License
public String obtenerIdSeleccionado() { for (int i = 1; i < listadoAnimales.getRowCount(); i++) { RadioButton radio = (RadioButton) listadoAnimales.getWidget(i, 0); if (radio.getValue()) return listadoAnimales.getText(i, 8); }//from ww w . j a v a 2 s .c om return ""; }
From source file:com.achow101.bctalkaccountpricer.client.Bitcointalk_Account_Pricer.java
License:Open Source License
/** * This is the entry point method.//from w w w.j a va 2s . com */ public void onModuleLoad() { // Add Gui stuff final Button sendButton = new Button("Estimate Price"); final TextBox nameField = new TextBox(); nameField.setText("User ID/Token"); final Label errorLabel = new Label(); final Label uidLabel = new Label(); final Label usernameLabel = new Label(); final Label postsLabel = new Label(); final Label activityLabel = new Label(); final Label potActivityLabel = new Label(); final Label postQualityLabel = new Label(); final Label trustLabel = new Label(); final Label priceLabel = new Label(); final Label loadingLabel = new Label(); final Label tokenLabel = new Label(); final InlineHTML estimateShareLabel = new InlineHTML(); final InlineHTML reportTimeStamp = new InlineHTML(); final RadioButton radioNormal = new RadioButton("merch", "Normal"); final RadioButton radioMerchant = new RadioButton("merch", "Merchant"); // We can add style names to widgets sendButton.addStyleName("sendButton"); radioNormal.setValue(true); radioMerchant.setValue(false); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); RootPanel.get("uidLabelContainer").add(uidLabel); RootPanel.get("usernameLabelContainer").add(usernameLabel); RootPanel.get("postsLabelContainer").add(postsLabel); RootPanel.get("activityLabelContainer").add(activityLabel); RootPanel.get("potActivityLabelContainer").add(potActivityLabel); RootPanel.get("postQualityLabelContainer").add(postQualityLabel); RootPanel.get("trustLabelContainer").add(trustLabel); RootPanel.get("priceLabelContainer").add(priceLabel); RootPanel.get("loadingLabelContainer").add(loadingLabel); RootPanel.get("tokenLabelContainer").add(tokenLabel); RootPanel.get("tokenShareLabelContainer").add(estimateShareLabel); RootPanel.get("radioNormalContainer").add(radioNormal); RootPanel.get("radioMerchantContainer").add(radioMerchant); RootPanel.get("reportTimeStamp").add(reportTimeStamp); // Create activity breakdown panel final VerticalPanel actPanel = new VerticalPanel(); final FlexTable actTable = new FlexTable(); actPanel.add(actTable); RootPanel.get("activityBreakdown").add(actPanel); // Create posts breakdown panel final VerticalPanel postsPanel = new VerticalPanel(); final FlexTable postsTable = new FlexTable(); postsPanel.add(postsTable); RootPanel.get("postsBreakdown").add(postsPanel); // Create addresses breakdown panel final VerticalPanel addrPanel = new VerticalPanel(); final FlexTable addrTable = new FlexTable(); postsPanel.add(addrTable); RootPanel.get("addrBreakdown").add(addrTable); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler, KeyUpHandler { /** * Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { // Add request to queue addToQueue(); } /** * Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { addToQueue(); } } // Adds the request to server queue private void addToQueue() { // Clear previous output uidLabel.setText(""); usernameLabel.setText(""); postsLabel.setText(""); activityLabel.setText(""); potActivityLabel.setText(""); postQualityLabel.setText(""); trustLabel.setText(""); priceLabel.setText(""); sendButton.setEnabled(false); errorLabel.setText(""); loadingLabel.setText(""); tokenLabel.setText(""); estimateShareLabel.setText(""); reportTimeStamp.setText(""); actTable.removeAllRows(); postsTable.removeAllRows(); addrTable.removeAllRows(); // Create and add request request = new QueueRequest(); request.setMerchant(radioMerchant.getValue()); if (nameField.getText().matches("^[0-9]+$")) request.setUid(Integer.parseInt(escapeHtml(nameField.getText()))); else { request.setToken(escapeHtml(nameField.getText())); request.setOldReq(); } final String urlPath = com.google.gwt.user.client.Window.Location.getPath(); final String host = com.google.gwt.user.client.Window.Location.getHost(); final String protocol = com.google.gwt.user.client.Window.Location.getProtocol(); final String url = protocol + "//" + host + urlPath + "?token="; // Request check loop Timer requestTimer = new Timer() { public void run() { // send request to server pricingService.queueServer(request, new AsyncCallback<QueueRequest>() { @Override public void onFailure(Throwable caught) { errorLabel.setText("Request Queuing failed. Please try again."); sendButton.setEnabled(true); pricingService.removeRequest(request, null); cancel(); } @Override public void onSuccess(QueueRequest result) { if (result.getQueuePos() == -3) { loadingLabel.setText( "Please wait for your previous request to finish and try again"); sendButton.setEnabled(true); cancel(); } else if (result.getQueuePos() == -2) { loadingLabel.setText("Please wait 2 minutes before requesting again."); sendButton.setEnabled(true); cancel(); } else if (result.getQueuePos() == -4) { loadingLabel.setText("Invalid token"); sendButton.setEnabled(true); cancel(); } else { tokenLabel.setText("Your token is " + result.getToken()); estimateShareLabel.setHTML("Share this estimate: <a href=\"" + url + result.getToken() + "\">" + url + result.getToken() + "</a>"); if (!result.isProcessing() && !result.isDone()) { loadingLabel.setText("Please wait. You are number " + result.getQueuePos() + " in the queue."); } if (result.isProcessing()) { loadingLabel.setText("Request is processing. Please wait."); } if (result.isDone()) { // Clear other messages errorLabel.setText(""); loadingLabel.setText(""); // Output results uidLabel.setText(result.getResult()[0]); usernameLabel.setText(result.getResult()[1]); postsLabel.setText(result.getResult()[2]); activityLabel.setText(result.getResult()[3]); potActivityLabel.setText(result.getResult()[4]); postQualityLabel.setText(result.getResult()[5]); trustLabel.setText(result.getResult()[6]); priceLabel.setText(result.getResult()[7]); int indexOfLastAct = 0; int startAddrIndex = 0; for (int i = 8; i < result.getResult().length; i++) { if (result.getResult()[i].equals("<b>Post Sections Breakdown</b>")) { indexOfLastAct = i; break; } actTable.setHTML(i - 8, 0, result.getResult()[i]); } for (int i = indexOfLastAct; i < result.getResult().length; i++) { if (result.getResult()[i] .contains("<b>Addresses posted in non-quoted text</b>")) { startAddrIndex = i; break; } postsTable.setHTML(i - indexOfLastAct, 0, result.getResult()[i]); } if (!result.isMerchant()) { for (int i = startAddrIndex; i < result.getResult().length; i++) { addrTable.setHTML(i - startAddrIndex, 0, result.getResult()[i]); } } // Set the right radio radioMerchant.setValue(result.isMerchant()); radioNormal.setValue(!result.isMerchant()); // Report the time stamp DateTimeFormat fmt = DateTimeFormat.getFormat("MMMM dd, yyyy, hh:mm:ss a"); Date completedDate = new Date(1000L * result.getCompletedTime()); Date expireDate = new Date( 1000L * (result.getCompletedTime() + result.getExpirationTime())); reportTimeStamp .setHTML("<i>Report generated at " + fmt.format(completedDate) + " and expires at " + fmt.format(expireDate) + "</i>"); // Kill the timer after everything is done cancel(); } request = result; request.setPoll(true); sendButton.setEnabled(true); } } }); } }; requestTimer.scheduleRepeating(2000); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); // Check the URL for URL parameters String urlTokenParam = com.google.gwt.user.client.Window.Location.getParameter("token"); if (!urlTokenParam.isEmpty()) { nameField.setText(urlTokenParam); handler.addToQueue(); } }
From source file:com.allen_sauer.gwt.dnd.demo.client.BidiBehaviorPanel.java
License:Apache License
public BidiBehaviorPanel(final DragController dragController) { super("Bidi", "Force rtl/ltr text direction"); final RadioButton ltrButton = newButton("Left to right", "direction: ltr"); final RadioButton rtlButton = newButton("Right to left", "direction: rtl"); add(ltrButton);/*from www .j a va 2 s.com*/ add(rtlButton); if ("rtl".equals(DOMUtil.getEffectiveStyle(Document.get().getBody(), "direction"))) { rtlButton.setValue(true); } else { ltrButton.setValue(true); } ClickHandler handler = new ClickHandler() { @Override public void onClick(ClickEvent event) { BodyElement body = Document.get().getBody(); if (rtlButton.getValue()) { body.addClassName("rtl"); body.removeClassName("ltr"); } else { body.addClassName("ltr"); body.removeClassName("rtl"); } } }; ltrButton.addClickHandler(handler); rtlButton.addClickHandler(handler); }
From source file:com.allen_sauer.gwt.dnd.demo.client.ConstrainedToBoundaryBehaviorPanel.java
License:Apache License
public ConstrainedToBoundaryBehaviorPanel(final DragController dragController) { super("Drag Operations", "getBehaviorConstrainedToBoundaryPanel() / setBehaviorConstrainedToBoundaryPanel(boolean)"); final RadioButton constrainedButton = newButton("Constrained by Boundary", "DragController#setBehaviorConstrainedToBoundaryPanel(true)"); final RadioButton unconstrainedButton = newButton("Unconstrained", "DragController#setBehaviorConstrainedToBoundaryPanel(false)"); add(constrainedButton);/* www. ja v a 2 s . co m*/ add(unconstrainedButton); if (dragController.getBehaviorConstrainedToBoundaryPanel()) { constrainedButton.setValue(true); } else { unconstrainedButton.setValue(true); } ClickHandler handler = new ClickHandler() { @Override public void onClick(ClickEvent event) { dragController.setBehaviorConstrainedToBoundaryPanel(constrainedButton.getValue()); } }; constrainedButton.addClickHandler(handler); unconstrainedButton.addClickHandler(handler); }
From source file:com.allen_sauer.gwt.dnd.demo.client.DragProxyBehaviorPanel.java
License:Apache License
public DragProxyBehaviorPanel(final PickupDragController dragController) { super("Drag Proxy Behavior", "getBehaviorDragProxy() / setBehaviorDragProxy(boolean)"); final RadioButton classicButton = newButton("Widget is dragged", "PickupDragController#setBehaviorDragProxy(false)"); final RadioButton proxyButton = newButton("Use drag proxies", "PickupDragController#setBehaviorDragProxy(true)"); add(classicButton);// w w w .j av a 2 s . c o m add(proxyButton); if (dragController.getBehaviorDragProxy()) { proxyButton.setValue(true); } else { classicButton.setValue(true); } ClickHandler handler = new ClickHandler() { @Override public void onClick(ClickEvent event) { dragController.setBehaviorDragProxy(proxyButton.getValue()); } }; classicButton.addClickHandler(handler); proxyButton.addClickHandler(handler); }
From source file:com.allen_sauer.gwt.dnd.demo.client.MultipleSelectionBehaviorPanel.java
License:Apache License
public MultipleSelectionBehaviorPanel(final PickupDragController dragController) { super("Multiple Selections", "getBehaviorMultipleSelection() / setBehaviorMultipleSelection(boolean)"); final RadioButton constrainedButton = newButton("Allow via <code>CTRL</code>/<code>META</code>-click", "DragController#setBehaviorMultipleSelection(true)"); final RadioButton unconstrainedButton = newButton("Single widget drag only", "DragController#setBehaviorMultipleSelection(false)"); add(constrainedButton);/*from www. j a va 2 s.c o m*/ add(unconstrainedButton); if (dragController.getBehaviorMultipleSelection()) { constrainedButton.setValue(true); } else { unconstrainedButton.setValue(true); } ClickHandler listener = new ClickHandler() { @Override public void onClick(ClickEvent event) { dragController.setBehaviorMultipleSelection(constrainedButton.getValue()); } }; constrainedButton.addClickHandler(listener); unconstrainedButton.addClickHandler(listener); }
From source file:com.edgenius.wiki.gwt.client.space.SpaceLinkedBlogForm.java
License:Open Source License
public BlogMeta getSelectedBlog() { BlogMeta selectedBlog = null;//from w w w . j a va 2s. c o m //first, try to check if user select a blog from blog list checkbox if (blogMetas != null && blogMetas.size() > 0) { //following code looks ugly: for get linked blogMeta for (Iterator<Widget> iter = bloglist.iterator(); iter.hasNext();) { Widget widget = iter.next(); if (widget instanceof RadioButton) { RadioButton radio = ((RadioButton) widget); if (radio.getValue()) { String blogID = radio.getFormValue(); for (Iterator<BlogMeta> it = blogMetas.iterator(); it.hasNext();) { BlogMeta meta = it.next(); if (StringUtil.equals(meta.getId(), blogID)) { selectedBlog = meta; break; } } } } if (selectedBlog != null) ; break; } } //if user not select from checkbox, then check if we already have a "currentBlog" if (selectedBlog == null) { selectedBlog = currentBlogMeta; } //all input(URL,user, password) will overwrite existed value, this is true if user want to update - //for example, only update password then save //the bad is, we need do further validate in link blog to space as the inputs maybe wrong even they pick up //from drop list. if (selectedBlog != null) { int blogType = NumberUtil.toInt(blogs.getSelectedValue(), 0); if (blogType == 0 || !blogUser.isValidForSubmit() || !blogPassword.isValidForSubmit() || !blogUrl.isValidForSubmit()) { //if any input are wrong value, return null,means invalid input selectedBlog = null; } else { selectedBlog.setType(blogType); selectedBlog.setUsername(blogUser.getText()); selectedBlog.setPassword(blogPassword.getText()); selectedBlog.setUrl(blogUrl.getText()); } } return selectedBlog; }
From source file:com.facebook.tsdb.tsdash.client.ui.SelectTimeWidget.java
License:Apache License
@Override public void selectedHistory(Object button) { if (selectedHistory == button) { return;//from w w w . j a va 2 s.co m } if (selectedHistory != null) { CssHelper.toggleClass((UIObject) selectedHistory, style.historySelected()); RadioButton radio = (RadioButton) selectedHistory; if (button == null) { radio.setValue(false); } } if (button != null) { CssHelper.toggleClass((UIObject) button, style.historySelected()); } selectedHistory = button; if (selectedHistory != null) { RadioButton radio = (RadioButton) selectedHistory; if (!radio.getValue()) { radio.setValue(true); } } }
From source file:com.google.testing.testify.risk.frontend.client.view.widgets.EditCapabilityWidget.java
License:Apache License
private String getSelectedOptionInPanel(Panel panel) { for (Widget w : panel) { if (w instanceof RadioButton) { RadioButton b = (RadioButton) w; if (b.getValue()) { return b.getText(); }/* w ww . j a v a2s. c o m*/ } } return null; }
From source file:com.gwtm.ui.client.widgets.RadioButtonGroup.java
License:Apache License
@Override public void onClick(ClickEvent e) { EventTarget target = e.getNativeEvent().getEventTarget(); String targetTagName = ((Element) target.cast()).getTagName().toUpperCase(); if (targetTagName.equals("SPAN")) { int before = getCheckedIndex(); super.onClick(e); int after = getCheckedIndex(); Utils.Console("before " + before + " after " + after); if (after == -1) { RadioButton radio = (RadioButton) getWidget(before); if (!radio.getValue()) { // cannot un-select a radio button without selecting another one. radio.setValue(true);//from ww w. ja va 2 s . c o m } } else if (before > -1) { RadioButton radio = (RadioButton) getWidget(before); radio.setValue(false); } } else if (targetTagName.equals("INPUT")) { super.onClick(e); for (int i = 0; i < getWidgetCount(); i++) { RadioButton radio = (RadioButton) getWidget(i); radio.setValue(radio.getValue()); } } }