UKLUG 2009 - Extending Domino Designer on Eclipse

1,423 views

Published on

These slides have been shown at UKLUG 2009 in Edinburgh and are an introduction to extending Domino Designer (formerly known as DDE).

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,423
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
25
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

UKLUG 2009 - Extending Domino Designer on Eclipse

  1. 1. Extending Domino Designer on Eclipse The new “R” in Rapid Application Development ?! Presenter: René Winkelmeyer Company: Partner Dialog
  2. 2. Beta information•  All the code is based on Notes 8.5.1 Managed Beta Refresh 2 (Code Drop 8).•  Every code is subject to change, there is no commitment when it ships or what functionality will ship.
  3. 3. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE with live demos and sample code•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  4. 4. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  5. 5. About me•  René Winkelmeyer•  (still) 31 years old•  Married, two dogs, two cats•  Consultant for Business Process Optimization and Domino Development at Partner Dialog Unternehmensberatung GmbH•  IBM Business Partner•  Using Notes/Domino since 4.57 (OS/2!)•  Member of IBMs Domino NEXT Design Partner program•  http://blog.winkelmeyer.com (really not well maintained)
  6. 6. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  7. 7. About you•  Anybody here with strong Java experience?•  Anybody here with strong Eclipse know-how?•  And what about strong Notes/Domino experience? ;-)•  That’s what I expected…•  At least you need a litte bit of everything. But don’t be afraid, it’s quite easy.
  8. 8. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  9. 9. What’s to expect from this session•  No hard-core dive into every corner of Eclipse•  No basic coding course for Java•  No coaching for using LotusScript related classes in Domino Java•  To see some samples about extending your favourite Application Development Tool•  To learn some do’s and don’ts
  10. 10. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  11. 11. Ingedrients to make you more productive (I)•  Domino Designer on Eclipse •  With Domino Designer 8.5 a new, powerful application was given to our hands. •  Yes – it was slow (some people said). •  But – the new features reimbursed everything.•  With Domino Designer 8.5.1 (don’t forget, GA date is 12.10.2009!) we even get more power •  A new LotusScript editor •  More XPages features •  … (just to name a few)
  12. 12. Ingredients to make you more productive (II)•  Java •  Language basics (data types, loops, if’s, casting…)•  Domino Java •  Just as you use them from within Domino•  Eclipse (currently Ganymede=3.4) •  Using the UI extension model (for menu items or key bindings) •  Most things would work through “copy&paste”•  SWT / JFace •  If you would like to make interactive interfaces
  13. 13. Ingredients to make you more productive (III)•  Lotus Expeditor (6.2.1 for Notes 8.5.1) •  see the Resources section for download and install information
  14. 14. Ingredients to make you more productive (III) •  Ideas •  Get information about the current Notes session •  Run an agent from within the agent editorwith live demos •  Remove the “Prohibit design refresh” flag from all design notes of a selected database •  Set all or single design element aliases automatically •  Set the design template name for a database - with a visually chosen source database •  Archive a selected design element – or restore it •  Push design elements to other databases •  Create a form based on your own wizard •  …
  15. 15. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  16. 16. Understanding how to extend the UI (I)•  Contributions to the ui are made through the plugin.xml•  The most known – and chosen – extension points of Eclipse are located in the package org.eclipse.ui.* menus actionsets (key) bindings …
  17. 17. Understanding how to extend the UI (II)•  UI menus are nice – but when they don’t call anything… nearly useless•  So we need “commands” and “handlers” •  “commands” are the second part of a plugin.xml definition •  they are called by a handler „myCommand“ „myUIMenu“ „myHandler“ „myBinding“
  18. 18. Understanding how to extend the UI (III)•  Create your menu modifications with the standard editor.•  You can edit the plugin.xml directly (I prefer that because not every setting is available through the user interface).
  19. 19. Understanding how to extend the UI (IV) The main category id The main categoryOne command <command– you can build category=„uklugCategory"up multiple of categoryId="com.winkelmeyer.uklug.dde.commandCategory"them within id="com.winkelmeyer.uklug.dde.sessioninformation"one plugin.xml name="1. Session information"> </command> Name of the command A unique identifier – please no existing names…
  20. 20. Understanding how to extend the UI (V) ID of the related command <command commandId="com.winkelmeyer.uklug.dde.sessioninformation" icon="icons/wizard.gif" Provide your own iconThat‘s a menu to enhance the uicommand. id="SessionInformation" label="1. Session information" style="push"> </command> Unique ID of this ui element Push the entry… ;-) That‘s how the user will see the menu entry
  21. 21. Understanding how to extend the UI (VI) The Java class name <handler A simple class="com.winkelmeyer.uklug.dde.SessionInformation" handler commandId="com.winkelmeyer.uklug.dde.sessioninformation"> </handler> ID of the command
  22. 22. Understanding how to extend the UI (VII) <handler class="com.winkelmeyer.uklug.dde.CreateView" commandId="com.winkelmeyer.uklug.dde.createview"> <enabledWhen> <with variable="selection">A litte bit more <test property=_complex handler. "com.ibm.designer.domino.ui.commons.extensions.numAndType" value="1,forms" forcePluginActivation="true"> </test> </with> </enabledWhen> In this case the </handler> menu item is only available, when one form is selected.
  23. 23. Understanding how to extend the UI (VIII)•  Excursion: Domino Designer specifics for design element selection.•  You can find all properties in the file “com.ibm.designer.domino.ui.commons_8.5.0.20090810-1007.jar” which is located directly in <NOTES>frameworksharedeclipseplugins.•  In example you can choose this properties: •  elementType: Specify the needed design element •  elementCount: Specifiy just the needed number of selected design elements •  numAndType: Specify number and type of the design elements•  Or </enabledWhen> items when any design element is selected, disregarding the count or type. enable the menu <reference definitionId="com.ibm.designer.domino.ui.commons.extensions.designElementSelected" /> </enabledWhen>
  24. 24. Understanding how to extend the UI (IX) <?eclipse version="3.2"?> <plugin> <extension point="org.eclipse.ui.commands"> <category id="com.winkelmeyer.uklug.dde.commandCategory" name="UKLUG Examples"> </category> <command category=„uklugCategory" categoryId="com.winkelmeyer.uklug.dde.commandCategory" id="com.winkelmeyer.uklug.dde.sessioninformation" name="1. Session information"> </command> </extension> <extension point="org.eclipse.ui.handlers"> <handler class="com.winkelmeyer.uklug.dde.SessionInformation" commandId="com.winkelmeyer.uklug.dde.sessioninformation"> </handler> </extension>
  25. 25. Understanding how to extend the UI (X) <extension point="org.eclipse.ui.menus"> <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions"> <menu id="com.winkelmeyer.uklug.dde.testselection" label="UKLUG Examples"> <command commandId="com.winkelmeyer.uklug.dde.sessioninformation" icon="icons/wizard.gif" id="SessionInformation" label="1. Session information" style="push"> </command> </menu> </menuContribution> </extension> </plugin>
  26. 26. Understanding how to extend the UI (XI) •  Extra bonus: key bindings <extension point="org.eclipse.ui.bindings"> <key commandId="com.winkelmeyer.uklug.dde.runagent"Make your ownkey bindings! schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" sequence="M2+A"> </key> </extension> That means „SHIFT+A“ for any operating system.
  27. 27. Understanding how to extend the UI (XII)•  Now you know everything to make your own menus.•  There are uncountable sites on the internet for more information, i. e. to make context-menus, toolbars and so on. More on that in the resources section.
  28. 28. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  29. 29. Using Domino Java within DDE (I)•  Using the Domino Java API from within DDE is the same as developing an Domino Java agent.•  This is not related to using the Designer Extensibility API. It’s just Domino Java development. DEMO 1 – Session information
  30. 30. Using Domino Java within DDE (II) public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell=HandlerUtil.getActiveShell(event); try { NotesThread.sinitThread();You always need try {a shell for GUI Session session = NotesFactory.createSession();interaction String sessionInformation = null; sessionInformation = "User: " + session.getCommonUserName() + NL +_ "Version: " + session.getNotesVersion() + NL + "Platform: " + _ session.getPlatform(); Standard MessageDialog.openInformation(shell, "Session information", _ Domino sessionInformation); Java code } catch (Exception e) { throw e; } finally { NotesThread.stermThread(); } A java dialog box } catch (Exception e) { e.printStackTrace(); } return null; }
  31. 31. Using Domino Java within DDE (III)•  Just do any Notes backend action you want – without any strong Java experience.•  Another example could be to run an agent. •  But wait – which agent do you want to run? •  I think you have to wait a little bit…
  32. 32. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  33. 33. Leveraging DDE with the Extensibility API (I)•  Domino Designer on Eclipse 8.5 has shipped with the new Designer Extensibility API. It maps between the Eclipse resources and the Notes design elements.•  With the Extensibility API you are allowed to gain the actual selected design element(s). And it doesn’t matter where you select it (in the app navigator or in the design element list).•  Now you can easily access i. e. the noteid of a selected design element.•  The API consists of these interfaces and classes: •  DesignerDesignElement – representing a single design element •  DesignerDesignElementSelection – representing a design element selection •  DesignerException – I think you know the word exception •  DesignerProject – every Notes app represents a single DesignerProject •  DesignerResource – the counter-part of an Eclipse IResource
  34. 34. Leveraging DDE with the Extensibility API (II)
  35. 35. Leveraging DDE with the Extensibility API (III)•  Step-by-step •  Think about an idea •  Add the required plug-ins to your plug-in project •  Prepare the UI stuff (remember the first chapters) •  Code your plug-in •  Have fun !!
  36. 36. Leveraging DDE with the Extensibility API (IV)•  The problem: running an agent from within Designer was always a little bit “tricky” •  Switch between Designer tabs was necessary (1-click) •  search the agent from the agent list •  select the agent context-menu (1-click) •  select “Run…” from the context-menu (1-click) •  click “OK” in the dialog (1-click) •  going back to the agent (1-click)•  The idea: running an agent via a custom menu item
  37. 37. Leveraging DDE with the Extensibility API (V)•  Add the required plug-ins to your plug-in project •  You need “com.ibm.designer.domino.ui.commons” and “com.ibm.designer.domino.ide.resources. Both are provided with the DDE installation. •  And other plug-ins, like com.ibm.notes.java.api for Domino Java.
  38. 38. Leveraging DDE with the Extensibility API (VI)•  Create the appropriate plugin.xml •  Watch out for the handler! <handler class="com.winkelmeyer.uklug.dde.RunAgent" Testing for count and type of commandId="com.winkelmeyer.uklug.dde.runagent"> the selected design element <enabledWhen> <with variable="selection"> <test property="com.ibm.designer.domino.ui.commons.extensions.numAndType" value="1,agents" forcePluginActivation="true"> </test> </with> </enabledWhen> It should be only available, </handler> when one agent is selected.
  39. 39. Leveraging DDE with the Extensibility API (VII)•  The Java class – Part one: creating the class public class RunAgent implements IHandler { As we are working with handlers we have to implement an IHandler. Eclipse will then add the unimplemented methods automatically.
  40. 40. Leveraging DDE with the Extensibility API (VIII) •  The Java class – Part two: getting the active selection public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window= HandlerUtil.getActiveWorkbenchWindow(event); ISelection selection = window.getSelectionService().getSelection(); // do your stuff hereThe currentEclipse return null;workbench } This selection represents the current selected Eclipse resource.
  41. 41. Leveraging DDE with the Extensibility API (IX) •  The Java class – Part three: moving the active Eclipse selection to the Extensibility API String serverName = null; String dbPath = null; DesignerDesignElementSelection ddes = DesignerResource.getDesignerSelection(selection);Just somevariables First time usage of the Extensibility API: Retrieve the ISelection element from Eclipse. Now we have the selection. But not the project or the elements…
  42. 42. Leveraging DDE with the Extensibility API (X) •  The Java class – Part four: getting the project and some project properties if (ddes.isDominoProjectSelected()) { try { DesignerProject dp = ddes.getSelectedDesignerProject(); serverName = dp.getServerName(); dbPath = dp.getDatabaseName();Being sure, that Get the DesignerProjectthere is a Assigning the server name and the from the selected designDomino project database path to the string vars. element. Hints: - The method „getDatabaseName“ returns the file path. There is no method „getFilePath“. - The method „getServerName“ returns null if the database is local.
  43. 43. Leveraging DDE with the Extensibility API (XI) •  The Java class – Part five: get the selected design element Get the DesignerProject from the selected design element. if (ddes.getDesignElementCount() == 1) { DesignerDesignElement elem; List<DesignerDesignElement> elems = ddes.getSelectedDesignElements(); elem = elems.get(0);Just a double- Put all selected Getting the first selectedcheck, as the design elements into design element.menu-item is a DesignElement list.only enabledwhen onedesign elementis selected.
  44. 44. Leveraging DDE with the Extensibility API (XII) •  The Java class – Part six: use some Domino Java code try { NotesThread.sinitThread(); try { Session sess = NotesFactory.createSession(); Get the element Database db = sess.getDatabase(serverName,dbPath); name, so we can Agent ag = db.getAgent(elem.getName()); choose the agent byThe database if (serverName!=null) { name.is not local, so if (ag.runOnServer() == 0) {we use MessageDialog.openInformation(shell, title, messageSuccess);runOnServer. } else { MessageDialog.openError(shell, title, messageError); } } else { ag.run(); MessageDialog.openInformation(shell, title, messageSuccess); }
  45. 45. Leveraging DDE with the Extensibility API (XIII) DEMO 2 – Run agent
  46. 46. Leveraging DDE with the Extensibility API (XIV)•  The problem: sometimes you forgot to remove the “ProhibitDesign” flag from design elements •  switch through all design elements (n-clicks) •  switch to the property view (n-clicks) •  disable the flag (n-clicks)•  The idea: remove that flag automatically from all design elements
  47. 47. Leveraging DDE with the Extensibility API (XV)•  The Java class – Part one: basic implementation public Object execute(ExecutionEvent event) { IWorkbenchWindow window= HandlerUtil.getActiveWorkbenchWindow(event); ISelection selection = window.getSelectionService().getSelection(); DesignerDesignElementSelection uisel=DesignerResource.getDesignerSelection(selection); DesignerProject designerProject = uisel.getSelectedDesignerProject(); You already know this stuff from the previous example.
  48. 48. Leveraging DDE with the Extensibility API (XVI)•  The Java class – Part two: retrieving the resource folder Assigning the IProject eclipseProject = designerProject.getProject(); Designer project IResource resMembers[]=null; to a standard try { Eclipse project. resMembers=eclipseProject.members(); } catch (CoreException e) { e.printStackTrace(); } Now all design elements of the DesignerProject are assigned to the IResource array.
  49. 49. Leveraging DDE with the Extensibility API (XVII)•  The Java class – Part three: retrieving the design element resources IResource resChilds[]=null; DesignerDesignElement dele=null; for(int i=0;i<resMembers.length;i++){ All design elements are if(resMembers[i]instanceof IFolder){ in their specific „folders“. IFolder folder = (IFolder)resMembers[i]; try { resChilds=null; This are the „real“ design resChilds=folder.members(); element resources
  50. 50. Leveraging DDE with the Extensibility API (XVIII)•  The Java class – Part three: iterating through the design elements for(int m=0;m<resChilds.length;m++){ Getting every if(resChilds[m]!=null) { single design dele = DesignerResource.getDesignElement(resChilds[m]); element from the if (dele.isProhibitRefresh()) { IResource array. dele.setProhibitRefresh(false); } } } And just remove the flag. Hint: - You can do that with Domino Java, too. But I don‘t want a Notes thread for this.
  51. 51. Leveraging DDE with the Extensibility API (XIX)•  The problem: I don’t want to set the alias manually •  You always have to think about your corporate standards •  sometimes you write something wrong•  The idea: just set the alias automatically for all design elements
  52. 52. Leveraging DDE with the Extensibility API (XX)•  The Java class – Part one: set the design element alias for(int m=0;m<resChilds.length;m++){ if(resChilds[m]!=null) { dele = DesignerResource.getDesignElement(resChilds[m]); if (isUsableDesignElement(dele)) { dele.setAlias(buildAliasName(dele)); } } } Use some custom classes
  53. 53. Leveraging DDE with the Extensibility API (XXI)•  The Java class – Part two: creating custom classes You MUST check null ! private boolean isUsableDesignElement(DesignerDesignElement deleUsable) { boolean retVal=false; if (deleUsable.getDesignElementType()!=null) { String delType = deleUsable.getDesignElementType(); if (delType.equals("metamodel.forms") || delType.equals("metamodel.views") || _ delType.equals("metamodel.outlines") || delType.equals("metamodel.framesets") || _ delType.equals("metamodel.agents")) { retVal=true; } } Watch out the „metamodel“, return retVal; use DesignerResource } constants, i. e. TYPE_AGENTS Specific: - If you don‘t have a specific design element in your database, you‘ll get a null value for that element type. - Every DesignElementType starts with „metamodel.type“. Care about that!
  54. 54. Leveraging DDE with the Extensibility API (XXII) Element name Element type ($AgentContexts) metamodel.views About Document metamodel.aboutdocument actions null AgentContext metamodel.forms AgentContexts metamodel.views Agents null Applets null Applications null no design element Columns null Components null Database Script metamodel.databasescript DataConnections null DB2AccessViews null dbprops metamodel.applicationproperties Fields null Files null Icon metamodel.icon Images null MasterView metamodel.views Navigators null Outlines null plugin null ScriptLibraries null no design element StyleSheets null Subforms null Themes null Using Document metamodel.usingdocument WEB-INF metamodel.webcontent WebServiceConsumer null WebServices null WiringProperties null
  55. 55. Leveraging DDE with the Extensibility API (XXIII) DEMO 3 – Set alias automatically
  56. 56. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  57. 57. Reaching the top – using GUI interaction (I)•  As you build user-friendly apps – there should be user friendly plug-ins in DDE, too!•  For that you should use SWT/JFace, as it’s the favourite GUI programming language for DDE.•  The best way to use a GUI is to use separate classes.
  58. 58. Reaching the top – using GUI interaction (II)•  The problem: changing the design template property always needs to leave the current app•  The idea: build a user interface for choosing the design template name DEMO 4 – Set design template name (visually)
  59. 59. Reaching the top – using GUI interaction (III)•  The problem: sometimes you change a design element – and want to undo that later •  Where to put the “old” design element? •  Not a real version tracking – just an archiving solution. •  And how to get it back? •  Always copy and paste?•  The idea: build a plug-in that archives and restores from and to another database
  60. 60. Reaching the top – using GUI interaction (IV)•  The archiving workflow •  get selected design element •  get the noteid of the design element •  get the design document by noteid •  copy the document – with some manipulated fields – to another database
  61. 61. Reaching the top – using GUI interaction (V)•  The restoring workflow •  get selected design element •  get the name of the design element •  search the name in the archiving database •  get the noteid of the archived design document •  copy the design document to the original database
  62. 62. Reaching the top – using GUI interaction (VI)•  Watch out when using DesignerDesignElement.getNoteId() !! •  elem.getNoteId() returns an int value! •  So you need to cast it into a hex string: Integer.toHexString(elem.getNoteId()); •  And this string must not have the needed length of 8! Please use a helper method. public String updateNoteID(String noteID) { for (int i=8-noteID.length();i<=8;i++) { noteID = "0"+noteID; } return noteID; }
  63. 63. Reaching the top – using GUI interaction (VII) DEMO 5 – Archive and restore design elements
  64. 64. Agenda•  About me•  About you•  What’s to expect from this session•  Ingredients to make you more productive•  Understanding how to extend the UI•  Using Domino Java within DDE•  Leveraging DDE with the Extensibility API•  Reaching the top – using GUI interaction•  Resources
  65. 65. Resources•  Books •  The Java Developer’s Guide to Eclipse, Addison Wesley •  Professional Java Native Interfaces with SWT/JFace, Wiley & Sons•  Internet •  http://lekkimworld.com, a very real good and well known Notes/Java blog •  http://www.vogella.de, everything you could find about RCP development – in English•  Code •  The JavaDoc of the Designer Extensibility API •  The source code of this session
  66. 66. Resources•  Tutorials •  Setting up Eclipse with the Expeditor Toolkit http://www-10.lotus.com/ldd/compappwiki.nsf/dx/setting-up-eclipse-and-the-expeditor-toolkit
  67. 67. Thank you! Thank you very much for attending my session ! René Winkelmeyer Questions and – hopefully good – answers can now be placed !

×