objectsupport.java
字号:
package piy.support;
import piy.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.awt.Dimension;
import java.beans.*;
/**
* Support for properties of the Object type. All Object properties need to be bound to another
* Property property in the same holder. The way an object property is bound to another is by
* having a <code>get<PropertyName>Binding()</code> method. That is, if the object property
* is called <code>Value</code> then there must be a method called <code>getValueBinding()</code>.
* The method should return a String representing the property name the object property depends
* upon. This class needs to be told the reference of the class support that has been set up
* for its pair. <p>
* Note: The object property will be given a FixedProperty object as its value - to get the
* actual value, FixedProperty.getActualValue() should be used.
* @author David Vivash
* @version 1.0.1, 26/03/01
*/
public class ObjectSupport extends ClassSupport implements PropertyChangeListener
{
ClassSupport support = null;
public ObjectSupport(Property property) {
super(property);
setLayout(new BorderLayout());
}
public void setPairSupport(ClassSupport pair) {
pair.addPropertyChangeListener(this);
setup(new Property(null, null, ((Property)pair.getProperty().getValue()).getType()), false);
}
public static Class getSupportedClass() { return Object.class; }
public Dimension getMinimumSize() { return support == null ? new Dimension(10, 40) : support.getMinimumSize(); }
public Dimension getPreferredSize() { return support == null ? new Dimension(100, 40) : support.getPreferredSize(); }
public Dimension getMaximumSize() { return support == null ? new Dimension(10000, 40) : support.getMaximumSize(); }
public void propertyChange(PropertyChangeEvent e) {
removeAll();
Property value = (Property)e.getNewValue();
property.setValue(new FixedProperty(null, value.getType()));
ProjectHandler.getInstance().projectChanged();
setup(value, true);
}
private void setup(Property value, boolean validate) {
if (value != null)
if (value.getType() != null) {
Object newVal = property.getValue();
if (!(newVal instanceof FixedProperty)) {
newVal = new FixedProperty(null, value.getType());
property.setValue(newVal);
}
support = new FixedPropertySupport(property);
if (support != null) add(support, BorderLayout.CENTER);
if (validate) {
getParent().validate();
getParent().repaint();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -