Commit | Line | Data |
---|---|---|
90e2b925 FC |
1 | /*******************************************************************************\r |
2 | * Copyright (c) 2010 Ericsson\r | |
013a5f1c | 3 | *\r |
90e2b925 FC |
4 | * All rights reserved. This program and the accompanying materials are\r |
5 | * made available under the terms of the Eclipse Public License v1.0 which\r | |
6 | * accompanies this distribution, and is available at\r | |
7 | * http://www.eclipse.org/legal/epl-v10.html\r | |
013a5f1c | 8 | *\r |
90e2b925 FC |
9 | * Contributors:\r |
10 | * Yuriy Vashchuk - Initial API and implementation\r | |
11 | *******************************************************************************/\r | |
12 | \r | |
13 | package org.eclipse.linuxtools.tmf.ui.views.filter;\r | |
14 | \r | |
15 | import java.util.ArrayList;\r | |
16 | \r | |
17 | import org.eclipse.jface.viewers.ITreeContentProvider;\r | |
18 | import org.eclipse.jface.viewers.Viewer;\r | |
6c13869b | 19 | import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r |
90e2b925 FC |
20 | \r |
21 | /**\r | |
90e2b925 | 22 | * This is the Content Provider of our tree\r |
013a5f1c AM |
23 | *\r |
24 | * @version 1.0\r | |
25 | * @author Yuriy Vashchuk\r | |
90e2b925 FC |
26 | */\r |
27 | public class FilterTreeContentProvider implements ITreeContentProvider {\r | |
28 | \r | |
29 | /*\r | |
30 | * (non-Javadoc)\r | |
31 | * @see org.eclipse.jface.viewers.IContentProvider#dispose()\r | |
32 | */\r | |
33 | @Override\r | |
34 | public void dispose() {\r | |
35 | // TODO Auto-generated method stub\r | |
36 | }\r | |
37 | \r | |
38 | /*\r | |
39 | * (non-Javadoc)\r | |
40 | * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)\r | |
41 | */\r | |
42 | @Override\r | |
43 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r | |
44 | // TODO Auto-generated method stub\r | |
45 | }\r | |
46 | \r | |
47 | /*\r | |
48 | * (non-Javadoc)\r | |
49 | * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)\r | |
50 | */\r | |
51 | @Override\r | |
52 | public Object[] getElements(Object inputElement) {\r | |
53 | if (inputElement instanceof ITmfFilterTreeNode) {\r | |
54 | ArrayList<ITmfFilterTreeNode> result = new ArrayList<ITmfFilterTreeNode>();\r | |
55 | for(int i = 0; i < ((ITmfFilterTreeNode)inputElement).getChildrenCount(); i++) {\r | |
56 | result.add(((ITmfFilterTreeNode)inputElement).getChild(i));\r | |
57 | }\r | |
013a5f1c | 58 | \r |
90e2b925 FC |
59 | return result.toArray();\r |
60 | }\r | |
61 | return null;\r | |
62 | }\r | |
63 | \r | |
64 | /*\r | |
65 | * (non-Javadoc)\r | |
66 | * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)\r | |
67 | */\r | |
68 | @Override\r | |
69 | public Object[] getChildren(Object parentElement) {\r | |
70 | ArrayList<ITmfFilterTreeNode> result = new ArrayList<ITmfFilterTreeNode>();\r | |
71 | for(int i = 0; i < ((ITmfFilterTreeNode)parentElement).getChildrenCount(); i++) {\r | |
72 | result.add(((ITmfFilterTreeNode)parentElement).getChild(i));\r | |
73 | }\r | |
74 | return result.toArray();\r | |
75 | }\r | |
76 | \r | |
77 | /*\r | |
78 | * (non-Javadoc)\r | |
79 | * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)\r | |
80 | */\r | |
81 | @Override\r | |
82 | public Object getParent(Object element) {\r | |
83 | return ((ITmfFilterTreeNode) element).getParent();\r | |
84 | }\r | |
85 | \r | |
86 | /*\r | |
87 | * (non-Javadoc)\r | |
88 | * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)\r | |
89 | */\r | |
90 | @Override\r | |
91 | public boolean hasChildren(Object element) {\r | |
92 | return ((ITmfFilterTreeNode) element).hasChildren();\r | |
93 | }\r | |
94 | \r | |
95 | }\r |