comparison org.eclipse.jface/src/org/eclipse/jface/fieldassist/AutoCompleteField.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) 2006, 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 module org.eclipse.jface.fieldassist.AutoCompleteField;
14
15 import org.eclipse.jface.fieldassist.IControlContentAdapter;
16 import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
17 import org.eclipse.jface.fieldassist.ContentProposalAdapter;
18
19 import org.eclipse.swt.widgets.Control;
20
21 import java.lang.all;
22 import java.util.Set;
23
24 /**
25 * AutoCompleteField is a class which attempts to auto-complete a user's
26 * keystrokes by activating a popup that filters a list of proposals according
27 * to the content typed by the user.
28 *
29 * @see ContentProposalAdapter
30 * @see SimpleContentProposalProvider
31 *
32 * @since 3.3
33 */
34 public class AutoCompleteField {
35
36 private SimpleContentProposalProvider proposalProvider;
37 private ContentProposalAdapter adapter;
38
39 /**
40 * Construct an AutoComplete field on the specified control, whose
41 * completions are characterized by the specified array of Strings.
42 *
43 * @param control
44 * the control for which autocomplete is desired. May not be
45 * <code>null</code>.
46 * @param controlContentAdapter
47 * the <code>IControlContentAdapter</code> used to obtain and
48 * update the control's contents. May not be <code>null</code>.
49 * @param proposals
50 * the array of Strings representing valid content proposals for
51 * the field.
52 */
53 public this(Control control,
54 IControlContentAdapter controlContentAdapter, String[] proposals) {
55 proposalProvider = new SimpleContentProposalProvider(proposals);
56 proposalProvider.setFiltering(true);
57 adapter = new ContentProposalAdapter(control, controlContentAdapter,
58 proposalProvider, null, null);
59 adapter.setPropagateKeys(true);
60 adapter
61 .setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
62 }
63
64 /**
65 * Set the Strings to be used as content proposals.
66 *
67 * @param proposals
68 * the array of Strings to be used as proposals.
69 */
70 public void setProposals(String[] proposals) {
71 proposalProvider.setProposals(proposals);
72 }
73 }