Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ve-dev] Codegen for GridBagConstraint

Hi Rich,

Here is the whole picture to help you to help me:

1. ULCContainer has SF "components" which takes ULCComponents. For this SF
"containment = false"

2. ULCComponents have SF "containment" which take Object which can be a
String or and object like GridBagConstraints (not awt's but our own) For
this SF "containment = true".

We donot use intermediate object for containment. We directly add children
to the container (SF components) and then set SF containment with the object
representing constraints.

So in the case of GridBagLayout, we want to generate a local var for the
constraint object GridBagConstraints.

3. In our case, when we add a label to a GridBagLayoutPane: we create two
commands:

set "components" SF of GridBagLayoutPane with value label - this is done
with a ruled command and has preset command).

set containment SF of label with a JavaInstance of GridBagConstraints
class (our own, not awt) - this is not done in a ruled command. I am not
sure if it should be.

4. Now when the Preset command is executed, it finds that label does not yet
have "containment" SF set with GridBagConstraints object (it will be set
after the second command is executed). So there is no question of of
promoting GridBagConstraints to LOCAL.

5. Suppose I somehow set GridBagConstraints on SF "containment" of label
before Preset command  (like you do it for your ConstraintComponent object),
even then GridBagConstraints object is not processed for promotion because
its eContainer() is not null. It is ULCLabel.

In your case eContainer() for GridBagConstraint is null. Therefore in
getMethod() and handleValue() methods of VCEPreset command you are able to
promote instance location.

6. So even if I set the annotation for BeanLocation on "containment" SF or
on the GridBagConstraints class itself it is never checked (by calling
settingType() method) because its eContainer() is never null!

I hope this clarifies the whole issue for you to suggest a solution for our
peculiar case.

Thanks and regards,

Janak





-----Original Message-----
From: ve-dev-bounces@xxxxxxxxxxx [mailto:ve-dev-bounces@xxxxxxxxxxx]On
Behalf Of Rich Kulp
Sent: Tuesday, July 12, 2005 2:21 AM
To: Discussions people developing code for the Visual Editor project
Subject: RE: [ve-dev] Codegen for GridBagConstraint



Hi Janak,

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.


Rich



Back to the top