Skip to content

Commit

Permalink
clean up DisplayRuntimeInstance changes
Browse files Browse the repository at this point in the history
  • Loading branch information
daykin committed Jun 14, 2024
1 parent ab0a944 commit 6738310
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@


import java.awt.geom.Rectangle2D;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.FutureTask;
import java.util.logging.Level;

import org.csstudio.display.builder.model.DisplayModel;
Expand Down Expand Up @@ -74,7 +77,7 @@ public class DisplayRuntimeInstance implements AppInstance
private final BorderPane layout = new BorderPane();
private final DockItemWithInput dock_item;
private final DockItemRepresentation representation;
private FutureTask<Object> representation_init = new FutureTask<>(() -> {return null;});
private FutureTask<Void> representation_init = new FutureTask<>(() -> {return null;});
private Node toolbar;

/** Property on the 'model_parent' of the JFX scene that holds this DisplayRuntimeInstance */
Expand Down Expand Up @@ -157,9 +160,10 @@ public static DisplayRuntimeInstance ofDisplayModel(final DisplayModel model)
representation.fireContextMenu(model, (int)event.getScreenX(), (int)event.getScreenY());
}
});

layout.addEventFilter(KeyEvent.KEY_PRESSED, this::handleKeys);

dock_item.addClosedNotification(this::onClosed);
representation_init.run();
}

@Override
Expand All @@ -186,9 +190,9 @@ DisplayNavigation getNavigation()
}

/* Clients waiting for the representation to be initialized can get() this,
* which will block until the representation is initialized.
*/
public FutureTask<Object> getRepresentation_init() {
* which will block until the representation is initialized.
*/
public FutureTask<Void> getRepresentation_init() {
return representation_init;
}

Expand Down Expand Up @@ -313,6 +317,7 @@ public void loadDisplayFile(final DisplayInfo info)
RuntimeUtil.startRuntime(model);

logger.log(Level.FINE, "Waiting for representation of model " + info.getPath());

try
{
representation.awaitRepresentation(30, TimeUnit.SECONDS);
Expand Down Expand Up @@ -505,11 +510,6 @@ public void onClosed()
navigation.dispose();
}

DisplayModel getActiveModel()
{
return active_model;
}

public void addListener(ToolkitListener listener){
this.getRepresentation().removeListener(listener);
this.getRepresentation().addListener(listener);
Expand Down

0 comments on commit 6738310

Please sign in to comment.