Visual Designer generates custom class code, is there a way

Posted by Rob Motmans on 05-Jan-2010 05:25

Here an example:


USING Progress.Lang.*.

CLASS TestVisDes.CustomTestField inherits Infragistics.Win.UltraWinEditors.UltraTextEditor:

DEFINE PUBLIC PROPERTY FieldValue AS CHARACTER NO-UNDO
GET.
SET.

END CLASS.

--> A custom UltraTextEditor with one property in it

I created a form and placed a control on it and changed the data type to TestVisDes.CustomTestField.


USING Progress.Lang.*.
USING Progress.Windows.Form.

CLASS TestVisDes.FormViaCode INHERITS Form   :

DEFINE PRIVATE VARIABLE components AS System.ComponentModel.IContainer NO-UNDO.

DEFINE PRIVATE VARIABLE ultraTextEditor1 AS TestVisDes.CustomTestField NO-UNDO.

CONSTRUCTOR PUBLIC FormViaCode (  ):

SUPER().
InitializeComponent().
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.

END CONSTRUCTOR.

METHOD PRIVATE VOID InitializeComponent(  ):

/* NOTE: The following method is automatically generated.

We strongly suggest that the contents of this method only be modified using the
Visual Designer to avoid any incompatible modifications.

Modifying the contents of this method using a code editor will invalidate any support for this file. */
THIS-OBJECT:ultraTextEditor1 = NEW TestVisDes.CustomTestField().
CAST(THIS-OBJECT:ultraTextEditor1, System.ComponentModel.ISupportInitialize):BeginInit().
THIS-OBJECT:SuspendLayout().
/*  */
/* ultraTextEditor1 */
/*  */
THIS-OBJECT:ultraTextEditor1:Location = NEW System.Drawing.Point(93, 102).
THIS-OBJECT:ultraTextEditor1:Name = "ultraTextEditor1".
THIS-OBJECT:ultraTextEditor1:Size = NEW System.Drawing.Size(100, 21).
THIS-OBJECT:ultraTextEditor1:TabIndex = 0.
THIS-OBJECT:ultraTextEditor1:Text = "ultraTextEditor1".
/*  */
/* FormViaCode */
/*  */
THIS-OBJECT:ClientSize = NEW System.Drawing.Size(292, 266).
THIS-OBJECT:Controls:Add(THIS-OBJECT:ultraTextEditor1).
THIS-OBJECT:Name = "FormViaCode".
THIS-OBJECT:Text = "FormViaCode".
CAST(THIS-OBJECT:ultraTextEditor1, System.ComponentModel.ISupportInitialize):EndInit().
THIS-OBJECT:ResumeLayout(FALSE).
THIS-OBJECT:PerformLayout().
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END METHOD.

DESTRUCTOR PUBLIC FormViaCode ( ):
IF VALID-OBJECT(components) THEN DO:
CAST(components, System.IDisposable):Dispose().
END.
END DESTRUCTOR.
END CLASS.

As long as you don’t open the visual designer, everything stays this way.

But when you open it with the visual designer, it automatically implements all the properties from the custom control (in bold).
I really don’t want this behaviour and this for following reasons:
- it generates lots of extra code that you don’t always want
- the properties get initialized with the default value, but what’s the point of that, it also has the default value without adding the property to the code
- it basically takes away the functionality to group some behaviour in a custom class that you don’t always want to use in a form or usercontrol (it’s not an option to make the property private)


USING Progress.Lang.*.
USING Progress.Windows.Form.

CLASS TestVisDes.FormViaVisDes INHERITS Form   :

DEFINE PRIVATE VARIABLE components AS System.ComponentModel.IContainer NO-UNDO.
DEFINE PRIVATE VARIABLE ultraTextEditor1 AS TestVisDes.CustomTestField NO-UNDO.

CONSTRUCTOR PUBLIC FormViaVisDes (  ):
SUPER().
InitializeComponent().
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END CONSTRUCTOR.
METHOD PRIVATE VOID InitializeComponent(  ):

/* NOTE: The following method is automatically generated.

We strongly suggest that the contents of this method only be modified using the
Visual Designer to avoid any incompatible modifications.

Modifying the contents of this method using a code editor will invalidate any support for this file. */
THIS-OBJECT:ultraTextEditor1 = NEW TestVisDes.CustomTestField().
CAST(THIS-OBJECT:ultraTextEditor1, System.ComponentModel.ISupportInitialize):BeginInit().
THIS-OBJECT:SuspendLayout().
/*  */
/* ultraTextEditor1 */
/*  */
THIS-OBJECT:ultraTextEditor1:FieldValue = "".
THIS-OBJECT:ultraTextEditor1:Location = NEW System.Drawing.Point(102, 85).
THIS-OBJECT:ultraTextEditor1:Name = "ultraTextEditor1".
THIS-OBJECT:ultraTextEditor1:Size = NEW System.Drawing.Size(100, 21).
THIS-OBJECT:ultraTextEditor1:TabIndex = 0.
THIS-OBJECT:ultraTextEditor1:Text = "ultraTextEditor1".
/*  */
/* FormViaVisDes */
/*  */
THIS-OBJECT:ClientSize = NEW System.Drawing.Size(292, 266).
THIS-OBJECT:Controls:Add(THIS-OBJECT:ultraTextEditor1).
THIS-OBJECT:Name = "FormViaVisDes".
THIS-OBJECT:Text = "FormViaVisDes".
CAST(THIS-OBJECT:ultraTextEditor1, System.ComponentModel.ISupportInitialize):EndInit().
THIS-OBJECT:ResumeLayout(FALSE).
THIS-OBJECT:PerformLayout().
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END METHOD.

DESTRUCTOR PUBLIC FormViaVisDes ( ):
IF VALID-OBJECT(components) THEN DO:
CAST(components, System.IDisposable):Dispose().
END.
END DESTRUCTOR.
END CLASS.

--> Is there any way to disable this?????

I know how this is done in C#

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string FieldValue
{
    get { return ...; }
    set { ... = value; }
}

All Replies

Posted by Admin on 06-Jan-2010 02:07

--> Is there any way to disable this?????

I know how this is done in C#

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string FieldValue
{
    get { return ...; }
    set { ... = value; }
}

The ABL does not support similar annotations in the source code. I guess that's time for an ERS entry :-)

But for similar reasons (but I want to disable this only for some properties of ABL UserControls and Inherited Controls) I'm experimenting with the System.ComponentModel.ICustomTypeDescriptor interface and the System.ComponentModel.TypeDescriptor static class. In your case you might try if the inhereted Control returns the Type information (Attributes, Properties and Events) from the base type in the methods required by ICustomTypeDescriptor.

As said before: I'm just exerimenting right now... Don't want to call this a recommendation, just a hint.

Posted by jquerijero on 25-Jan-2010 10:19

This is cause by the fact that there is still no way to designate a default property value in OE GUI for .NET that the designer can see as such. I have asked for enhancement, but I'm not so sure how important to Progress they see this issue.

Posted by Shelley Chase on 26-Jan-2010 10:36

To effectively use all of the .NET declarative programming features ABL will need to support code annotations. This is a very large development effort. As a result I do not believe it's a matter of importantance but a matter of prioritization with other requirements, bugs and enhancement requests.

-Shelley

Posted by jquerijero on 26-Jan-2010 11:44

The urgency of at least implementing the default value will grow as the number of CLS files written by a company. I'm just saying that this can not go on to the backlog way too long. As the time passes by, the number of CLS files that a programmer have to touch to implement a new default will grow and grow. This will eventually affect Progress customer's development cycle as doing such process will become time intensive/prohibitive.

This thread is closed