1 56 57 package org.objectstyle.cayenne.modeler.action; 58 59 import java.awt.event.ActionEvent ; 60 61 import org.objectstyle.cayenne.modeler.Application; 62 import org.objectstyle.cayenne.modeler.dialog.validator.ValidationDisplayHandler; 63 import org.objectstyle.cayenne.modeler.dialog.validator.ValidatorDialog; 64 import org.objectstyle.cayenne.modeler.util.CayenneAction; 65 import org.objectstyle.cayenne.project.Project; 66 import org.objectstyle.cayenne.project.ProjectPath; 67 import org.objectstyle.cayenne.project.validator.Validator; 68 69 74 public class ValidateAction extends CayenneAction { 75 76 public static String getActionName() { 77 return "Validate Project"; 78 } 79 80 public ValidateAction(Application application) { 81 super(getActionName(), application); 82 } 83 84 87 public void performAction(ActionEvent e) { 88 Validator val = getCurrentProject().getValidator(); 89 int validationCode = val.validate(); 90 91 if (validationCode >= ValidationDisplayHandler.WARNING) { 93 ValidatorDialog.showDialog(Application.getFrame(), val); 94 } 95 else { 96 ValidatorDialog.showValidationSuccess(Application.getFrame(), val); 97 } 98 } 99 100 104 public boolean enableForPath(ProjectPath path) { 105 if (path == null) { 106 return false; 107 } 108 109 Project project = (Project)path.firstInstanceOf(Project.class); 110 return project != null; 111 } 112 } 113 | Popular Tags |