Search in sources :

Example 1 with TargetValueDTO

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;
}
Also used : AbstractImagePrototype(com.google.gwt.user.client.ui.AbstractImagePrototype) ModelData(com.extjs.gxt.ui.client.data.ModelData) TreeStore(com.extjs.gxt.ui.client.store.TreeStore) BorderLayoutData(com.extjs.gxt.ui.client.widget.layout.BorderLayoutData) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) TargetValueDTO(org.activityinfo.shared.dto.TargetValueDTO) Link(org.activityinfo.client.page.common.nav.Link)

Example 2 with TargetValueDTO

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;
}
Also used : TargetValueDTO(org.activityinfo.shared.dto.TargetValueDTO)

Example 3 with 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);
            }
        }
    }
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) HashMap(java.util.HashMap) TargetValueDTO(org.activityinfo.shared.dto.TargetValueDTO) Link(org.activityinfo.client.page.common.nav.Link)

Aggregations

TargetValueDTO (org.activityinfo.shared.dto.TargetValueDTO)3 Link (org.activityinfo.client.page.common.nav.Link)2 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1 BorderLayoutData (com.extjs.gxt.ui.client.widget.layout.BorderLayoutData)1 AbstractImagePrototype (com.google.gwt.user.client.ui.AbstractImagePrototype)1 HashMap (java.util.HashMap)1 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)1 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1