1 56 package org.objectstyle.cayenne.modeler.action; 57 58 import java.awt.event.ActionEvent ; 59 60 import org.objectstyle.cayenne.access.DataDomain; 61 import org.objectstyle.cayenne.map.DataMap; 62 import org.objectstyle.cayenne.modeler.Application; 63 import org.objectstyle.cayenne.modeler.ProjectController; 64 import org.objectstyle.cayenne.modeler.util.CayenneAction; 65 import org.objectstyle.cayenne.project.NamedObjectFactory; 66 import org.objectstyle.cayenne.project.ProjectPath; 67 68 74 public class CreateDataMapAction extends CayenneAction { 75 76 public static String getActionName() { 77 return "Create DataMap"; 78 } 79 80 public CreateDataMapAction(Application application) { 81 super(getActionName(), application); 82 } 83 84 public String getIconName() { 85 return "icon-datamap.gif"; 86 } 87 88 89 protected void createDataMap() { 90 ProjectController mediator = getProjectController(); 91 DataDomain currentDomain = mediator.getCurrentDataDomain(); 92 93 DataMap map = 95 (DataMap) NamedObjectFactory.createObject( 96 DataMap.class, 97 currentDomain, 98 currentDomain.getName() + "Map"); 99 mediator.addDataMap(this, map); 100 } 101 102 public void performAction(ActionEvent e) { 103 createDataMap(); 104 } 105 106 109 public boolean enableForPath(ProjectPath path) { 110 if (path == null) { 111 return false; 112 } 113 114 return path.firstInstanceOf(DataDomain.class) != null; 115 } 116 } | Popular Tags |