/** * Sets the Properties of the selected Item on the <tt>Tree View.</tt> * * @param item <tt>Tree Item</tt> to set properties for. * @param tree <tt>Tree View</tt> to set properties on. * @param popup <tt>Popup</tt> for the <tt>Tree View.</tt> */ public static void changeEditableProperties(Object item, Tree tree, PopupPanel popup) { TreeItem treeItem = tree.getSelectedItem(); if (item == null) return; // How can this happen? if (item instanceof StudyDef) { StudyDef studyDef = (StudyDef) item; treeItem.setWidget(new TreeItemWidget(images.note(), studyDef.getName(), popup)); treeItem.setTitle(studyDef.getDescription()); studyDef.setDirty(true); } else if (item instanceof FormDef) { FormDef formDef = (FormDef) item; treeItem.setWidget(new TreeItemWidget(images.drafts(), formDef.getName(), popup)); treeItem.setTitle(formDef.getDescription()); formDef.setDirty(true); } else if (item instanceof FormDefVersion) { FormDefVersion formDefVersion = (FormDefVersion) item; treeItem.setWidget(new TreeItemWidget(images.markRead(), formDefVersion.getName(), popup)); treeItem.setTitle(formDefVersion.getDescription()); formDefVersion.setDirty(true); } }
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; } }