/** * 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); }
/** * 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); } }