@Override public void execute() { module = model.getModuleElement(); module.getSite().addCommitListener(this); cmds = new ArrayList<ConnectionDeleteCommand>(); for (Connection connection : model.getSourceConnections()) { cmds.add(new ConnectionDeleteCommand(connection)); } for (Connection connection : model.getTargetConnections()) { cmds.add(new ConnectionDeleteCommand(connection)); } module.removeModel(model); for (ConnectionDeleteCommand cmd : cmds) { cmd.execute(); } }
@Override public boolean preSave() { if (backups == null) { Module module = model.getModuleElement().getModule(); backups = new ArrayList<Backup>(); File file = model.getFile(); backups.add(new Backup(file)); backups.add(new Backup(module.getControllerFor(file))); backups.add(new Backup(module.getViewsFolder(file))); backups.add(new Backup(module.getNotifier(file))); model.destroy(); } else { model.save(); for (Backup backup : backups) { backup.restore(); } backups.clear(); backups = null; } return true; }