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());
}
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;
}
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();
}
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();
}
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();
}
}
Aggregations