1 /*******************************************************************************
\r
2 * Copyright (c) 2011 Laurent CARON.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * Peter Weishapl - Inspiration
\r
10 * Laurent CARON (laurent.caron@gmail.com) - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.mihalis.opal.promptSupport;
\r
14 import org.eclipse.swt.widgets.Text;
\r
17 * Focus/Control listener for a Text widget
\r
19 class TextFocusControlListener extends BaseFocusControlListener {
\r
24 * @param control control on which this listener will be attached
\r
26 public TextFocusControlListener(final Text control) {
\r
31 * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#hidePrompt()
\r
34 protected void hidePrompt() {
\r
35 ((Text) this.control).setText("");
\r
39 * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#highLightPrompt()
\r
42 protected void highLightPrompt() {
\r
43 // If we do a select all directly, it's not working !
\r
44 this.control.getDisplay().asyncExec(new Runnable() {
\r
47 ((Text) TextFocusControlListener.this.control).selectAll();
\r
53 * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#fillPromptText()
\r
56 protected void fillPromptText() {
\r
57 final String promptText = PromptSupport.getPrompt(this.control);
\r
58 if (promptText != null) {
\r
59 ((Text) this.control).setText(promptText);
\r
64 * @see org.mihalis.opal.promptSupport.BaseFocusControlListener#isFilled()
\r
67 protected boolean isFilled() {
\r
68 final String promptText = PromptSupport.getPrompt(this.control);
\r
69 if (promptText != null && promptText.equals(((Text) this.control).getText().trim())) {
\r
72 return !"".equals(((Text) this.control).getText().trim());
\r