Search in sources :

Example 1 with CallbackMap

use of org.apache.cayenne.map.CallbackMap in project cayenne by apache.

the class AbstractCallbackMethodsTab method rebuildTables.

/**
 * rebuilds table content
 */
protected void rebuildTables() {
    CallbackMap callbackMap = getCallbackMap();
    for (int i = 0; i < callbackTypes.length; i++) {
        CallbackType callbackType = callbackTypes[i];
        List<String> methods = new ArrayList<>();
        CallbackDescriptor descriptor = null;
        if (callbackMap != null && callbackType != null) {
            descriptor = callbackMap.getCallbackDescriptor(callbackType.getType());
            methods.addAll(descriptor.getCallbackMethods());
        }
        CallbackDescriptorTableModel model = new CallbackDescriptorTableModel(mediator, this, methods, descriptor, callbackType);
        tables[i].setModel(model);
    }
    for (CayenneTable table : tables) {
        tablePreferences.bind(table, null, null, null);
    }
}
Also used : CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) CallbackDescriptor(org.apache.cayenne.map.CallbackDescriptor) ArrayList(java.util.ArrayList) CallbackMap(org.apache.cayenne.map.CallbackMap)

Example 2 with CallbackMap

use of org.apache.cayenne.map.CallbackMap 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

CallbackMap (org.apache.cayenne.map.CallbackMap)2 ArrayList (java.util.ArrayList)1 CallbackDescriptor (org.apache.cayenne.map.CallbackDescriptor)1 CallbackType (org.apache.cayenne.modeler.editor.CallbackType)1 ObjCallbackMethod (org.apache.cayenne.modeler.editor.ObjCallbackMethod)1 CallbackMethodEvent (org.apache.cayenne.modeler.event.CallbackMethodEvent)1 RemoveCallbackMethodUndoableEdit (org.apache.cayenne.modeler.undo.RemoveCallbackMethodUndoableEdit)1 CayenneTable (org.apache.cayenne.modeler.util.CayenneTable)1