예제 #1
0
  /**
   * Load all the returned <code>Studies</code>.
   *
   * @param studies <code>List</code> of <code>Studies</code> to load.
   */
  public static void loadAllStudies(List<StudyDef> studies) {

    if (studies == null) studies = Context.getStudies();

    for (StudyDef def : studies) {
      loadStudy(def);
    }
  }
예제 #2
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);
    }
  }
예제 #3
0
 /**
  * Fired when an option is selected on the <tt>FormVersionOpenDialogListener.</tt>
  *
  * @param option the selected option.
  * @param tree <tt>Tree View</tt> we checking items from.
  * @param item <tt>Tree Item</tt> we checking.
  * @param eventBus <tt>ItemSelectionListener</tt> for the data check operation.
  * @param popup <tt>Popup</tt> for the <tt>Tree View.</tt>
  */
 public static void onOptionSelected(
     int option, Tree tree, TreeItem item, EventBus eventBus, PopupPanel popup) {
   if (option == 0) { // Create new form verson
     if (item.getUserObject() instanceof FormDefVersion) {
       FormDefVersion copyVersion = (FormDefVersion) item.getUserObject();
       String xForm = copyVersion.getXform();
       addNewItem(xForm, tree, Context.getStudies(), popup);
     }
   } else if (option == 1) { // Open the dialog as read only
     final Object userObject = tree.getSelectedItem().getUserObject();
     // ((StudyView)eventBus).designItem(true, tree.getSelectedItem().getUserObject());
     if (userObject instanceof FormDefVersion)
       eventBus.fireEvent(new DesignFormEvent((FormDefVersion) userObject));
   } else if (option == 2) { // Cancel option
     return;
   } else {
     // ((StudyView)eventBus).designItem(false, tree.getSelectedItem().getUserObject());
     final Object userObject = tree.getSelectedItem().getUserObject();
     if (userObject instanceof FormDefVersion)
       eventBus.fireEvent(new DesignFormEvent((FormDefVersion) userObject, true));
   }
 }