Rajesh Kumar Dash
Rajesh Kumar Dash

Reputation: 2277

How to add action item to the coolbar of e4 eclipse rcp application?

I am currently trying to port my eclipse 3 rcp application to e4.The major hurdle I am facing is to use action item which i was using in e3.In eclipse 3 application i was creating action item of coolbar by extending action.The code was looking like below spinets.

public class Testaction extends Action  {

  private IWorkbenchWindow window;


  public Testaction (IWorkbenchWindow window, String string) {
    setText(string);
    setToolTipText(string);
    setId("ID");

    setImageDescriptor(Activator.getImageDescriptor("/icons/some.png")); 

    this.window = window;
  }


  @override
  public void run() {
  /**
Do something
**/
super.run();
    }

was adding it to coolbar through

toolbar.add(demoaction);

But with e4 this part seems to be changed and I understand that there we need to have annotation @Execute which will excute the contribution which we will be giving through setcontribuitionuri as below snippet

  part.setContributionURI(
          "bundleclass://bundle/bundle.contribuitionclass"); 

I just want to know whether I can use my old action class here or i need to port everything to newer style . Any help on this will be appreciated.Thanks in advance...

Upvotes: 0

Views: 421

Answers (1)

greg-449
greg-449

Reputation: 111216

e4 does not support Actions for model elements in the Application.e4xmi.

The simplest conversion is to use a Direct ToolItem in the tool bar. However using a Handled ToolItem with a Command and Handler is more flexible.

In either case the Image, Label and Tooltip are specified in the Application.e4xmi.

Upvotes: 1

Related Questions