comparison dwtx/jface/viewers/ArrayContentProvider.d @ 10:b6c35faf97c8

Viewers
author Frank Benoit <benoit@tionex.de>
date Mon, 31 Mar 2008 00:47:19 +0200
parents
children dad2e11b8ae4
comparison
equal deleted inserted replaced
9:6c14e54dfc11 10:b6c35faf97c8
1 /*******************************************************************************
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13
14 module dwtx.jface.viewers.ArrayContentProvider;
15
16 import dwtx.jface.viewers.IStructuredContentProvider;
17 import dwtx.jface.viewers.Viewer;
18
19 import tango.util.collection.model.View;
20
21 import dwt.dwthelper.utils;
22
23 /**
24 * This implementation of <code>IStructuredContentProvider</code> handles
25 * the case where the viewer input is an unchanging array or collection of elements.
26 * <p>
27 * This class is not intended to be subclassed outside the viewer framework.
28 * </p>
29 *
30 * @since 2.1
31 */
32 public class ArrayContentProvider : IStructuredContentProvider {
33
34 /**
35 * Returns the elements in the input, which must be either an array or a
36 * <code>Collection</code>.
37 */
38 public Object[] getElements(Object inputElement) {
39 if ( auto aw = cast(ArrayWrapperObject) inputElement ) {
40 return aw.array;
41 }
42 if ( auto col = cast(View!(Object)) inputElement ) {
43 return col.toArray();
44 }
45 return null;
46 }
47
48 /**
49 * This implementation does nothing.
50 */
51 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
52 // do nothing.
53 }
54
55 /**
56 * This implementation does nothing.
57 */
58 public void dispose() {
59 // do nothing.
60 }
61 }