1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Yuriy Vashchuk - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.filter
;
15 import java
.util
.ArrayList
;
17 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
18 import org
.eclipse
.jface
.viewers
.Viewer
;
19 import org
.eclipse
.linuxtools
.tmf
.filter
.model
.ITmfFilterTreeNode
;
22 * <b><u>FilterTreeContentProvider</u></b>
24 * This is the Content Provider of our tree
27 public class FilterTreeContentProvider
implements ITreeContentProvider
{
31 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
34 public void dispose() {
35 // TODO Auto-generated method stub
40 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
43 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
44 // TODO Auto-generated method stub
49 * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
52 public Object
[] getElements(Object inputElement
) {
53 if (inputElement
instanceof ITmfFilterTreeNode
) {
54 ArrayList
<ITmfFilterTreeNode
> result
= new ArrayList
<ITmfFilterTreeNode
>();
55 for(int i
= 0; i
< ((ITmfFilterTreeNode
)inputElement
).getChildrenCount(); i
++) {
56 result
.add(((ITmfFilterTreeNode
)inputElement
).getChild(i
));
59 return result
.toArray();
66 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
69 public Object
[] getChildren(Object parentElement
) {
70 ArrayList
<ITmfFilterTreeNode
> result
= new ArrayList
<ITmfFilterTreeNode
>();
71 for(int i
= 0; i
< ((ITmfFilterTreeNode
)parentElement
).getChildrenCount(); i
++) {
72 result
.add(((ITmfFilterTreeNode
)parentElement
).getChild(i
));
74 return result
.toArray();
79 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
82 public Object
getParent(Object element
) {
83 return ((ITmfFilterTreeNode
) element
).getParent();
88 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
91 public boolean hasChildren(Object element
) {
92 return ((ITmfFilterTreeNode
) element
).hasChildren();