use of com.extjs.gxt.ui.client.data.ModelData in project activityinfo by bedatadriven.
the class BaseMapDialog method loadBaseMaps.
private void loadBaseMaps() {
listView.getStore().removeAll();
listView.getStore().add(googleThumb(GoogleBaseMap.ROADMAP, I18N.CONSTANTS.googleRoadmap()));
listView.getStore().add(googleThumb(GoogleBaseMap.SATELLITE, I18N.CONSTANTS.googleSatelliteMap()));
listView.getStore().add(googleThumb(GoogleBaseMap.HYBRID, I18N.CONSTANTS.googleHybrid()));
listView.getStore().add(googleThumb(GoogleBaseMap.TERRAIN, I18N.CONSTANTS.googleTerrainMap()));
updateSelection();
service.execute(new GetBaseMaps(), new MaskingAsyncMonitor(listView, I18N.CONSTANTS.loading()), new AsyncCallback<BaseMapResult>() {
@Override
public void onFailure(Throwable caught) {
failLoadingBaseMaps();
}
@Override
public void onSuccess(BaseMapResult result) {
List<ModelData> thumbnails = new ArrayList<ModelData>();
for (BaseMap baseMap : result.getBaseMaps()) {
thumbnails.add(tileThumb(baseMap));
}
listView.getStore().add(thumbnails);
updateSelection();
}
});
}
use of com.extjs.gxt.ui.client.data.ModelData in project activityinfo by bedatadriven.
the class DbTargetGrid method createColumnModel.
protected ColumnModel createColumnModel() {
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
ColumnConfig projectColumn = new ColumnConfig("projectId", messages.project(), 150);
projectColumn.setRenderer(new GridCellRenderer() {
@Override
public SafeHtml render(ModelData modelData, String s, ColumnData columnData, int i, int i1, ListStore listStore, Grid grid) {
SafeHtmlBuilder sb = new SafeHtmlBuilder();
Integer id = modelData.get(s);
if (id != null) {
ProjectDTO project = db.getProjectById(id);
if (project != null) {
sb.appendEscaped(project.getName());
}
}
return sb.toSafeHtml();
}
});
ColumnConfig partnerColumn = new ColumnConfig("partnerId", messages.partner(), 150);
partnerColumn.setRenderer(new GridCellRenderer() {
@Override
public SafeHtml render(ModelData modelData, String s, ColumnData columnData, int i, int i1, ListStore listStore, Grid grid) {
SafeHtmlBuilder sb = new SafeHtmlBuilder();
Integer id = modelData.get(s);
if (id != null) {
PartnerDTO partner = db.getPartnerById(id);
if (partner != null) {
sb.appendEscaped(partner.getName());
}
}
return sb.toSafeHtml();
}
});
columns.add(new ColumnConfig("name", messages.name(), 150));
columns.add(projectColumn);
columns.add(partnerColumn);
columns.add(new TimePeriodColumn("timePeriod", messages.timePeriod(), 300));
return new ColumnModel(columns);
}
use of com.extjs.gxt.ui.client.data.ModelData 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.setStateful(true);
tree.setIconProvider(new ModelIconProvider<ModelData>() {
@Override
public AbstractImagePrototype getIcon(ModelData model) {
if (model instanceof IsActivityDTO) {
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 com.extjs.gxt.ui.client.data.ModelData in project activityinfo by bedatadriven.
the class DbEditor method promptDeleteSelection.
private void promptDeleteSelection() {
ModelData selected = tree.getSelectionModel().getSelectedItem();
if (!(selected instanceof EntityDTO)) {
return;
}
EntityDTO selectedEntity = (EntityDTO) selected;
if (selectedEntity instanceof FolderDTO && treeStore.getChildCount(selectedEntity) != 0) {
MessageBox.alert(I18N.CONSTANTS.delete(), I18N.CONSTANTS.folderNotEmpty(), null);
return;
}
SafeHtml message = confirmationMessage(selectedEntity);
if (message == null) {
deleteEntity(selectedEntity);
} else {
MessageBox.confirm(SafeHtmlUtils.fromString(I18N.CONSTANTS.confirmDeletion()), message, event -> {
if (event.getButtonClicked().getItemId().equals(Dialog.YES)) {
deleteEntity(selectedEntity);
}
});
}
}
use of com.extjs.gxt.ui.client.data.ModelData in project activityinfo by bedatadriven.
the class DbEditor method onNew.
private void onNew(String entityName) {
final EntityDTO newEntity;
ModelData parent;
ModelData selected = tree.getSelectionModel().getSelectedItem();
if (ActivityDTO.ENTITY_NAME.equals(entityName)) {
newEntity = new ActivityDTO();
newEntity.set(DATABASE_ID_PROPERTY, db.getId());
newEntity.set(CLASSIC_VIEW_PROPERTY, true);
newEntity.set(PUBLISHED_PROPERTY, Published.NOT_PUBLISHED);
parent = null;
} else if ("Form".equals(entityName)) {
newEntity = new ActivityDTO();
newEntity.set(DATABASE_ID_PROPERTY, db.getId());
newEntity.set(CLASSIC_VIEW_PROPERTY, false);
newEntity.set(REPORTING_FREQUENCY_PROPERTY, ActivityFormDTO.REPORT_ONCE);
newEntity.set(LOCATION_TYPE_ID_PROPERTY, db.getCountry().getNullLocationType().getId());
newEntity.set(PUBLISHED_PROPERTY, Published.NOT_PUBLISHED);
parent = null;
} else if (FolderDTO.ENTITY_NAME.equals(entityName)) {
newEntity = new FolderDTO(db.getId(), null);
parent = null;
} else if (LocationTypeDTO.ENTITY_NAME.equals(entityName)) {
newEntity = new LocationTypeDTO();
newEntity.set(DATABASE_ID_PROPERTY, db.getId());
parent = null;
} else if (AttributeGroupDTO.ENTITY_NAME.equals(entityName)) {
IsActivityDTO activity = findActivityFolder(selected);
AttributeGroupDTO newAttributeGroup = new AttributeGroupDTO();
newAttributeGroup.setMultipleAllowed(false);
newEntity = newAttributeGroup;
newEntity.set("activityId", activity.getId());
parent = treeStore.getChild((ModelData) activity, 0);
} else if (AttributeDTO.ENTITY_NAME.equals(entityName)) {
AttributeGroupDTO group = findAttributeGroupNode(selected);
newEntity = new AttributeDTO();
newEntity.set("attributeGroupId", group.getId());
parent = group;
} else if (IndicatorDTO.ENTITY_NAME.equals(entityName)) {
IsActivityDTO activity = findActivityFolder(selected);
IndicatorDTO newIndicator = new IndicatorDTO();
newIndicator.setAggregation(IndicatorDTO.AGGREGATE_SUM);
newIndicator.setType(FieldTypeClass.QUANTITY);
if (activity instanceof ActivityFormDTO) {
newIndicator.set(SORT_ORDER_PROPERTY, ((ActivityFormDTO) activity).getIndicators().size() + 1);
}
newEntity = newIndicator;
newEntity.set("activityId", activity.getId());
parent = treeStore.getChild((ModelData) activity, 1);
} else {
Log.error("Unsupported entity type.");
return;
}
createEntity(parent, newEntity);
}
Aggregations