Visual Designer generates custom class code, is there a way to disable this??

First of all, this isn't really iMo related but it's something that will affect everybody so I post this here in hope to find a solution (i couldn't find something on google)

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. This is the same result as the Roundtrip engineering (like the InputField)


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?????

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
stefan's picture

repository based ui-generation

Hallo Rob,

I suggest you ask this question at http://communities.progress.com/pcom/community/psdn/openedge/gui4dotnet?... as answers are interesting for others outside the imo-usersgroup too. Besides the group is not very responsive as I experienced several times. :-(
A big step forward in iMo (and OE Architect itself!) would be repository based generation of the ui (in developmentmode and runtime). Mike Fechner, a member of this group, knows all about it, he built dynamics4dotnet. That would be the ideal way to stop the visual designer producing redundant code. Just use visual designer ++ instead of the old one.
While working with progress 9.1D I recognized the problem with the appbuilder. I built my own screenpainter, if you like to see a small presentation: http://www.slideshare.net/stefan.houtzager/developing-the-developmentkit....

Kind regards, Stefan.

stefan's picture

no time

As you see, within no time you get an answer on this. What you need on a forum is not a critical mass (thats more atomic bomb theory) but active members (Mike Fechner is one of the most active members on that forum)!