1 56 package org.objectstyle.cayenne.modeler.action; 57 58 import java.awt.event.ActionEvent ; 59 60 import org.objectstyle.cayenne.map.DataMap; 61 import org.objectstyle.cayenne.modeler.Application; 62 import org.objectstyle.cayenne.modeler.dialog.db.DBGeneratorOptions; 63 import org.objectstyle.cayenne.modeler.dialog.db.DataSourceWizard; 64 import org.objectstyle.cayenne.modeler.pref.DBConnectionInfo; 65 import org.objectstyle.cayenne.project.ProjectPath; 66 67 70 public class GenerateDBAction extends DBWizardAction { 71 72 public static String getActionName() { 73 return "Generate Database Schema"; 74 } 75 76 public GenerateDBAction(Application application) { 77 super(getActionName(), application); 78 } 79 80 public void performAction(ActionEvent e) { 81 82 DBConnectionInfo nodeInfo = preferredDataSource(); 83 String nodeKey = preferredDataSourceLabel(nodeInfo); 84 85 DataSourceWizard connectWizard = new DataSourceWizard( 86 getProjectController(), 87 "Generate DB Schema: Connect to Database", 88 nodeKey, 89 nodeInfo); 90 91 if (!connectWizard.startupAction()) { 92 return; 94 } 95 96 DataMap map = getProjectController().getCurrentDataMap(); 97 98 if (map == null) { 100 throw new IllegalStateException ("No current DataMap selected."); 101 } 102 103 new DBGeneratorOptions( 105 getProjectController(), 106 "Generate DB Schema: Options", 107 connectWizard.getConnectionInfo(), 108 map).startupAction(); 109 } 110 111 114 public boolean enableForPath(ProjectPath path) { 115 if (path == null) { 116 return false; 117 } 118 119 return path.firstInstanceOf(DataMap.class) != null; 120 } 121 } | Popular Tags |