blob: a33b690f83b7a4f45c1bd9108fc884e1aa57e451 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*******************************************************************************
* Copyright (c) 2012 Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Miles Parker (Tasktop Technologies) - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.reviews.ui.providers;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.mylyn.reviews.core.model.ITopicContainer;
/**
* Flattens all contents of a review to their lowest level of detail. (In current implementations, this is comments.)
*
* @author Miles Parker
*/
public class ReviewsFlatContentProvider extends GenericTreeContentProvider {
public Object[] getElements(Object element) {
if (element instanceof ITopicContainer) {
List<Object> children = new ArrayList<Object>();
children.addAll(((ITopicContainer) element).getAllComments());
return children.toArray();
}
return getCollectionChildren(element);
}
@Override
public boolean hasChildren(Object element) {
return ((element instanceof ITopicContainer) && ((ITopicContainer) element).getAllComments().size() > 0)
|| hasCollectionChildren(element);
}
}
|