abstractbutton.java

来自「基于eclipse的工具开发代码」· Java 代码 · 共 65 行

JAVA
65
字号
package com.cownew.uidesigner.model;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

import com.cownew.uidesigner.common.ComponentUtils;

public abstract class AbstractButton extends Component
{
	public static final String TEXT = "TEXT";

	private static IPropertyDescriptor[] descriptors = new IPropertyDescriptor[] { new TextPropertyDescriptor(
			TEXT, "Text") };

	private String text;

	public AbstractButton()
	{
		super();
		text = "";
	}

	public String getText()
	{
		return text;
	}

	public void setText(String text)
	{
		String oldValue = getText();
		this.text = text;
		this.firePropertyChange(TEXT, oldValue, text);
	}

	public IPropertyDescriptor[] getPropertyDescriptors()
	{
		IPropertyDescriptor[] sd = super.getPropertyDescriptors();
		return ComponentUtils.mergePropDesc(sd, descriptors);
	}

	public Object getPropertyValue(Object id)
	{
		Object v = super.getPropertyValue(id);
		if (v != null)
		{
			return v;
		}
		if (id.equals(TEXT))
		{
			return getText();
		}
		return null;

	}

	public void setPropertyValue(Object id, Object value)
	{
		super.setPropertyValue(id, value);
		if (id.equals(TEXT))
		{
			setText((String) value);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?