Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>While I agree that this seems a little strange to have the default editor be different for the same file based on the open perspective, here is how you could do it.</p> <ol> <li>Create two new Content Type extensions</li> <li>Register your first editor as default editor for 1st new Content Type</li> <li>Register your 2nd editor as the default editor for the 2nd new Content Type</li> <li>For each content type, you have a 'content type describer'. In these describer classes, have it check the active workbench page for the current perspective ID and if it matches the expected value, then VALID, if perspective id doesn't match, return INVALID.</li> <li>For both editors you need to associate those editors with a content-type instead of a file-extension or filename</li> <li>Now only one content type will match at a time depending on which perspective is open. Make sure that one of the content types is the 'default' so that it will always match if the user has some other perspective open.</li> </ol> <p><strong>Update #1 added some examples</strong></p> <p>There are some <a href="http://www.developer.com/java/data/article.php/3648736/Eclipse-Tip-Define-Custom-Content-Types-to-Identify-Your-Data-Files.htm" rel="nofollow">online</a> <a href="http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/guide/runtime_content_contributing.htm?cp=2_0_3_4_1" rel="nofollow">tutorials</a> for this. But here is some example code to make it easier to see what work is required. Here is how you declare your content types (you would need two of them)</p> <pre><code>&lt;plugin&gt; &lt;extension point="org.eclipse.core.contenttype.contentTypes"&gt; &lt;content-type base-type="org.eclipse.core.runtime.xml" describer="com.liferay.ide.core.FirstContentTypeDescriber" id="com.liferay.ide.core.contentType1" name="First Content Type" priority="normal"&gt; &lt;/content-type&gt; &lt;/extension&gt; &lt;/plugin&gt; </code></pre> <p>Then in the Describer class you would do your matching logic. Then in the editor extension point you reference a content type instead of a file-name or extension like this:</p> <pre><code> &lt;extension point="org.eclipse.ui.editors"&gt; &lt;editor class="com.liferay.ide.ui.FirstEditor" default="false" id="com.liferay.ide.ui.editor1" name="My First Editor"&gt; &lt;contentTypeBinding contentTypeId="com.liferay.ide.core.firstContentType"&gt; &lt;/contentTypeBinding&gt; &lt;/editor&gt; &lt;/extension&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload