Ejemplo n.º 1
0
 private Predicate<Location> getShowItemPredicate() {
   final Predicate<Location> typePredicate =
       LocationPredicates.getTropixObjectTreeItemTypePredicate(types, true);
   return new Predicate<Location>() {
     public boolean apply(final Location treeItem) {
       return typePredicate.apply(treeItem) && validIdentification(treeItem);
     }
   };
 }
Ejemplo n.º 2
0
 FileLocationComponentImpl(final UploadComponentOptions uploadOptions) {
   this.options = uploadOptions;
   final TreeOptions treeOptions = new TreeOptions();
   final String extension = uploadOptions.getExtension();
   treeOptions.setSelectionType(
       uploadOptions.isAllowMultiple() ? SelectionType.MULTIPlE : SelectionType.SINGLE);
   treeOptions.setInitialItems(locationFactory.getTropixObjectSourceRootItems(null));
   treeOptions.setShowPredicate(
       LocationPredicates.getTropixFileTreeItemPredicate(extension, true));
   treeOptions.setSelectionPredicate(
       LocationPredicates.getTropixFileTreeItemPredicate(extension, false));
   treeComponent = treeComponentFactory.get(treeOptions);
   treeComponent.addSelectionListener(
       new Listener<TreeItem>() {
         public void onEvent(final TreeItem location) {}
       });
   final TreeGrid treeGrid = treeComponent.get();
   treeGrid.setWidth100();
   treeGrid.setHeight100();
   super.setWidget(treeGrid);
 }
Ejemplo n.º 3
0
    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();
    }