comparison org.eclipse.jface/src/org/eclipse/jface/viewers/NamedHandleObjectLabelProvider.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
1 /*******************************************************************************
2 * Copyright (c) 2005, 2007 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 org.eclipse.jface.viewers.NamedHandleObjectLabelProvider;
15
16 import org.eclipse.jface.viewers.DialogCellEditor;
17 import org.eclipse.jface.viewers.LabelProvider;
18
19
20 import org.eclipse.core.commands.common.NamedHandleObject;
21 import org.eclipse.core.commands.common.NotDefinedException;
22
23 import java.lang.all;
24
25 /**
26 * A label provider for instances of <code>NamedHandlerObject</code>, which
27 * exposes the name as the label.
28 *
29 * @since 3.2
30 */
31 public final class NamedHandleObjectLabelProvider : LabelProvider {
32
33 /**
34 * The text of the element is simply the name of the element if its a
35 * defined instance of <code>NamedHandleObject</code>. Otherwise, this
36 * method just returns <code>null</code>.
37 *
38 * @param element
39 * The element for which the text should be retrieved; may be
40 * <code>null</code>.
41 * @return the name of the handle object; <code>null</code> if there is no
42 * name or if the element is not a named handle object.
43 */
44 public override final String getText(Object element) {
45 if ( cast(NamedHandleObject)element ) {
46 try {
47 return (cast(NamedHandleObject) element).getName();
48 } catch (NotDefinedException e) {
49 return null;
50 }
51 }
52
53 return null;
54 }
55 }
56