Search in sources :

Example 1 with ProcedureParameterDisplayEvent

use of org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent in project cayenne by apache.

the class CreateProcedureParameterAction method fireProcedureParameterEvent.

/**
 * Fires events when an proc parameter was added
 */
static void fireProcedureParameterEvent(Object src, ProjectController mediator, Procedure procedure, ProcedureParameter parameter) {
    mediator.fireProcedureParameterEvent(new ProcedureParameterEvent(src, parameter, MapEvent.ADD));
    mediator.fireProcedureParameterDisplayEvent(new ProcedureParameterDisplayEvent(src, parameter, procedure, mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode()));
}
Also used : ProcedureParameterDisplayEvent(org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ProcedureParameterEvent(org.apache.cayenne.configuration.event.ProcedureParameterEvent)

Example 2 with ProcedureParameterDisplayEvent

use of org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent in project cayenne by apache.

the class ProcedureParameterErrorMsg method displayField.

public void displayField(ProjectController mediator, JFrame frame) {
    Object object = super.validationFailure.getSource();
    DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
    ProcedureParameter procedureParameter = (ProcedureParameter) object;
    Procedure procedure = procedureParameter.getProcedure();
    DataMap map = procedure.getDataMap();
    // Race condition between the two events...?
    // first display the stored procedure
    // for whatever reason, other validators do not require this step
    // (E.g. DbAttributeErrorMsg)
    ProcedureDisplayEvent procedureEvent = new ProcedureDisplayEvent(frame, procedure, map, domain);
    procedureEvent.setTabReset(true);
    mediator.fireProcedureDisplayEvent(procedureEvent);
    // now show the failed parameter
    ProcedureParameterDisplayEvent event = new ProcedureParameterDisplayEvent(frame, procedureParameter, procedure, map, domain);
    event.setTabReset(true);
    mediator.fireProcedureParameterDisplayEvent(event);
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) ProcedureDisplayEvent(org.apache.cayenne.modeler.event.ProcedureDisplayEvent) ProcedureParameterDisplayEvent(org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) Procedure(org.apache.cayenne.map.Procedure) DataMap(org.apache.cayenne.map.DataMap)

Example 3 with ProcedureParameterDisplayEvent

use of org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent in project cayenne by apache.

the class ProcedureParameterTab method processExistingSelection.

public void processExistingSelection(EventObject e) {
    if (e instanceof ChangeEvent) {
        table.clearSelection();
    }
    ProcedureParameter[] parameters = new ProcedureParameter[0];
    boolean enableUp = false;
    boolean enableDown = false;
    boolean enableRemoveButton = false;
    int selectedRow = table.getSelectedRow();
    if (selectedRow >= 0) {
        enableRemoveButton = true;
        ProcedureParameterTableModel model = (ProcedureParameterTableModel) table.getModel();
        int[] sel = table.getSelectedRows();
        parameters = new ProcedureParameter[sel.length];
        for (int i = 0; i < sel.length; i++) {
            parameters[i] = model.getParameter(sel[i]);
        }
        if (sel.length == 1) {
            // scroll table
            UIUtil.scrollToSelectedRow(table);
            int rowCount = table.getRowCount();
            if (rowCount > 1) {
                if (selectedRow > 0) {
                    enableUp = true;
                }
                if (selectedRow < (rowCount - 1)) {
                    enableDown = true;
                }
            }
        }
    }
    removeParameterButton.setEnabled(enableRemoveButton);
    moveUp.setEnabled(enableUp);
    moveDown.setEnabled(enableDown);
    syncButtons();
    ProcedureParameterDisplayEvent ppde = new ProcedureParameterDisplayEvent(this, parameters, eventController.getCurrentProcedure(), eventController.getCurrentDataMap(), (DataChannelDescriptor) eventController.getProject().getRootNode());
    eventController.fireProcedureParameterDisplayEvent(ppde);
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) ProcedureParameterDisplayEvent(org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent) ChangeEvent(javax.swing.event.ChangeEvent)

Example 4 with ProcedureParameterDisplayEvent

use of org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent in project cayenne by apache.

the class FindAction method jumpToProcedureResult.

private static void jumpToProcedureResult(ProcedureParameter parameter, EditorView editor, DataChannelDescriptor domain) {
    Procedure procedure = parameter.getProcedure();
    DataMap map = procedure.getDataMap();
    buildAndSelectTreePath(map, procedure, editor);
    ProcedureParameterDisplayEvent event = new ProcedureParameterDisplayEvent(editor.getProjectTreeView(), parameter, procedure, map, domain);
    editor.getProcedureView().currentProcedureParameterChanged(event);
    editor.getProcedureView().repaint();
}
Also used : ProcedureParameterDisplayEvent(org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent) Procedure(org.apache.cayenne.map.Procedure) DataMap(org.apache.cayenne.map.DataMap)

Example 5 with ProcedureParameterDisplayEvent

use of org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent in project cayenne by apache.

the class ProcedureParameterDisplayEventType method fireLastDisplayEvent.

@Override
public void fireLastDisplayEvent() {
    DataChannelDescriptor dataChannel = (DataChannelDescriptor) controller.getProject().getRootNode();
    if (!dataChannel.getName().equals(preferences.getDomain())) {
        return;
    }
    DataMap dataMap = dataChannel.getDataMap(preferences.getDataMap());
    if (dataMap == null) {
        return;
    }
    Procedure procedure = dataMap.getProcedure(preferences.getProcedure());
    if (procedure == null) {
        return;
    }
    ProcedureDisplayEvent procedureDisplayEvent = new ProcedureDisplayEvent(this, procedure, dataMap, dataChannel);
    controller.fireProcedureDisplayEvent(procedureDisplayEvent);
    ProcedureParameter[] procedureParameters = getLastProcedureParameters(procedure);
    ProcedureParameterDisplayEvent procedureParameterDisplayEvent = new ProcedureParameterDisplayEvent(this, procedureParameters, procedure, dataMap, dataChannel);
    controller.fireProcedureParameterDisplayEvent(procedureParameterDisplayEvent);
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) ProcedureDisplayEvent(org.apache.cayenne.modeler.event.ProcedureDisplayEvent) ProcedureParameterDisplayEvent(org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) Procedure(org.apache.cayenne.map.Procedure) DataMap(org.apache.cayenne.map.DataMap)

Aggregations

ProcedureParameterDisplayEvent (org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent)5 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)3 DataMap (org.apache.cayenne.map.DataMap)3 Procedure (org.apache.cayenne.map.Procedure)3 ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)3 ProcedureDisplayEvent (org.apache.cayenne.modeler.event.ProcedureDisplayEvent)2 ChangeEvent (javax.swing.event.ChangeEvent)1 ProcedureParameterEvent (org.apache.cayenne.configuration.event.ProcedureParameterEvent)1