Search code examples
eclipseeclipse-plugineclipse-rcpe4

E4 doesn´t invoke my @PostConstruct-Method


I´m having trouble with the migration of my E3-RCP-Application to a E4. There I got 3 parts. 2 with Sample Content of Lars Vogel (http://www.vogella.com/tutorials/EclipseRCP/article.html#plugin_creatinge4 "Using the SWT power widget") to test and compare it with my part.

Long Story short(er): The Method that should create the View´s content, marked with @PostConstruct, won´t be invoked, but the @PostConstruct of the SampleContent would. What reasons could that have? The Constructor of MyView is invoked.

The Structure of my View is as the following:

Many Imports

public class MyView1 implements IRefreshableView, ISomeListener {

a lot of fields, some are injected...

public MyView1()  {
        reference to the Activator-Class to get some item.
    }

@PostConstruct
public void createControls(Composite parent) {
        createViewToolbar();``

and much more Part Creation stuff that won´t be invoked...

}

much more methods
@Focus
    public void setFocus() {
        if (treeViewer.getTree().isVisible()) {
            treeViewer.getTree().setFocus();
        } else {
            mainForm.setFocus();
        }
    }

}

new class definition in the same file. 

END

Sorry for not posting the whole Code, it´s like 1000 rows long :/

I´m using Mars 4.5.1 on Win7


Solution

  • One cause of the @PostConstruct failing to run is the Direct Injection code not being able to find objects which are injected in fields (or an injected constructor). If this happens the injector just logs an error and stops.

    The error is logged in the '.log' file in the workspace '.metadata' directory.