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
 @Override
 protected void layout() {
   curFolderGroup.setPosition(getInnerX(), getInnerY());
   curFolderGroup.setSize(getInnerWidth(), curFolderGroup.getHeight());
   listbox.setPosition(getInnerX(), curFolderGroup.getBottom());
   listbox.setSize(getInnerWidth(), Math.max(0, getInnerBottom() - listbox.getY()));
 }
Example #3
0
  private void userChanged() {
    if (users == null) {
      return;
    }
    ClientUser user = null;
    if (users.getSelectedIndex() > 0) {
      final String email = users.getValue(users.getSelectedIndex());
      if (userInfo.containsKey(email)) {
        user = userInfo.get(email);
      }

      Cookies.setCookie(
          "email",
          users.getValue(users.getSelectedIndex()),
          ParamSetSelectionController.getCookieExpirationDate(),
          null,
          "/",
          false);
    }

    // Figure out whether this user can edit parameters or not
    final boolean editorEnabled = user != null && user.isParameterEditorEnabled();
    if (paramsEditor != null) {
      paramsEditor.setEditorEnabled(editorEnabled, user);
    }
    setOutputPathChangeEnabled(user != null && user.isOutputPathChangeEnabled());
  }
Example #4
0
 private void selectUser(final String userEmail) {
   if (userEmail != null) {
     for (int i = 0; i < users.getItemCount(); i++) {
       if (users.getValue(i).equalsIgnoreCase(userEmail)) {
         users.setSelectedIndex(i);
         break;
       }
     }
   }
   userChanged();
 }
  private void removeWorkspace() {
    String name =
        availableWorkspacesListBox.getItemText(availableWorkspacesListBox.getSelectedIndex());

    repositoryService.removeWorkspace(
        name,
        new GenericCallback<java.lang.Void>() {
          public void onSuccess(Void v) {
            Window.alert(constants.WorkspaceRemoved());
            refreshWorkspaceList();
          }
        });
  }
  private void updateWorkspace() {
    String name =
        availableWorkspacesListBox.getItemText(availableWorkspacesListBox.getSelectedIndex());

    List<String> selectedModulesList = new ArrayList<String>(selectedModulesListBox.getItemCount());
    for (int i = 0; i < selectedModulesListBox.getItemCount(); i++) {
      selectedModulesList.add(selectedModulesListBox.getItemText(i));
    }
    List<String> availableModuleList =
        new ArrayList<String>(availableModulesListBox.getItemCount());
    for (int i = 0; i < availableModulesListBox.getItemCount(); i++) {
      availableModuleList.add(availableModulesListBox.getItemText(i));
    }
    availableModuleList.removeAll(selectedModulesList);
    LoadingPopup.showMessage(constants.LoadingStatuses());

    repositoryService.updateWorkspace(
        name,
        selectedModulesList.toArray(new String[selectedModulesList.size()]),
        availableModuleList.toArray(new String[availableModuleList.size()]),
        new GenericCallback<java.lang.Void>() {
          public void onSuccess(Void v) {
            Window.alert(constants.WorkspaceUpdated());
            refreshWorkspaceList();
          }
        });
  }
 private void selectFirstConfig() {
   if (isConfigListEmpty()) {
     disableDeleteButton();
   } else {
     enableDeleteButton();
     configList.setSelectedIndex(0);
   }
 }
  private void runPlugin(String pluginName) {
    ConnectInfo[] friends = null;
    Plugin plugin = PluginManager.getInstance().getPlugin(pluginName);

    // get users
    if (plugin.isStandalone()) friends = new ConnectInfo[0];
    else {
      ListBox userList =
          new ListBox(
              null, plugin.getTitle(), tr("msg.selectUsers"), Client.getInstance().getUserList());
      Object[] users = userList.selectItems();
      if (users != null) {
        friends = new ConnectInfo[users.length];
        for (int i = 0; i < friends.length; i++)
          friends[i] = Communicator.getInstance().getConnectInfo((String) users[i]);
      }
    }

    // run the plugin if the user didn't click on cancel
    if (friends != null) PluginManager.getInstance().run(pluginName, friends);
  }
Example #9
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);
  }
Example #10
0
 private void go() {
   target.clear();
   switch (demoList.getSelectedIndex()) {
     case 0:
       demoButtonsAndBody();
       break;
     case 1:
       demoSidebarAndMargin();
       break;
     case 2:
       demoBorder();
       break;
   }
   target.layout();
 }
Example #11
0
  public boolean setCurrentFolder(Object folder) {
    if (model.listFolders(folder)) {
      // if we show root and it has only a single entry go directly into
      // it
      if (folder == null && model.getNumEntries() == 1) {
        if (setCurrentFolder(model.getFolder(0))) {
          return true;
        }
      }

      currentFolder = folder;
      listbox.setSelected(ListBox.NO_SELECTION);

      rebuildCurrentFolderGroup();

      doCallback();
      return true;
    }
    return false;
  }
Example #12
0
  public FolderBrowser(FileSystemModel fsm) {
    if (fsm == null) {
      throw new NullPointerException("fsm");
    }

    this.fsm = fsm;
    this.model = new FolderModel();
    this.listbox = new ListBox<Object>(model);
    this.curFolderGroup = new BoxLayout();

    curFolderGroup.setTheme("currentpathbox");
    curFolderGroup.setScroll(true);
    curFolderGroup.setClip(true);
    curFolderGroup.setAlignment(Alignment.BOTTOM);

    listbox.addCallback(
        new CallbackWithReason<ListBox.CallbackReason>() {
          private Object lastSelection;

          public void callback(ListBox.CallbackReason reason) {
            if (listbox.getSelected() != ListBox.NO_SELECTION) {
              if (reason.actionRequested()) {
                setCurrentFolder(model.getFolder(listbox.getSelected()));
              }
            }
            Object selection = getSelectedFolder();
            if (selection != lastSelection) {
              lastSelection = selection;
              fireSelectionChangedCallback();
            }
          }
        });

    add(listbox);
    add(curFolderGroup);

    setCurrentFolder(null);
  }
  private Grid buildDoubleList() {
    Grid grid = new Grid(2, 5);

    availableWorkspacesListBox = new ListBox();
    availableWorkspacesListBox.setVisibleItemCount(10);
    availableWorkspacesListBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent arg0) {
            String selectedWorkspaceName =
                availableWorkspacesListBox.getItemText(
                    availableWorkspacesListBox.getSelectedIndex());
            refreshModuleList(selectedWorkspaceName);
          }
        });
    // availableWorkspaces.setWidth( "30%" );

    refreshWorkspaceList();

    try {
      availableModulesListBox.setVisibleItemCount(10);
      selectedModulesListBox.setVisibleItemCount(10);

      Grid btnsPanel = new Grid(2, 1);

      btnsPanel.setWidget(
          0,
          0,
          new Button(
              ">",
              new ClickHandler() {

                public void onClick(ClickEvent sender) {
                  copySelected(availableModulesListBox, selectedModulesListBox);
                }
              }));

      btnsPanel.setWidget(
          1,
          0,
          new Button(
              "&lt;",
              new ClickHandler() {

                public void onClick(ClickEvent sender) {
                  copySelected(selectedModulesListBox, availableModulesListBox);
                }
              }));

      grid.setWidget(0, 0, new SmallLabel(constants.Workspaces()));
      grid.setWidget(0, 2, new SmallLabel("Workspace: Available Modules"));
      grid.setWidget(0, 3, new SmallLabel(""));
      grid.setWidget(0, 4, new SmallLabel("Workspace: Selected Modules"));
      grid.setWidget(1, 0, availableWorkspacesListBox);
      grid.setWidget(1, 2, availableModulesListBox);
      grid.setWidget(1, 3, btnsPanel);
      grid.setWidget(1, 4, selectedModulesListBox);

      grid.getColumnFormatter().setWidth(0, "25%");
      grid.getColumnFormatter().setWidth(1, "10%");
      grid.getColumnFormatter().setWidth(2, "25%");
      grid.getColumnFormatter().setWidth(3, "15%");
      grid.getColumnFormatter().setWidth(4, "25%");
      return grid;
    } finally {
      // sce.setFilteringFacts( filteringFact );
    }
  }
Example #14
0
 /**
  * Get the current selected folder in the list box
  *
  * @return a folder or null if nothing is selected
  */
 public Object getSelectedFolder() {
   if (listbox.getSelected() != ListBox.NO_SELECTION) {
     return model.getFolder(listbox.getSelected());
   }
   return null;
 }
  public MediaSourcePanel(
      final DeviceAudioOutServiceAsync service, final MediaSourcePanelListener listener) {
    this.service = service;
    this.listener = listener;

    source = new ListBox(false);
    source.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent event) {
            int selectedIndex = source.getSelectedIndex();

            if (selectedIndex >= 0)
              service.setMediaSource(
                  source.getItemText(selectedIndex),
                  new AsyncCallback<Void>() {
                    @Override
                    public void onFailure(Throwable caught) {}

                    @Override
                    public void onSuccess(Void result) {
                      updateNavItem();
                    }
                  });
          }
        });
    add(source);
    navigation = new ListBox(true);
    add(navigation);

    add = new Button("Add to queue");
    add.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            service.addToQueue(
                getSelectedNavItem(),
                new AsyncCallback<Void>() {
                  @Override
                  public void onFailure(Throwable caught) {}

                  @Override
                  public void onSuccess(Void result) {
                    listener.itemAddedToQueue();
                  }
                });
          }
        });

    open = new Button("Open");
    open.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            selectNavItem(getSelectedNavItem());
          }
        });

    back = new Button("Back");
    back.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            moveBackToParent();
          }
        });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.add(add);
    buttonPanel.add(open);
    buttonPanel.add(back);
    add(buttonPanel);
  }
 private String getSelectedNavItem() {
   return navigation.getItemText(navigation.getSelectedIndex());
 }
 private void selectLastConfig() {
   int lastIndex = configList.getItemCount() - 1;
   configList.setSelectedIndex(lastIndex);
 }
 private int getSelectedConfigIndex() {
   return configList.getSelectedIndex();
 }
 private String getSelectedConfig() {
   return configList.getItemText(getSelectedConfigIndex());
 }
 private void removeSelectedConfig() {
   configurations.remove(getSelectedConfig());
   configList.removeItem(getSelectedConfigIndex());
 }
 private void addConfig(Configuration configuration) {
   configList.addItem(configuration.getName());
   configurations.put(configuration.getName(), configuration);
 }
Example #22
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);
  }
  /**
   * 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 boolean isConfigListEmpty() {
   return configList.getItemCount() == 0;
 }
Example #25
0
  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();
  }
Example #26
0
 public boolean selectFolder(Object current) {
   int idx = model.findFolder(current);
   listbox.setSelected(idx);
   return idx != ListBox.NO_SELECTION;
 }