try {
_parser.reset();
// Export the model into moml string and then import it
// again. Needed b some models with unnoticeable state.
NamedObj newModel = _parser.parse(model.exportMoML());
Tableau tableau = configuration.openModel(newModel,
effigy);
if (_tableaus[i] != null) {
_tableaus[i].close();
}
_tableaus[i] = tableau;
JFrame frame = tableau.getFrame();
// Compute location of the new frame.
RecordToken location =
(RecordToken) screenLocation.getToken();
int x = ((IntToken) location.get("x")).intValue();
int y = ((IntToken) location.get("y")).intValue();
Point newLocation = frame.getLocation();
if (x >= 0) {
newLocation.x = x;
}
if (y >= 0) {
newLocation.y = y;
}
// Move the frame to the edge if it exceeds the screen.
Dimension size = frame.getSize();
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
newLocation.x = Math.min(newLocation.x,
screenSize.width - size.width);
newLocation.y = Math.min(newLocation.y,
screenSize.height - size.height);
frame.setLocation(newLocation);
frame.addWindowListener(this);
String titleString = null;
if (titleValue.equals("")) {
URI uri = URIAttribute.getModelURI(newModel);
if (uri != null) {
URI modelURI = new URI(uri.getScheme(), uri
.getUserInfo(), uri.getHost(), uri
.getPort(), uri.getPath()
+ newModel.getName() + ".xml", null,
null);
titleString = modelURI.toString() + " ("
+ getName() + ")";
}
} else {
titleString = titleValue;
}
tableau.setTitle(titleString);
} catch (NameDuplicationException e) {
throw new IllegalActionException(this, e,
"Cannot open model.");
} catch (Exception e) {
throw new IllegalActionException(this, e,