blob: 0a629ea12455fd4739a5e71e1fd25876e3005dec [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011 Laurent CARON.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Laurent CARON (laurent.caron at gmail dot com) - Initial API and implementation
*******************************************************************************/
package org.mihalis.opal.promptSupport;
import org.eclipse.swt.widgets.Combo;
/**
* Focus/Control listener for a Combo widget.
*
* @see ComboFocusControlEvent
*/
class ComboFocusControlListener extends BaseFocusControlListener {
/**
* Constructor.
*
* @param control control on which this listener will be attached
*/
public ComboFocusControlListener(final Combo control) {
super(control);
}
/**
* Hide prompt.
*
* @see org.mihalis.opal.promptSupport.BaseFocusControlListener#hidePrompt()
*/
@Override
protected void hidePrompt() {
((Combo) this.control).setText("");
}
/**
* High light prompt.
*
* @see org.mihalis.opal.promptSupport.BaseFocusControlListener#highLightPrompt()
*/
@Override
protected void highLightPrompt() {
}
/**
* Fill prompt text.
*
* @see org.mihalis.opal.promptSupport.BaseFocusControlListener#fillPromptText()
*/
@Override
protected void fillPromptText() {
final String promptText = PromptSupport.getPrompt(this.control);
if (promptText != null) {
this.control.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
((Combo) ComboFocusControlListener.this.control).setText(promptText);
}
});
}
}
/**
* Checks if is filled.
*
* @return true, if is filled
* @see org.mihalis.opal.promptSupport.BaseFocusControlListener#isFilled()
*/
@Override
protected boolean isFilled() {
final String promptText = PromptSupport.getPrompt(this.control);
if (promptText != null && promptText.equals(((Combo) this.control).getText().trim())) {
return false;
}
return !"".equals(((Combo) this.control).getText().trim());
}
}