1 / 19

Where OO meets the GUI for .NET

Session 135. Where OO meets the GUI for .NET. It’s new, it’s different, it’s still just ABL. Peter Judge Principal Software Engineer OpenEdge Development. What is the GUI for .NET?. Who does what?. OpenEdge Built-in Progress.* classes do the ABL-to-.NET talking

Télécharger la présentation

Where OO meets the GUI for .NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Session 135 Where OO meets the GUI for .NET It’s new, it’s different, it’s still just ABL Peter Judge Principal Software Engineer OpenEdge Development

  2. What is the GUI for .NET?

  3. Who does what? • OpenEdge • Built-in Progress.* classes do the ABL-to-.NET talking • All ABL classes inherit Progress.Lang.Object • All .NET classes inherit System.Object … which also inherits Progress.Lang.Object • You • Composition of UI • UI logic • Business logic procedures or classes (on AppServer)

  4. Building blocks used by Demo • .NET Controls • OpenEdge built-ins • Progress.Windows.FormProgress.Windows.UserControl • Progress.Data.BindingSource • MicrosoftSystem.Windows.FormsTextBox & LabelDataGridViewTreeViewSplitContainerPanelGroupBox • OOABL Classes • MainForm • ItemUserControl • DepartmentDataObjectCustomerDataObject SalesrepDataObject Sports2000

  5. If you can read this, we survived the demo

  6. Form design • Start with static nodes • Easy resizing & layout • Multiple UI elements share ABL data • Compose complex controls: ABL User Controls

  7. ProBindingSource:Binding UI controls to ProDataSet data ProDataSet • Set DataSource, DataMember on dataGridOrder • Set BindingSourceProp on Item detail UserControl eCustomer eOrder eOrderLine dataGridOrder:DataMember = "eOrder". dataGridOrder:DataSource = bsCustomer. ucItems1:BindingSourceProp = bsCustomer. eItem ItemNum edtItemNum:DataBindings:Add(new Binding( "Text", BindingSourceProp, "eOrder.eOrderLine.eItem.ItemNum")).

  8. Interacting with the .NET UI:Handling UI events method private InitializeComponent(): /* lotsa stuff */ treeView1:NodeMouseClick:subscribe(treeView1_NodeMouseClick). methodprivatevoid treeview1_NodeMouseClick( sender as System.Object, e as TreeNodeMouseClickEventArgs ): System.EventArgs Empty : System.EventArgs System.Windows.Forms.MouseEventArgs Button : MouseButtons Clicks : integer System.Windows.Forms.TreeNodeMouseClickEventArgs Node : TreeNode

  9. Interacting with the .NET UI:tree node click event handler using System.Windows.Forms.*. methodprivatevoid tree1_NodeMouseClick( sender asSystem.Object, e asTreeNodeMouseClickEventArgs ): /* Deal with top level (zero-based) */ if e:Node:Level eq0then do: cNodeName = e:Node:Name. /* only create the children once. */ if e:Node:Nodes:Count eq0then casecNodeName: when'CustomerNode' then do: CreateCustomerNodes(). DecorateCustomerNodes(). end./* customer */ • Everything’s an object • e:Node - Just Like Any Other Node Object • Chained calls • Call ABL node creation method • Using USING Makes Life Easier!

  10. CreateCustomerNodes() method defvaroParent, oNodeasTreeNode. oData = GetCustomerData(). hBuffer = oData:DatasetHandle :get-buffer-handle('eCustomer'). bsCustomer:Handle = oData:DatasetHandle. oParent = treeView1:Nodes:Item['CustomerNode']. /* create ABL query, set buffers */ hQuery:query-prepare ('preselecteacheCustomerbyName'). hQuery:query-open(). hQuery:get-first(). dowhilehBuffer:available: cKey = hBuffer::CustNum. cText = hBuffer::Name. oNode = oParent:Nodes:Add(cKey, cText). oNode:Tag = 'Some extra info'. • oData contains filled ProDataSet • DatasetHandle property same as handle variable • BindingSource uses ProDataSet • Nodes property collection of Node objects • Query stuff is all standardABL • Can work on new node

  11. DecorateCustomerNodes() method defvaroCustomerNodesasTreeNodeCollection. oCustomerNodes = treeView1:Nodes['CustomerNode']:Nodes. doiLoop = 0tooCustomerNodes:Count - 1: oNode = oCustomerNodes[iLoop]. /* hBuffer from oData, as earlier */ hBuffer:find-unique( ' where CustNum = ' + quoter(oNode:Name)). dPercent = hBuffer::Balance / hBuffer::CreditLimit * 100. ifdPercent > 90then oNode:BackColor = System.Drawing.Color:Red. • Get node by name or by index • Zero-based counting • Standard ABL query finds data to manipulate .NET UI • Node colour based on business rules

  12. Customer data binding • OneBindingSource binds to oneProDataSet providing multi-level data to UI controls • Automatic “linkednavigation” via ProDataSet data-relations • WICKEDcool, no? CustomerBindingSource Orders OrderLines Items

  13. ProBindingSource: Binding UI controls to an ABL query • Not using ProDataSets? Use a query instead • Can even query PDS data • Always single-level to UI • Provides data to multiple controls SalesrepBindingSource createqueryhQuery. hQuery:query-prepare('for each eSalesrep'). bsSalesrep:Handle = hQuery.

  14. Sorting the DataGridView • Standard event handler signature • Sorting location depends on control, could be on grid or BindingSource • Identity is not equality • Build standard ABL query off event args • Easily make this generic methodvoidBindingSource_SortRequest( sender asSystem.Object, easProgress.Data.SortRequestEventArgs): ifsender:Equals(bsSalesrep) then do: hQuery = bsSalesrep:Handle. cSortBy = ' by ' + e:FieldName. ifnot e:Ascending then cSortBy = cSortBy + ' desc '. hQuery:query-prepare ('for each eSalesrep ' + cSortBy). hQuery:query-open(). end. end method.

  15. Alternate controls: same data, same business logic, much prettier, different & more features • Microsoft controls do the basics • Vendor-specific functionality • Grouping, multi-column sorting, multi-level browsing • Filters, aggregates • Themes / skins • Presentation layer design opportunity: OERA, MVP et al

  16. What you see is .NET, what you get is ABL • .NET … • Paints stuff on screen • Fires UI events : Click, Resize, Sort • ABL … • Works with data • Temp-tables, queries, ProDataSets • Built-in ProBindingSource talks both ways • Handles UI events • Invokes methods & classes, set properties • Same on all types: OO ABL and .NET

  17. Where can I learn more? • Right here at ExchangeOnlineOhNine • Shelley Chase’s Introducing OpenEdge GUI for .NET • Alex Herbstritt’s Advanced OO Techniques • Niels Bredegaard’s Tales from the Trenches: Using the GUI for .NET • OpenEdge Documentation’s Getting Started books • Object Oriented Programming • Introducing the OpenEdge Architect Visual Designer • GUI for .NET Mapping Reference • GUI for .NET Programming • OpenEdge Architect : Class browser, help files, etc • Progress Communities discussions (forums) • 3rd party control vendors’ documentation, support, forums • MSDN

  18. Conclusion • Pretty easy, right? • It’s Just ABL … and you’re all experts in ABL • From the ABL, you don’t care if it’s .NET

  19. Peter Judge Principal Software Engineer, OpenEdge Development pjudge@progress.com

More Related