⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 personpropertysource.java

📁 基于eclipse的工具开发代码
💻 JAVA
字号:
package propertypagetest.model;

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

public class PersonPropertySource implements IPropertySource
{

	private final static String ID_NAME = "NAME";

	private final static String ID_ADDRESS = "ADDRESS";

	private final static String DEFAULT_ADDRESS = "太阳系地球";

	private final static IPropertyDescriptor[] propDescs = new IPropertyDescriptor[] {
			new PropertyDescriptor(ID_NAME, "姓名"),
			new TextPropertyDescriptor(ID_ADDRESS, "地址") };
	
	private Person person;	

	public PersonPropertySource(Person person)
	{
		super();
		this.person = person;
	}

	public IPropertyDescriptor[] getPropertyDescriptors()
	{
		return propDescs;
	}

	public Object getEditableValue()
	{
		return null;
	}

	public Object getPropertyValue(Object id)
	{
		if (id == ID_NAME)
		{
			return person.getName();
		}
		if (id == ID_ADDRESS)
		{
			return person.getAddress();
		}
		return null;
	}

	public boolean isPropertySet(Object id)
	{
		if (id == ID_ADDRESS)
		{
			return person.getAddress() != DEFAULT_ADDRESS;
		}
		return false;
	}

	public void resetPropertyValue(Object id)
	{
		if (id == ID_ADDRESS)
		{
			person.setName(DEFAULT_ADDRESS);
		}
	}

	public void setPropertyValue(Object id, Object value)
	{
		if (id == ID_NAME)
		{
			person.setName((String) value);
		}

	}

}

⌨️ 快捷键说明

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