| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2010, 2013 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 | @Override |
| 32 | public Object[] getElements(Object inputElement) { |
| 33 | if (inputElement instanceof TmfTraceFolder) { |
| 34 | TmfTraceFolder folder = (TmfTraceFolder) inputElement; |
| 35 | List<ITmfProjectModelElement> elements = new ArrayList<ITmfProjectModelElement>(); |
| 36 | for (ITmfProjectModelElement element : folder.getChildren()) { |
| 37 | if (element instanceof TmfTraceElement) { |
| 38 | TmfTraceElement trace = (TmfTraceElement) element; |
| 39 | if (trace.getTraceType() != null) { |
| 40 | elements.add(trace); |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | return elements.toArray(); |
| 45 | } |
| 46 | return null; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public void dispose() { |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
| 55 | } |
| 56 | |
| 57 | } |