package com.fr.design.mainframe.widget.editors;

import com.fr.base.Utils;
import com.fr.design.Exception.ValidationException;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.form.ui.Button;
import com.fr.stable.StableUtils;
import com.fr.design.widget.btn.ButtonConstants;

import java.awt.*;


/**
 * Author : Shockway
 * Date: 13-9-29
 * Time: 下午2:26
 */
public class ShortCutTextEditor extends AbstractPropertyEditor {
	private Button widget;
	private UITextField text;

	public ShortCutTextEditor(Object o) {
		this.widget = (Button) o;
		this.text = new UITextField();
		this.text.setToolTipText(StableUtils.join(ButtonConstants.HOTKEYS, ","));
		this.text.setText(widget.getHotkeys());
	}

	public void validateValue() throws ValidationException {
	}

	public void setValue(Object value) {
		this.text.setText(Utils.objectToString(value));
	}

	public Object getValue() {
		return this.text.getText();
	}

	public Component getCustomEditor() {
		return this.text;
	}
}