0

I'm experimenting with eclipse 4 API. I try to contribute a new view with a plugin. What I have so far is:

An extension to org.eclipse.e4.workbench.model

<plugin>
   <extension id="id1" point="org.eclipse.e4.workbench.model">
      <fragment uri="fragment.e4xmi"></fragment>
   </extension>
</plugin>

The fragment.e4xmi

<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmi:id="_r_EgIEXDEeGuDquXwerIpw">
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_rC_ngEXFEeGuDquXwerIpw">
    <elements xsi:type="basic:Part" xmi:id="_sQq7kEXFEeGuDquXwerIpw" elementId="test.TestView2" contributionURI="platform:/plugin/test/test.TestView2" label="TestView2" tooltip="Test Test Test" closeable="true"/>
  </fragments>
</fragment:ModelFragments>

My view implementation:

package test;

import javax.inject.Inject;
import org.eclipse.e4.ui.di.Focus;

public class TestView2 {
    @Inject
    public TestView2() {
    }

    @Focus
    public void onFocus() {
    }
}

For some reason the view seems not to be contributed. Have I missed something? Do I need another thing to complete the puzzle? How can I debug the problem?

Edit:

I guess the problem is, that I do not have an Element Id nor a Featurename for my String Model Fragment. I guess I have to insert the ID of an PartStack and the children as Featurename. Problem: The editor does not show any elements in the wizard to select the Element Id ...

Kai
  • 38,985
  • 14
  • 88
  • 103
Arne Deutsch
  • 14,629
  • 5
  • 53
  • 72

1 Answers1

1

This might not be possible with the Eclipse 4.2 IDE.

As you noted, the Element ID and Feature must be set. By using the model editor (Alt+Shift+F9) you can see that the IDE uses an application ID of org.eclipse.e4.legacy.ide.application, so in principle you can follow the Lars Vogel tutorial to contribute for example a command, handler and menu entry to the IDE, and the command could then open your view.

While this works fine if you contribute to your own E4 application, it fails when you try to contribute to the Eclipse 4.2 IDE because of Bug 376486 - "Eclipse 4 IDE not extendable via fragments or processors".

As far as I understand, the problem is that the Eclipse 3 compatibility layer creates the E4 model in a way that you can then not add your own E4 fragments to it.

Benoit
  • 1,995
  • 1
  • 13
  • 18
Kay
  • 527
  • 2
  • 8
  • But in fact this would mean that the eclipse 4 ide is not extensible without the compability layer!? You can not contribute a view with the new API??? – Arne Deutsch Jul 03 '12 at 06:43
  • You can still extend it via the Eclipse 3 mechanisms: Define view or editor in plugin.xml. But you cannot add Eclipse 4 model fragments to the 4.2 IDE because it's using the compatibility layer. – Kay Jul 04 '12 at 21:06