private void reset(final UploadComponentOptions options) {
      resetComponents(options);
      clear();

      final Set<String> types = components.keySet();
      currentType = types.iterator().next();

      parentCanvas = new Canvas();
      layout = new VLayout();
      final SelectItem typeItem = new SelectItem("uploadType", "Upload Type");
      typeItem.setValueMap(types.toArray(new String[types.size()]));
      typeItem.setValue(currentType);
      typeItem.setWidth(250);
      typeItem.addChangedHandler(
          new ChangedHandler() {
            public void onChanged(final ChangedEvent event) {
              currentType = typeItem.getValue().toString();
              update();
            }
          });
      final Form form =
          new Form(
              DomConstants.buildConstant(DomConstants.UPLOAD_COMPONENT_TYPE, uploadComponentNumber),
              typeItem);
      form.setPadding(0);
      form.setMargin(0);
      form.setCellSpacing(0);
      form.setCellPadding(0);

      form.setAlign(Alignment.RIGHT);
      form.setWidth(350);
      form.setHeight(20);
      final HLayout header = new HLayout();
      header.setAlign(Alignment.RIGHT);
      header.addMember(form);
      header.setHeight(20);

      layout.setAlign(Alignment.RIGHT);
      layout.addMember(header);
      layout.addMember(parentCanvas);
      layout.setGroupTitle("File Chooser");
      layout.setIsGroup(true);
      layout.setHeight("185px");
      layout.setPadding(2);
      layout.setLayoutAlign(Alignment.CENTER);
      layout.setAlign(Alignment.CENTER);

      for (final UploadComponent uploadComponent : components.values()) {
        final Canvas childCanvas = uploadComponent.get();
        childCanvas.hide();
        parentCanvas.addChild(childCanvas);
      }
      update();
      wrapperLayout.addMember(layout);
    }
    private void init(final ListGridRecord sampleRecord, final boolean add) {
      final Form form = new Form(nameItem, mudpitItem, categoryItem);
      form.setWrapItemTitles(false);
      nameItem.setValue(sampleRecord.getAttributeAsString("Name"));
      nameItem.addChangedHandler(
          new ChangedHandler() {
            public void onChanged(final ChangedEvent event) {
              checkOk();
            }
          });
      mudpitItem.setValue(sampleRecord.getAttributeAsBoolean("Mudpit"));
      categoryItem.setValue(sampleRecord.getAttributeAsString("Category"));

      final Label label = new Label(CONSTANTS.scaffoldWizardSampleSearchLabel());
      label.setWidth100();
      label.setHeight(12);

      final TreeOptions treeOptions = new TreeOptions();
      treeOptions.setInitialItems(
          locationFactory.getTropixObjectSourceRootItems(TropixObjectTreeItemExpanders.get(types)));
      treeOptions.setShowPredicate(getShowItemPredicate());
      treeOptions.setSelectionPredicate(LocationPredicates.getTropixObjectNotFolderPredicate());
      treeOptions.setSelectionType(SelectionType.MULTIPlE);
      @SuppressWarnings("unchecked")
      final Collection<TreeItem> selectedItems =
          (Collection<TreeItem>) sampleRecord.getAttributeAsObject("Selection");
      treeOptions.setExpandIds(Locations.getAncestorIds(selectedItems));
      treeOptions.setSelectedItems(selectedItems);
      final TreeComponent tree = treeComponentFactory.get(treeOptions);
      tree.addMultiSelectionListener(this);
      final TreeGrid treeGrid = tree.get();
      treeGrid.setTooltip("Hold the control key to select multiple items.");
      final VLayout layout = new VLayout();
      layout.addMember(form);
      layout.addMember(label);
      layout.addMember(treeGrid);
      layout.setSize("500px", "500px");
      okButton =
          SmartUtils.getButton(
              add ? "Add" : "Update",
              null,
              new Command() {
                public void execute() {
                  sampleRecord.setAttribute("Name", (String) nameItem.getValue());
                  sampleRecord.setAttribute("Category", (String) categoryItem.getValue());
                  sampleRecord.setAttribute("Mudpit", (Boolean) mudpitItem.getValue());
                  sampleRecord.setAttribute("Selection", selection);
                  if (add) {
                    dataSource.addData(sampleRecord);
                    records.add(sampleRecord);
                  }
                  listGrid.markForRedraw();
                  get().markForDestroy();
                  checkValid();
                }
              });
      final Button cancelButton = SmartUtils.getCancelButton(this);
      final Layout opsLayout = new CanvasWithOpsLayout<VLayout>(layout, okButton, cancelButton);
      final Window window =
          PopOutWindowBuilder.titled((add ? "Add" : "Update") + " Sample")
              .withContents(opsLayout)
              .autoSized()
              .get();
      setWidget(window);
      checkOk();
      get().draw();
    }