1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.pcmbench.tabs.parameters; |
5 | |
6 | import org.eclipse.jface.text.IDocument; |
7 | import org.eclipse.jface.text.contentassist.ContentAssistant; |
8 | import org.eclipse.jface.viewers.TextCellEditor; |
9 | import org.eclipse.swt.SWT; |
10 | import org.eclipse.swt.widgets.Composite; |
11 | import org.eclipse.swt.widgets.Control; |
12 | import org.eclipse.swt.widgets.Event; |
13 | import org.eclipse.swt.widgets.Listener; |
14 | import org.eclipse.swt.widgets.Text; |
15 | |
16 | import de.uka.ipd.sdq.pcm.dialogs.stoex.StoExCompletionProcessor; |
17 | import de.uka.ipd.sdq.pcm.repository.Parameter; |
18 | |
19 | /** |
20 | * @author Roman Andrej |
21 | * |
22 | */ |
23 | public class StoExTextCellEditor extends TextCellEditor { |
24 | |
25 | /** |
26 | * The text control; initially <code>null</code>. |
27 | */ |
28 | protected Text text; |
29 | |
30 | private ContentAssistant contentAssistant; |
31 | |
32 | public StoExTextCellEditor(Composite parent) { |
33 | super(parent); |
34 | contentAssistant = new ContentAssistant(); |
35 | contentAssistant.setContentAssistProcessor( |
36 | new StoExCompletionProcessor(new Parameter[0]), |
37 | IDocument.DEFAULT_CONTENT_TYPE); |
38 | contentAssistant.setAutoActivationDelay(1); |
39 | contentAssistant.enableAutoActivation(true); |
40 | } |
41 | |
42 | /* (non-Javadoc) |
43 | * @see org.eclipse.jface.viewers.TextCellEditor#createControl(org.eclipse.swt.widgets.Composite) |
44 | */ |
45 | @Override |
46 | protected Control createControl(Composite parent) { |
47 | // TODO Auto-generated method stub |
48 | text = (Text) super.createControl(parent); |
49 | |
50 | |
51 | text.addListener(SWT.KeyDown, new Listener(){ |
52 | |
53 | public void handleEvent(Event event) { |
54 | if (event.character == ' ' && (event.stateMask & SWT.CTRL) == SWT.CTRL){ |
55 | contentAssistant.showPossibleCompletions(); |
56 | } |
57 | } |
58 | |
59 | }); |
60 | |
61 | return text; |
62 | } |
63 | } |