Example #1
0
 @UiHandler("remove")
 public void onRemoveClick(ClickEvent event) {
   int selectedIndexA = previewA.getSelectedIndex();
   int selectedIndexZ = previewZ.getSelectedIndex();
   if (selectedIndexA == selectedIndexZ) {
     previewA.removeItem(selectedIndexA);
     previewZ.removeItem(selectedIndexZ);
   } else {
     Window.alert("请确保所选中记录为同一行...");
   }
 }
 private void copySelected(final ListBox from, final ListBox to) {
   int selected;
   while ((selected = from.getSelectedIndex()) != -1) {
     to.addItem(from.getItemText(selected));
     from.removeItem(selected);
   }
 }
 public String removeSelected() {
   int idx = listBox.getSelectedIndex();
   String value = listBox.getItemText(idx);
   listBox.removeItem(idx);
   if (listBox.getItemCount() > 0) {
     listBox.setSelectedIndex(0);
   }
   return value;
 }
Example #4
0
 public void setAllowedAuthApps(String allowedAuthApps) {
   int size = idProvider.getItemCount();
   for (int i = 0; i < size; i++) {
     idProvider.removeItem(0);
   }
   String[] options = allowedAuthApps.split(",");
   for (String option : options) {
     idProvider.addItem(option, option);
   }
 }
 @Override
 public void userOnlineStatusChanged(int userId, boolean online) {
   if (online) {
     usersOnline.addItem(String.valueOf(userId));
   } else {
     for (int i = 0; i < usersOnline.getItemCount(); ++i) {
       if (usersOnline.getItemText(i).equals(String.valueOf(userId))) {
         usersOnline.removeItem(i);
       }
     }
   }
 }
 @Override
 public void deleteItem(String label) {
   if (label != null) {
     items.remove(label);
     int size = 0;
     do {
       size = listBox.getItemCount();
       for (int index = 0; index < listBox.getItemCount(); index++) {
         if (listBox.getItemText(index).equals(label)) {
           listBox.removeItem(index);
           break;
         }
       }
     } while (size != listBox.getItemCount());
   }
 }
  @Override
  public void onClick(ClickEvent event) {
    if (event.getSource() == includeDbScriptBox) {
      if (includeDbScriptBox.getValue()) {
        dbInstructionArea.setValue("");
        dbInstructionArea.setVisible(true);
      } else {
        dbInstructionArea.setValue("");
        dbInstructionArea.setVisible(false);
      }
    } else if (event.getSource() == addSurveyButton) {
      String group = selectionWidget.getSelectedSurveyGroupName();
      List<String> name = selectionWidget.getSelectedSurveyNames();
      List<Long> ids = selectionWidget.getSelectedSurveyIds();
      for (int i = 0; i < name.size(); i++) {
        boolean alreadyThere = false;
        for (int j = 0; j < selectionListbox.getItemCount(); j++) {
          if (selectionListbox.getValue(j).equals(ids.get(i).toString())) {
            alreadyThere = true;
            break;
          }
        }
        if (!alreadyThere) {
          selectionListbox.addItem(group + ": " + name.get(i), ids.get(i).toString());
        }
      }
    } else if (event.getSource() == removeButton) {
      List<Integer> victimList = new ArrayList<Integer>();
      for (int i = 0; i < selectionListbox.getItemCount(); i++) {
        if (selectionListbox.isItemSelected(i)) {
          victimList.add(i);
        }
      }
      if (victimList.size() > 0) {
        // remove the items in descending order so we don't have to
        // worry about adjusting indexes as we remove
        Collections.sort(victimList);
        for (int i = victimList.size() - 1; i >= 0; i--) {
          selectionListbox.removeItem(victimList.get(i));
        }
      }
    } else if (event.getSource() == generateFileButton) {

      List<Long> idList = new ArrayList<Long>();
      for (int i = 0; i < selectionListbox.getItemCount(); i++) {
        idList.add(new Long(selectionListbox.getValue(i)));
      }

      List<String> errors = validate();
      if (errors.size() == 0) {
        surveyService.generateBootstrapFile(
            idList,
            dbInstructionArea.getText(),
            notificationEmailBox.getText(),
            new AsyncCallback<Void>() {

              @Override
              public void onFailure(Throwable caught) {
                MessageDialog errDia =
                    new MessageDialog(
                        TEXT_CONSTANTS.error(),
                        TEXT_CONSTANTS.errorTracePrefix() + " " + caught.getLocalizedMessage());
                errDia.showCentered();
              }

              @Override
              public void onSuccess(Void result) {
                MessageDialog dia =
                    new MessageDialog(
                        TEXT_CONSTANTS.requestSubmitted(), TEXT_CONSTANTS.emailWillBeSent());
                dia.showCentered();
                resetUI();
              }
            });
      } else {
        StringBuilder builder = new StringBuilder(TEXT_CONSTANTS.pleaseCorrect() + "<br><ul>");
        for (String e : errors) {
          builder.append("<li>").append(e).append("</li>");
        }
        builder.append("</ul>");
        MessageDialog dia = new MessageDialog(TEXT_CONSTANTS.inputError(), builder.toString());
        dia.showCentered();
      }
    }
  }
 private void removeSelectedConfig() {
   configurations.remove(getSelectedConfig());
   configList.removeItem(getSelectedConfigIndex());
 }