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