private void copySelected(final ListBox from, final ListBox to) {
   int selected;
   while ((selected = from.getSelectedIndex()) != -1) {
     to.addItem(from.getItemText(selected));
     from.removeItem(selected);
   }
 }
Example #2
0
  private void initUserList(final ClientUser[] list) {
    // The user listing is downloaded by an async call.
    final RootPanel userPanel = RootPanel.get("email");
    userPanel.add(users);
    users.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(final ChangeEvent event) {
            userChanged();
          }
        });
    users.addItem(SELECT_USER_STRING, "");
    userInfo.clear();
    for (final ClientUser user : list) {
      users.addItem(user.getName(), user.getEmail());
      userInfo.put(user.getEmail(), user);
    }

    // Select the user according to the cookie stored
    final String userEmail = Cookies.getCookie("email");
    selectUser(userEmail);
  }
  public RowLayoutPortlet() {
    LayoutPanel panel = new LayoutPanel();
    initWidget(panel);

    final CheckBox column = new CheckBox("Column");
    column.addValueChangeHandler(
        new ValueChangeHandler<Boolean>() {
          public void onValueChange(ValueChangeEvent<Boolean> event) {
            getTargetLayout().setColumn(column.getValue());
            target.layout();
          }
        });

    final TextBox spacing = new TextBox();
    spacing.setVisibleLength(4);
    spacing.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            try {
              getTargetLayout().setSpacing(Integer.parseInt(spacing.getText()));
            } catch (NumberFormatException e) {
              // ignore
            }
            target.layout();
          }
        });

    final Label bounds = new Label();
    target.addLayoutHandler(
        new LayoutHandler() {
          public void onLayoutUpdated(LayoutEvent layoutEvent) {
            bounds.setText(LDOM.getBounds(target).toString());
            column.setValue(getTargetLayout().isColumn());
            spacing.setText(Integer.toString(getTargetLayout().getSpacing()));
          }
        });

    demoList.addItem("Buttons & Body");
    demoList.addItem("Sidebar & Margin");
    demoList.addItem("Border Layout");
    demoList.setSelectedIndex(0);

    Button add =
        new CssButton(
            "Add Widget",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                target.add(new Thing("Widget-" + (target.getWidgetCount() + 1)));
                target.layout();
              }
            },
            "Add a new widget to the layout");

    final Button go =
        new CssButton(
            "Go",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                go();
              }
            },
            "Reset the layout to the selected state");

    demoList.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            go.click();
          }
        });

    FormBuilder b = new FormBuilder();
    b.add(add)
        .label("Spacing")
        .field(spacing)
        .field(column)
        .add("")
        .field(bounds)
        .wrap()
        .width("100%")
        .add(demoList)
        .add(go)
        .endRow();

    panel.add(b.getForm(), 22);
    panel.add(target, LayoutConstraints.HIDDEN);

    go();
  }
  /**
   * Tests submitting using url-encoded get, with all form widgets (other than FileUpload, which
   * requires post/multipart.
   */
  public void testMethodGet() {
    System.out.println("testMethodGet");
    final FormPanel form = new FormPanel();
    form.setMethod(FormPanel.METHOD_GET);
    form.setEncoding(FormPanel.ENCODING_URLENCODED);
    form.setAction(GWT.getModuleBaseURL() + "formHandler");

    TextBox tb = new TextBox();
    tb.setText("text");
    tb.setName("tb");

    PasswordTextBox ptb = new PasswordTextBox();
    ptb.setText("password");
    ptb.setName("ptb");

    CheckBox cb0 = new CheckBox(), cb1 = new CheckBox();
    cb1.setValue(true);
    cb0.setName("cb0");
    cb1.setName("cb1");

    RadioButton rb0 = new RadioButton("foo");
    RadioButton rb1 = new RadioButton("foo");
    rb0.setValue(true);
    rb0.setName("rb0");
    rb1.setName("rb1");

    ListBox lb = new ListBox();
    lb.addItem("option0");
    lb.addItem("option1");
    lb.addItem("option2");
    lb.setValue(0, "value0");
    lb.setValue(1, "value1");
    lb.setValue(2, "value2");
    lb.setSelectedIndex(1);
    lb.setName("lb");

    Hidden h = new Hidden("h", "v");

    FlowPanel panel = new FlowPanel();
    panel.add(tb);
    panel.add(ptb);
    panel.add(cb0);
    panel.add(cb1);
    panel.add(rb0);
    panel.add(rb1);
    panel.add(lb);
    panel.add(h);
    form.setWidget(panel);
    RootPanel.get().add(form);

    delayTestFinish(TEST_DELAY);

    form.addSubmitCompleteHandler(
        new SubmitCompleteHandler() {
          public void onSubmitComplete(SubmitCompleteEvent event) {
            // The server just echoes the query string. This is what it should look
            // like.
            assertTrue(
                event
                    .getResults()
                    .equals(
                        "tb=text&amp;ptb=password&amp;cb1=on&amp;rb0=on&amp;lb=value1&amp;h=v"));
            finishTest();
          }
        });

    form.submit();
  }
 private void addConfig(Configuration configuration) {
   configList.addItem(configuration.getName());
   configurations.put(configuration.getName(), configuration);
 }
Example #6
0
  public PackageBuilderWidget(final PackageConfigData conf, ClientFactory clientFactory) {

    this.conf = conf;
    this.clientFactory = clientFactory;

    // UI above the results table
    FormStyleLayout layout = new FormStyleLayout();
    final VerticalPanel container = new VerticalPanel();
    final VerticalPanel buildResults = new VerticalPanel();

    RadioButton wholePackageRadioButton = new RadioButton("action", constants.BuildWholePackage());
    RadioButton builtInSelectorRadioButton =
        new RadioButton("action", constants.BuildPackageUsingBuiltInSelector());
    RadioButton customSelectorRadioButton =
        new RadioButton("action", constants.BuildPackageUsingCustomSelector());
    wholePackageRadioButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(true);
            builtInSelectorLayout.setVisible(false);
            customSelectorLayout.setVisible(false);
            buildMode = "buildWholePackage";
          }
        });
    builtInSelectorRadioButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(false);
            builtInSelectorLayout.setVisible(true);
            customSelectorLayout.setVisible(false);
            buildMode = "BuiltInSelector";
          }
        });
    customSelectorRadioButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(false);
            builtInSelectorLayout.setVisible(false);
            customSelectorLayout.setVisible(true);
            buildMode = "customSelector";
          }
        });

    VerticalPanel verticalPanel = new VerticalPanel();

    HorizontalPanel wholePackageRadioButtonPanel = new HorizontalPanel();
    wholePackageRadioButtonPanel.add(wholePackageRadioButton);
    wholePackageRadioButtonPanel.add(
        new InfoPopup(constants.BuildWholePackage(), constants.BuildWholePackageTip()));
    verticalPanel.add(wholePackageRadioButtonPanel);

    HorizontalPanel builtInSelectorRadioButtonPanel = new HorizontalPanel();
    builtInSelectorRadioButtonPanel.add(builtInSelectorRadioButton);
    builtInSelectorRadioButtonPanel.add(
        new InfoPopup(constants.BuiltInSelector(), constants.BuiltInSelectorTip()));
    verticalPanel.add(builtInSelectorRadioButtonPanel);

    HorizontalPanel customSelectorRadioButtonPanel = new HorizontalPanel();
    customSelectorRadioButtonPanel.add(customSelectorRadioButton);
    customSelectorRadioButtonPanel.add(
        new InfoPopup(constants.CustomSelector(), constants.SelectorTip()));
    verticalPanel.add(customSelectorRadioButtonPanel);

    layout.addAttribute("", verticalPanel);
    wholePackageRadioButton.setValue(true);

    buildWholePackageLayout.setVisible(true);
    builtInSelectorLayout.setVisible(false);
    customSelectorLayout.setVisible(false);

    // Build whole package layout
    layout.addRow(buildWholePackageLayout);

    // Built-in selector layout
    builtInSelectorLayout.addRow(
        new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingFollowingAssets() + "</i>"));

    HorizontalPanel builtInSelectorStatusPanel = new HorizontalPanel();
    final CheckBox enableStatusCheckBox = new CheckBox();
    enableStatusCheckBox.setValue(false);
    builtInSelectorStatusPanel.add(enableStatusCheckBox);
    builtInSelectorStatusPanel.add(
        new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingBuiltInSelectorStatus() + " </i>"));
    final ListBox statusOperator = new ListBox();
    String[] vals = new String[] {"=", "!="};
    for (int i = 0; i < vals.length; i++) {
      statusOperator.addItem(vals[i], vals[i]);
    }
    builtInSelectorStatusPanel.add(statusOperator);

    final TextBox statusValue = new TextBox();
    statusValue.setTitle(constants.WildCardsSearchTip());
    builtInSelectorStatusPanel.add(statusValue);

    builtInSelectorLayout.addRow(builtInSelectorStatusPanel);

    HorizontalPanel builtInSelectorCatPanel = new HorizontalPanel();
    final CheckBox enableCategoryCheckBox = new CheckBox();
    enableCategoryCheckBox.setValue(false);
    builtInSelectorCatPanel.add(enableCategoryCheckBox);
    builtInSelectorCatPanel.add(
        new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingBuiltInSelectorCat() + " </i>"));
    final ListBox catOperator = new ListBox();
    String[] catVals = new String[] {"=", "!="};
    for (int i = 0; i < catVals.length; i++) {
      catOperator.addItem(catVals[i], catVals[i]);
    }
    builtInSelectorCatPanel.add(catOperator);
    final CategoryExplorerWidget catChooser =
        new CategoryExplorerWidget(
            new CategorySelectHandler() {
              public void selected(String selectedPath) {}
            });
    ScrollPanel catScroll = new ScrollPanel(catChooser);
    catScroll.setAlwaysShowScrollBars(true);
    catScroll.setSize("300px", "130px");

    builtInSelectorCatPanel.add(catScroll);
    builtInSelectorLayout.addRow(builtInSelectorCatPanel);

    layout.addRow(builtInSelectorLayout);

    // Custom selector layout
    customSelectorLayout.setVisible(false);
    HorizontalPanel customSelectorPanel = new HorizontalPanel();
    customSelectorPanel.add(
        new HTML(
            "&nbsp;&nbsp;<i>"
                + constants.BuildPackageUsingCustomSelectorSelector()
                + " </i>")); // NON-NLS

    final ListBox customSelector = new ListBox();
    customSelector.setTitle(constants.WildCardsSearchTip());
    customSelectorPanel.add(customSelector);
    loadCustomSelectorList(customSelector);

    customSelectorLayout.addRow(customSelectorPanel);
    layout.addRow(customSelectorLayout);

    final Button b = new Button(constants.BuildPackage());
    b.setTitle(constants.ThisWillValidateAndCompileAllTheAssetsInAPackage());
    b.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            doBuild(
                buildResults,
                statusOperator.getValue(statusOperator.getSelectedIndex()),
                statusValue.getText(),
                enableStatusCheckBox.getValue(),
                catOperator.getValue(catOperator.getSelectedIndex()),
                catChooser.getSelectedPath(),
                enableCategoryCheckBox.getValue(),
                customSelector.getSelectedIndex() != -1
                    ? customSelector.getValue(customSelector.getSelectedIndex())
                    : null);
          }
        });
    HorizontalPanel buildStuff = new HorizontalPanel();
    buildStuff.add(b);

    layout.addAttribute(constants.BuildBinaryPackage(), buildStuff);
    layout.addRow(
        new HTML("<i><small>" + constants.BuildingPackageNote() + "</small></i>")); // NON-NLS
    container.add(layout);

    // The build results
    container.add(buildResults);

    // UI below the results table
    layout = new FormStyleLayout();
    Button snap = new Button(constants.CreateSnapshotForDeployment());
    snap.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            showSnapshotDialog(conf.getName(), null);
          }
        });
    layout.addAttribute(constants.TakeSnapshot(), snap);
    container.add(layout);

    initWidget(container);
  }