?? propertyinfo.java
字號(hào):
/*
* 08/10/2005
*
* PropertyInfo.java - Information about a property.
* Copyright (C) 2005 Robert Futrell
* email@address.com
* www.website.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.fife.ui.propertysheet.infos;
import java.beans.PropertyDescriptor;
import org.fife.ui.propertysheet.InvalidPropertyValueException;
/**
* Information about a property.
*
* @author Robert Futrell
* @version 1.0
*/
public abstract class PropertyInfo implements Comparable {
private String name;
private String displayName;
private String description;
private String category;
private Object value;
private Object defaultValue;
private Object data;
private boolean modifiable;
private PropertyDescriptor propertyDescriptor; // Set only for JavaBeans.
/*****************************************************************************/
public PropertyInfo(String name, Object value,
Object defaultValue) {
this.name = name;
setDisplayName(name);
setValue(value);
setDefaultValue(defaultValue);
setModifiable(true);
}
/*****************************************************************************/
public int compareTo(Object o) {
int rc = -1;
if (o instanceof PropertyInfo) {
PropertyInfo info2 = (PropertyInfo)o;
rc = info2.getName().compareTo(getName());
}
return rc;
}
/*****************************************************************************/
public String getCategory() {
return category;
}
/*****************************************************************************/
public Object getData() {
return data;
}
/*****************************************************************************/
public Object getDefaultValue() {
return defaultValue;
}
/*****************************************************************************/
public String getDescription() {
return description;
}
/*****************************************************************************/
public String getDisplayName() {
return displayName!=null ? displayName : name;
}
/*****************************************************************************/
public String getName() {
return name;
}
/*****************************************************************************/
public PropertyDescriptor getPropertyDescriptor() {
return propertyDescriptor;
}
/*****************************************************************************/
public abstract Class getType();
/*****************************************************************************/
public Object getValue() {
return value;
}
/*****************************************************************************/
public boolean isModifiable() {
return modifiable;
}
/*****************************************************************************/
public void setCategory(String category) {
this.category = category;
}
/*****************************************************************************/
public void setData(Object data) {
this.data = data;
}
/*****************************************************************************/
public void setDefaultValue(Object defaultValue) {
validateValue(defaultValue);
this.defaultValue = defaultValue;
}
/*****************************************************************************/
public void setDescription(String description) {
this.description = description;
}
/*****************************************************************************/
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
/*****************************************************************************/
public void setModifiable(boolean modifiable) {
this.modifiable = modifiable;
}
/*****************************************************************************/
public void setPropertyDescriptor(PropertyDescriptor descriptor) {
this.propertyDescriptor = descriptor;
}
/*****************************************************************************/
public void setValue(Object value) {
validateValue(value);
this.value = value;
if (getDefaultValue()==null) {
setDefaultValue(value);
}
}
/*****************************************************************************/
protected abstract void validateValue(Object value)
throws InvalidPropertyValueException;
/*****************************************************************************/
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -