문제

I'm trying to build an RCP application with Eclipse 4.2.

First problem; I have a TreeViewer. When an item is selected in the tree viewer, I need one of two stacked MParts to be displayed. How do I activate a part in a part stack in e4?

Second; I have a context menu associated with one of my parts. I need the menu to appear only when certain composites are right clicked. I have a mouse down handler that is adding an object with all the data I need into the current context (IEclipseContext), but I don't know how to access that from a CoreExpression (which seems to be the only real way to control the visibility of the menu). The object is removed from the context on mouse up. Say my class is RightClickData. How do I write a core expression to test whether an instance of RightClickData exists in the current context?

Edit, part of my Application.e4xmi:

        <children xsi:type="basic:InputPart" xmi:id="_6nSEEJuhEeGpoZf9DvK6pQ" elementId="com.example.MyEditor" contributionURI="bundleclass://MyPlugin/com.example.MyEditor" label="The Editor" tooltip="My Editor">
          <menus xsi:type="menu:PopupMenu" xmi:id="_UdHPEJ4SEeGi0uxvOaa4gw" elementId="MyPlugin.rsmenu" label="Asdf" tooltip="asdf">
            <children xsi:type="menu:HandledMenuItem" xmi:id="_jwOz0J4SEeGi0uxvOaa4gw" label="Add Column" command="_fhTxwJ4REeGi0uxvOaa4gw"/>
            <children xsi:type="menu:HandledMenuItem" xmi:id="_trlpsJ4SEeGi0uxvOaa4gw" label="Delete Column" command="_iAIkoJ4REeGi0uxvOaa4gw"/>
            <children xsi:type="menu:MenuSeparator" xmi:id="_v8f8YJ4SEeGi0uxvOaa4gw"/>
            <children xsi:type="menu:HandledMenuItem" xmi:id="_wR7Z0J4SEeGi0uxvOaa4gw" label="Add Row" command="_bXrp8J4REeGi0uxvOaa4gw"/>
            <children xsi:type="menu:HandledMenuItem" xmi:id="_yf5GMJ4SEeGi0uxvOaa4gw" label="Delete Row" command="_l58HwJ4REeGi0uxvOaa4gw"/>
          </menus>
        </children>
도움이 되었습니까?

해결책

For your first question, you can use org.eclipse.e4.ui.workbench.modeling.EPartService.activate(MPart) to activate the part you want.

다른 팁

I make visible my parts like this:

MPart part = partService.findPart("my.part.id");
if( part != null ){
    if( part.isVisible() == false )
        part.setVisible(true);
    partService.showPart( part, PartState.VISIBLE);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top