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

📄 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 ID_WEBSITE = "ID_WEBSITE";
	
	private final static String ID_EMAIL = "ID_EMAIL";
	
	private final static String CATEGORY_NET = "网络联系方式";

	private final static IPropertyDescriptor[] propDescs;
	
	static
	{
		TextPropertyDescriptor webSitePropDesc = new TextPropertyDescriptor(
				ID_WEBSITE, "网站");
		webSitePropDesc.setCategory(CATEGORY_NET);
		TextPropertyDescriptor emailPropDesc = new TextPropertyDescriptor(
				ID_EMAIL, "邮件");
		emailPropDesc.setCategory(CATEGORY_NET);
		propDescs = new IPropertyDescriptor[] {
				new PropertyDescriptor(ID_NAME, "姓名"),
				new TextPropertyDescriptor(ID_ADDRESS, "地址"), webSitePropDesc,
				emailPropDesc };
	}
	
	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();
		}
		if (id == ID_WEBSITE)
		{
			return person.getWebSite();
		}
		if (id == ID_EMAIL)
		{
			return person.getEmail();
		}
		return null;
	}

	public boolean isPropertySet(Object id)
	{
		return false;
	}

	public void resetPropertyValue(Object id)
	{
		
	}

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

	}

}

⌨️ 快捷键说明

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