1 56 package org.objectstyle.cayenne.modeler.action; 57 58 import java.awt.event.ActionEvent ; 59 60 import org.objectstyle.cayenne.map.Procedure; 61 import org.objectstyle.cayenne.map.ProcedureParameter; 62 import org.objectstyle.cayenne.map.event.MapEvent; 63 import org.objectstyle.cayenne.map.event.ProcedureParameterEvent; 64 import org.objectstyle.cayenne.modeler.Application; 65 import org.objectstyle.cayenne.modeler.ProjectController; 66 import org.objectstyle.cayenne.modeler.event.ProcedureParameterDisplayEvent; 67 import org.objectstyle.cayenne.modeler.util.CayenneAction; 68 import org.objectstyle.cayenne.project.NamedObjectFactory; 69 import org.objectstyle.cayenne.project.ProjectPath; 70 71 75 public class CreateProcedureParameterAction extends CayenneAction { 76 77 public static String getActionName() { 78 return "Create Parameter"; 79 } 80 81 85 public CreateProcedureParameterAction(Application application) { 86 super(getActionName(), application); 87 } 88 89 public String getIconName() { 90 return "icon-plus.gif"; 91 } 92 93 96 public void performAction(ActionEvent e) { 97 if (getProjectController().getCurrentProcedure() != null) { 98 createProcedureParameter(); 99 } 100 } 101 102 public void createProcedureParameter() { 103 Procedure procedure = getProjectController().getCurrentProcedure(); 104 105 ProcedureParameter parameter = 106 (ProcedureParameter) NamedObjectFactory.createObject( 107 ProcedureParameter.class, 108 procedure); 109 110 procedure.addCallParameter(parameter); 111 112 ProjectController mediator = getProjectController(); 113 mediator.fireProcedureParameterEvent( 114 new ProcedureParameterEvent(this, parameter, MapEvent.ADD)); 115 116 mediator.fireProcedureParameterDisplayEvent( 117 new ProcedureParameterDisplayEvent( 118 this, 119 parameter, 120 procedure, 121 mediator.getCurrentDataMap(), 122 mediator.getCurrentDataDomain())); 123 } 124 125 128 public boolean enableForPath(ProjectPath path) { 129 if (path == null) { 130 return false; 131 } 132 133 return path.firstInstanceOf(Procedure.class) != null; 134 } 135 } 136 | Popular Tags |