_alreadyReadInputs = true;
if (_model instanceof CompositeActor) {
// Will need the effigy for the model this actor is in.
NamedObj toplevel = toplevel();
final Effigy myEffigy = Configuration.findEffigy(toplevel);
// If there is no such effigy, then skip trying to open a tableau.
// The model may have no graphical elements.
if (myEffigy != null) {
try {
// Conditionally show the model in Vergil. The openModel()
// method also creates the right effigy.
if ((_openOnFiringValue == _OPEN_IN_VERGIL)
|| (_openOnFiringValue == _OPEN_IN_VERGIL_FULL_SCREEN)) {
// NOTE: The opening must occur in the event thread.
// Regrettably, we cannot continue with the firing until
// the open is complete, so we use the very dangerous
// invokeAndWait() method.
Runnable doOpen = new Runnable() {
public void run() {
Configuration configuration = (Configuration) myEffigy
.toplevel();
if (_debugging) {
_debug("** Using the configuration to open a tableau.");
}
try {
// NOTE: Executing this in the event thread averts
// a race condition... Previous close(), which was
// deferred to the UI thread, will have completed.
_exception = null;
_tableau = configuration.openModel(_model,
myEffigy);
// Set this tableau to be a master so that when it
// gets closed, all its subwindows get closed.
_tableau.setMaster(true);
} catch (KernelException e) {
// Record the exception for later reporting.
_exception = e;
}
_tableau.show();
JFrame frame = _tableau.getFrame();
if (frame != null) {
if (_openOnFiringValue == _OPEN_IN_VERGIL_FULL_SCREEN) {
if (frame instanceof ExtendedGraphFrame) {
((ExtendedGraphFrame) frame)
.fullScreen();
}
}
frame.toFront();
}
}
};
try {
SwingUtilities.invokeAndWait(doOpen);
} catch (Exception ex) {
throw new IllegalActionException(this, null, ex,
"Open failed.");
}
if (_exception != null) {
// An exception occurred while trying to open.
throw new IllegalActionException(this, null,
_exception, "Failed to open.");
}
} else {
// Need an effigy for the model, or else graphical elements
// of the model will not work properly. That effigy needs
// to be contained by the effigy responsible for this actor.
PtolemyEffigy newEffigy = new PtolemyEffigy(myEffigy,
myEffigy.uniqueName(_model.getName()));
newEffigy.setModel(_model);
// Since there is no tableau, this is probably not
// necessary, but as a safety precaution, we prevent
// writing of the model.