Dependency Injection möchte einfach nicht funktionieren

darksmilie

Erfahrenes Mitglied
Dependency Injection

Hi,

ich versuche grade eigene Objekte über DI zu übergeben. Leider gelinkt mir das noch nicht so ganz.

Ich benutze Eclipse 4.2.2.

Ich möchte die Variable "table" aus dem ListView an die CreateFeatureHandler Klasse übergeben, leider bekomme ich immer folgende fehlermeldung:
org.eclipse.e4.core.di.InjectionException: Unable to process "ListView.table": no actual value was f
ound for the argument "javafx.scene.control.TableView<Feature>".

Code:
@SuppressWarnings("restriction")
public class ListView {

    @Inject 
    private TableView<Feature> table;
    
    
    @SuppressWarnings("unchecked")
    @Inject
    public ListView(BorderPane parent, final MApplication application, IEclipseContext context) {
	table = new TableView<Feature>();
       
        ... (inhalt für die tabelle)
   
	context.modify("table", table);
    }
    
}

Code:
public class CreateFeatureHandler {


    private Stage stage;

    @Execute
    @Inject
    void execute(@Optional final Feature feature, @Named("table") final TableView<Feature> table) {
	GridPane grid = new GridPane();
	grid.setHgap(10);
	grid.setVgap(10);
	grid.setPadding(new Insets(0, 10, 0, 10));
	final TextField name = new TextField();
	name.setPromptText("name");
	final TextField number = new TextField();
	number.setPromptText("number");
	Button b = new Button("Create");
	b.setOnAction(new EventHandler<ActionEvent>() {
	    public void handle(ActionEvent e) {
		Feature feat = TeamFactory.eINSTANCE.createFeature();
		feat.setName(name.getText());
		feat.setNumber(number.getText());
		LocalFileTest.addFeatureAndSaveIt(feat);

		System.out.println("TABLE:\t"+table);
		stage.close();
	    }
	});

	grid.add(new Label("name:"), 0, 0);
	grid.add(name, 1, 0);
	grid.add(new Label("number:"), 0, 1);
	grid.add(number, 1, 1);
	grid.add(b, 1, 2);

	stage = new Stage(StageStyle.DECORATED);
	stage.initModality(Modality.WINDOW_MODAL);

	Scene s1 = new Scene(grid);
	stage.setScene(s1);
	stage.show();

    }
 
Zuletzt bearbeitet: