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

📄 manageritempropertysource.java

📁 基于Eclipse RCP开发的管理工具
💻 JAVA
字号:
 /*    * Copyright 2006 Marcel Schoffelmeer   *   * Licensed under the Apache License, Version 2.0 (the "License");   * you may not use this file except in compliance with the License.   * You may obtain a copy of the License at   *   *    http://www.apache.org/licenses/LICENSE-2.0   *      * Unless required by applicable law or agreed to in writing, software  * distributed under the License is distributed on an "AS IS" BASIS,   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  * See the License for the specific language governing permissions and  * limitations under the License.  */package com.s10r.manager.view;import java.util.ArrayList;import java.util.List;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;import com.s10r.manager.model.ManagerItem;public class ManagerItemPropertySource implements IPropertySource{	private ManagerItem item;	protected static final String PROPERTY_LAST_UPDATED = "lastUpdated";	protected static final String PROPERTY_NAME = "name";	protected static final String PROPERTY_CREATED = "created";	protected static final String PROPERTY_DESCRIPTION = "description";		private Object PropertiesTable[][] = null;	public ManagerItemPropertySource(ManagerItem item)	{		this.item = item;		PropertiesTable = new Object[][] {				{ PROPERTY_NAME,						new TextPropertyDescriptor(PROPERTY_NAME, "name") },				// TODO: url property, for some reason remain read-only in				// properties view...				{						PROPERTY_DESCRIPTION,						new TextPropertyDescriptor(PROPERTY_DESCRIPTION,								"description") },				{						PROPERTY_LAST_UPDATED,						new PropertyDescriptor(PROPERTY_LAST_UPDATED,								"last updated") },				{ PROPERTY_CREATED,						new PropertyDescriptor(PROPERTY_CREATED, "created") }, };	}	public Object getEditableValue()	{		return this;	}	public IPropertyDescriptor[] getPropertyDescriptors()	{		List<IPropertyDescriptor> propertyDescriptors = new ArrayList<     	IPropertyDescriptor>();				fillPropertyDescriptors(propertyDescriptors);		// doesn't fly		// return (IPropertyDescriptor[])propertyDescriptors.toArray();		return propertyDescriptors.toArray(new IPropertyDescriptor[propertyDescriptors.size()]);	}	public Object getPropertyValue(Object name)	{		Object ret = "";				if (name.equals(PROPERTY_NAME))		{			ret = item.getName();		}		else if (name.equals(PROPERTY_CREATED))		{			ret = item.getCreated();		}		else if (name.equals(PROPERTY_LAST_UPDATED))		{			ret = item.getLastUpdated();		}		else if (name.equals(PROPERTY_DESCRIPTION))		{			ret = item.getDescription();		}		else		{			// use default		}		// property editors don't like nulls: they make the		// field readonly		return ret == null ? "" : ret;	}	public boolean isPropertySet(Object arg0)	{		// TODO Auto-generated method stub		return false;	}	public void resetPropertyValue(Object arg0)	{		// TODO Auto-generated method stub	}	public void setPropertyValue(Object name, Object value)	{		if (name.equals(PROPERTY_NAME))		{			item.setName((String) value);			item.setLastUpdated();		}		else if (name.equals(PROPERTY_DESCRIPTION))		{			item.setDescription((String) value);			item.setLastUpdated();		}		else		{			System.err.println("PasswordEntryPropertySource.setPropertyValue:"					+ " invalid property (" + name + ")");		}	}	public void fillPropertyDescriptors(			List<IPropertyDescriptor> propertyDescriptors)	{		for (int i = 0; i < PropertiesTable.length; i++)		{			// Add each property supported.			PropertyDescriptor descriptor;			descriptor = (PropertyDescriptor) PropertiesTable[i][1];						propertyDescriptors.add(descriptor);						descriptor.setCategory("Basic");		}			}	protected ManagerItem getItem()	{		return item;	}}

⌨️ 快捷键说明

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