{"id":150,"date":"2014-02-14T09:54:51","date_gmt":"2014-02-14T07:54:51","guid":{"rendered":"http:\/\/www.descher.at\/descher-vu\/?p=150"},"modified":"2014-02-14T09:57:21","modified_gmt":"2014-02-14T07:57:21","slug":"horizontal-extending-the-application-model-editor","status":"publish","type":"post","link":"http:\/\/www.descher.at\/descher-vu\/2014\/02\/horizontal-extending-the-application-model-editor\/","title":{"rendered":"Horizontal extending the application model editor"},"content":{"rendered":"<p>With <a href=\"http:\/\/git.eclipse.org\/c\/e4\/org.eclipse.e4.tools.git\/commit\/?id=618232e94a06cad2a6b921203fc3f0451cfe58ef\">this<\/a> commit the functionality to extend the <a href=\"https:\/\/marketplace.eclipse.org\/content\/eclipse-4-tools-application-model-editor\">Application model editor <\/a>is augmented to allow for <em>horizontal extension<\/em> of its elements. So what does this mean?<\/p>\n<p>Lars describes in his <a href=\"http:\/\/www.vogella.com\/tutorials\/EclipsePlatformDevelopment\/article.html#e4tools_editor\">tutorial<\/a> how to <em>vertically<\/em> extend the application model, that is, how to add additional model elements and provide a respective editor for it. But what if I want additional editing capabilities to already existing model elements like e.g. the command element?<\/p>\n<p>This is where the new extension point <em>org.eclipse.e4.tools.emf.ui.editors.editorTab<\/em> comes into play. The following image shows an example of the current usage within the <a href=\"https:\/\/github.com\/ecrit\/ecrit\">\u00c9crit<\/a> project:<\/p>\n<figure id=\"attachment_152\" aria-describedby=\"caption-attachment-152\" style=\"width: 757px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.descher.at\/descher-vu\/wp-content\/uploads\/2014\/02\/withoutAndWith.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-152\" alt=\"horizontal extension point with and without\" src=\"http:\/\/www.descher.at\/descher-vu\/wp-content\/uploads\/2014\/02\/withoutAndWith.png\" width=\"757\" height=\"304\" srcset=\"http:\/\/www.descher.at\/descher-vu\/wp-content\/uploads\/2014\/02\/withoutAndWith.png 1113w, http:\/\/www.descher.at\/descher-vu\/wp-content\/uploads\/2014\/02\/withoutAndWith-300x120.png 300w, http:\/\/www.descher.at\/descher-vu\/wp-content\/uploads\/2014\/02\/withoutAndWith-1024x411.png 1024w\" sizes=\"(max-width: 757px) 100vw, 757px\" \/><\/a><figcaption id=\"caption-attachment-152\" class=\"wp-caption-text\">horizontal extension point with and without<\/figcaption><\/figure>\n<p>We added the possibility to augment existing model elements with additional documentation artifacts &#8211; but this will become part of another blog (series) \ud83d\ude09<\/p>\n<p>Back to the extension point. In order to use it you have to first extend this new extension point, directing it to a class extending <em>org.eclipse.e4.tools.emf.ui.common.AbstractElementEditorContribution<\/em>:<\/p>\n<figure id=\"attachment_153\" aria-describedby=\"caption-attachment-153\" style=\"width: 647px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.descher.at\/descher-vu\/wp-content\/uploads\/2014\/02\/extPoint.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-153\" alt=\"editorTab EP\" src=\"http:\/\/www.descher.at\/descher-vu\/wp-content\/uploads\/2014\/02\/extPoint.png\" width=\"647\" height=\"89\" srcset=\"http:\/\/www.descher.at\/descher-vu\/wp-content\/uploads\/2014\/02\/extPoint.png 647w, http:\/\/www.descher.at\/descher-vu\/wp-content\/uploads\/2014\/02\/extPoint-300x41.png 300w\" sizes=\"(max-width: 647px) 100vw, 647px\" \/><\/a><figcaption id=\"caption-attachment-153\" class=\"wp-caption-text\">editorTab EP<\/figcaption><\/figure>\n<p>This class may look like<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nimport org.eclipse.core.databinding.observable.value.WritableValue;\r\nimport org.eclipse.core.resources.IProject;\r\nimport org.eclipse.e4.tools.emf.ui.common.AbstractElementEditorContribution;\r\nimport org.eclipse.e4.ui.model.application.commands.MCommand;\r\nimport org.eclipse.emf.databinding.EMFDataBindingContext;\r\nimport org.eclipse.emf.edit.domain.EditingDomain;\r\nimport org.eclipse.swt.widgets.Composite;\r\n\r\npublic class blaClass extends AbstractElementEditorContribution {\r\n\r\n@Override\r\npublic void createContributedEditorTab(Composite arg0,\r\nEMFDataBindingContext arg1, WritableValue arg2, EditingDomain arg3,\r\nIProject arg4) {\r\n\/\/ create the editor tab in here\r\n}\r\n\r\n@Override\r\npublic Class&lt;?&gt; getContributableTo() {\r\nreturn MCommand.class;\r\n}\r\n\r\n@Override\r\npublic String getTabLabel() {\r\nreturn &quot;myNewTab&quot;;\r\n}\r\n}\r\n<\/pre>\n<p>The <em>getContributableTo<\/em> denotes to what model elements the editorTab will be added (this is determined as you returned Class must be instanceof).<\/p>\n<p>If you want to have a look at a more specific example, take a look at the \u00c9crit <a href=\"https:\/\/github.com\/ecrit\/ecrit\/blob\/master\/at.ecrit.e4.tools.extension.core\/src\/at\/ecrit\/e4\/tools\/extension\/core\/EcritDocumentationElementEditorContribution.java\">implementation<\/a> of the extension point.<\/p>\n<p>Questions, comments? \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With this commit the functionality to extend the Application model editor is augmented to allow for horizontal extension of its elements. So what does this mean? Lars describes in his tutorial how to vertically extend the application model, that is, how to add additional model elements and provide a respective editor for it. But what &hellip; <a href=\"http:\/\/www.descher.at\/descher-vu\/2014\/02\/horizontal-extending-the-application-model-editor\/\" class=\"more-link\"><span class=\"screen-reader-text\">Horizontal extending the application model editor<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,4],"tags":[],"_links":{"self":[{"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/posts\/150"}],"collection":[{"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":6,"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":158,"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/posts\/150\/revisions\/158"}],"wp:attachment":[{"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.descher.at\/descher-vu\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}