ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / viewers / ArrayTreeContentProvider.java
CommitLineData
6b44794a
MK
1/*******************************************************************************
2 * Copyright (c) 2014 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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.ui.viewers;
14
15import java.util.Collection;
16
17import org.eclipse.jface.viewers.ITreeContentProvider;
18import org.eclipse.jface.viewers.Viewer;
19
20/**
21 * This implementation of <code>ITreeContentProvider</code> handles the case
22 * where the viewer input is an unchanging array or collection of elements.
23 * The elements do not have children.
24 *
25 * @author Patrick Tasse
26 * @since 3.2
27 */
28public class ArrayTreeContentProvider implements ITreeContentProvider {
29
30 @Override
31 public void dispose() {
32 }
33
34 @Override
35 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
36 }
37
38 @Override
39 public Object[] getChildren(Object parentElement) {
40 return null;
41 }
42
43 @Override
44 public Object getParent(Object element) {
45 return null;
46 }
47
48 @Override
49 public boolean hasChildren(Object element) {
50 return false;
51 }
52
53 @Override
54 public Object[] getElements(Object inputElement) {
55 if (inputElement instanceof Object[]) {
56 return (Object[]) inputElement;
57 }
58 if (inputElement instanceof Collection) {
59 return ((Collection<?>) inputElement).toArray();
60 }
61 return new Object[0];
62 }
63
64}
This page took 0.0267 seconds and 5 git commands to generate.