Example usage for com.google.gwt.user.client.ui RadioButton getText

List of usage examples for com.google.gwt.user.client.ui RadioButton getText

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui RadioButton getText.

Prototype

@Override
    public String getText() 

Source Link

Usage

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();
            }/*from  w  ww . j  a  v a 2s.c  o m*/
        }
    }
    return null;
}

From source file:com.wfairclough.foundation4gwt.client.ui.widget.RadioButtonGroup.java

License:Apache License

/**
 * {@inheritDoc}//from  w w  w.j a v a 2 s  .com
 */
public <W extends Enum<W> & WidgetValues> void setSelectedWidgetValue(W widgetValue) {
    for (RadioButton item : getRadioButtons()) {
        if (item.getText().equals(widgetValue.getValue())) {
            item.setValue(true);
            break;
        }
    }
}

From source file:edu.ucdenver.bios.glimmpseweb.client.guided.MainEffectHypothesisPanel.java

License:Open Source License

/**
 * Find and select the radio button corresponding to the factor.  
 * If no match, then no effect./*from   ww w. ja  v  a 2 s.c  om*/
 * @param factorName name of the factor
 * @param table the between or within participant factor table
 * @return true if a match is found
 */
private boolean selectRadioButtonByFactor(String factorName, FlexTable table) {
    for (int row = 0; row < table.getRowCount(); row++) {
        RadioButton rb = (RadioButton) table.getWidget(row, RADIO_BUTTON_COLUMN);
        if (rb.getText().equals(factorName)) {
            rb.setValue(true);
            return true;
        }
    }
    return false;
}

From source file:it.unibo.cs.v2.client.NewMachineWizard.java

License:Open Source License

@Override
public void onClick(ClickEvent event) {
    final MachineInfo machineInfo = new MachineInfo();
    hideError();//www  .j a  va  2 s. c  o  m

    if (RegExp.compile("[^A-z0-9]").test(name.getText())) {
        showError("Machine name may only contain letters or digits (e.g. MyFirstMachine01)");
        return;
    }

    if (name.getText().equals("")) {
        showError("Machine name can't be blank");
        return;
    }

    machineInfo.setName(name.getText());
    machineInfo.setDescription(descriptionVM.getText());

    for (HashMap<String, String> hm : isos) {
        if (hm.get("name").equals(isoListBox.getValue(isoListBox.getSelectedIndex()))) {
            machineInfo.setIso(hm.get("iso"));
            break;
        }
    }
    //      
    //      if (!disk1name.getText().equals(name.getText())) {
    //         showError("Primary disk name must match the machine's name.");
    //         return;
    //      }
    //      
    machineInfo.setHda(name.getText());
    for (RadioButton b : rb1) {
        if (!b.getValue())
            continue;
        machineInfo.setHdaSize(b.getText());
    }

    //      if (disk2name.isEnabled() && disk2name.getText().equals((""))) {
    //         showError("Disk name can't be blank");
    //         return;
    //      }

    machineInfo.setHdbEnabled(disk2name.isEnabled());
    if (disk2name.isEnabled()) {
        machineInfo.setHdb(name.getText() + "-secondary");
        for (RadioButton b : rb2) {
            if (!b.getValue())
                continue;
            machineInfo.setHdbSize(b.getText());
        }
    }

    machineInfo.setVirtuacluster(virtuaCluster.getValue());
    machineInfo.setSecondNetwork(addNetworkIf.getValue());

    if (addNetworkIf.getValue() && socketName.getText().equals("")) {
        showError("Socket name can't be blank");
        return;
    }

    machineInfo.setSocketPath(socketName.getText());
    machineInfo.setMacAddress(secondMacAddr.getText());

    createMachineProxy.createMachine(machineInfo, new AsyncCallback<Boolean>() {

        @Override
        public void onFailure(Throwable caught) {
            Window.alert(caught.getMessage());
        }

        @Override
        public void onSuccess(Boolean result) {
            clear();
            add(errorLabel);

            if (result) {
                showSuccess("Machine successfully created");
                finished = true;
                MainPanel.getInstance().refresh();
            } else
                showError("Error while creating the machine. This is programmers' fault, not yours. "
                        + "Please reload the page and retry.");
        }
    });
}

From source file:net.sf.mmm.client.ui.impl.gwt.widget.field.adapter.UiWidgetAdapterGwtRadioButtons.java

License:Apache License

/**
 * {@inheritDoc}/*ww  w . j  ava 2 s  . co m*/
 */
@Override
public String getValue() {

    for (RadioButton rb : this.radioButtons) {
        if (Boolean.TRUE.equals(rb.getValue())) {
            return rb.getText();
        }
    }
    return null;
}

From source file:net.sf.mmm.client.ui.impl.gwt.widget.field.adapter.UiWidgetAdapterGwtRadioButtons.java

License:Apache License

/**
 * {@inheritDoc}//from w w w.  j a v a 2s .  c o m
 */
@Override
public void setValue(String value) {

    for (RadioButton rb : this.radioButtons) {
        if (value.equals(rb.getText())) {
            rb.setValue(Boolean.TRUE, false);
            break;
        }
    }
}

From source file:org.abondar.industrial.videorouterdemo.client.MainEntryPoint.java

public void showSourcesMonitors() {

    vp1 = new VerticalPanel();
    vp.add(vp1);/*w  ww. ja v  a2s  .c  o  m*/
    vp.remove(update);
    for (int i = 0; i < monitorData.size(); i++) { //number of outputs loop;
        final Label out = new Label(monitorData.get(i));

        hp1 = new HorizontalPanel();
        hp1.add(out);

        for (final SourceBean sb : sourcesData) {

            vp1.add(hp1);

            final RadioButton rb = new RadioButton(sourcesData.get(i).getName(), sb.getName());

            hp1.add(rb);

            if (rb.getText().equals("")) {
                hp1.remove(rb);
            }
            if (rb.getText().equals("Undefined Source")) {
                rb.setEnabled(false);
            }

            for (ConnectionBean cb : connections) {
                for (String s : cb.getSourceID()) {
                    for (String ss : cb.getDestnation()) {
                        if (out.getText().equals(ss) && sb.getId().equals(s)) {
                            rb.setValue(true);
                            prevSourceName = cb.getName().substring(7);
                            monitor = new ArrayList<>();
                            monitor.add(ss);
                        }
                    }

                }
            }

            rb.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {

                    String sourceID = "";
                    if (sb.getName().equals(rb.getText())) {
                        sourceID = sb.getId();

                    }
                    if (monitor == null) {
                        monitor = new ArrayList<>();

                    } else if (prevSourceName.equals(rb.getText()) == false) {
                        monitor.clear();
                    }
                    monitor.add(out.getText());

                    if (rb.getText().equals(prevSourceName)) {
                        rb.setValue(Boolean.TRUE);
                    }
                    deleteConnection("Connect" + prevSourceName, sourceID, rb.getText());
                    prevSourceName = rb.getText();
                }

            });

        }

    }
    vp.add(update);

}

From source file:org.drools.brms.client.packages.PackageBuilderWidget.java

License:Apache License

/**
 * This will display a dialog for creating a snapshot.
 *//*w  w w. ja  v  a 2s . com*/
private void showSnapshotDialog(Widget w) {
    LoadingPopup.showMessage("Loading existing snapshots...");
    final FormStylePopup form = new FormStylePopup("images/snapshot.png", "Create a snapshot for deployment.");
    form.addRow(new HTML("<i>A package snapshot is essentially a "
            + "read only 'locked in' and labelled view of a package at a point in time, which can be used for deployment.</i>"));

    final VerticalPanel vert = new VerticalPanel();
    form.addAttribute("Choose or create snapshot name:", vert);
    final List radioList = new ArrayList();
    final TextBox newName = new TextBox();
    final String newSnapshotText = "NEW: ";

    RepositoryServiceFactory.getService().listSnapshots(conf.name, new GenericCallback() {
        public void onSuccess(Object data) {
            SnapshotInfo[] result = (SnapshotInfo[]) data;
            for (int i = 0; i < result.length; i++) {
                RadioButton existing = new RadioButton("snapshotNameGroup", result[i].name);
                radioList.add(existing);
                vert.add(existing);
            }
            HorizontalPanel newSnap = new HorizontalPanel();

            final RadioButton newSnapRadio = new RadioButton("snapshotNameGroup", newSnapshotText);
            newSnap.add(newSnapRadio);
            newName.setEnabled(false);
            newSnapRadio.addClickListener(new ClickListener() {

                public void onClick(Widget w) {
                    newName.setEnabled(true);
                }

            });

            newSnap.add(newName);
            radioList.add(newSnapRadio);
            vert.add(newSnap);

            LoadingPopup.close();
        }
    });

    final TextBox comment = new TextBox();
    form.addAttribute("Comment:", comment);

    Button create = new Button("Create new snapshot");
    form.addAttribute("", create);

    create.addClickListener(new ClickListener() {
        String name = "";

        public void onClick(Widget w) {
            boolean replace = false;
            for (Iterator iter = radioList.iterator(); iter.hasNext();) {
                RadioButton but = (RadioButton) iter.next();
                if (but.isChecked()) {
                    name = but.getText();
                    if (!but.getText().equals(newSnapshotText)) {
                        replace = true;
                    }
                    break;
                }
            }
            if (name.equals(newSnapshotText)) {
                name = newName.getText();
            }

            if (name.equals("")) {
                Window.alert("You have to enter or chose a label (name) for the snapshot.");
                return;
            }

            RepositoryServiceFactory.getService().createPackageSnapshot(conf.name, name, replace,
                    comment.getText(), new GenericCallback() {
                        public void onSuccess(Object data) {
                            Window.alert("The snapshot called: " + name + " was successfully created.");
                            form.hide();
                        }
                    });
        }
    });

    form.setWidth("50%");

    form.setPopupPosition((DirtyableComposite.getWidth() - form.getOffsetWidth()) / 2, 100);
    form.show();

    // form.setPopupPosition( Window.getClientWidth() / 3,
    // Window.getClientHeight() / 3 );
    // form.show();

}

From source file:org.drools.guvnor.client.moduleeditor.drools.PackageBuilderWidget.java

License:Apache License

/**
 * This will display a dialog for creating a snapshot.
 *//*  w  w  w  .j  a va2s.c om*/
public static void showSnapshotDialog(final String packageName, final Command refreshCmd) {
    LoadingPopup.showMessage(Constants.INSTANCE.LoadingExistingSnapshots());
    final FormStylePopup form = new FormStylePopup(DroolsGuvnorImages.INSTANCE.Snapshot(),
            Constants.INSTANCE.CreateASnapshotForDeployment());
    form.addRow(new HTML(Constants.INSTANCE.SnapshotDescription()));

    final VerticalPanel vert = new VerticalPanel();
    form.addAttribute(Constants.INSTANCE.ChooseOrCreateSnapshotName(), vert);
    final List<RadioButton> radioList = new ArrayList<RadioButton>();
    final TextBox newName = new TextBox();
    final String newSnapshotText = Constants.INSTANCE.NEW() + ": ";
    ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
    moduleService.listSnapshots(packageName, new GenericCallback<SnapshotInfo[]>() {
        public void onSuccess(SnapshotInfo[] result) {
            for (int i = 0; i < result.length; i++) {
                RadioButton existing = new RadioButton("snapshotNameGroup", result[i].getName()); // NON-NLS
                radioList.add(existing);
                vert.add(existing);
            }
            HorizontalPanel newSnap = new HorizontalPanel();

            final RadioButton newSnapRadio = new RadioButton("snapshotNameGroup", newSnapshotText); // NON-NLS
            newSnap.add(newSnapRadio);
            newName.setEnabled(false);
            newSnapRadio.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    newName.setEnabled(true);
                }

            });

            newSnap.add(newName);
            radioList.add(newSnapRadio);
            vert.add(newSnap);

            LoadingPopup.close();
        }
    });

    final TextBox comment = new TextBox();
    form.addAttribute(Constants.INSTANCE.Comment(), comment);

    Button create = new Button(Constants.INSTANCE.CreateNewSnapshot());
    form.addAttribute("", create);

    create.addClickHandler(new ClickHandler() {
        String name = "";

        public void onClick(ClickEvent event) {
            boolean replace = false;
            for (RadioButton but : radioList) {
                if (but.getValue()) {
                    name = but.getText();
                    if (!but.getText().equals(newSnapshotText)) {
                        replace = true;
                    }
                    break;
                }
            }
            if (name.equals(newSnapshotText)) {
                name = newName.getText();
            }

            if (name.equals("")) {
                Window.alert(Constants.INSTANCE.YouHaveToEnterOrChoseALabelNameForTheSnapshot());
                return;
            }

            LoadingPopup.showMessage(Constants.INSTANCE.PleaseWaitDotDotDot());
            ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
            moduleService.createModuleSnapshot(packageName, name, replace, comment.getText(), true,
                    new GenericCallback<java.lang.Void>() {
                        public void onSuccess(Void v) {
                            Window.alert(Constants.INSTANCE.TheSnapshotCalled0WasSuccessfullyCreated(name));
                            form.hide();
                            if (refreshCmd != null) {
                                refreshCmd.execute();
                            }
                            LoadingPopup.close();
                        }

                        public void onFailure(Throwable t) {
                            LoadingPopup.close();
                            if (t instanceof SessionExpiredException) {
                                showSessionExpiry();
                            } else if (t instanceof DetailedSerializationException) {
                                if (((DetailedSerializationException) t).getMessage()
                                        .contains("Your package has not been built since last change")) {
                                    ErrorPopup.showMessage(Constants.INSTANCE.PackageHadNotBeenBuiltWarning());
                                } else {
                                    ErrorPopup.showMessage((DetailedSerializationException) t);
                                }
                            } else {
                                String message = t.getMessage();
                                if (t.getMessage() != null && t.getMessage().trim().equals("0")) {
                                    message = ((Constants) GWT.create(Constants.class)).CommunicationError();
                                }
                                ErrorPopup.showMessage(message);
                            }
                        }
                    });
        }
    });
    form.show();

}

From source file:org.drools.guvnor.client.moduleeditor.drools.SnapshotView.java

License:Apache License

private GenericCallback<SnapshotInfo[]> createGenericCallback(final String snapshotName,
        final String packageName, final ModuleServiceAsync serv) {
    return new GenericCallback<SnapshotInfo[]>() {
        public void onSuccess(final SnapshotInfo[] snaps) {
            final FormStylePopup copy = new FormStylePopup(DroolsGuvnorImages.INSTANCE.Snapshot(),
                    Constants.INSTANCE.CopySnapshotText(snapshotName));
            final List<RadioButton> options = new ArrayList<RadioButton>();
            VerticalPanel vert = new VerticalPanel();
            for (int i = 0; i < snaps.length; i++) {
                // cant copy onto to itself...
                if (!snaps[i].getName().equals(snapshotName)) {
                    RadioButton existing = new RadioButton("snapshotNameGroup", snaps[i].getName()); // NON-NLS
                    options.add(existing);
                    vert.add(existing);/*www.j a v a2s . com*/
                }
            }

            HorizontalPanel newNameHorizontalPanel = new HorizontalPanel();
            final TextBox newNameTextBox = new TextBox();
            final String newNameText = Constants.INSTANCE.NEW() + ": ";

            final RadioButton newNameRadioButton = new RadioButton("snapshotNameGroup", newNameText);
            newNameHorizontalPanel.add(newNameRadioButton);
            newNameTextBox.setEnabled(false);
            newNameRadioButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    newNameTextBox.setEnabled(true);
                }
            });

            newNameHorizontalPanel.add(newNameTextBox);
            options.add(newNameRadioButton);
            vert.add(newNameHorizontalPanel);

            copy.addAttribute(Constants.INSTANCE.ExistingSnapshots(), vert);

            Button ok = new Button(Constants.INSTANCE.OK());
            copy.addAttribute("", ok);
            ok.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    if (!isOneButtonSelected(options)) {
                        Window.alert(Constants.INSTANCE.YouHaveToEnterOrChoseALabelNameForTheSnapshot());
                        return;
                    }

                    if (newNameRadioButton.getValue()) {
                        if (checkUnique(snaps, newNameTextBox.getText())) {
                            serv.copyOrRemoveSnapshot(packageName, snapshotName, false,
                                    newNameTextBox.getText(), new GenericCallback<java.lang.Void>() {
                                        public void onSuccess(Void v) {
                                            copy.hide();
                                            Window.alert(Constants.INSTANCE.CreatedSnapshot0ForPackage1(
                                                    newNameTextBox.getText(), packageName));
                                        }
                                    });
                        }
                    } else {
                        for (RadioButton rb : options) {
                            if (rb.getValue()) {
                                final String newName = rb.getText();
                                serv.copyOrRemoveSnapshot(packageName, snapshotName, false, newName,
                                        new GenericCallback<java.lang.Void>() {
                                            public void onSuccess(Void v) {
                                                copy.hide();
                                                Window.alert(
                                                        Constants.INSTANCE.Snapshot0ForPackage1WasCopiedFrom2(
                                                                newName, packageName, snapshotName));
                                            }
                                        });
                            }
                        }
                    }
                }

                private boolean isOneButtonSelected(final List<RadioButton> options) {
                    boolean oneButtonIsSelected = false;
                    for (RadioButton rb : options) {
                        if (rb.getValue()) {
                            oneButtonIsSelected = true;
                            break;
                        }
                    }
                    return oneButtonIsSelected;
                }

                private boolean checkUnique(SnapshotInfo[] snaps, String name) {
                    for (SnapshotInfo sn : snaps) {
                        if (sn.getName().equals(name)) {
                            Window.alert(Constants.INSTANCE.PleaseEnterANonExistingSnapshotName());
                            return false;
                        }
                    }
                    return true;
                }
            });
            copy.show();
        }
    };
}