VCEPreSetCommand is responsible for
the scoping of Java elements that are added to the JEM model. It
has four possible scopes:
GLOBAL_GLOBAL - This is an instance
variable and it also has its own method that initializes and returns it.
(value = 2)
GLOBAL_LOCAL - This is
an instance variable, but it is initialized in the method that initializes
the parent (value = 3)
LOCAL
- This is local to the method that uses
the object (value = 1)
PROPERTY
- There is no instance variable and it is a method argument
(value = 0)
Right now the decision of the scope
is hard coded. For example, the code in VCEPresSetCommand right now
hard codes AWT and SWT to scope in a particular way.
protectedint
settingType(EObject property) {
if
(classAWTComponent.isInstance(property))
return
GLOBAL_GLOBAL;
// Hard
code AWT components to be global and globally initialized (in their own
getJavaBean() method)
elseif(classSWTShell
!= null
&& classSWTShell.isInstance(property))
return
GLOBAL_GLOBAL;
elseif
(classSWTControl != null
&& classSWTControl.isInstance(property))
return
GLOBAL_LOCAL;
// Hard
code SWT controls to be globally declared and initialized in their parent
method
else return
PROPERTY;
}
We need to make this more flexible.
For one thing It means the ve.java package has knowledge of AWT and
SWT (which should be described just their respective jfc and swt plugins),
and for another it means that other people like Canoo cannot leverage the
logic.
Proposal:
Introduce an Enum property on org.eclipse.ve.internal.jcm.BeanFeatureDecorator
called scope.
Introduce an Enum property on org.eclipse.ve.internal.jcm.BeanDecorator
called scope.
The logic in VCEPreSetCommand would
be to check the BeanDecorator scope of the newValue and use this. If
it wasn't set then the BeanFeatureDecorator of the feature would be used.
If neither were present then the default would be PROPERTY;
Examples:
All AWT components are scoped in their
own method - java/awt/Component.override
The default for everyone who doesn't
have a scope is "property". For anyone else who has their
own custom parent/child relationship they can override the scope on a per
class or per relationship basis.