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

📄 favoritepropertysource.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.TextPropertyDescriptor;

public class FavoritePropertySource implements IPropertySource
{
	private final static String ID_SINGER = "SINGER";

	private final static String ID_FOOD = "FOOD";

	private final static String ID_MOTTO = "MOTTO";

	private Favorite favorite;

	private final static IPropertyDescriptor[] propDescs = new IPropertyDescriptor[] {
			new TextPropertyDescriptor(ID_SINGER, "歌手"),
			new TextPropertyDescriptor(ID_FOOD, "食品"),
			new TextPropertyDescriptor(ID_MOTTO, "座右铭"), };

	public FavoritePropertySource(Favorite favorite)
	{
		super();
		this.favorite = favorite;
	}

	public Object getEditableValue()
	{
		return null;
	}

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

	public Object getPropertyValue(Object id)
	{
		if (id == ID_SINGER)
		{
			return favorite.getSinger();
		}
		if (id == ID_FOOD)
		{
			return favorite.getFood();
		}
		if (id == ID_MOTTO)
		{
			return favorite.getMotto();
		}
		return null;
	}

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

	public void resetPropertyValue(Object id)
	{

	}

	public void setPropertyValue(Object id, Object value)
	{
		if (id == ID_SINGER)
		{
			favorite.setSinger((String) value);
		}
		if (id == ID_FOOD)
		{
			favorite.setFood((String) value);
		}
		if (id == ID_MOTTO)
		{
			favorite.setMotto((String) value);
		}
	}

}

⌨️ 快捷键说明

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