private void _replaceFactory(PtolemyMenuFactory menuFactory,
MenuItemFactory replacedFactory, MenuItemFactory replacement) {
List<?> factories = menuFactory.menuItemFactoryList();
int size = factories.size();
for (int i = 0; i < size; i++) {
MenuItemFactory factory = (MenuItemFactory) factories.get(0);
menuFactory.removeMenuItemFactory(factory);
if (factory == replacedFactory) {
menuFactory.addMenuItemFactory(replacement);
} else {
menuFactory.addMenuItemFactory(factory);