Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.energyict.gwt.components.explorer.client.model.Example;
- import com.google.gwt.core.client.EntryPoint;
- import com.google.gwt.user.client.ui.IsWidget;
- import com.google.gwt.user.client.ui.Label;
- import com.google.gwt.user.client.ui.RadioButton;
- import com.google.gwt.user.client.ui.RootPanel;
- import com.google.gwt.user.client.ui.Widget;
- import com.sencha.gxt.core.client.util.Margins;
- import com.sencha.gxt.core.client.util.ToggleGroup;
- import com.sencha.gxt.widget.core.client.button.TextButton;
- import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer;
- import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
- import com.sencha.gxt.widget.core.client.container.MarginData;
- import com.sencha.gxt.widget.core.client.container.SimpleContainer;
- import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
- import com.sencha.gxt.widget.core.client.event.SelectEvent;
- import com.sencha.gxt.widget.core.client.form.CheckBox;
- import com.sencha.gxt.widget.core.client.form.Radio;
- @Example.Detail(name = "CheckBox & Radio example", category = "Issues", icon = "issue", fit = true)
- public class CheckBoxAndRadioExample implements EntryPoint, IsWidget {
- public void onModuleLoad() {
- RootPanel.get().add(asWidget());
- }
- @Override
- public Widget asWidget() {
- CheckBox box = new CheckBox(); box.setBoxLabel("This is a GXT CheckBox. You can't click on this text to select the check box");
- CheckBox box2 = new CheckBox(); box2.setBoxLabel("This is another GXT CheckBox. You can't click on this text to select the check box");
- ToggleGroup toggleGroup = new ToggleGroup();
- toggleGroup.add(box);
- toggleGroup.add(box2);
- HBoxLayoutContainer gxtCBContainer = new HBoxLayoutContainer();
- gxtCBContainer.setBorders(true);
- gxtCBContainer.add(box, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- gxtCBContainer.add(box2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- Radio radio = new Radio();
- radio.setBoxLabel("This is a GXT Radio. You can't click on this text to select the radio button");
- Radio radio2 = new Radio();
- radio2.setBoxLabel("This is another GXT Radio. You can't click on this text to select the radio button");
- ToggleGroup toggleGroup2 = new ToggleGroup();
- toggleGroup2.add(radio);
- toggleGroup2.add(radio2);
- HBoxLayoutContainer gxtRBContainer = new HBoxLayoutContainer();
- gxtRBContainer.setBorders(true);
- gxtRBContainer.add(radio, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- gxtRBContainer.add(radio2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- RadioButton rButton1 = new RadioButton("rbtn", "This is a GWT RadioButton. You CAN click on this text to select the check box");
- RadioButton rButton2 = new RadioButton("rbtn", "This is another GWT RadioButton. You CAN click on this text to select the check box");
- ToggleGroup toggleGroup3 = new ToggleGroup();
- toggleGroup3.add(rButton1);
- toggleGroup3.add(rButton2);
- HBoxLayoutContainer gwtRBContainer = new HBoxLayoutContainer();
- gwtRBContainer.setBorders(true);
- gwtRBContainer.add(rButton1, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- gwtRBContainer.add(rButton2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- com.google.gwt.user.client.ui.CheckBox gch = new com.google.gwt.user.client.ui.CheckBox("This is a GWT CheckBox. You CAN click on this text to select the check box");
- com.google.gwt.user.client.ui.CheckBox gch2 = new com.google.gwt.user.client.ui.CheckBox("This is another GWT CheckBox. You CAN click on this text to select the check box");
- ToggleGroup toggleGroup4 = new ToggleGroup();
- toggleGroup4.add(gch);
- toggleGroup4.add(gch2);
- HBoxLayoutContainer gwtCBContainer = new HBoxLayoutContainer();
- gwtCBContainer.setBorders(true);
- gwtCBContainer.add(gch, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- gwtCBContainer.add(gch2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- VerticalLayoutContainer container = new VerticalLayoutContainer();
- container.add(gxtCBContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(gxtRBContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(gwtRBContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(gwtCBContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(new Label("Issue filed @ the Sencha forum (16-mar-2012). Accepted as bug in 3.0.0 Beta 4. Fixed in 3.0.0 RC"),
- new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- // --------------------------------------------
- // New problem in 3.0.0 RC & RC 2
- // --------------------------------------------
- final Radio radio01 = new Radio();
- radio01.setBoxLabel("Choice 1");
- final Radio radio02 = new Radio();
- radio02.setBoxLabel("Choice 2");
- final Radio radio03 = new Radio();
- radio03.setBoxLabel("Choice 3");
- final ToggleGroup toggleGroup01 = new ToggleGroup();
- toggleGroup01.add(radio01);
- toggleGroup01.add(radio02);
- toggleGroup01.add(radio03);
- toggleGroup01.setValue(radio01);
- HBoxLayoutContainer radioContainer = new HBoxLayoutContainer();
- radioContainer.setBorders(true);
- radioContainer.add(radio01, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- radioContainer.add(radio02, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- radioContainer.add(radio03, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- HBoxLayoutContainer buttonContainer = new HBoxLayoutContainer();
- buttonContainer.setBorders(true);
- TextButton btn1 = new TextButton("Choice 1");
- btn1.addSelectHandler(new SelectEvent.SelectHandler() {
- public void onSelect(SelectEvent event) {
- toggleGroup01.setValue(radio01);
- }
- });
- buttonContainer.add(btn1, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- TextButton btn2 = new TextButton("Choice 2");
- btn2.addSelectHandler(new SelectEvent.SelectHandler() {
- public void onSelect(SelectEvent event) {
- toggleGroup01.setValue(radio02);
- }
- });
- buttonContainer.add(btn2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- TextButton btn3 = new TextButton("Choice 3");
- btn3.addSelectHandler(new SelectEvent.SelectHandler() {
- public void onSelect(SelectEvent event) {
- toggleGroup01.setValue(radio03);
- }
- });
- buttonContainer.add(btn3, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
- container.add(new Label("- - - - - - - - - - - - - - - - - - - - - - - - - - -"),
- new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(new Label("By fixing the above, another ToggleGroup problem occurs:"),
- new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(radioContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(new Label("Clicking the icons: everything works OK. Clicking the texts: multiple selection possible (IE version 8.0.7601.17514)"),
- new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(new Label("Issue filed @ the Sencha forum (3-apr-2012) as bug in 3.0.0 RC [EXTGWT-1844]"),
- new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(new Label("- - - - - - - - - - - - - - - - - - - - - - - - - - -"),
- new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(new Label("The so called fix in 3.0.0 RC 2 made the problem worse: Initially you can't select a radio button by clicking it! (13-apr-2012)"),
- new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(new Label("Only programmatically. Eg. by clicking these buttons:"),
- new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(buttonContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- container.add(new Label("Strange enough: once set programmatically, you can select them again. But then multiple selection problem is back!"),
- new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
- SimpleContainer simple = new SimpleContainer();
- simple.add(container, new MarginData(20));
- return simple;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement