Search in sources :

Example 6 with AdminLevelDTO

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

the class SiteExporter method createHeaders.

private void createHeaders(ActivityDTO activity, HSSFSheet sheet) {
    // / The HEADER rows
    Row headerRow1 = sheet.createRow(0);
    Row headerRow2 = sheet.createRow(1);
    headerRow2.setHeightInPoints(HEADER_CELL_HEIGHT);
    // Create a title cell with the complete database + activity name
    Cell titleCell = headerRow1.createCell(0);
    titleCell.setCellValue(creationHelper.createRichTextString(activity.getDatabase().getName() + " - " + activity.getName()));
    titleCell.setCellStyle(titleStyle);
    int column = 0;
    createHeaderCell(headerRow2, column++, "Date1", CellStyle.ALIGN_RIGHT);
    createHeaderCell(headerRow2, column++, "Date2", CellStyle.ALIGN_RIGHT);
    createHeaderCell(headerRow2, column, "Partner");
    sheet.setColumnWidth(column, characters(PARTNER_COLUMN_WIDTH));
    column++;
    createHeaderCell(headerRow2, column, activity.getLocationType().getName());
    sheet.setColumnWidth(column, characters(LOCATION_COLUMN_WIDTH));
    column++;
    createHeaderCell(headerRow2, column++, "Axe");
    indicators = new ArrayList<Integer>(activity.getIndicators().size());
    if (activity.getReportingFrequency() == ActivityDTO.REPORT_ONCE) {
        for (IndicatorGroup group : activity.groupIndicators()) {
            if (group.getName() != null) {
                // create a merged cell on the top row spanning all members
                // of the group
                createHeaderCell(headerRow1, column, group.getName());
                sheet.addMergedRegion(new CellRangeAddress(0, 0, column, column + group.getIndicators().size() - 1));
            }
            for (IndicatorDTO indicator : group.getIndicators()) {
                indicators.add(indicator.getId());
                createHeaderCell(headerRow2, column, indicator.getName(), indicatorHeaderStyle);
                sheet.setColumnWidth(column, characters(INDICATOR_COLUMN_WIDTH));
                column++;
            }
        }
    }
    attributes = new ArrayList<Integer>();
    for (AttributeGroupDTO group : activity.getAttributeGroups()) {
        if (group.getAttributes().size() != 0) {
            createHeaderCell(headerRow1, column, group.getName(), CellStyle.ALIGN_CENTER);
            sheet.addMergedRegion(new CellRangeAddress(0, 0, column, column + group.getAttributes().size() - 1));
            for (AttributeDTO attrib : group.getAttributes()) {
                attributes.add(attrib.getId());
                createHeaderCell(headerRow2, column, attrib.getName(), attribHeaderStyle);
                sheet.setColumnWidth(column, characters(ATTRIBUTE_COLUMN_WIDTH));
                column++;
            }
        }
    }
    levels = new ArrayList<Integer>();
    for (AdminLevelDTO level : activity.getAdminLevels()) {
        createHeaderCell(headerRow2, column++, "Code " + level.getName());
        createHeaderCell(headerRow2, column++, level.getName());
        levels.add(level.getId());
    }
    int latColumn = column++;
    int lngColumn = column++;
    createHeaderCell(headerRow2, latColumn, I18N.CONSTANTS.longitude(), CellStyle.ALIGN_RIGHT);
    createHeaderCell(headerRow2, lngColumn, I18N.CONSTANTS.latitude(), CellStyle.ALIGN_RIGHT);
    sheet.setColumnWidth(lngColumn, characters(COORD_COLUMN_WIDTH));
    sheet.setColumnWidth(latColumn, characters(COORD_COLUMN_WIDTH));
    createHeaderCell(headerRow2, column++, I18N.CONSTANTS.comments());
}
Also used : AttributeDTO(org.activityinfo.shared.dto.AttributeDTO) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) IndicatorGroup(org.activityinfo.shared.dto.IndicatorGroup) AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) Row(org.apache.poi.ss.usermodel.Row) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) Cell(org.apache.poi.ss.usermodel.Cell)

Example 7 with AdminLevelDTO

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

the class BoundLocationSection method isDirty.

private boolean isDirty() {
    for (AdminLevelDTO level : adminFieldSet.getAdminLevels()) {
        AdminEntityDTO original = location.getAdminEntity(level.getId());
        AdminEntityDTO current = adminFieldSet.getAdminEntity(level);
        if (current == null && original != null) {
            return true;
        }
        if (current != null && original == null) {
            return true;
        }
        if (current.getId() != original.getId()) {
            return true;
        }
    }
    return false;
}
Also used : AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO)

Example 8 with AdminLevelDTO

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

the class AdminLevelPanel method showOptions.

protected void showOptions(List<AdminLevelDTO> levels) {
    removeAll();
    if (radioGroup != null) {
        radioGroup.removeAllListeners();
    }
    radioGroup = new RadioGroup();
    boolean missingPolygons = false;
    for (AdminLevelDTO level : levels) {
        Radio radio = new Radio();
        radio.setBoxLabel(level.getName());
        radio.setEnabled(level.getPolygons());
        radio.setData("adminLevelId", level.getId());
        radioGroup.add(radio);
        add(radio);
        if (!level.getPolygons()) {
            missingPolygons = true;
        }
    }
    if (missingPolygons) {
        addMissingPolygonMessage();
    }
    radioGroup.addListener(Events.Change, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            AdminLevelPanel.this.fireEvent(Events.Change, new BaseEvent(Events.Change));
        }
    });
    layout();
}
Also used : RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) Radio(com.extjs.gxt.ui.client.widget.form.Radio)

Example 9 with AdminLevelDTO

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

the class ClusteringOptionsWidget method buildForm.

private void buildForm(Set<CountryDTO> countries) {
    radios = Lists.newArrayList();
    radios.add(new ClusteringRadio(I18N.CONSTANTS.none(), new NoClustering()));
    radios.add(new ClusteringRadio(I18N.CONSTANTS.automatic(), new AutomaticClustering()));
    if (countries.size() == 1) {
        CountryDTO country = countries.iterator().next();
        for (AdminLevelDTO level : country.getAdminLevels()) {
            AdministrativeLevelClustering clustering = new AdministrativeLevelClustering();
            clustering.getAdminLevels().add(level.getId());
            radios.add(new ClusteringRadio(level.getName(), clustering));
        }
    }
    radioGroup = new RadioGroup();
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setStyleAttribute("padding", "5px");
    for (ClusteringRadio radio : radios) {
        radioGroup.add(radio);
        if (radio.getClustering().equals(value)) {
            radioGroup.setValue(radio);
        }
    }
    add(radioGroup);
    radioGroup.addListener(Events.Change, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
            ClusteringRadio radio = (ClusteringRadio) radioGroup.getValue();
            setValue(radio.getClustering(), true);
        }
    });
    layout();
// unmask();
}
Also used : AdministrativeLevelClustering(org.activityinfo.shared.report.model.clustering.AdministrativeLevelClustering) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) CountryDTO(org.activityinfo.shared.dto.CountryDTO) AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) FieldEvent(com.extjs.gxt.ui.client.event.FieldEvent) NoClustering(org.activityinfo.shared.report.model.clustering.NoClustering) AutomaticClustering(org.activityinfo.shared.report.model.clustering.AutomaticClustering)

Example 10 with AdminLevelDTO

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

the class DimensionTree method addGeography.

private void addGeography(SchemaDTO schema) {
    Set<CountryDTO> countries = schema.getCountriesForIndicators(model.getIndicators());
    store.removeAll(geographyRoot);
    if (countries.size() == 1) {
        CountryDTO country = countries.iterator().next();
        for (AdminLevelDTO level : country.getAdminLevels()) {
            store.add(geographyRoot, new DimensionModel(level), false);
        }
        addLocationDimension();
    }
}
Also used : CountryDTO(org.activityinfo.shared.dto.CountryDTO) AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO)

Aggregations

AdminLevelDTO (org.activityinfo.shared.dto.AdminLevelDTO)13 AdminEntityDTO (org.activityinfo.shared.dto.AdminEntityDTO)3 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)2 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)2 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)2 CountryDTO (org.activityinfo.shared.dto.CountryDTO)2 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)2 LocationDTO (org.activityinfo.shared.dto.LocationDTO)2 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)1 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)1 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 Radio (com.extjs.gxt.ui.client.widget.form.Radio)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GetSchema (org.activityinfo.shared.command.GetSchema)1 AdminLevelResult (org.activityinfo.shared.command.result.AdminLevelResult)1