use of org.activityinfo.shared.dto.TargetValueDTO in project activityinfo by bedatadriven.
the class TargetIndicatorView method createGridAndAddToContainer.
@Override
protected Grid<ModelData> createGridAndAddToContainer(Store store) {
final TreeStore treeStore = (TreeStore) store;
tree = new EditorTreeGrid<ModelData>(treeStore, createColumnModel());
tree.setAutoExpandColumn("name");
tree.setSelectionModel(new ImprovedCellTreeGridSelectionModel<ModelData>());
tree.setClicksToEdit(EditorGrid.ClicksToEdit.ONE);
tree.setLoadMask(true);
tree.setStateId("TargetValueGrid" + db.getId());
tree.setIconProvider(new ModelIconProvider<ModelData>() {
@Override
public AbstractImagePrototype getIcon(ModelData model) {
if (model instanceof ActivityDTO) {
return IconImageBundle.ICONS.activity();
} else if (model instanceof TargetValueDTO) {
return IconImageBundle.ICONS.indicator();
} else if (model instanceof Link) {
return IconImageBundle.ICONS.folder();
} else {
return null;
}
}
});
addBeforeEditListener();
addAfterEditListener();
add(tree, new BorderLayoutData(Style.LayoutRegion.CENTER));
return tree;
}
use of org.activityinfo.shared.dto.TargetValueDTO in project activityinfo by bedatadriven.
the class TargetIndicatorPresenter method createTargetValueModel.
private TargetValueDTO createTargetValueModel(IndicatorDTO indicator) {
TargetValueDTO targetValueDTO = new TargetValueDTO();
targetValueDTO.setTargetId(targetDTO.getId());
targetValueDTO.setIndicatorId(indicator.getId());
targetValueDTO.setName(indicator.getName());
return targetValueDTO;
}
use of org.activityinfo.shared.dto.TargetValueDTO in project activityinfo by bedatadriven.
the class TargetIndicatorPresenter method addIndicatorLinks.
private void addIndicatorLinks(ActivityDTO activity, ModelData parent) {
Map<String, Link> indicatorCategories = new HashMap<String, Link>();
for (IndicatorDTO indicator : activity.getIndicators()) {
if (indicator.getCategory() != null) {
Link indCategoryLink = indicatorCategories.get(indicator.getCategory());
if (indCategoryLink == null) {
indCategoryLink = createIndicatorCategoryLink(indicator, indicatorCategories);
indicatorCategories.put(indicator.getCategory(), indCategoryLink);
treeStore.add(parent, indCategoryLink, false);
}
TargetValueDTO targetValueDTO = getTargetValueByIndicatorId(indicator.getId());
if (null != targetValueDTO) {
treeStore.add(indCategoryLink, targetValueDTO, false);
} else {
treeStore.add(indCategoryLink, createTargetValueModel(indicator), false);
}
} else {
TargetValueDTO targetValueDTO = getTargetValueByIndicatorId(indicator.getId());
if (null != targetValueDTO) {
treeStore.add(parent, targetValueDTO, false);
} else {
treeStore.add(parent, createTargetValueModel(indicator), false);
}
}
}
}
Aggregations