Your SlideShare is downloading. ×
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale Applications
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale Applications

1,147
views

Published on

How do you effectively control commands, menus and handlers in a large pluggable application to get a consistent use of the commands across the complete application? This is definitely one of the …

How do you effectively control commands, menus and handlers in a large pluggable application to get a consistent use of the commands across the complete application? This is definitely one of the areas where the Eclipse IDE is not a good sample application. Just notice how all team providers add commands with the same text and function and how multiple identical menu items some times show up...
Here the Adapter framework of Eclipse can be a big help if used properly.
While the Adapter framework arguably is one of the more difficult to understand and use properly, the is also a framework that will solve many of the problems you might face is larger non-trivial applications. Especially when used in conjunction with the menus extension point and handlers. This presentation will show how to use the adapter framework of the Eclipse framework with special emphasis on the menus and handlers.

Published in: Technology, Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,147
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
53
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • Before “checkEnabled” was implemented in Eclipse (3.3 I believe), you also had to specify a visibleWhen expression which was a or’ed together version of the activewhen expression for all relevant handlers. A difficult position\n
  • This often happens because the involved teams cannot\n
  • \n
  • This can entail all sorts of problems, where the top two are:\n- conflicts between the different involved interface - what is getNsme()\n- often you don’t want have you UI concerns and application functionality in your domain model - separation of concerns\n\n
  • Here we solve the problems by having a manager that can return the correct class given one of the domain objects and a wanted functionality\n\nThe participants:\n- The Adabtable Type: the types that can be adapted\n- The Adapter: the type that can be adapted to\n- Factory:entity that can adapt a specific adaptable type to a number of adapters\n- Manager: manager of factories\n\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Using Adapters to Handle Menus and Handlers inLarge Scale ApplicationsHow do you effectively control commands, menus and handlers in a large pluggableapplication to get a consistent use of the commands across the complete application?This is definitely one of the areas where the Eclipse IDE is not a good sample application.Just notice how all team providers add commands with the same text and function andhow multiple identical menu items some times show up...Here the Adapter framework of Eclipse can be a big help if used properly.While the Adapter framework arguably is one of the more difficult to understand and useproperly, the is also a framework that will solve many of the problems you might face islarger non-trivial applications. Especially when used in conjunction with the menusextension point and handlers. This presentation will show how to use the adapterframework of the Eclipse framework with special emphasis on the menus and handlers.Redistribution and other use of this material requires written permission from The RCP Company.L0001 - 2010-11-27
    • 2. The AgendaThe problem with commands andhandlers in large Eclipse basedapplicationsThe Adapter framework of EclipseHow to use the Adapter framework tosolve the problem with focus on theactual code used2 L0001 - 2010-11-27
    • 3. Complexity of Handler ExpressionsExpressions for handlers (activeWhen andenabledWhen) are often difficult to getcorrectIf the expression depends on internalstate a property tester is needed  The flow is more complicated  The tests get more involved3 L0001 - 2010-11-27
    • 4. The ProblemsIf we want to implement a specificcommand for a large number of differentdomain objects, then a large portion ofthe code for the handles will be identicalE.g. handlers for “cut”, “print”, connect”,etc4 L0001 - 2010-11-27
    • 5. The ProblemsMultiple - basically identical - commandsIn large enterprise applications, this isalmost impossible to manageHow about key bindings?5 L0001 - 2010-11-27
    • 6. The IdeaGiven  a specific object in the domain model (here a customer Benjamin”)  a command, we like to perform on the object (here “Show Segment”)...use the Adapter Manager of Eclipse toget the type specific behavior for theobjectIf no specific behavior can be found, thecommand is not activeUse the same method in the generichandler6 L0001 - 2010-11-27
    • 7. Why Adapters? UI Concerns Label Provider Domain Model Contact Tree Providers Content Providers Segment Customer Domain Model Contract Functionality Edit Print Offer Price Item Call Save7 L0001 - 2010-11-27
    • 8. Why Adapters? UI Concerns Label Provider Domain Model } Contact Tree Providers Content Providers Segment Customer Manager Domain Model Contract Functionality Edit Print Offer Price Item Call Save8 L0001 - 2010-11-27
    • 9. Adding AdaptersImplement the interface directlySub-class IAdaptableDeclare using org.eclipse.core.runtime.adaptersRegister directly at run-time <extension point="org.eclipse.core.runtime.adapters"> <factory adaptableType="com.rcpcompany.ex.adapterhandlers.model.Segment" class="com.rcpcompany.ex.adapterhandlers.adapters.SegmentAdapterFactory"> <adapter type="com.rcpcompany.ex.adapterhandlers.functionality.IDoShowSegment" /> </factory> </extension>9 L0001 - 2010-11-27
    • 10. The Code10 L0001 - 2010-11-27
    • 11. A Few Closing Remarks The way the adapt expression works, it is best to place the the adapter in the same plug-in as the domain model - see BugZilla #82973 for a long and complicated description for the background The adapt expression is going to be invoked often, so use stateless adapter object rather than stateful adapters to the same adapter object can be re- used Put the interfaces for the relevant functionality - e.g. IDoShowSegment - in a separate plug-in along with the declaration of the same commands11 L0001 - 2010-11-27
    • 12. Summing Up All handlers will have almost identical12 L0001 - 2010-11-27
    • 13. Resources This presentation is based on the same outline as the following blog entry  http://blog.rcp-company.com/2010/02/using-adapters-in-handlers-to- control.html13 L0001 - 2010-11-27
    • 14. About Me Tonny Madsen, Founder and Owner of The RCP Company  20 years of experience in system development in major companies  9 years of experience with Eclipse and Eclipse RCP Chairman of Eclipse.dk Extern Lecturer at IT-University on Model Driven Development and Domain Specific Languages Regular speaker at EclipseCon, Eclipse Summit Europe, Eclipse Summit India, etc Reached via  tonny.madsen@rcp-company.com  Phone: +45 70 22 25 92  Twitter: tonnymadsen  Blog: http://blog.rcp-company.com/  LinkedIn: http://linkedin.com/in/tonnymadsen14 L0001 - 2010-11-27