private void displayDiscussionThread(DiscussionThread thread) { view.removeAllNotes(); final List<Note> rootNotes = new ArrayList<Note>(thread.getRootNotes()); Collections.sort( rootNotes, new Comparator<Note>() { @Override public int compare(Note o1, Note o2) { return (int) -(o1.getTimestamp() - o2.getTimestamp()); } }); for (Note rootNote : rootNotes) { appendNote(rootNote, 0, thread); } currentNoteIds.clear(); currentNoteIds.addAll(thread.getNoteIds()); }
private void appendNote(Note note, int depth, DiscussionThread discussionThread) { NoteContainerPresenter noteContainerPresenter = new NoteContainerPresenter(new NoteContainerViewImpl()); noteContainerPresenter.setNote(note, discussionThread); view.addNote(noteContainerPresenter, depth); for (Note childNote : discussionThread.getReplies(note.getNoteId())) { appendNote(childNote, depth + 1, discussionThread); } }