Exemple #1
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());
  }
Exemple #2
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 selectFirstConfig() {
   if (isConfigListEmpty()) {
     disableDeleteButton();
   } else {
     enableDeleteButton();
     configList.setSelectedIndex(0);
   }
 }
Exemple #4
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 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 boolean isConfigListEmpty() {
   return configList.getItemCount() == 0;
 }
 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);
 }