Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [ve-dev] RE: Need Help

Dear VE Team:
 
Let me describe the ULC scenario with respect to the VE framework code.
 
We have a feature on ULC Component called "containment". Its value is set when we add a component to a conatiner.
 
Unlike in  Swing VE, we do not use an intermediate object (ConstratintComponent) to model conatiner. We directly set a ULCComponent to the structural feature "component" of a container. (please see the attached override files).
 
 
The generated code is as follows:
 
---------------------------------------------------------------------------
public class BlackBoard {
       private ULCFrame ulcFrame = null;  //  @jve:decl-index=0:visual-constraint="162,24"
     private ULCLabel ulcLabel = null;
 /**
  * This method initializes ulcFrame 
  *  
  * @return com.ulcjava.base.application.ULCFrame 
  */    
 
     private ULCFrame getUlcFrame() {
          if (ulcFrame == null) {
               ulcFrame = new ULCFrame();
               ulcFrame.setTitle("ULCFrame");
               ulcFrame.add(com.ulcjava.base.shared.IDefaults.BOX_EXPAND_EXPAND, getUlcLabel());
          }
          return ulcFrame;
     }

 /**
  * 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
 
---------------------------------------------------------------------------------------------------------
 

-----Original Message-----
From: ve-dev-admin@xxxxxxxxxxx [mailto:ve-dev-admin@xxxxxxxxxxx]On Behalf Of Dr Gili Mendel
Sent: Thursday, September 02, 2004 6:00 PM
To: ve-dev@xxxxxxxxxxx
Subject: Re: [ve-dev] RE: Need Help


In general every feature will have a decoder and _expression_ associated with it.  The question is not just on the top/down generation side, but what should be done bottom up... i.e.,
if you have no code associated with the feature, will you need to reCreate it  when you parse the code in and it that case how?

An example of this will be in the SWT case, where we have two features:   controls, allocation.

allocation, the feature that denotes how to instantiate the object and is related to the Constructor _expression_ for all JavaBeans

        MyControl = new MyControl(myShell, SWT.NONE);

The controls feature is the SWT feature that designate the container/child relationship (e.g., a button inside a composite), and will determine, within others, the z order of the child.

In some cases, if the Control is a composite we create an init method for the Control, so the control feature will be associated with the following _expression_:

private void createMyShell() {
       myShell = new Shell();        
         createMyControl() <------------------------  controls _expression_ will determine the z order
       

}


private void createMyControl() {
        .....
                MyControl = new MyControl(myShell, SWT.NONE);                        <--------------allocation _expression_ ... constructor feature and will be used by the target VM

}


In other cases, when the Control is not a composite, we will reUse the container's init method:


private void createMyShell() {
       myShell = new Shell();        
         MyControl = new MyControl(myShell, SWT.NONE);                        <--------------allocation _expression_
       

}


.... here we get a case where there is NO code associated with the controls feature, but we need to create it during parsing.... in the later case the allocation _expression_ drives the z order on behalf of the controls feature.


CodeGen does create a CodeExpressionRef for the control feature in the last case, but it marks it with the STATE_NO_SRC flag.

... this area is changing with https://bugs.eclipse.org/bugs/show_bug.cgi?id=72561 ... but check out the CompositeAddDecoderHelper.





The isChildValue() is being used to determine if the feature refers to a value that potentially have a instance variable or a local variable associated with it.






------------
Dr. Gili Mendel
IBM
Software Development
RTP Raleigh, NC
(919)543 6408, tie: 441 6408
 

Attachment: ULCWindow.override
Description: Binary data

Attachment: ULCComponent.override
Description: Binary data


Back to the top