1 56 package org.objectstyle.cayenne.modeler.action; 57 58 import java.awt.event.ActionEvent ; 59 60 import org.objectstyle.cayenne.map.DerivedDbEntity; 61 import org.objectstyle.cayenne.map.event.EntityEvent; 62 import org.objectstyle.cayenne.modeler.Application; 63 import org.objectstyle.cayenne.modeler.util.CayenneAction; 64 import org.objectstyle.cayenne.modeler.util.ProjectUtil; 65 import org.objectstyle.cayenne.project.ProjectPath; 66 67 70 public class DerivedEntitySyncAction extends CayenneAction { 71 72 public static String getActionName() { 73 return "Reset Derived Entity"; 74 } 75 76 80 public DerivedEntitySyncAction(Application application) { 81 super(getActionName(), application); 82 } 83 84 87 public void performAction(ActionEvent e) { 88 DerivedDbEntity ent = (DerivedDbEntity) getProjectController().getCurrentDbEntity(); 89 90 if (ent != null && ent.getParentEntity() != null) { 91 ent.resetToParentView(); 92 ProjectUtil.cleanObjMappings(getProjectController().getCurrentDataMap()); 93 94 getProjectController().fireObjEntityEvent( 97 new EntityEvent(this, ent, EntityEvent.REMOVE)); 98 getProjectController().fireObjEntityEvent(new EntityEvent(this, ent, EntityEvent.ADD)); 99 } 100 } 101 102 105 public boolean enableForPath(ProjectPath path) { 106 if (path == null) { 107 return false; 108 } 109 110 return path.firstInstanceOf(DerivedDbEntity.class) != null; 111 } 112 } 113 | Popular Tags |