/**
* This method initializes ulcLabel
*
* @return com.ulcjava.base.application.ULCLabel
*/
private ULCLabel getUlcLabel()
{
if (ulcLabel == null) {
ulcLabel = new
ULCLabel();
ulcLabel.setText("ULCLabel");
}
return
ulcLabel;
}
}
---------------------------------------------------------------------------------------
For ULCLabel we have a SF containment which has a string value
com.ulcjava.base.shared.IDefaults.BOX_EXPAND_EXPAND.
"ulcFrame.add(com.ulcjava.base.shared.IDefaults.BOX_EXPAND_EXPAND,
getUlcLabel());" is generated for the SF "component" of ULCFrame when it is set
to ULCLabel.
We
donot want to generate any code while setting this value on the SF
containment. However we would like this SF to be present in the
model.
So
from BeanDecoder.setElement() (while setting the SF containment with string) the
following is called:
--------------------------------------------------------------------------
//
Need to generate an _expression_
ExpressionRefFactory eGen = new
ExpressionRefFactory(fBean, (EStructuralFeature)
msg.getFeature());
try {
CodeExpressionRef
exp = eGen.createFromJVEModel(args);
if (exp !=
null)
exp.insertContentToDocument();
}
--------------------------------------------------------------------------------
We do
not have an ExpressionDecoder for ULCComponent, therefore while setting the
SF containment to the string IDefaults.BOX_EXPAND_EXPAND, the
code generator defaults to ObjectDecoder and
ChildRelationshipDecoderHelper. But the generate of
ChildRelationshipDecoderHelper returns null, so it defaults to
SimpleAttributeDecoderHelper.generate() which also returns null. (see the
code below from
AbstractExpressionDecoder.generate()):
-------------------------------------------------------------------------------------
public
String generate(EStructuralFeature feature, Object[] args) throws
CodeGenException {
if (!Initialize(feature))
return
null;
if (isImplicit(args) &&
!fhelper.isGenerateOnImplicit())
return
null;
// Go for it
String result = null;
try
{
result = fhelper.generate(args);
} catch
(CodeGenException e) {
}
if
(fExprRef.isStateSet(CodeExpressionRef.STATE_NO_SRC))
{
fhelper.adaptToCompositionModel(this);
return
result ;
}
if (result == null && !(fhelper instanceof
SimpleAttributeDecoderHelper)) {
// Specialized decoder may
not be applicable, try a vanilla one
fhelper = new
SimpleAttributeDecoderHelper(fbeanPart, fExpr, fFeatureMapper,
this);
JavaVEPlugin.log("generate(): *Defaulting* to
a SimpleAttr. Helper", Level.FINE); //$NON-NLS-1$
result =
fhelper.generate(args);
}
if (result != null)
{
fExprRef.setState(CodeExpressionRef.STATE_EXIST,
true);
fExprRef.setState(CodeExpressionRef.STATE_IN_SYNC,
true);
fhelper.adaptToCompositionModel(this);
}
else
{
fExprRef.dispose();
}
return
result;
}
-----------------------------------------------------------------------------
So
while setting the SF containment, result = null. which results in dispose().
1.
Earlier (VE 0.5.0) dispose() used to do only unadaptToComposition, but now it
does deleteFromModel thus removing the SF containment from the ULCLabel. Why is
the deleteFromModel done now?
2.
dispose() sets STATE_DELETE on the CodeExprRef, while the
createJVEModel checks for NO_SRC as follows:
---------------------------------------------------
exp.generateSource(fSF);
if ((!exp.isAnyStateSet()) ||
exp.isStateSet(CodeExpressionRef.STATE_NO_SRC))
return exp ;
---------------
And then in
BeanDecoder.setElem():
------------
//
Need to generate an _expression_
ExpressionRefFactory eGen = new
ExpressionRefFactory(fBean, (EStructuralFeature)
msg.getFeature());
try {
CodeExpressionRef
exp = eGen.createFromJVEModel(args);
if (exp !=
null)
exp.insertContentToDocument();
}
----------------------------------
The
insertContent does a check on STATE_NO_SRC. However, since the state
is STATE_DELETE exprn, insertContent tries to insert code and there are
exceptions.
Should
dispose() also set state to NO_SRC in addition to DELETE? Is this a
bug?
3.
what is the significance of isImplicit for a Decoderhelper? It appears that it
stands for SF that is in model but has no source. But, in VE code it always
returns false.?
Thanks
and regards,
Janak
---------------------------------------------------------------------------------------------------------