The setting of the field is done here
in VCEPresetCommand:
protected
InstanceLocation settingType(EObject property, EStructuralFeature feature)
{
// First see if the property has an annotation
with the location set.
Annotation annotation = domain.getAnnotationLinkagePolicy().getAnnotation(property);
if (annotation != null) {
InstanceLocation
il = (InstanceLocation) annotation.getKeyedValues().get(BEAN_LOCATION_KEY);
if (il
!= null)
return il;
}
// Next check if the feature has it set.
// We may not have a feature if we are the
target of the entire command (and not the value being set).
BeanFeatureDecorator bfd = feature != null
? (BeanFeatureDecorator) CDEUtilities.findDecorator(feature, BeanFeatureDecorator.class)
: null;
if (bfd != null && bfd.isSetBeanLocation())
return
bfd.getBeanLocation();
For some reason it is not getting here
or you didn't set the BeanFeatureDecorator correctly, or you aren't using
the VCEPresetCommand for some reason.
As for the second question you have
three ways to set the instance location in this order:
Set it on the annotation of
the instance. This is hard to do and it is on a per-instance basis.
Set it on the feature that is
being set. Then it uses the location from the BeanFeatureDecorator.
Set it on the JavaClass. This
will then do it for all instances of the class. (But if the GridBagConstraint
you are using here is the AWT one, then you can't do this because you would
then mess up everyone who is not ULC since it is a global setting).
Default it. In this case it
will do property setting (i.e. new XYZ() right in the set method), or make
it a variable if there is at least one sub-property setting on it.