Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

TMF meets GMF

765 Aufrufe

Veröffentlicht am

Talk at EclipseCon Europe 2011, Ludwigsburg, Germany

Veröffentlicht in: Software
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

TMF meets GMF

  1. 1. TMF meets GMF Combining Graphical & Textual Modeling Alexander Nyßen itemis AG Donnerstag, 3. November 2011
  2. 2. Simultaneous/Parallel Editing • http://www.eclipse.org/Xtext/documentation/2_0_0/210- emf-integration.php • A. Mülder, A. Nyßen: TMF meets GMF. Eclipse Magazin 03/2011 (German) Donnerstag, 3. November 2011
  3. 3. Simultaneous/Parallel Editing • http://www.eclipse.org/Xtext/documentation/2_0_0/210- emf-integration.php • A. Mülder, A. Nyßen: TMF meets GMF. Eclipse Magazin 03/2011 (German) Out of Scope here! Donnerstag, 3. November 2011
  4. 4. Editing Embedded-Xtext Donnerstag, 3. November 2011
  5. 5. Editing Embedded-Xtext Donnerstag, 3. November 2011
  6. 6. Editing Embedded-Xtext Enable editing of Xtext-strings Donnerstag, 3. November 2011
  7. 7. Editing Embedded-Xtext Enable editing of Xtext-strings, providing all the nice Xtext-features like syntax coloring, content assist, and validation Donnerstag, 3. November 2011
  8. 8. Editing Embedded-Xtext Enable editing of Xtext-strings, providing all the nice Xtext-features like syntax coloring, content assist, and validation, outside an Xtext-editor within the following contexts: • SWT/JFace: enable editing of Xtext-strings e.g. within WizardPages or PropertySheets. • GEF/GMF (and potentially Graphiti): enable „direct- editing“ of Xtext-strings from within graphical editors. Donnerstag, 3. November 2011
  9. 9. So, let‘s start with looking at SWT/JFace! Donnerstag, 3. November 2011
  10. 10. Xtext-JFace-Integration • StyledTextXtextAdapter to adapt Xtext-editing functionality to any StyledText (SWT control) • XtextStyledTextCellEditor to enable Xtext-editing within arbitrary JFaceViewers (using StyledText and XtextAdapter) Donnerstag, 3. November 2011
  11. 11. Adapter & CellEditor Usage • StyledTextXtextAdapter can easily be „hooked“ to any StyledText • XtextStyledTextCellEditor can be used transparently as any JFace CellEditor (it adapts internally) StyledText styledText = new StyledText(parent, style); xtextAdapter = new StyledTextXtextAdapter(getInjector()); xtextAdapter.adapt(styledText); xtextCellEditor = new XtextStyledTextCellEditor(style, getInjector()); xtextCellEditor.create((Composite)viewer.getControl()); Donnerstag, 3. November 2011
  12. 12. Xtext-JFace-Integration • Syntax Highlighting: • Auto Completion: • Validation: ✓ ✓ ✓ Donnerstag, 3. November 2011
  13. 13. And how to integrate Xtext with GEF/GMF? Donnerstag, 3. November 2011
  14. 14. Direct-Editing Embedded-Xtext • GEF-integration: • XtextDirectEditManager, internally making use of the Xtext- StyledTextCellEditor • GMF-integration: • XtextLabelEditPart (CompartmentEditPart) • ExternalXtextLabelEditPart (LabelEditPart) Donnerstag, 3. November 2011
  15. 15. DirectEditManager Usage protected void performDirectEditRequest(final Request request) { final XtextDirectEditManager manager = new XtextDirectEditManager(this, getInjector(), getEditorStyles()); try { getEditingDomain().runExclusive(new Runnable() { public void run() { ... manager.show(); ... } }); } catch (final InterruptedException e) {...} } • XtextDirectEditManager can be transparently used as any GEF DirectEditManager: Donnerstag, 3. November 2011
  16. 16. Editing Embedded-Xtext Donnerstag, 3. November 2011
  17. 17. And how does it work? Donnerstag, 3. November 2011
  18. 18. PropertySection Donnerstag, 3. November 2011
  19. 19. PropertySection Donnerstag, 3. November 2011
  20. 20. PropertySection PropertySection Donnerstag, 3. November 2011
  21. 21. PropertySection PropertySection Input Object Property Donnerstag, 3. November 2011
  22. 22. PropertySection PropertySection PropertyPage Text (SWT) Input Object Property Donnerstag, 3. November 2011
  23. 23. PropertySection PropertySection PropertyPage Text (SWT) Input Object Property Donnerstag, 3. November 2011
  24. 24. Xtext-Editor Donnerstag, 3. November 2011
  25. 25. Xtext-Editor Donnerstag, 3. November 2011
  26. 26. Xtext-Editor XtextEditor Donnerstag, 3. November 2011
  27. 27. Xtext-Editor XtextEditor XtextDocument XtextResource Donnerstag, 3. November 2011
  28. 28. Xtext-Editor XtextEditor XtextDocument XtextSourceViewer StyledText (SWT) XtextResource Donnerstag, 3. November 2011
  29. 29. Xtext-Editor XtextEditor XtextDocument XtextSourceViewer StyledText (SWT) XtextResource Donnerstag, 3. November 2011
  30. 30. Xtext-JFace-Integration -The Principle Donnerstag, 3. November 2011
  31. 31. Xtext-JFace-Integration -The Principle Donnerstag, 3. November 2011
  32. 32. PropertySection PropertyPage Text (SWT) Xtext-JFace-Integration -The Principle Input Object Property Donnerstag, 3. November 2011
  33. 33. PropertySection PropertyPage Text (SWT)StyledText (SWT) Xtext-JFace-Integration -The Principle Input Object Property Donnerstag, 3. November 2011
  34. 34. PropertySection PropertyPage Text (SWT)StyledText (SWT) Xtext-JFace-Integration -The Principle Input Object PropertyXtext-String Donnerstag, 3. November 2011
  35. 35. PropertySection PropertyPage Text (SWT)StyledText (SWT) Xtext-JFace-Integration -The Principle Input Object PropertyXtext-String Donnerstag, 3. November 2011
  36. 36. PropertySection PropertyPage Text (SWT)StyledText (SWT) XtextEditor XtextDocument XtextSourceViewer StyledText (SWT) Xtext-JFace-Integration -The Principle XtextResource Input Object PropertyXtext-String Donnerstag, 3. November 2011
  37. 37. PropertySection PropertyPage Text (SWT)StyledText (SWT) XtextDocument XtextSourceViewer StyledText (SWT) Xtext-JFace-Integration -The Principle XtextResource Input Object PropertyXtext-String Donnerstag, 3. November 2011
  38. 38. PropertySection PropertyPage Text (SWT)StyledText (SWT) StyledTextXtextAdapter XtextDocument XtextSourceViewer StyledText (SWT) Xtext-JFace-Integration -The Principle XtextResource Input Object PropertyXtext-String Donnerstag, 3. November 2011
  39. 39. PropertySection PropertyPage Text (SWT)StyledText (SWT) StyledTextXtextAdapter XtextDocument XtextSourceViewer Xtext-JFace-Integration -The Principle XtextResource Input Object PropertyXtext-String StyledText (SWT) Donnerstag, 3. November 2011
  40. 40. PropertySection PropertyPage Text (SWT)StyledText (SWT) StyledTextXtextAdapter XtextDocument XtextSourceViewer Xtext-JFace-Integration -The Principle Input Object (Fake-)XtextResourcePropertyXtext-String StyledText (SWT) Donnerstag, 3. November 2011
  41. 41. And what about scoping? Donnerstag, 3. November 2011
  42. 42. Scoping in Xtext • When resolving cross-references scoping decides which elements (of potentially different resources) are referable Donnerstag, 3. November 2011
  43. 43. Scoping in Xtext • When resolving cross-references scoping decides which elements (of potentially different resources) are referable Donnerstag, 3. November 2011
  44. 44. Scoping in Xtext (continued) • Xtext distincs two notions of scope: • Local Scope (internal to the context resource) • Global Scope (external to the context resource) • Global Scope is based on ResourceDescriptions which are provided by an indexing mechanism (Xtext builder) • XtextEditors are dirty-aware, i.e. their current editing state is proclamated to the ResourceDescriptions Donnerstag, 3. November 2011
  45. 45. Scoping in Embedded Xtext? Donnerstag, 3. November 2011
  46. 46. Scoping in Embedded Xtext? Donnerstag, 3. November 2011
  47. 47. Fake-XtextResource The Fake-XtextResource used by the XtextAdapter does only contain the currently edited Xtext-String, not any other contents of the context resource Local scope will allow us to refer to elements in the edited Xtext-String, but not outside Global scope will allow to reference external elements, but by default context resource contents is not proclamated to the global scope Donnerstag, 3. November 2011
  48. 48. Scoping based on Fake Resources • Sophisticated Solution: • Expose all Xtext-Strings contained within context resource to ResourceDescriptions „dirty-state aware“ • Simple Solution: • Populate the Fake-Xtext-Resource‘s ResourceSet with other Fake-Context-Resources (e.g. one for each Xtext-String) Donnerstag, 3. November 2011
  49. 49. StyledTextXtextAdapter IFakeContextResourcesProvider XtextDocument XtextSourceViewer StyledText (SWT) Fake-XtextResource Donnerstag, 3. November 2011
  50. 50. StyledTextXtextAdapter IFakeContextResourcesProvider XtextDocument XtextSourceViewer StyledText (SWT) Fake-ResourceSet Fake-XtextResource Donnerstag, 3. November 2011
  51. 51. StyledTextXtextAdapterIXtextFakeContext ResourcesProvider IFakeContextResourcesProvider XtextDocument XtextSourceViewer StyledText (SWT) Fake-ResourceSet Fake-XtextResource Donnerstag, 3. November 2011
  52. 52. StyledTextXtextAdapterIXtextFakeContext ResourcesProvider IFakeContextResourcesProvider XtextDocument XtextSourceViewer StyledText (SWT) Fake-ResourceSet Fake-XtextResource Context-Fake Resource (1) Donnerstag, 3. November 2011
  53. 53. StyledTextXtextAdapterIXtextFakeContext ResourcesProvider IFakeContextResourcesProvider XtextDocument XtextSourceViewer StyledText (SWT) Fake-ResourceSet Fake-XtextResource Context-Fake Resource (2) Context-Fake Resource (1) Donnerstag, 3. November 2011
  54. 54. StyledTextXtextAdapterIXtextFakeContext ResourcesProvider IFakeContextResourcesProvider XtextDocument XtextSourceViewer StyledText (SWT) Fake-ResourceSet Fake-XtextResource Context-Fake Resource(n) Context-Fake Resource (2) Context-Fake Resource (1) ... Donnerstag, 3. November 2011
  55. 55. Populating Fake Resource Set • IXtextContextFakeResourcesProvider allows to populate the fake ResourceSet: IXtextFakeContextResourcesProvider provider = new IXtextFakeContextResourcesProvider(){ public void populateFakeResourceSet( ResourceSet fakeResourceSet, XtextResource fakeResource){ // create context fake resources via given resource set ... } }; xtextAdapter = new StyledTextXtextAdapter(getInjector(), provider); xtextAdapter.adapt(styledText); Donnerstag, 3. November 2011
  56. 56. And where can I get it? Donnerstag, 3. November 2011
  57. 57. Xtext-Integration @Yakindu • Xtext-JFace-Integration and Xtext-GMF-Integration is made available by theYAKINDU project • Open Source / EPL • Project Site: http://yakindu.org • Eclipse Labs Site: http://code.google.com/a/eclipselabs.org/p/yakindu/ • Update Site: http://updates.yakindu.com/indigo/milestones/ • Source Code: http://svn.codespot.com/a/eclipselabs.org/yakindu/BASE/trunk/ de.itemis.xtext.utils Donnerstag, 3. November 2011
  58. 58. ThankYou! Questions? Donnerstag, 3. November 2011

×