Why jzy3/jogl newt window is always on top?

107 views Asked by At

I'm using jzy3d/SWT with mapper and surface and this code to create the chart (container is a composite with gridLayout) :

Settings.getInstance().setHardwareAccelerated(true);
jzy3DChart = SWTChartComponentFactory.chart(container);
((CanvasNewtSWT)jzy3DChart.getCanvas()).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
jzy3DChart.black();
jzy3DChart.getScene().getGraph().add(surface);
ChartLauncher.openChart(jzy3DChart);

I get this rendering at initial creation : enter image description here

But when another part is selected, the newt window always stay on top (chart3 is 2D chart and should be on top) : enter image description here

I've tried to toggle newt window visibility using :

newtCanvasSWT.getNEWTChild().setVisible(false/true);

But doing so the newt window becomes independent and no longer embedded in its SWT container and can disappear under other controls when it should not.

enter image description here

What am I doing wrong ? How to set newt window not to be always on top ?

Edit :

Here is the workaround code I've used :

getSite().getPage().addPartListener(new IPartListener2() {
    @Override
    public void partHidden(IWorkbenchPartReference partRef) {
        // Dispose jsyz3d chart composite when this part is hidden
        if(partRef.getPart(false) == XYZChartEditor.this) {
            if(chart != null) {
                chart.dispose();
                chart = null;
            }
        }
    }
    @Override
    public void partVisible(IWorkbenchPartReference partRef) {
        // Refresh or rebuild chart when this part reappears
        if(partRef.getPart(false) == XYZChartEditor.this) {
            if(chart != null) {
                // Force chart parent composite to layout
                chartContainer.layout();
                return;
            }
            // Rebuild chart
            chart = SWTChartFactory.chart(chartContainer, Quality.Nicest());
            chart.getView().setViewPoint(xyzChartData.getViewPoint());   
            chart.getView().addViewPointChangedListener(XYZChartEditor.this);
            chart.black();
            ChartLauncher.openChart(chart);
            // Force chart parent composite to layout
            chartContainer.layout();
            boolean wasDirty = XYZChartEditor.this.isDirty();
            SelectionChangedEvent event = new SelectionChangedEvent(trialsListViewer, trialsListViewer.getSelection());
            XYZChartEditor.this.selectionChanged(event);
            if(!wasDirty) XYZChartEditor.this.setDirty(false);
            ((CanvasNewtSWT)chart.getCanvas()).addMouseListener(XYZChartEditor.this);       
            canvas = ((CanvasNewtSWT) chart.getCanvas());
            newtCanvasSWT = canvas.getCanvas();
            newtWindow = ((CanvasNewtSWT) chart.getCanvas()).getCanvas().getNEWTChild();
        }
    }
});
0

There are 0 answers