| 86 | |
| 87 | * Write a new ItemPropertyDescriptor for B: |
| 88 | {{{ |
| 89 | |
| 90 | public class ImagePropertyDescriptor extends ItemPropertyDescriptor { |
| 91 | |
| 92 | EStructuralFeature feature; |
| 93 | |
| 94 | public ImagePropertyDescriptor(AdapterFactory adapterFactory, |
| 95 | ResourceLocator resourceLocator, String displayName, |
| 96 | String description, EStructuralFeature feature, boolean isSettable, |
| 97 | boolean multiLine, boolean sortChoices, Object staticImage, |
| 98 | String category, String[] filterFlags) { |
| 99 | super(adapterFactory, resourceLocator, displayName, description, feature, |
| 100 | isSettable, multiLine, sortChoices, staticImage, category, filterFlags); |
| 101 | this.feature = feature; |
| 102 | } |
| 103 | |
| 104 | // here you decide what data of B is displayed in property view for A |
| 105 | @Override |
| 106 | protected Object getValue(EObject object, EStructuralFeature feature) { |
| 107 | Object propertyObject = object.eGet(feature); |
| 108 | if (propertyObject == null) return ""; |
| 109 | if (propertyObject instanceof Image) |
| 110 | { |
| 111 | String path = ((Image) propertyObject).getImagePath(); |
| 112 | return path; |
| 113 | } |
| 114 | return super.getValue(object, feature); |
| 115 | } |
| 116 | |
| 117 | // this is how to handle the input from the file chooser |
| 118 | @Override |
| 119 | public void setPropertyValue(Object object, Object value) { |
| 120 | if (object instanceof EObject) |
| 121 | { |
| 122 | EObject eobject = (EObject) object; |
| 123 | Image backgroundImage = ExhibitionFactory.eINSTANCE.createImage(); |
| 124 | backgroundImage.setImagePath(value.toString()); |
| 125 | eobject.eSet(feature, backgroundImage); |
| 126 | return; |
| 127 | } |
| 128 | super.setPropertyValue(object, value); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | } |
| 133 | }}} |