Contributing to the Status Bar/Trim in Eclipse RCP

后端 未结 3 1982
借酒劲吻你
借酒劲吻你 2021-01-05 18:49

I have a requirement to show a status indicator in the status bar of an Eclipse application. I can\'t contribute through the ApplicationWindowAdviser (another team owns the

3条回答
  •  情歌与酒
    2021-01-05 19:06

    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..");
    

提交回复
热议问题