Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » is it possible to use eclipse service in controller of fxml?
is it possible to use eclipse service in controller of fxml? [message #1724147] Sun, 21 February 2016 18:21 Go to next message
Milankumar Ardeshana is currently offline Milankumar ArdeshanaFriend
Messages: 27
Registered: August 2015
Junior Member
hi

for my application i am loading ui from fxml. i have multiple part application. and each part is as below

Part1                                                   | Part2
personabstractpart.java (part)                          | PersonDetailedInfoPart.java (part)                                                                
personabstractpart.fxml (ui-> built using javafx 8)     | PersonDetailedInfoPart.fxml (ui-> built using javafx 8)             
personabstractpartcontroller.java (controller for fxml) | PersonDetailedInfoPartcontroller.java (controller for fxml)


now i want to use ESelectionService in my controller class. as below

@FXML
private TableView<Person> personTable;

@Inject
private ESelectionService selectionService;
...
@FXML
private void initialize() {
    	
    	
    	personTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
    		
			@Override
			public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue) {
				selectionService.setSelection(newValue);
				System.out.println("set: " + newValue); 
			}
		});
.
.
.
}



my controller class is not able to inject selection service here.

Question is
(a) is it possible to inject selectionService/controllerclass using ContextInjectionFactory? i don't know what(controller/service) i should inject and where(view/controller) i should inject and is it recommended?

(b) (i) so what currently i am doing is loading fxml and after that i am fetching my controlls from root of fxml and adding listener to my tableview. is this recommended?

root = FXMLLoader.load(PersonAbstractPart.class.getResource("PersonAbstractPart.fxml"));
AnchorPane box=(AnchorPane)root;
parent.setTop(box);
Node splitpane = box.getChildren().get(0);
SplitPane spnode = (SplitPane)splitpane;
Node anchornode = spnode.getItems().get(0);
AnchorPane anchorPane = (AnchorPane)anchornode;
personTable=(TableView<Person>)anchorPane.getChildren().get(0);
.
.
.
personTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
    		
			@Override
			public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue) {
				selectionService.setSelection(newValue);
				System.out.println("set: " + newValue); 
			}
		});



(ii) can i make my view to be controller? --> in view class @FXML is not fetching the controls after loading the fxml. and can't use easily as i can use in controller class.

any help appreciated.

Thanks,
Milan
Re: is it possible to use eclipse service in controller of fxml? [message #1724149 is a reply to message #1724147] Sun, 21 February 2016 19:48 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6329
Registered: July 2009
Senior Member
Hi,

https://wiki.eclipse.org/Efxclipse/Runtime/Recipes#.40FXMLLoader

Tom


On 21.02.16 19:21, Milankumar Ardeshana wrote:
> hi
> for my application i am loading ui from fxml. i have multiple part
> application. and each part is as below
>
>
> Part1 | Part2
> personabstractpart.java (part) |
> PersonDetailedInfoPart.java
> (part)
> personabstractpart.fxml (ui-> built using javafx 8) |
> PersonDetailedInfoPart.fxml (ui-> built using javafx 8)
> personabstractpartcontroller.java (controller for fxml) |
> PersonDetailedInfoPartcontroller.java (controller for fxml)
>
>
> now i want to use ESelectionService in my controller class. as below
>
>
> @FXML
> private TableView<Person> personTable;
>
> @Inject
> private ESelectionService selectionService;
> ..
> @FXML
> private void initialize() {
>
>
>
> personTable.getSelectionModel().selectedItemProperty().addListener(new
> ChangeListener<Person>() {
>
> @Override
> public void changed(ObservableValue<? extends Person>
> observable, Person oldValue, Person newValue) {
> selectionService.setSelection(newValue);
> System.out.println("set: " + newValue); }
> });
Re: is it possible to use eclipse service in controller of fxml? [message #1724150 is a reply to message #1724149] Sun, 21 February 2016 20:50 Go to previous message
Milankumar Ardeshana is currently offline Milankumar ArdeshanaFriend
Messages: 27
Registered: August 2015
Junior Member
Perfect. Thanks.
Previous Topic:opening a ui modeled dialogue from main thread leads to exception
Next Topic:Multiple Application.launch() from Plugin jobs
Goto Forum:
  


Current Time: Mon Jul 24 19:05:59 GMT 2017

Powered by FUDForum. Page generated in 0.03681 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software