Search in sources :

Example 6 with AdminLevelDTO

use of org.activityinfo.legacy.shared.model.AdminLevelDTO in project activityinfo by bedatadriven.

the class AdminFieldSetPresenterTest method expectEnabledEvents.

private void expectEnabledEvents(AdminLevelDTO... levels) {
    resetToDefault(levelStateChangeListener);
    for (AdminLevelDTO level : levels) {
        levelStateChangeListener.handleEvent(eq(new LevelStateChangeEvent(level.getId(), true)));
    }
    replay(levelStateChangeListener);
}
Also used : AdminLevelDTO(org.activityinfo.legacy.shared.model.AdminLevelDTO)

Example 7 with AdminLevelDTO

use of org.activityinfo.legacy.shared.model.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.legacy.shared.model.AdminLevelDTO) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) Radio(com.extjs.gxt.ui.client.widget.form.Radio)

Example 8 with AdminLevelDTO

use of org.activityinfo.legacy.shared.model.AdminLevelDTO in project activityinfo by bedatadriven.

the class AdminFieldSetPresenter method sort.

private ArrayList<AdminLevelDTO> sort(List<AdminLevelDTO> levels2) {
    ArrayList<AdminLevelDTO> sortedList = new ArrayList<>();
    ArrayList<AdminLevelDTO> sorterList = new ArrayList<>();
    for (AdminLevelDTO level : levels2) {
        if (level.getParentLevelId() == null) {
            sorterList.add(level);
            sortedList.add(level);
        }
    }
    while (levels2.size() != sortedList.size()) {
        ArrayList<AdminLevelDTO> tempList = new ArrayList<>();
        for (AdminLevelDTO dto : sorterList) {
            for (AdminLevelDTO e : levels2) {
                if (e.getParentLevelId() != null) {
                    if (e.getParentLevelId().equals(dto.getId())) {
                        tempList.add(e);
                    }
                }
            }
        }
        sortedList.addAll(tempList);
        sorterList.clear();
        sorterList.addAll(tempList);
    }
    return sortedList;
}
Also used : AdminLevelDTO(org.activityinfo.legacy.shared.model.AdminLevelDTO)

Aggregations

AdminLevelDTO (org.activityinfo.legacy.shared.model.AdminLevelDTO)8 ArrayList (java.util.ArrayList)3 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)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 List (java.util.List)1 AdminLevelResult (org.activityinfo.legacy.shared.command.result.AdminLevelResult)1 LocationDTO (org.activityinfo.legacy.shared.model.LocationDTO)1 AdministrativeLevelClustering (org.activityinfo.legacy.shared.reports.model.clustering.AdministrativeLevelClustering)1 AutomaticClustering (org.activityinfo.legacy.shared.reports.model.clustering.AutomaticClustering)1 NoClustering (org.activityinfo.legacy.shared.reports.model.clustering.NoClustering)1 KeyGenerator (org.activityinfo.model.legacy.KeyGenerator)1 Test (org.junit.Test)1