| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2010, 2012 Ericsson |
| 3 | * |
| 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 |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Francois Chouinard - Initial API and implementation |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | package org.eclipse.linuxtools.tmf.ui.project.model; |
| 14 | |
| 15 | import java.util.ArrayList; |
| 16 | import java.util.List; |
| 17 | |
| 18 | import org.eclipse.jface.viewers.IStructuredContentProvider; |
| 19 | import org.eclipse.jface.viewers.Viewer; |
| 20 | |
| 21 | /** |
| 22 | * Content provider implementation for trace folders for tree viewers that display |
| 23 | * the content of a trace folder. |
| 24 | * <p> |
| 25 | * |
| 26 | * @version 1.0 |
| 27 | * @author Francois Chouinard |
| 28 | */ |
| 29 | public class TraceFolderContentProvider implements IStructuredContentProvider { |
| 30 | |
| 31 | /* |
| 32 | * (non-Javadoc) |
| 33 | * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) |
| 34 | */ |
| 35 | @Override |
| 36 | public Object[] getElements(Object inputElement) { |
| 37 | if (inputElement instanceof TmfTraceFolder) { |
| 38 | TmfTraceFolder folder = (TmfTraceFolder) inputElement; |
| 39 | List<ITmfProjectModelElement> elements = new ArrayList<ITmfProjectModelElement>(); |
| 40 | for (ITmfProjectModelElement element : folder.getChildren()) { |
| 41 | if (element instanceof TmfTraceElement) { |
| 42 | TmfTraceElement trace = (TmfTraceElement) element; |
| 43 | if (trace.getTraceType() != null) { |
| 44 | elements.add(trace); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | return elements.toArray(); |
| 49 | } |
| 50 | return null; |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | * (non-Javadoc) |
| 55 | * @see org.eclipse.jface.viewers.IContentProvider#dispose() |
| 56 | */ |
| 57 | @Override |
| 58 | public void dispose() { |
| 59 | } |
| 60 | |
| 61 | /* |
| 62 | * (non-Javadoc) |
| 63 | * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
| 64 | */ |
| 65 | @Override |
| 66 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
| 67 | } |
| 68 | |
| 69 | } |