Hi,
i want to use DI with my own classes and variables but unfortunately it doesn't work.
I use eclipse 4.2.2.
I want to use the variable "table" from the ListView class in the CreateFeatureHanlder but i get always this error message:
Quote: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>".
@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>();
... (content of the table)
context.modify("table", table);
}
}
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();
}