33import com .google .common .eventbus .EventBus ;
44import com .google .common .eventbus .Subscribe ;
55import com .google .inject .Singleton ;
6+ import com .sun .javafx .application .PlatformImpl ;
67import edu .wpi .grip .core .*;
78import edu .wpi .grip .core .events .*;
89import edu .wpi .grip .ui .annotations .ParametrizedController ;
910import edu .wpi .grip .ui .pipeline .input .InputSocketController ;
1011import edu .wpi .grip .ui .pipeline .source .SourceController ;
1112import edu .wpi .grip .ui .pipeline .source .SourceControllerFactory ;
12- import edu .wpi .grip .ui .util .GRIPPlatform ;
1313import edu .wpi .grip .ui .util .ControllerMap ;
14- import javafx .application .Platform ;
1514import javafx .beans .InvalidationListener ;
1615import javafx .beans .property .ReadOnlyObjectProperty ;
1716import javafx .collections .ObservableList ;
@@ -56,8 +55,6 @@ public final class PipelineController {
5655 private StepController .Factory stepControllerFactory ;
5756 @ Inject
5857 private AddSourceView addSourceView ;
59- @ Inject
60- private GRIPPlatform platform ;
6158
6259 private ControllerMap <StepController , Node > stepsMapManager ;
6360 private ControllerMap <SourceController , Node > sourceMapManager ;
@@ -182,7 +179,7 @@ private ConnectionView findConnectionView(Connection connection) {
182179 * details of adding the connection.
183180 */
184181 private void addConnectionView (Connection connection ) {
185- platform . runAsSoonAsPossible (() -> {
182+ PlatformImpl . runAndWait (() -> {
186183 // Before adding a connection control, we have to look up the controls for both sockets in the connection so
187184 // we know where to position it.
188185 final OutputSocketController outputSocketView = findOutputSocketView (connection .getOutputSocket ());
@@ -207,35 +204,33 @@ private void addConnectionView(Connection connection) {
207204 final double x2 = inputSocketBounds .getMinX () + inputSocketBounds .getWidth () / 2.0 ;
208205 final double y2 = inputSocketBounds .getMinY () + inputSocketBounds .getHeight () / 2.0 ;
209206
210- // This can run whenever. Don't wait for it to complete.
211- // This should be Platform.runLater
212- Platform .runLater (() -> {
207+ PlatformImpl .runAndWait (() -> {
213208 connectionView .inputHandleProperty ().setValue (new Point2D (x1 , y1 ));
214209 connectionView .outputHandleProperty ().setValue (new Point2D (x2 , y2 ));
215210 ((ReadOnlyObjectProperty ) observable ).get ();
216211 });
217212 }
218213 };
219214
220- inputSocketController .getRoot ().localToSceneTransformProperty ().addListener (handleListener );
221- outputSocketView .getRoot ().localToSceneTransformProperty ().addListener (handleListener );
222- handleListener .invalidated (inputSocketController . getRoot ().localToSceneTransformProperty ());
215+ inputSocketController .getHandle ().localToSceneTransformProperty ().addListener (handleListener );
216+ outputSocketView .getHandle ().localToSceneTransformProperty ().addListener (handleListener );
217+ handleListener .invalidated (outputSocketView . getHandle ().localToSceneTransformProperty ());
223218
224219 connections .getChildren ().add (connectionView );
225220 });
226221 }
227222
228223 @ Subscribe
229224 public void onSourceAdded (SourceAddedEvent event ) {
230- platform . runAsSoonAsPossible (() -> {
225+ PlatformImpl . runAndWait (() -> {
231226 final SourceController sourceController = sourceControllerFactory .create (event .getSource ());
232227 sourceMapManager .add (sourceController );
233228 });
234229 }
235230
236231 @ Subscribe
237232 public void onSourceRemoved (SourceRemovedEvent event ) {
238- platform . runAsSoonAsPossible (() -> {
233+ PlatformImpl . runAndWait (() -> {
239234 final SourceController sourceController = findSourceView (event .getSource ());
240235 sourceMapManager .remove (sourceController );
241236 eventBus .unregister (sourceController );
@@ -245,7 +240,7 @@ public void onSourceRemoved(SourceRemovedEvent event) {
245240 @ Subscribe
246241 public void onStepAdded (StepAddedEvent event ) {
247242 // Add a new view to the pipeline for the step that was added
248- platform . runAsSoonAsPossible (() -> {
243+ PlatformImpl . runAndWait (() -> {
249244 final int index = event .getIndex ().or (stepBox .getChildren ().size ());
250245 final Step step = event .getStep ();
251246
@@ -259,7 +254,7 @@ public void onStepAdded(StepAddedEvent event) {
259254 @ Subscribe
260255 public void onStepRemoved (StepRemovedEvent event ) {
261256 // Remove the control that corresponds with the step that was removed
262- platform . runAsSoonAsPossible (() -> {
257+ PlatformImpl . runAndWait (() -> {
263258 final StepController stepController = findStepController (event .getStep ());
264259
265260 stepsMapManager .remove (stepController );
@@ -269,7 +264,7 @@ public void onStepRemoved(StepRemovedEvent event) {
269264
270265 @ Subscribe
271266 public void onStepMoved (StepMovedEvent event ) {
272- platform . runAsSoonAsPossible (() -> {
267+ PlatformImpl . runAndWait (() -> {
273268 final StepController stepController = findStepController (event .getStep ());
274269 stepsMapManager .moveByDistance (stepController , event .getDistance ());
275270 });
@@ -278,13 +273,13 @@ public void onStepMoved(StepMovedEvent event) {
278273 @ Subscribe
279274 public void onConnectionAdded (ConnectionAddedEvent event ) {
280275 // Add the new connection view
281- platform . runAsSoonAsPossible (() -> addConnectionView (event .getConnection () ));
276+ addConnectionView (event .getConnection ());
282277 }
283278
284279 @ Subscribe
285280 public void onConnectionRemoved (ConnectionRemovedEvent event ) {
286281 // Remove the control that corresponds with the connection that was removed
287- platform . runAsSoonAsPossible (() -> {
282+ PlatformImpl . runAndWait (() -> {
288283 final ConnectionView connectionView = findConnectionView (event .getConnection ());
289284 connections .getChildren ().remove (connectionView );
290285 eventBus .unregister (connectionView );
0 commit comments