How to contribute to the Eclipse IDE from a model fragment

有些话、适合烂在心里 提交于 2019-12-11 11:08:53

问题


I need to contribute a part (with a command and handler) to the eclipse IDE.

I'm using Eclipse RCP and RAP developers (Mars 4.5) and I don't know how to program my handler so my part goes to the editor of the eclipse ide.

My part contributor is something like this:

public class Menu extends ViewPart {

@PostConstruct
@Override
public void createPartControl(Composite parent) {
    parent.setLayout(null);

    Label lblService = new Label(parent, SWT.NONE);
    lblService.setBounds(67, 49, 40, 15);
    lblService.setText("Service:");

    Combo combo = new Combo(parent, SWT.NONE);
    combo.setBounds(112, 45, 213, 23);

    Label lblOperacion = new Label(parent, SWT.NONE);
    lblOperacion.setBounds(51, 97, 56, 15);
    lblOperacion.setText("Operation:");

    Combo combo_1 = new Combo(parent, SWT.NONE);
    combo_1.setBounds(112, 93, 214, 23);

    Label lblRequest = new Label(parent, SWT.NONE);
    lblRequest.setBounds(62, 145, 45, 15);
    lblRequest.setText("Request:");

    Combo combo_2 = new Combo(parent, SWT.NONE);
    combo_2.setBounds(112, 141, 213, 23);

    Button btnCommandButton = new Button(parent, SWT.NONE);
    btnCommandButton.setBounds(223, 189, 108, 25);
    btnCommandButton.setText("Command Button");     
}

@Override
public void setFocus() {
    // TODO Auto-generated method stub

}

I already know how to contribute to another aplication but not to the eclipse ide. If someone could help me or give me some ideas, maybe a web page with tutorial of this or something...

EDIT: ok, i found someone who ask almost the same question here:How to contribute a new view in eclipse 4.2?

No one give a solution beacuse of the bug, but now the bug its fixed in 4.5.

My plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
    <extension
         id="py.com.leverit.gepetto.services.tester.fragment"
         point="org.eclipse.e4.workbench.model">
      <fragment
            uri="fragment.e4xmi">
      </fragment>
   </extension>
</plugin>

My fragment.e4xmi:

<?xml version="1.0" encoding="ASCII"?>
    <fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_HszDYEDxEeWo0NbVsB9ULA">
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_PCMHIEDyEeWo0NbVsB9ULA" featurename="children" parentElementId="menu:org.eclipse.ui.main.menu" positionInList="first">
    <elements xsi:type="menu:Menu" xmi:id="_H5DcEEEEEeWo0NbVsB9ULA" elementId="py.com.leverit.gepetto.services.tester.menu.menucontributor" label="MenuContributor" iconURI="platform:/plugin/py.com.leverit.gepetto.services.tester/icons/sample.png">
      <children xsi:type="menu:HandledMenuItem" xmi:id="_LkmgwEEEEeWo0NbVsB9ULA" elementId="py.com.leverit.gepetto.services.tester.handledmenuitem.view" label="View" command="_XWhHQEESEeWsyKfsIG3sSg"/>
    </elements>
  </fragments>
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_NWq7UEEEEeWo0NbVsB9ULA" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application" positionInList="">
    <elements xsi:type="commands:Handler" xmi:id="_Jgr_4EESEeWsyKfsIG3sSg" elementId="py.com.leverit.gepetto.services.tester.handler.tester" contributionURI="bundleclass://py.com.leverit.gepetto.services.tester/py.com.leverit.gepetto.services.tester.handler.TesterHandler" command="_XWhHQEESEeWsyKfsIG3sSg"/>
  </fragments>
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_VIr9wEESEeWsyKfsIG3sSg" featurename="coomand" parentElementId="org.eclipse.e4.legacy.ide.application">
    <elements xsi:type="commands:Command" xmi:id="_XWhHQEESEeWsyKfsIG3sSg" elementId="py.com.leverit.gepetto.services.tester.command.tester" commandName="tester"/>
  </fragments>
</fragment:ModelFragments>

EDIT2: Ok, i found exactly what i need to do, it was in front of my eyes the whole time. If someone come here for the same thing can go to http://www.vogella.com/tutorials/EclipsePlugIn/article.html#plugin_ideextensionsintroducion

来源:https://stackoverflow.com/questions/31971488/how-to-contribute-to-the-eclipse-ide-from-a-model-fragment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!