Search in sources :

Example 1 with CallbackType

use of org.apache.cayenne.modeler.editor.CallbackType in project cayenne by apache.

the class CreateCallbackMethodAction method performAction.

/**
 * performs adding new callback method
 *
 * @param e event
 */
public final void performAction(ActionEvent e) {
    CallbackType callbackType = getProjectController().getCurrentCallbackType();
    String methodName = NameBuilder.builderForCallbackMethod(getProjectController().getCurrentObjEntity()).baseName(toMethodName(callbackType.getType())).name();
    createCallbackMethod(callbackType, methodName);
    application.getUndoManager().addEdit(new CreateCallbackMethodUndoableEdit(callbackType, methodName));
}
Also used : CallbackType(org.apache.cayenne.modeler.editor.CallbackType) CreateCallbackMethodUndoableEdit(org.apache.cayenne.modeler.undo.CreateCallbackMethodUndoableEdit)

Example 2 with CallbackType

use of org.apache.cayenne.modeler.editor.CallbackType in project cayenne by apache.

the class RemoveCallbackMethodAction method removeCallbackMethods.

/**
 * base logic for callback method removing
 * @param actionEvent event
 */
private void removeCallbackMethods(ActionEvent actionEvent) {
    ProjectController mediator = getProjectController();
    CallbackType callbackType = mediator.getCurrentCallbackType();
    ObjCallbackMethod[] callbackMethods = mediator.getCurrentCallbackMethods();
    for (ObjCallbackMethod callbackMethod : callbackMethods) {
        removeCallbackMethod(callbackType, callbackMethod.getName());
    }
    Application.getInstance().getUndoManager().addEdit(new RemoveCallbackMethodUndoableEdit(callbackType, callbackMethods));
}
Also used : CallbackType(org.apache.cayenne.modeler.editor.CallbackType) RemoveCallbackMethodUndoableEdit(org.apache.cayenne.modeler.undo.RemoveCallbackMethodUndoableEdit) ProjectController(org.apache.cayenne.modeler.ProjectController) ObjCallbackMethod(org.apache.cayenne.modeler.editor.ObjCallbackMethod)

Example 3 with CallbackType

use of org.apache.cayenne.modeler.editor.CallbackType in project cayenne by apache.

the class RemoveAction method removeMethods.

private void removeMethods(ProjectController mediator, ConfirmRemoveDialog dialog, ObjCallbackMethod[] methods) {
    CallbackMap callbackMap = mediator.getCurrentObjEntity().getCallbackMap();
    CallbackType callbackType = mediator.getCurrentCallbackType();
    if ((methods.length == 1 && dialog.shouldDelete("callback method", methods[0].getName())) || (methods.length > 1 && dialog.shouldDelete("selected callback methods"))) {
        for (ObjCallbackMethod callbackMethod : methods) {
            callbackMap.getCallbackDescriptor(callbackType.getType()).removeCallbackMethod(callbackMethod.getName());
            CallbackMethodEvent ce = new CallbackMethodEvent(this, null, callbackMethod.getName(), MapEvent.REMOVE);
            mediator.fireCallbackMethodEvent(ce);
        }
        Application.getInstance().getUndoManager().addEdit(new RemoveCallbackMethodUndoableEdit(callbackType, methods));
    }
}
Also used : CallbackType(org.apache.cayenne.modeler.editor.CallbackType) CallbackMethodEvent(org.apache.cayenne.modeler.event.CallbackMethodEvent) RemoveCallbackMethodUndoableEdit(org.apache.cayenne.modeler.undo.RemoveCallbackMethodUndoableEdit) CallbackMap(org.apache.cayenne.map.CallbackMap) ObjCallbackMethod(org.apache.cayenne.modeler.editor.ObjCallbackMethod)

Aggregations

CallbackType (org.apache.cayenne.modeler.editor.CallbackType)3 ObjCallbackMethod (org.apache.cayenne.modeler.editor.ObjCallbackMethod)2 RemoveCallbackMethodUndoableEdit (org.apache.cayenne.modeler.undo.RemoveCallbackMethodUndoableEdit)2 CallbackMap (org.apache.cayenne.map.CallbackMap)1 ProjectController (org.apache.cayenne.modeler.ProjectController)1 CallbackMethodEvent (org.apache.cayenne.modeler.event.CallbackMethodEvent)1 CreateCallbackMethodUndoableEdit (org.apache.cayenne.modeler.undo.CreateCallbackMethodUndoableEdit)1