Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Cause an unsettable EInt attribute to be unset by default?
Cause an unsettable EInt attribute to be unset by default? [message #1142338] Thu, 17 October 2013 15:00 Go to next message
Eclipse UserFriend
Hello everybody.

In E4 we have a modelled UI. Our Window class has 4 integer attributes to represent the x, y, height, and width of the window. We'd like to make these unsettable by default. When unset, they default to wherever the OS chooses to place the window; when set, they are used to force the window bounds.

Is there any way to modify the .ecore to cause these fields to default to an unset state? Or do I have to modify the generated WindowImpl to set the appropriate __ESet variables?

	/**
	 * The default value of the '{@link #getX() <em>X</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getX()
	 * @generated
	 * @ordered
	 */
	protected static final int X_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getX() <em>X</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getX()
	 * @generated
	 * @ordered
	 */
	protected int x = X_EDEFAULT;

	/**
	 * This is true if the X attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean xESet;


Thanks!

Brian.
Re: Cause an unsettable EInt attribute to be unset by default? [message #1142366 is a reply to message #1142338] Thu, 17 October 2013 15:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Make sure the features are Unsettable.

Make sure the Default Value Literal is really blank; (Use the Restore
Default Value icon/command otherwise you get the empty string rather
than null).

Regards

Ed Willink


On 17/10/2013 16:00, Brian de Alwis wrote:
> Hello everybody.
>
> In E4 we have a modelled UI. Our Window class has 4 integer
> attributes to represent the x, y, height, and width of the window.
> We'd like to make these unsettable by default. When unset, they
> default to wherever the OS chooses to place the window; when set, they
> are used to force the window bounds.
>
> Is there any way to modify the .ecore to cause these fields to default
> to an unset state? Or do I have to modify the generated WindowImpl to
> set the appropriate __ESet variables?
>
>
> /**
> * The default value of the '{@link #getX() <em>X</em>}' attribute.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @see #getX()
> * @generated
> * @ordered
> */
> protected static final int X_EDEFAULT = 0;
>
> /**
> * The cached value of the '{@link #getX() <em>X</em>}' attribute.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @see #getX()
> * @generated
> * @ordered
> */
> protected int x = X_EDEFAULT;
>
> /**
> * This is true if the X attribute has been set.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> * @ordered
> */
> protected boolean xESet;
>
>
> Thanks!
>
> Brian.
Re: Cause an unsettable EInt attribute to be unset by default? [message #1142421 is a reply to message #1142366] Thu, 17 October 2013 16:07 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the reply Ed. I had already done what you suggested (I should have included the extract from the .ecore), but it makes no difference. I suspect it's because EInts have a default of 0, and not null like a reference object.

        <eStructuralFeatures xsi:type="ecore:EAttribute" name="x" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
            unsettable="true">
          <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
            <details key="documentation" value="&lt;p>&#xD;&#xA;The 'X' position of this window&#xD;&#xA;&lt;/p>"/>
          </eAnnotations>
        </eStructuralFeatures>


Brian.
Re: Cause an unsettable EInt attribute to be unset by default? [message #1142499 is a reply to message #1142421] Thu, 17 October 2013 17:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

/**
* This is true if the X attribute has been set.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
protected boolean xESet;

You had it right all along. There is an XESet variable whose default is
false. The EInt obviously has all 2^32 valid values so the extra not-set
has to be handled by an extra boolean.

Regards

Ed Willink


On 17/10/2013 17:07, Brian de Alwis wrote:
> Thanks for the reply Ed. I had already done what you suggested (I
> should have included the extract from the .ecore), but it makes no
> difference. I suspect it's because EInts have a default of 0, and not
> null like a reference object.
>
>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="x"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
> unsettable="true">
> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
> <details key="documentation" value="<p>
> The 'X' position of this window
> </p>"/>
> </eAnnotations>
> </eStructuralFeatures>
>
>
> Brian.
Re: Cause an unsettable EInt attribute to be unset by default? [message #1142527 is a reply to message #1142499] Thu, 17 October 2013 17:39 Go to previous message
Eclipse UserFriend
Oops, I really should brush up on my default initializations, as
protected boolean xESet;

defaults to false. Sorry for the noise.

Brian.
Previous Topic:IllegalValueException when loading model with recommended performance options
Next Topic: [CDO] Offline update of CDO objects
Goto Forum:
  


Current Time: Fri Apr 26 02:31:15 GMT 2024

Powered by FUDForum. Page generated in 0.03211 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top