Is there a way to indicate a property default value in OEA?

Posted by jquerijero on 24-Nov-2009 11:41

This question is mostly concerned about the values that show on Property Grid at design-time. Normally if the value is bold, it means the value has been overwritten, and it will be added to the InitializeComponent code block.

When building base classes and custom controls/usercontrols, you want to be able to give a property a default value that OE Architect will treat as such and won't create an entry inside the InitializeComponent for a given property.

This way, you don't need to touch every file that uses the base class or usercontrol if you happen to change the default valure of the property later on.

All Replies

Posted by jquerijero on 01-Mar-2010 15:12

Looks like, this going to be fixed in 10.2B SP1

Posted by pkavuri on 04-Mar-2010 03:50

Yes - you can set default value to the Property. You can do this in the following manner.

DEFINE VARIABLE m_charProperty AS CHARACTER INITIAL "default"  NO-UNDO.

DEFINE PUBLIC PROPERTY TestProperty AS CHARACTER NO-UNDO
    GET():
        return m_charProperty.
    END GET.
    SET(INPUT arg AS CHARACTER):
        THIS-OBJECT:m_charProperty = arg.       
    END SET.

This propery will be shown in property grid, on selection, by defining this in usercontrol and use it on a form. It will be shown in normal format (not in bold) if  you dont change the property value and code will not get generated for this property in initializecomponent() method. It will be displayed in bold format if the value is different from default value and code will be generated. Currently Property grid has support for ABL scalar types and .NET Types  which have default type descriptors.

I have just tested this in 10.2B and it is working fine. Please let us know if you are seeing different behavior from this.

You also mentioned it may be fixed in 10.2B01. I dont find any bug for this. Did you file a support case for this? If so, can you share the WR#?

Thanks.

Phani

Posted by Admin on 04-Mar-2010 05:17

DEFINE VARIABLE m_charProperty AS CHARACTER INITIAL "default"  NO-UNDO.

Having to set the INITIAL value of the property to "default" in not very satisfying - at least for our use cases.

I wouldn't even call it a workaround.

Posted by Matt Baker on 04-Mar-2010 07:29

The correct syntax is this way:

DEFINE PUBLIC PROPERTY TestProperty AS CHARACTER NO-UNDO INIT "this is an example"
    GET.
    SET.

You can use this with any ABL primitive type that can be mapped to a  .NET type.  The important part is that you provided an INIT option on  the property and provide a value.  The presence of the INIT phrase tells the AVM to add the proper annotation to the .NET class.

Posted by jquerijero on 04-Mar-2010 08:56

Giving an initial value is not the main problem. The fact that the Property editor doesn't recognize it as such is the problem. When the value is in BOLD letters that means, the designer assumes that it is overwritten thus creating an entry in the InitializeComponent. When this happens, you can no longer propagate changes across your application if you happen to change your defualt value later on.

BUG #: OE00193019

Posted by Matt Baker on 04-Mar-2010 09:19

This works fine in 10.2B and the property grid displays the default value as bold if overwritten or not build if you have provided a default value using the INIT option.  This doesn't work in 10.2A FCS.  Make sure you are on latest service pack.

Note that this only works for "primitive" types such as character, integer and so on.  It does not work with any object type since the ABL can only use constant values in the INIT phrase.

Posted by jquerijero on 03-May-2010 10:20

Looks like full support of default property value will not be available soon.

Posted by Admin on 03-May-2010 10:31

Looks like full support of default property value will not be available soon.

Doesn't Matts workaround or solution work for you?

Posted by jquerijero on 03-May-2010 10:45

Works on primitive types.

Posted by Admin on 03-May-2010 11:21

Works on primitive types.

So you need it on properties of that reference .NET value types? (ABL value types are not shown in the property grid anyway). Like Enums?

Did you try ICustomTypeDescriptor?

This thread is closed