Search in sources :

Example 6 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class ColumnModelBuilder method addTreeNameColumn.

public ColumnModelBuilder addTreeNameColumn() {
    ColumnConfig name = new ColumnConfig("name", I18N.CONSTANTS.location(), 200);
    name.setRenderer(new TreeGridCellRenderer<ModelData>() {

        @Override
        public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
            return super.render(model, propertyName(model), config, rowIndex, colIndex, store, grid);
        }

        private String propertyName(ModelData model) {
            if (model instanceof SiteDTO) {
                return "locationName";
            } else {
                return "name";
            }
        }
    });
    columns.add(name);
    return this;
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) SiteDTO(org.activityinfo.shared.dto.SiteDTO)

Example 7 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class ColumnModelBuilder method addActivityColumn.

public ColumnModelBuilder addActivityColumn(final UserDatabaseDTO database) {
    ColumnConfig config = new ColumnConfig("activityId", I18N.CONSTANTS.activity(), 100);
    config.setRenderer(new GridCellRenderer<SiteDTO>() {

        @Override
        public Object render(SiteDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<SiteDTO> store, Grid<SiteDTO> grid) {
            ActivityDTO activity = database.getActivityById(model.getActivityId());
            return activity == null ? "" : activity.getName();
        }
    });
    columns.add(config);
    return this;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 8 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class ColumnModelBuilder method addDatabaseColumn.

public ColumnModelBuilder addDatabaseColumn(final SchemaDTO schema) {
    ColumnConfig config = new ColumnConfig("activityId", I18N.CONSTANTS.activity(), 100);
    config.setRenderer(new GridCellRenderer<SiteDTO>() {

        @Override
        public Object render(SiteDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<SiteDTO> store, Grid<SiteDTO> grid) {
            ActivityDTO activity = schema.getActivityById(model.getActivityId());
            return activity == null ? "" : activity.getDatabase().getName();
        }
    });
    columns.add(config);
    return this;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 9 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class SiteDialog method updateSite.

private void updateSite() {
    final SiteDTO updated = new SiteDTO(site);
    updateModel(updated);
    dispatcher.execute(new UpdateSite(site, updated), new AsyncCallback<VoidResult>() {

        @Override
        public void onFailure(Throwable caught) {
            showError(caught);
        }

        @Override
        public void onSuccess(VoidResult result) {
            hide();
            callback.onSaved(updated);
        }
    });
}
Also used : VoidResult(org.activityinfo.shared.command.result.VoidResult) SiteDTO(org.activityinfo.shared.dto.SiteDTO) UpdateSite(org.activityinfo.shared.command.UpdateSite)

Example 10 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class SiteDialogLauncher method addNewSiteWithBoundLocation.

private void addNewSiteWithBoundLocation(ActivityDTO activity, SiteDialogCallback callback) {
    SiteDTO newSite = new SiteDTO();
    newSite.setActivityId(activity.getId());
    LocationDTO location = new LocationDTO();
    location.setId(new KeyGenerator().generateInt());
    location.setLocationTypeId(activity.getLocationTypeId());
    SiteDialog dialog = new SiteDialog(dispatcher, activity);
    dialog.showNew(newSite, location, true, callback);
}
Also used : SiteDTO(org.activityinfo.shared.dto.SiteDTO) KeyGenerator(org.activityinfo.client.local.command.handler.KeyGenerator) LocationDTO(org.activityinfo.shared.dto.LocationDTO)

Aggregations

SiteDTO (org.activityinfo.shared.dto.SiteDTO)71 Test (org.junit.Test)32 GetSites (org.activityinfo.shared.command.GetSites)16 SiteResult (org.activityinfo.shared.command.result.SiteResult)11 CreateSite (org.activityinfo.shared.command.CreateSite)9 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)8 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)7 ArrayList (java.util.ArrayList)7 CreateResult (org.activityinfo.shared.command.result.CreateResult)7 Date (java.util.Date)6 OnDataSet (org.activityinfo.server.database.OnDataSet)6 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)6 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)6 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)5 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)5 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)5 UpdateSite (org.activityinfo.shared.command.UpdateSite)5 LocationDTO (org.activityinfo.shared.dto.LocationDTO)5 PointValue (org.activityinfo.shared.report.model.PointValue)5 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)4