// Mirror the ports of the container in the refinement.
// Note that this is done here rather than as part of
// the MoML because we have set protected variables
// in the refinement to prevent it from trying to again
// mirror the changes in the container.
Refinement entity = (Refinement) _case
.getEntity(pattern);
// Get the initial port configuration from the container.
Iterator ports = _case.portList().iterator();
while (ports.hasNext()) {
Port port = (Port) ports.next();
// No need to mirror the control port, as it's a PortParameter.
// Hence, its value is available as a parameter.
if (port == _case.control.getPort()) {
continue;
}
try {
entity.setMirrorDisable(true);
Port newPort = entity.newPort(port.getName());
if (newPort instanceof RefinementPort
&& port instanceof IOPort) {
try {
((RefinementPort) newPort)
.setMirrorDisable(true);
if (((IOPort) port).isInput()) {
((RefinementPort) newPort)
.setInput(true);
}
if (((IOPort) port).isOutput()) {
((RefinementPort) newPort)
.setOutput(true);
}
if (((IOPort) port).isMultiport()) {
((RefinementPort) newPort)
.setMultiport(true);
}
} finally {
((RefinementPort) newPort)
.setMirrorDisable(false);
}
}
} finally {
entity.setMirrorDisable(false);
}
}
_addTabbedPane(entity, true);
}
};