Exemplo n.º 1
0
  /**
   * Constructs a <code>StudyDef Tree item root</code> to bind other items to.
   *
   * @param xDef <code>StudyDef</code> for whom to create root.
   * @return Constructed <code>Tree Item.</code>
   */
  private static TreeItem constructTreeItem(StudyDef xDef) {
    TreeItem root = new CompositeTreeItem(new TreeItemWidget(images.note(), xDef.getName(), popup));
    if (root.getUserObject() != null) {
      if (!root.getUserObject().equals(xDef)) {
        root.setUserObject(xDef);
        tree.addItem(root);
      }
    } else {
      root.setUserObject(xDef);
      tree.addItem(root);
    }

    return root;
  }
 /**
  * Constructs a tree item for generic ("Advanced") component blocks for component types that
  * appear in form.
  *
  * @param form only component types that appear in this Form will be included
  * @return tree item for this form
  */
 public TreeItem getGenericComponentsTree(MockForm form) {
   Map<String, String> typesAndIcons = Maps.newHashMap();
   form.collectTypesAndIcons(typesAndIcons);
   TreeItem advanced = new TreeItem(new HTML("<span>" + MESSAGES.anyComponentLabel() + "</span>"));
   List<String> typeList = new ArrayList<String>(typesAndIcons.keySet());
   Collections.sort(typeList);
   for (final String typeName : typeList) {
     TreeItem itemNode =
         new TreeItem(
             new HTML(
                 "<span>"
                     + typesAndIcons.get(typeName)
                     + MESSAGES.textAnyComponentLabel()
                     + TranslationDesignerPallete.getCorrespondingString(typeName)
                     + "</span>"));
     SourceStructureExplorerItem sourceItem =
         new BlockSelectorItem() {
           @Override
           public void onSelected() {
             fireGenericDrawerSelected(typeName);
           }
         };
     itemNode.setUserObject(sourceItem);
     advanced.addItem(itemNode);
   }
   return advanced;
 }
Exemplo n.º 3
0
  public TreeItem buildTreeItem(final CategoryItem category) {
    final TreeItem it = new TreeItem();
    it.setHTML(
        AbstractImagePrototype.create(ImageResources.INSTANCE.categorySmall()).getHTML()
            + h(category.getName()));
    it.setUserObject(category);

    return it;
  }
Exemplo n.º 4
0
  /**
   * Adds a new Item according to selected item on the <tt>Tree View.</tt>
   *
   * <p>If a <Study</tt> is selected, a new <tt>Study</tt> will be added.
   *
   * <p>If a <tt>Form</tt> is selected, a new <tt>Form</tt> will be added.
   *
   * <p>If a <tt>Form Version</tt> is selected, a new <tt>Form Version</tt> will be added.
   */
  public static void addNewItem(String xForm, Tree tree, List<StudyDef> studies, PopupPanel popup) {

    TreeItem item = tree.getSelectedItem();
    if (item == null || item.getUserObject() instanceof StudyDef) {
      StudyDef studyDef = new StudyDef(0, "New Study" + (tree.getItemCount() + 1));
      studyDef.setCreator(Context.getAuthenticatedUser());
      studyDef.setDateCreated(new Date());
      studyDef.setDirty(true);

      TreeItem root =
          new CompositeTreeItem(new TreeItemWidget(images.note(), studyDef.getName(), popup));
      root.setUserObject(studyDef);
      tree.addItem(root);
      studies.add(studyDef);
      tree.setSelectedItem(root);

      // Automatically add a new form
      addNewChildItem(tree, studies, popup);

    } else if (item.getUserObject() instanceof FormDef) {
      TreeItem parent = item.getParentItem();
      FormDef formDef =
          new FormDef(
              0, "New Form" + (parent.getChildCount() + 1), (StudyDef) parent.getUserObject());
      formDef.setCreator(Context.getAuthenticatedUser());
      formDef.setDateCreated(new Date());
      formDef.setDirty(true);

      item = addImageItem(parent, formDef.getName(), images.drafts(), formDef, null, popup);
      ((StudyDef) parent.getUserObject()).addForm(formDef);
      tree.setSelectedItem(item);
      parent.setState(true);

      // Automatically add a new form version
      addNewChildItem(tree, studies, popup);
    } else if (item.getUserObject() instanceof FormDefVersion) {
      TreeItem parent = item.getParentItem();
      FormDefVersion formDefVersion =
          new FormDefVersion(
              0, "v" + (parent.getChildCount() + 1), (FormDef) parent.getUserObject());
      formDefVersion.setCreator(Context.getAuthenticatedUser());
      formDefVersion.setDateCreated(new Date());
      formDefVersion.getFormDef().turnOffOtherDefaults(formDefVersion);
      formDefVersion.setDirty(true);

      if (xForm != null) formDefVersion.setXform(xForm);

      item =
          addImageItem(
              parent, formDefVersion.getName(), images.markRead(), formDefVersion, null, popup);
      ((FormDef) parent.getUserObject()).addVersion(formDefVersion);
      tree.setSelectedItem(item);
      parent.setState(true);
    }
  }
  /** Initialize the menu */
  private void intiMenu() {

    removeAll();

    // Item 1 sub-tree
    TreeItem item1 = new TreeItem();

    item1.setText(SafeHtmlUtils.htmlEscape(CATEGORY_MENU));
    item1.setUserObject(CATEGORY_MENU);

    addItem(item1);
  }
Exemplo n.º 6
0
  /**
   * Loads a study and its contents in this view.
   *
   * @param studyDef the study definition object.
   */
  public static void loadStudy(StudyDef studyDef) {

    TreeItem studyRoot =
        new CompositeTreeItem(new TreeItemWidget(images.note(), studyDef.getName(), popup));
    studyRoot.setUserObject(studyDef);
    tree.addItem(studyRoot);

    if (studyDef.getForms() != null) {
      for (FormDef def : studyDef.getForms()) loadForm(def, studyRoot, false);
    }

    Utilities.selectFirstItemOnTreeView(tree);
  }
Exemplo n.º 7
0
  /**
   * A helper method to simplify adding tree items that have attached images. {@link
   * #addImageItem(TreeItem, String) code}
   *
   * @param root the tree item to which the new item will be added.
   * @param title the text associated with this item.
   */
  private static TreeItem addImageItem(
      TreeItem root,
      String title,
      ImageResource imageProto,
      Object userObj,
      String helpText,
      PopupPanel popup) {

    TreeItem item = new CompositeTreeItem(new TreeItemWidget(imageProto, title, popup));
    item.setUserObject(userObj);
    item.setTitle(helpText);
    root.addItem(item);
    return item;
  }
 private void loadItem(VariableSerializable[] vars) {
   for (int j = 0; j < vars.length; j++) {
     // Do not include variables with subset_variable="true" used to denote "selector"
     // variables in in-situ data sets like SOCAT
     // TODO and for now no variables with character string values
     // if ( Util.keep(vars[j].getDSID(), vars[j].getName()) && Util.keep(vars[j].getDSID(),
     // vars[j].getAttributes()) ) {
     TreeItem item = new TreeItem();
     item.setText(vars[j].getName());
     item.setUserObject(vars[j]);
     currentlySelected.addItem(item);
     // }
   }
 }
Exemplo n.º 9
0
        public void onSuccess(GWTFolder result) {
          // Only executes on initalization and the actualItem is root
          // element on initialization
          // We put the id on root
          actualItem.setUserObject(result);
          evaluesFolderIcon(actualItem);
          actualItem.setState(true);
          actualItem.setSelected(true);

          // Enables or disables move button ( evalues security to move to folder with permissions )
          evaluateSecurityToAction(actualItem);

          getChilds(result.getPath());
        }
Exemplo n.º 10
0
    private void addTreeItem(JSONObject jsonObject, int index) {

      Node node =
          new Node(
              jsonObject.get("id").isString().stringValue(),
              jsonObject.get("leaf").isBoolean().booleanValue(),
              jsonObject.get("text").isString().stringValue());
      if (node.getText() != null) {
        TreeItem item = new TreeItem();
        item.setText(node.getText());
        item.setUserObject(node);
        if (!node.isLeaf()) item.addItem(""); // Temporarily add an item so we can expand this node

        treeItem.addItem(item);
      }
    }
Exemplo n.º 11
0
  /**
   * Bind <tt>StudyDef</tt> contents.
   *
   * @param tree <tt>Tree View</tt> to bind <tt>StudyDef</tt> to.
   * @param popup <tt>Popup</tt> to bind to the <tt>Tree View.</tt>
   * @param editable <tt>Editable</tt> we are checking contents for.
   */
  private static void setStudyContent(final Tree tree, final PopupPanel popup, Editable editable) {
    StudyDef studyDef = (StudyDef) editable;
    studyDef.setCreator(Context.getAuthenticatedUser());
    studyDef.setDateCreated(new Date());
    studyDef.setDirty(true);

    TreeItem root =
        new CompositeTreeItem(new TreeItemWidget(images.note(), studyDef.getName(), popup));
    root.setUserObject(studyDef);
    tree.addItem(root);
    Context.getStudies().add(studyDef);
    tree.setSelectedItem(root);

    List<FormDef> forms = studyDef.getForms();
    if (forms != null) {
      for (FormDef formDef : forms) importForm(tree, root, formDef, popup);
    }
  }
Exemplo n.º 12
0
  /** Folder Tree */
  public FolderSelectTree() {
    tree = new Tree();
    rootItem.setStyleName("okm-TreeItem");
    rootItem.setUserObject(new GWTFolder());
    rootItem.setSelected(true);
    rootItem.setState(true);
    tree.setStyleName("okm-Tree");
    tree.addItem(rootItem);
    tree.addSelectionHandler(
        new SelectionHandler<TreeItem>() {

          @Override
          public void onSelection(SelectionEvent<TreeItem> event) {
            boolean refresh = true;
            TreeItem item = event.getSelectedItem();

            // Enables or disables move button ( evalues security to move to folder with permissions
            // )
            evaluateSecurityToAction(item);

            // Case that not refreshing tree and file browser ( right click )
            if (actualItem.equals(item)) {
              refresh = false;
            } else {
              // Disables actual item because on changing active node by
              // application this it's not changed automatically
              if (!actualItem.equals(item)) {
                actualItem.setSelected(false);
                actualItem = item;
              } else {
                refresh = false;
              }
            }

            if (refresh) {
              refresh(true);
            }
          }
        });
    actualItem = tree.getItem(0);
    initWidget(tree);
  }
Exemplo n.º 13
0
  public void setFullyQualifiedClassNames(final List<String> fullyQualifiedClassNames) {
    if (tree.getItem(0) != null) {
      tree.clear();
    }

    if (fullyQualifiedClassNames != null) {
      for (String type : fullyQualifiedClassNames) {
        final TreeItem it = new TreeItem();
        it.setHTML(
            AbstractImagePrototype.create(DRLTextEditorResources.INSTANCE.images().classImage())
                    .getHTML()
                + "<small>"
                + type
                + "</small>");
        it.setUserObject(new ClassUserObject(type + "( )", type));
        tree.addItem(it);
        it.addItem(Util.toSafeHtml(LAZY_LOAD));
      }
    }
  }
Exemplo n.º 14
0
  private void setupPackageNode(final TreeItem packageRootNode) {
    packageRootNode.setState(true);
    packageRootNode.setUserObject(new String("rootNode"));

    RepositoryServiceFactory.getService()
        .listPackages(
            new GenericCallback<PackageConfigData[]>() {
              public void onSuccess(PackageConfigData[] packageConfigDatas) {
                PackageHierarchy packageHierarchy = new PackageHierarchy();

                for (PackageConfigData packageConfigData : packageConfigDatas) {
                  packageHierarchy.addPackage(packageConfigData);
                }

                for (PackageHierarchy.Folder folder : packageHierarchy.getRoot().getChildren()) {
                  buildPkgTree(packageRootNode, folder);
                }
              }
            });
  }
Exemplo n.º 15
0
        public void onSuccess(List<GWTFolder> result) {
          boolean directAdd = true;

          // If has no childs directly add values is permited
          if (actualItem.getChildCount() > 0) {
            directAdd = false;
            // to prevent remote folder remove it disables all tree branch
            // items and after sequentially activate
            hideAllBranch(actualItem);
          }

          // On refreshing not refreshed the actual item values but must
          // ensure that has childs value is consistent
          if (result.isEmpty()) {
            ((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
          } else {
            ((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
          }

          // Ads folders childs if exists
          for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
            GWTFolder folder = it.next();
            TreeItem folderItem = new TreeItem(folder.getName());
            folderItem.setUserObject(folder);
            folderItem.setStyleName("okm-TreeItem");

            // If has no childs directly add values is permited, else
            // evalues each node to refresh, remove or add
            if (directAdd) {
              evaluesFolderIcon(folderItem);
              actualItem.addItem(folderItem);
            } else {
              // sequentially activate items and refreshes values
              addFolder(actualItem, folderItem);
            }
          }

          actualItem.setState(true);
          evaluesFolderIcon(actualItem);
        }
 /**
  * Constructs a tree item for built-in blocks.
  *
  * @return tree item
  */
 public TreeItem getBuiltInBlocksTree() {
   initBundledImages();
   TreeItem builtinNode =
       new TreeItem(new HTML("<span>" + MESSAGES.builtinBlocksLabel() + "</span>"));
   for (final String drawerName : BUILTIN_DRAWER_NAMES) {
     Image drawerImage = new Image(bundledImages.get(drawerName));
     TreeItem itemNode =
         new TreeItem(
             new HTML("<span>" + drawerImage + getBuiltinDrawerNames(drawerName) + "</span>"));
     SourceStructureExplorerItem sourceItem =
         new BlockSelectorItem() {
           @Override
           public void onSelected() {
             fireBuiltinDrawerSelected(drawerName);
           }
         };
     itemNode.setUserObject(sourceItem);
     builtinNode.addItem(itemNode);
   }
   builtinNode.setState(true);
   return builtinNode;
 }
Exemplo n.º 17
0
  private void initTree() {
    String section_key = "section";
    String subsection_key = "subsection";
    TreeItem root = new TreeItem("Help");
    PlaceRequest rootPlace = new PlaceRequest(NameTokens.helpPage);

    tree.addItem(
            new Hyperlink(
                "Introduction",
                placeManager.buildHistoryToken(rootPlace.with(section_key, "introduction"))))
        .setUserObject("introduction");

    // Phenotypes
    TreeItem phenotypes_item =
        new TreeItem(
            new Hyperlink(
                "Phenotypes",
                placeManager.buildHistoryToken(rootPlace.with(section_key, "phenotypes"))));
    phenotypes_item.setUserObject("phenotypes");
    phenotypes_item
        .addItem(
            new Hyperlink(
                "Uploading Phenotypes",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "phenotypes").with(subsection_key, "upload"))))
        .setUserObject("phenotypes_upload");
    phenotypes_item
        .addItem(
            new Hyperlink(
                "Phenotype Format",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "phenotypes").with(subsection_key, "format"))))
        .setUserObject("phenotypes_format");
    tree.addItem(phenotypes_item);

    // Accessions
    TreeItem accession_item =
        new TreeItem(
            new Hyperlink(
                "Accessions",
                placeManager.buildHistoryToken(rootPlace.with(section_key, "accessions"))));
    accession_item.setUserObject("accessions");
    tree.addItem(accession_item);

    // Analysis
    TreeItem analysis_item =
        new TreeItem(
            new Hyperlink(
                "Analysis",
                placeManager.buildHistoryToken(rootPlace.with(section_key, "analysis"))));
    analysis_item.setUserObject("analysis");
    analysis_item
        .addItem(
            new Hyperlink(
                "Navigation",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "analysis").with(subsection_key, "navigation"))))
        .setUserObject("analysis_navigation");
    analysis_item
        .addItem(
            new Hyperlink(
                "Phenotypes",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "analysis").with(subsection_key, "phenotypes"))))
        .setUserObject("analysis_phenotypes");
    analysis_item
        .addItem(
            new Hyperlink(
                "Datasets",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "analysis").with(subsection_key, "datasets"))))
        .setUserObject("analysis_datasets");
    analysis_item
        .addItem(
            new Hyperlink(
                "Transformations",
                placeManager.buildHistoryToken(
                    rootPlace
                        .with(section_key, "analysis")
                        .with(subsection_key, "transformations"))))
        .setUserObject("analysis_transformations");
    analysis_item
        .addItem(
            new Hyperlink(
                "Results",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "analysis").with(subsection_key, "results"))))
        .setUserObject("analysis_results");
    tree.addItem(analysis_item);

    // Tutorial
    /*TreeItem tutorial_item = new TreeItem(new Hyperlink("Tutorial",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial"))));
    tutorial_item.setUserObject("tutorial");
    tutorial_item.addItem(new Hyperlink("1.) Uploading Phenotypes",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "uploading")))).setUserObject("tutorial_uploading");
    tutorial_item.addItem(new Hyperlink("2.) Creating subset",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "subset")))).setUserObject("tutorial_subset");
    tutorial_item.addItem(new Hyperlink("3.) Changing transformation",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "transformation")))).setUserObject("tutorial_transformation");
    tutorial_item.addItem(new Hyperlink("4.) Running GWAS",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "gwas")))).setUserObject("tutorial_gwas");
    tutorial_item.addItem(new Hyperlink("5.) Viewing Results",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "results")))).setUserObject("tutorial_results");
    tutorial_item.addItem(new Hyperlink("6.) Running Step-Wise GWAS",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "gwas_step")))).setUserObject("tutorial_gwas_step");
    tree.addItem(tutorial_item);*/
    Iterator<TreeItem> iterator = tree.treeItemIterator();
    while (iterator.hasNext()) {
      iterator.next().setState(true, false);
    }
  }
Exemplo n.º 18
0
 private TreeItem loadPackage(String name, PackageConfigData conf) {
   TreeItem pn = ExplorerNodeConfig.getPackageItemStructure(name, conf.uuid, itemWidgets);
   pn.setUserObject(conf);
   return pn;
 }
 public void onSuccess(Object result) {
   CategorySerializable[] cats = (CategorySerializable[]) result;
   if (cats != null && cats.length > 0) {
     if (currentlySelected == null) {
       for (int i = 0; i < cats.length; i++) {
         CategorySerializable cat = cats[i];
         String children = cat.getAttributes().get("children");
         boolean empty = false;
         if (children != null && children.equals("none")) empty = true;
         if (applyFilters(cat) && !empty) {
           TreeItem item = new TreeItem();
           item.addItem(
               new SafeHtmlBuilder().appendEscaped(DatasetWidget.LOADING).toSafeHtml());
           InnerItem inner = new InnerItem(cat);
           item.setWidget(inner);
           item.setUserObject(cat);
           addItem(item);
         }
       }
     } else {
       for (int i = 0; i < cats.length; i++) {
         CategorySerializable cat = cats[i];
         if (cat.isCategoryChildren()) {
           String name = cat.getName();
           TreeItem item;
           if (i == 0) {
             item = currentlySelected.getChild(0);
           } else {
             item = new TreeItem();
           }
           item.addItem(
               new SafeHtmlBuilder().appendEscaped(DatasetWidget.LOADING).toSafeHtml());
           InnerItem inner = new InnerItem(cat);
           item.setWidget(inner);
           item.setUserObject(cat);
           if (i > 0) {
             currentlySelected.addItem(item);
           }
         } else if (cat.isVariableChildren()) {
           // Must have variable children...
           TreeItem item = currentlySelected.getChild(0);
           if (cat.hasMultipleDatasets()) {
             DatasetSerializable[] dses = cat.getDatasetSerializableArray();
             DatasetSerializable ds = dses[0];
             VariableSerializable[] vars = ds.getVariablesSerializable();
             currentlySelected.removeItems();
             for (int j = 0; j < dses.length; j++) {
               ds = dses[j];
               vars = ds.getVariablesSerializable();
               loadItem(vars);
             }
           } else {
             DatasetSerializable ds = cat.getDatasetSerializable();
             VariableSerializable[] vars = ds.getVariablesSerializable();
             currentlySelected.removeItems();
             loadItem(vars);
           }
         }
       }
     }
   } else {
     // A category was selected, but it came back empty...
     if (currentlySelected != null) {
       TreeItem item = currentlySelected.getChild(0);
       item.setText("No data sets found.");
     }
   }
   if (saveSelection != null) {
     currentlySelected = saveSelection;
     saveSelection = null;
   }
 }
Exemplo n.º 20
0
 private TreeItem loadPackage(String name, PackageConfigData config) {
   TreeItem treeItem = ExplorerNodeConfig.getPackageItemStructure(name, config.uuid, itemWidgets);
   treeItem.setUserObject(config);
   return treeItem;
 }