private void fillProjectsOnBoards(BoardsFilter filterObject, boolean loaded) { MessageBus.unregisterListener(GetAllProjectsResponseMessage.class, projectsOnBoardsCollector); MessageBus.registerListener(GetAllProjectsResponseMessage.class, projectsOnBoardsCollector); projectsOnBoardsCollector.init(); MessageBus.sendMessage(new GetAllProjectsRequestMessage(null, this)); List<Dtos.BoardWithProjectsDto> boardsWithProjectsDtos = projectsOnBoardsCollector.getData(); List<Dtos.BoardWithProjectsDto> shallowBoardsWithProjectsDtos = new ArrayList<Dtos.BoardWithProjectsDto>(); for (Dtos.BoardWithProjectsDto boardWithProjectsDto : boardsWithProjectsDtos) { Dtos.BoardWithProjectsDto shallowBoardWithProjectsDto = DtoFactory.boardWithProjectsDto(); shallowBoardWithProjectsDto.setBoard(asShallowBoard(boardWithProjectsDto.getBoard())); shallowBoardWithProjectsDto.setProjectsOnBoard(boardWithProjectsDto.getProjectsOnBoard()); shallowBoardsWithProjectsDtos.add(shallowBoardWithProjectsDto); } Collections.sort( shallowBoardsWithProjectsDtos, new Comparator<Dtos.BoardWithProjectsDto>() { @Override public int compare(Dtos.BoardWithProjectsDto b1, Dtos.BoardWithProjectsDto b2) { return b1.getProjectsOnBoard() .getValues() .get(0) .getName() .compareTo(b2.getProjectsOnBoard().getValues().get(0).getName()); } }); for (Dtos.BoardWithProjectsDto boardWithProjectDtos : shallowBoardsWithProjectsDtos) { if (!loaded || filterObject.findById(boardWithProjectDtos) == -1) { filterObject.add(boardWithProjectDtos); } projectOnBoardFilter.add( new ProjectOnBoardFilterCheckBox(boardWithProjectDtos, filterObject)); } }
private void fillBoards(BoardsFilter filterObject, boolean loaded) { MessageBus.unregisterListener(GetAllBoardsResponseMessage.class, boardsCollector); MessageBus.registerListener(GetAllBoardsResponseMessage.class, boardsCollector); boardsCollector.init(); MessageBus.sendMessage( new GetBoardsRequestMessage( null, new GetBoardsRequestMessage.Filter() { @Override public boolean apply(Dtos.BoardDto boardDto) { return true; } }, this)); List<Dtos.BoardDto> boards = boardsCollector.getData(); List<Dtos.BoardDto> shallowBoards = new ArrayList<Dtos.BoardDto>(); for (Dtos.BoardDto board : boards) { shallowBoards.add(asShallowBoard(board)); } Collections.sort( shallowBoards, new Comparator<Dtos.BoardDto>() { @Override public int compare(Dtos.BoardDto b1, Dtos.BoardDto b2) { return b1.getName().compareTo(b2.getName()); } }); for (Dtos.BoardDto board : shallowBoards) { if (!loaded || filterObject.findById(board) == -1) { filterObject.add(board); } boardFilter.add(new BoardsFilterCheckBox(board, filterObject)); } }