X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.charts%2Fsrc%2Forg%2Fsimantics%2Fcharts%2Feditor%2FTimeSeriesEditor.java;h=bffd4c8a24952fb60bfae8cd517be91a9d24e36d;hp=d83a37ad4f665241aed27d1b3618b1a549216714;hb=4fc32fefc5bd05dd9f41e879fce4cfe2e601af71;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07 diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/editor/TimeSeriesEditor.java b/bundles/org.simantics.charts/src/org/simantics/charts/editor/TimeSeriesEditor.java index d83a37ad4..bffd4c8a2 100644 --- a/bundles/org.simantics.charts/src/org/simantics/charts/editor/TimeSeriesEditor.java +++ b/bundles/org.simantics.charts/src/org/simantics/charts/editor/TimeSeriesEditor.java @@ -134,6 +134,7 @@ import org.simantics.utils.threads.ThreadUtils; import org.simantics.utils.ui.BundleUtils; import org.simantics.utils.ui.ErrorLogger; import org.simantics.utils.ui.ExceptionUtils; +import org.simantics.utils.ui.SWTDPIUtil; import org.simantics.utils.ui.SWTUtils; import org.simantics.utils.ui.dialogs.ShowMessage; import org.simantics.utils.ui.jface.ActiveSelectionProvider; @@ -567,13 +568,12 @@ public class TimeSeriesEditor extends ResourceEditorPart { if (event.button != MouseEvent.RIGHT_BUTTON) return false; - final Point p = new Point((int) event.screenPosition.getX(), (int) event.screenPosition.getY()); - SWTUtils.asyncExec(chassis, new Runnable() { - @Override - public void run() { - if (!canvas.isDisposed()) - showPopup(p); - } + Point p = new Point( + SWTDPIUtil.downscaleSwt((int) event.screenPosition.getX()), + SWTDPIUtil.downscaleSwt((int) event.screenPosition.getY())); + SWTUtils.asyncExec(chassis, () -> { + if (!canvas.isDisposed()) + showPopup(p); }); return true; } @@ -586,6 +586,7 @@ public class TimeSeriesEditor extends ResourceEditorPart { // Track data source and preinitialize chartData project.addHintListener(chartDataListener); chartData.readFrom( (ChartData) project.getHint( chartDataKey ) ); + chartData.reference(); if (chartData.run != null) { milestoneListener = new MilestoneSpecListener(); @@ -748,6 +749,7 @@ public class TimeSeriesEditor extends ResourceEditorPart { chartData.datasource.removeListener( stepListener ); if (chartData.experiment!=null) chartData.experiment.removeListener( experimentStateListener ); + chartData.dereference(); chartData.readFrom( null ); } @@ -840,7 +842,9 @@ public class TimeSeriesEditor extends ResourceEditorPart { } if (doLayout) trendNode.layout(); + this.chartData.dereference(); this.chartData.readFrom( data ); + this.chartData.reference(); tp.setDirty(); if (!ObjectUtils.objectEquals(oldExperimentResource, newExperimentResource)) { @@ -857,14 +861,14 @@ public class TimeSeriesEditor extends ResourceEditorPart { } @Override public void execute(ReadGraph graph, final Resource run) throws DatabaseException { - if(run != null) { - SimulationResource SIMU = SimulationResource.getInstance(graph); - Variable var = Variables.getVariable(graph, run); - IExperiment exp = var.getPossiblePropertyValue(graph, SIMU.Run_iExperiment); - ITrendSupport ts = exp.getService(ITrendSupport.class); - if (ts != null) - ts.setChartData(graph); - } + if(run != null) { + SimulationResource SIMU = SimulationResource.getInstance(graph); + Variable var = Variables.getPossibleVariable(graph, run); + IExperiment exp = var != null ? var.getPossiblePropertyValue(graph, SIMU.Run_iExperiment) : null; + ITrendSupport ts = exp != null ? exp.getService(ITrendSupport.class) : null; + if (ts != null) + ts.setChartData(graph); + } } @Override public boolean isDisposed() { @@ -989,18 +993,18 @@ public class TimeSeriesEditor extends ResourceEditorPart { tp.setDirty(); } - @SuppressWarnings("rawtypes") + @SuppressWarnings("unchecked") @Override - public Object getAdapter(Class adapter) { + public T getAdapter(Class adapter) { if (adapter == INode.class) { ICanvasContext ctx = cvsCtx; if (ctx != null) - return ctx.getSceneGraph(); + return (T) ctx.getSceneGraph(); } if (adapter == IPropertyPage.class) - return new StandardPropertyPage(getSite(), getPropertyPageContexts()); + return (T) new StandardPropertyPage(getSite(), getPropertyPageContexts()); if (adapter == ICanvasContext.class) - return cvsCtx; + return (T) cvsCtx; return super.getAdapter(adapter); }