Mercurial > projects > dwt-addons
annotate dwtx/jface/viewers/ArrayContentProvider.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | 7ffeace6c47f |
children |
rev | line source |
---|---|
10 | 1 /******************************************************************************* |
90 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
10 | 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 | |
20 import dwt.dwthelper.utils; | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
90
diff
changeset
|
21 import dwtx.dwtxhelper.Collection; |
10 | 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 | |
90 | 31 * @noextend This class is not intended to be subclassed by clients. |
10 | 32 */ |
74
dad2e11b8ae4
Make ArrayContentProvider a template for the arrays element type.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
33 public class ArrayContentProvider(T) : IStructuredContentProvider { |
10 | 34 |
35 /** | |
36 * Returns the elements in the input, which must be either an array or a | |
37 * <code>Collection</code>. | |
38 */ | |
39 public Object[] getElements(Object inputElement) { | |
74
dad2e11b8ae4
Make ArrayContentProvider a template for the arrays element type.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
40 if ( auto aw = cast(ArrayWrapperT!(T)) inputElement ) { |
10 | 41 return aw.array; |
42 } | |
104
04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
Frank Benoit <benoit@tionex.de>
parents:
90
diff
changeset
|
43 if ( auto col = cast(Collection) inputElement ) { |
10 | 44 return col.toArray(); |
45 } | |
46 return null; | |
47 } | |
48 | |
49 /** | |
50 * This implementation does nothing. | |
51 */ | |
52 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { | |
53 // do nothing. | |
54 } | |
55 | |
56 /** | |
57 * This implementation does nothing. | |
58 */ | |
59 public void dispose() { | |
60 // do nothing. | |
61 } | |
62 } |