I am creating an RCP application based on Eclipse 3.5. Thanks to two articles ( 1 , 2 ) that I found on oracle.com, I was able to implement a working RCP view that displays a pie chart.
Unfortunately, if I close the view and open it again, then the applications freeze and never return.
I am using JavaFX 2.2.7 under JDK 1.6.0.31 on Windows 7 X64.
Here is the code. The view is a standard subclass of org.eclipse.ui.part.ViewPart.
Composite panel = new Composite(parent, SWT.NONE); RowLayout layout = new RowLayout(); panel.setLayout(layout); FXCanvas fxCanvas = new FXCanvas(panel, SWT.NONE) { @Override public Point computeSize(int wHint, int hHint, boolean changed) { getScene().getWindow().sizeToScene(); int width = (int) getScene().getWidth(); int height = (int) getScene().getHeight(); return new Point(width, height); } }; Scene scene = new Scene(new Group()); RGB rgb = panel.getBackground().getRGB(); Color color = Color.rgb(rgb.red, rgb.green, rgb.blue); scene.setFill(color); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); pieChartData.add(new PieChart.Data("label1", 20)); pieChartData.add(new PieChart.Data("label2", 20)); pieChartData.add(new PieChart.Data("label3", 20)); pieChartData.add(new PieChart.Data("label4", 20)); pieChartData.add(new PieChart.Data("label5", 20)); Chart chart = new PieChart(pieChartData); chart.setLegendSide(Side.RIGHT); ((Group) scene.getRoot()).getChildren().add(chart); fxCanvas.setScene(scene);
Can anyone help?
source share