use of org.activityinfo.shared.dto.IndicatorDTO in project activityinfo by bedatadriven.
the class DesignPresenter method onNew.
public void onNew(String entityName) {
final EntityDTO newEntity;
ModelData parent;
ModelData selected = view.getSelection();
if ("Activity".equals(entityName)) {
newEntity = new ActivityDTO(db);
newEntity.set("databaseId", db.getId());
parent = null;
} else if ("AttributeGroup".equals(entityName)) {
ActivityDTO activity = findActivityFolder(selected);
newEntity = new AttributeGroupDTO();
newEntity.set("activityId", activity.getId());
parent = treeStore.getChild(activity, 0);
} else if ("Attribute".equals(entityName)) {
AttributeGroupDTO group = findAttributeGroupNode(selected);
newEntity = new AttributeDTO();
newEntity.set("attributeGroupId", group.getId());
parent = group;
} else if ("Indicator".equals(entityName)) {
ActivityDTO activity = findActivityFolder(selected);
IndicatorDTO newIndicator = new IndicatorDTO();
newIndicator.setAggregation(IndicatorDTO.AGGREGATE_SUM);
newEntity = newIndicator;
newEntity.set("activityId", activity.getId());
parent = treeStore.getChild(activity, 1);
} else {
// TODO log error
return;
}
createEntity(parent, newEntity);
}
use of org.activityinfo.shared.dto.IndicatorDTO 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);
}
}
}
}
use of org.activityinfo.shared.dto.IndicatorDTO in project activityinfo by bedatadriven.
the class DesignView method createGridAndAddToContainer.
@Override
protected Grid<ModelData> createGridAndAddToContainer(Store store) {
final TreeStore treeStore = (TreeStore) store;
tree = new EditorTreeGrid<ModelData>(treeStore, createColumnModel());
tree.setSelectionModel(new ImprovedCellTreeGridSelectionModel<ModelData>());
tree.setClicksToEdit(EditorGrid.ClicksToEdit.TWO);
tree.setAutoExpandColumn("name");
tree.setHideHeaders(true);
tree.setLoadMask(true);
// tree.setContextMenu(createContextMenu());
tree.setIconProvider(new ModelIconProvider<ModelData>() {
@Override
public AbstractImagePrototype getIcon(ModelData model) {
if (model instanceof ActivityDTO) {
return IconImageBundle.ICONS.activity();
} else if (model instanceof Folder) {
return GXT.IMAGES.tree_folder_closed();
} else if (model instanceof AttributeGroupDTO) {
return IconImageBundle.ICONS.attributeGroup();
} else if (model instanceof AttributeDTO) {
return IconImageBundle.ICONS.attribute();
} else if (model instanceof IndicatorDTO) {
return IconImageBundle.ICONS.indicator();
} else {
return null;
}
}
});
tree.addListener(Events.CellClick, new Listener<GridEvent>() {
@Override
public void handleEvent(GridEvent ge) {
showForm(tree.getStore().getAt(ge.getRowIndex()));
}
});
add(tree, new BorderLayoutData(Style.LayoutRegion.CENTER));
TreeGridDragSource source = new TreeGridDragSource(tree);
source.addDNDListener(new DNDListener() {
@Override
public void dragStart(DNDEvent e) {
ModelData sel = ((CellTreeGridSelectionModel) tree.getSelectionModel()).getSelectCell().model;
if (!db.isDesignAllowed() || sel == null || sel instanceof Folder) {
e.setCancelled(true);
e.getStatus().setStatus(false);
return;
}
super.dragStart(e);
}
});
TreeGridDropTarget target = new TreeGridDropTarget(tree);
target.setAllowSelfAsSource(true);
target.setFeedback(DND.Feedback.BOTH);
target.setAutoExpand(false);
target.addDNDListener(new DragDropListener(treeStore));
return tree;
}
use of org.activityinfo.shared.dto.IndicatorDTO in project activityinfo by bedatadriven.
the class DesignView method showNewForm.
@Override
public FormDialogTether showNewForm(EntityDTO entity, FormDialogCallback callback) {
AbstractDesignForm form = createForm(entity);
form.getBinding().bind(entity);
for (FieldBinding field : form.getBinding().getBindings()) {
field.getField().clearInvalid();
}
FormDialogImpl dlg = new FormDialogImpl(form);
dlg.setWidth(form.getPreferredDialogWidth());
dlg.setHeight(form.getPreferredDialogHeight());
dlg.setScrollMode(Style.Scroll.AUTOY);
if (entity instanceof ActivityDTO) {
dlg.setHeading(I18N.CONSTANTS.newActivity());
} else if (entity instanceof AttributeGroupDTO) {
dlg.setHeading(I18N.CONSTANTS.newAttributeGroup());
} else if (entity instanceof AttributeDTO) {
dlg.setHeading(I18N.CONSTANTS.newAttribute());
} else if (entity instanceof IndicatorDTO) {
dlg.setHeading(I18N.CONSTANTS.newIndicator());
}
dlg.show(callback);
return dlg;
}
use of org.activityinfo.shared.dto.IndicatorDTO in project activityinfo by bedatadriven.
the class IndicatorLinkPage method onIndicatorSelectionChanged.
protected void onIndicatorSelectionChanged() {
IndicatorDTO source = sourceIndicatorGrid.getSelectedItem();
IndicatorDTO dest = destIndicatorGrid.getSelectedItem();
if (source == null || dest == null) {
linkButton.disable();
} else {
sourceIndicatorGrid.getRowY(source);
destIndicatorGrid.getRowY(dest);
sourceIndicatorGrid.el().getRight(false);
linkButton.toggle(linkGraph.linked(source, dest));
linkButton.enable();
// linkButton.showAt(x - LinkTip.WIDTH/2, y - LinkTip.HEIGHT/2);
}
}
Aggregations