1 56 package org.objectstyle.cayenne.modeler.action; 57 58 import java.awt.event.ActionEvent ; 59 60 import org.objectstyle.cayenne.CayenneRuntimeException; 61 import org.objectstyle.cayenne.modeler.Application; 62 import org.objectstyle.cayenne.modeler.CayenneModelerController; 63 import org.objectstyle.cayenne.modeler.util.CayenneAction; 64 import org.objectstyle.cayenne.project.ApplicationProject; 65 import org.objectstyle.cayenne.project.Project; 66 67 70 public class RevertAction extends CayenneAction { 71 72 public static String getActionName() { 73 return "Revert"; 74 } 75 76 public RevertAction(Application application) { 77 super(getActionName(), application); 78 } 79 80 public void performAction(ActionEvent e) { 81 82 Project project = getCurrentProject(); 83 if (project == null) { 84 return; 85 } 86 87 boolean isNew = project.isLocationUndefined(); 88 89 CayenneModelerController controller = getApplication().getFrameController(); 90 91 controller.projectClosedAction(); 94 95 if (!isNew && project.getMainFile().isFile()) { 97 OpenProjectAction openAction = (OpenProjectAction) controller 98 .getApplication() 99 .getAction(OpenProjectAction.getActionName()); 100 openAction.openProject(project.getMainFile()); 101 } 102 else if (!(project instanceof ApplicationProject)) { 104 throw new CayenneRuntimeException("Only ApplicationProjects are supported."); 105 } 106 else { 107 controller 108 .getApplication() 109 .getAction(NewProjectAction.getActionName()) 110 .performAction(e); 111 } 112 } 113 } | Popular Tags |