1 56 package org.objectstyle.cayenne.modeler.action; 57 58 import java.awt.event.ActionEvent ; 59 import java.awt.event.KeyEvent ; 60 61 import javax.swing.KeyStroke ; 62 63 import org.objectstyle.cayenne.access.DataDomain; 64 import org.objectstyle.cayenne.modeler.Application; 65 import org.objectstyle.cayenne.modeler.CayenneModelerController; 66 import org.objectstyle.cayenne.modeler.event.DomainDisplayEvent; 67 import org.objectstyle.cayenne.project.ApplicationProject; 68 import org.objectstyle.cayenne.project.NamedObjectFactory; 69 70 73 public class NewProjectAction extends ProjectAction { 74 75 public static String getActionName() { 76 return "New Project"; 77 } 78 79 public NewProjectAction(Application application) { 80 super(getActionName(), application); 81 } 82 83 public String getIconName() { 84 return "icon-new.gif"; 85 } 86 87 public KeyStroke getAcceleratorKey() { 88 return KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK); 89 } 90 91 public void performAction(ActionEvent e) { 92 93 CayenneModelerController controller = Application 94 .getInstance() 95 .getFrameController(); 96 if (getCurrentProject() != null && !closeProject()) { 98 return; 99 } 100 101 ApplicationProject project = new ApplicationProject(null); 102 103 DataDomain domain = (DataDomain) NamedObjectFactory.createObject( 105 DataDomain.class, 106 project.getConfiguration()); 107 domain.getEntityResolver().setIndexedByClass(false); 108 project.getConfiguration().addDomain(domain); 109 110 controller.projectOpenedAction(project); 111 112 getProjectController().fireDomainDisplayEvent(new DomainDisplayEvent(this, domain)); 114 } 115 } | Popular Tags |