Home » Eclipse Projects » e(fx)clipse » Dependency Injection
Dependency Injection [message #1080106] |
Mon, 05 August 2013 13:28 |
Patrick Sowada Messages: 7 Registered: July 2009 |
Junior Member |
|
|
Hi,
i want to use my own DI objects 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 CreateFeatureHandler class. I always get the following 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();
}
|
|
|
Re: Dependency Injection [message #1080114 is a reply to message #1080106] |
Mon, 05 August 2013 13:35 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
You need to call IEC.set("table",table) - modify only works if you have
declared this variable at first on the IEC (not needed in your case)
Tom
On 05.08.13 15:29, Patrick Sowada wrote:
> Hi,
>
> i want to use my own DI objects 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
> CreateFeatureHandler class. I always get the following 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();
>
> }
|
|
|
Re: Dependency Injection [message #1080115 is a reply to message #1080114] |
Mon, 05 August 2013 13:38 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
.... not unimportant - this naturally only works if the part with the
table is the current active part in your application because handlers
are executed always in the current active context.
Tom
On 05.08.13 15:35, Tom Schindl wrote:
> You need to call IEC.set("table",table) - modify only works if you have
> declared this variable at first on the IEC (not needed in your case)
>
> Tom
>
> On 05.08.13 15:29, Patrick Sowada wrote:
>> Hi,
>>
>> i want to use my own DI objects 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
>> CreateFeatureHandler class. I always get the following 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();
>>
>> }
>
|
|
| | |
Goto Forum:
Current Time: Sat Apr 20 04:23:45 GMT 2024
Powered by FUDForum. Page generated in 0.03256 seconds
|