Advertisement
Guest User

Untitled

a guest
Apr 13th, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.16 KB | None | 0 0
  1. import com.energyict.gwt.components.explorer.client.model.Example;
  2. import com.google.gwt.core.client.EntryPoint;
  3. import com.google.gwt.user.client.ui.IsWidget;
  4. import com.google.gwt.user.client.ui.Label;
  5. import com.google.gwt.user.client.ui.RadioButton;
  6. import com.google.gwt.user.client.ui.RootPanel;
  7. import com.google.gwt.user.client.ui.Widget;
  8. import com.sencha.gxt.core.client.util.Margins;
  9. import com.sencha.gxt.core.client.util.ToggleGroup;
  10. import com.sencha.gxt.widget.core.client.button.TextButton;
  11. import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer;
  12. import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
  13. import com.sencha.gxt.widget.core.client.container.MarginData;
  14. import com.sencha.gxt.widget.core.client.container.SimpleContainer;
  15. import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
  16. import com.sencha.gxt.widget.core.client.event.SelectEvent;
  17. import com.sencha.gxt.widget.core.client.form.CheckBox;
  18. import com.sencha.gxt.widget.core.client.form.Radio;
  19.  
  20. @Example.Detail(name = "CheckBox & Radio example", category = "Issues", icon = "issue", fit = true)
  21. public class CheckBoxAndRadioExample implements EntryPoint, IsWidget {
  22.  
  23.     public void onModuleLoad() {
  24.         RootPanel.get().add(asWidget());
  25.     }
  26.  
  27.     @Override
  28.     public Widget asWidget() {
  29.  
  30.         CheckBox box = new CheckBox(); box.setBoxLabel("This is a GXT CheckBox. You can't click on this text to select the check box");
  31.         CheckBox box2 = new CheckBox(); box2.setBoxLabel("This is another GXT CheckBox. You can't click on this text to select the check box");
  32.         ToggleGroup toggleGroup = new ToggleGroup();
  33.         toggleGroup.add(box);
  34.         toggleGroup.add(box2);
  35.             HBoxLayoutContainer gxtCBContainer = new HBoxLayoutContainer();
  36.             gxtCBContainer.setBorders(true);
  37.             gxtCBContainer.add(box, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  38.             gxtCBContainer.add(box2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  39.  
  40.         Radio radio = new Radio();
  41.         radio.setBoxLabel("This is a GXT Radio. You can't click on this text to select the radio button");
  42.         Radio radio2 = new Radio();
  43.         radio2.setBoxLabel("This is another GXT Radio. You can't click on this text to select the radio button");
  44.         ToggleGroup toggleGroup2 = new ToggleGroup();
  45.         toggleGroup2.add(radio);
  46.         toggleGroup2.add(radio2);
  47.             HBoxLayoutContainer gxtRBContainer = new HBoxLayoutContainer();
  48.             gxtRBContainer.setBorders(true);
  49.             gxtRBContainer.add(radio, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  50.             gxtRBContainer.add(radio2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  51.  
  52.         RadioButton rButton1 = new RadioButton("rbtn", "This is a GWT RadioButton. You CAN click on this text to select the check box");
  53.         RadioButton rButton2 = new RadioButton("rbtn", "This is another GWT RadioButton. You CAN click on this text to select the check box");
  54.         ToggleGroup toggleGroup3 = new ToggleGroup();
  55.         toggleGroup3.add(rButton1);
  56.         toggleGroup3.add(rButton2);
  57.             HBoxLayoutContainer gwtRBContainer = new HBoxLayoutContainer();
  58.             gwtRBContainer.setBorders(true);
  59.             gwtRBContainer.add(rButton1, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  60.             gwtRBContainer.add(rButton2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  61.  
  62.         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");
  63.         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");
  64.         ToggleGroup toggleGroup4 = new ToggleGroup();
  65.         toggleGroup4.add(gch);
  66.         toggleGroup4.add(gch2);
  67.             HBoxLayoutContainer gwtCBContainer = new HBoxLayoutContainer();
  68.             gwtCBContainer.setBorders(true);
  69.             gwtCBContainer.add(gch, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  70.             gwtCBContainer.add(gch2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  71.  
  72.         VerticalLayoutContainer container = new VerticalLayoutContainer();
  73.         container.add(gxtCBContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  74.         container.add(gxtRBContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  75.         container.add(gwtRBContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  76.         container.add(gwtCBContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  77.         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"),
  78.             new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  79.  
  80.         // --------------------------------------------
  81.         // New problem in 3.0.0 RC & RC 2
  82.         // --------------------------------------------
  83.  
  84.         final Radio radio01 = new Radio();
  85.         radio01.setBoxLabel("Choice 1");
  86.         final Radio radio02 = new Radio();
  87.         radio02.setBoxLabel("Choice 2");
  88.         final Radio radio03 = new Radio();
  89.         radio03.setBoxLabel("Choice 3");
  90.         final ToggleGroup toggleGroup01 = new ToggleGroup();
  91.         toggleGroup01.add(radio01);
  92.         toggleGroup01.add(radio02);
  93.         toggleGroup01.add(radio03);
  94.         toggleGroup01.setValue(radio01);
  95.  
  96.         HBoxLayoutContainer radioContainer = new HBoxLayoutContainer();
  97.         radioContainer.setBorders(true);
  98.         radioContainer.add(radio01, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  99.         radioContainer.add(radio02, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  100.         radioContainer.add(radio03, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  101.  
  102.         HBoxLayoutContainer buttonContainer = new HBoxLayoutContainer();
  103.         buttonContainer.setBorders(true);
  104.         TextButton btn1 = new TextButton("Choice 1");
  105.         btn1.addSelectHandler(new SelectEvent.SelectHandler() {
  106.             public void onSelect(SelectEvent event) {
  107.                 toggleGroup01.setValue(radio01);
  108.             }
  109.         });
  110.         buttonContainer.add(btn1, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  111.         TextButton btn2 = new TextButton("Choice 2");
  112.         btn2.addSelectHandler(new SelectEvent.SelectHandler() {
  113.             public void onSelect(SelectEvent event) {
  114.                 toggleGroup01.setValue(radio02);
  115.             }
  116.         });
  117.         buttonContainer.add(btn2, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  118.         TextButton btn3 = new TextButton("Choice 3");
  119.         btn3.addSelectHandler(new SelectEvent.SelectHandler() {
  120.             public void onSelect(SelectEvent event) {
  121.                 toggleGroup01.setValue(radio03);
  122.             }
  123.         });
  124.         buttonContainer.add(btn3, new BoxLayoutContainer.BoxLayoutData(new Margins(4)));
  125.  
  126.         container.add(new Label("- - - - - - - - - - - - - - - - - - - - - - - - - - -"),
  127.             new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  128.         container.add(new Label("By fixing the above, another ToggleGroup problem occurs:"),
  129.             new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  130.         container.add(radioContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  131.         container.add(new Label("Clicking the icons: everything works OK. Clicking the texts: multiple selection possible (IE version 8.0.7601.17514)"),
  132.             new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  133.         container.add(new Label("Issue filed @ the Sencha forum (3-apr-2012) as bug in 3.0.0 RC [EXTGWT-1844]"),
  134.             new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  135.         container.add(new Label("- - - - - - - - - - - - - - - - - - - - - - - - - - -"),
  136.             new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  137.         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)"),
  138.             new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  139.         container.add(new Label("Only programmatically. Eg. by clicking these buttons:"),
  140.             new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  141.         container.add(buttonContainer, new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  142.         container.add(new Label("Strange enough: once set programmatically, you can select them again. But then multiple selection problem is back!"),
  143.             new VerticalLayoutContainer.VerticalLayoutData(1, -1, new Margins(0, 0, 10, 0)));
  144.  
  145.         SimpleContainer simple = new SimpleContainer();
  146.         simple.add(container, new MarginData(20));
  147.         return simple;
  148.     }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement