}
private void performAction(Project dest, String name, boolean replace,
final boolean twoInputs, final boolean useNands) {
if (replace) {
final Circuit circuit = dest.getLogisimFile().getCircuit(name);
if (circuit == null) {
JOptionPane.showMessageDialog(parent,
"Internal error prevents replacing circuit.",
"Internal Error", JOptionPane.ERROR_MESSAGE);
return;
}
CircuitMutation xn = CircuitBuilder.build(circuit, model, twoInputs,
useNands);
dest.doAction(xn.toAction(Strings.getter("replaceCircuitAction")));
} else {
// add the circuit
Circuit circuit = new Circuit(name);
CircuitMutation xn = CircuitBuilder.build(circuit, model, twoInputs,
useNands);
xn.execute();
dest.doAction(LogisimFileActions.addCircuit(circuit));
dest.setCurrentCircuit(circuit);