I currently have an eclipse rcp project where the main viewpart is using JavaFx via the FXViewPart. I want to be able to access the contents of the scene from an eclipse rcp command. I am able to access the view part by its id but not sure how to grab its scene.
Code Snippet of the Command:
FXViewPart view = (FXViewPart) page.findView("com.interpro.emmeclipse.views.PageBuilderPart");
The ViewPart:
public class PageBuilderPart extends FXViewPart {
@Override
protected Scene createFxScene() {
final WebView webView = new WebView();
final WebEngine engine = webView.getEngine();
final AnchorPane root = new AnchorPane();
engine.load("file:///Development/EMM/EMMEclipse/src/com/interpro/emmeclipse/html/PageCreator.html");
final IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor != null) {
final IDocument doc = (IDocument) activeEditor.getAdapter(IDocument.class);
if(doc != null)
System.out.println(doc.get());
}
AnchorPane.setBottomAnchor(webView, 0.0);
AnchorPane.setLeftAnchor(webView, 0.0);
AnchorPane.setTopAnchor(webView, 0.0);
AnchorPane.setRightAnchor(webView, 0.0);
root.getChildren().addAll(webView);
Scene scene = new Scene(root);
return scene;
}
@Override
protected void setFxFocus() {
}
}
Ultimately I want to grab the webview from the command class.
You need to publish it somewhere yourself eg
public PageBuilderPart extends FXViewPart implements FXSceneProvider {
private Scene s;
public Scene getScene() {
return s;
}
}
public interface FXSceneProvider {
public Scene getScene();
}
and use it
FXSceneProvider view = (FXSceneProvider) page.findView("com.interpro.emmeclipse.views.PageBuilderPart");
Anyways I'm not sure this is the right philosophie in Eclipse you should execute the command and the your part should have registered itself as a CommandListener and process the result of the command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.