Contributing to the Status Bar/Trim in Eclipse RCP

跟風遠走 提交于 2019-11-30 20:48:06

In the org.eclipse.ui.menuContributions extensions, use "toolbar:org.eclipse.ui.trim.status" as the locationURI. You can contribute commands/custom controls to the status bar.

VonC

A possible solution to check:
You should be able to define a fragment in order to be able to add to the core product functionality. (see here for another example).

The idea is to add functionality to the core plugin. May be your contribution can then merged to that main product that way.

Firstly, adding status bar to application.e4xmi (Application > Windows and Dialogs > Trimmed Window > TrimBars > WindowTrim (Bottom) > Toolbar > Tool Control)

Create .java class and give address in toolbar (class uri).

e4 status bar implementation is different than e3 implementation. In e4, you can use eventbroker to send text (info) to status bar.

@Inject
private IEventBroker eventBroker; 
private static final String STATUSBAR ="statusbar";

@Inject @Optional
public void  getEvent(@UIEventTopic(STATUSBAR) String message) {
    updateInterface(message); 
}

@PostConstruct
public void createControls(Composite parent) {
   .... \\ swt definitions e.g. label 
}

public void updateInterface(String message)
    {
        try{
            Display.getDefault().asyncExec(new Runnable() {
              @Override
              public void run() {
                 try{
                        label.setText(message);  
                    }
                    catch(Exception exc){
                        System.out.println(exc);
                    }               
              }
            });
        }
        catch(Exception exception){
            System.out.println(exception);
        }   
    }

Also, don't forget add eventbrokersender to another java class.

@Inject
private IEventBroker eventBroker; 
private static final String STATUSBAR ="statusbar";
eventBroker.send(STATUSBAR, "status bar test message..");
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!