Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 
 package org.apache.cayenne.modeler.editor;
 
 
 
 import  org.apache.cayenne.dba.TypesMapping;
 import  org.apache.cayenne.map.Procedure;
 import  org.apache.cayenne.map.ProcedureParameter;
 import  org.apache.cayenne.map.event.ProcedureParameterEvent;
 
     public static final int PARAMETER_NUMBER = 0;
     public static final int PARAMETER_NAME = 1;
     public static final int PARAMETER_DIRECTION = 2;
     public static final int PARAMETER_TYPE = 3;
     public static final int PARAMETER_LENGTH = 4;
     public static final int PARAMETER_PRECISION = 5;
 
     public static final String IN_PARAMETER = "IN";
     public static final String OUT_PARAMETER = "OUT";
     public static final String IN_OUT_PARAMETER = "INOUT";
 
     public static final String[] PARAMETER_DIRECTION_NAMES =
         new String[] { "" };
 
     private static final int[] PARAMETER_INDEXES =
         new int[] {
             ,
             ,
             ,
             ,
             ,
              };
 
     private static final String[] PARAMETER_NAMES =
         new String[] { "No.""Name""Direction""Type""Max Length""Precision" };
 
     protected Procedure procedure;
 
         Procedure procedure,
         ProjectController mediator,
         Object eventSource) {
 
         super(mediatoreventSourcenew ArrayList(procedure.getCallParameters()));
         this. = procedure;
     }

    
Returns procedure parameter at the specified row. Returns NULL if row index is outside the valid range.
 
     public ProcedureParameter getParameter(int row) {
         return (row >= 0 && row < .size())
             ? (ProcedureParameter) .get(row)
             : null;
     }
 
     public void setUpdatedValueAt(Object newValint rowIndexint columnIndex) {
         ProcedureParameter parameter = getParameter(rowIndex);
 
         if (parameter == null) {
             return;
         }
 
         ProcedureParameterEvent event =
             new ProcedureParameterEvent(parameter);
         switch (columnIndex) {
             case  :
                 event.setOldName(parameter.getName());
                 setParameterName((StringnewValparameter);
                 fireTableCellUpdated(rowIndexcolumnIndex);
                 break;
             case  :
                setParameterDirection((StringnewValparameter);
                break;
            case  :
                setParameterType((StringnewValparameter);
                break;
            case  :
                setMaxLength((StringnewValparameter);
                break;
            case  :
                setPrecision((StringnewValparameter);
                break;
        }
    }
    protected void setPrecision(String newVal, ProcedureParameter parameter) {
        if (newVal == null || newVal.trim().length() <= 0) {
            parameter.setPrecision(-1);
        }
        else {
            try {
                parameter.setPrecision(Integer.parseInt(newVal));
            }
            catch (NumberFormatException ex) {
                JOptionPane.showMessageDialog(
                    null,
                    "Invalid precision (" + newVal + "), only numbers are allowed.",
                    "Invalid Precision Value",
                    .);
            }
        }
    }
    protected void setMaxLength(String newVal, ProcedureParameter parameter) {
        if (newVal == null || newVal.trim().length() <= 0) {
            parameter.setMaxLength(-1);
        }
        else {
            try {
                parameter.setMaxLength(Integer.parseInt(newVal));
            }
            catch (NumberFormatException ex) {
                JOptionPane.showMessageDialog(
                    null,
                    "Invalid Max Length (" + newVal + "), only numbers are allowed",
                    "Invalid Maximum Length",
                    .);
                return;
            }
        }
    }
    protected void setParameterType(String newVal, ProcedureParameter parameter) {
        parameter.setType(TypesMapping.getSqlTypeByName(newVal));
    }
    protected void setParameterDirection(
        String direction,
        ProcedureParameter parameter) {
        if (..equals(direction)) {
            parameter.setDirection(ProcedureParameter.IN_PARAMETER);
        }
        else if (..equals(direction)) {
            parameter.setDirection(ProcedureParameter.OUT_PARAMETER);
        }
        else if (..equals(direction)) {
            parameter.setDirection(ProcedureParameter.IN_OUT_PARAMETER);
        }
        else {
            parameter.setDirection(-1);
        }
    }
    protected void setParameterName(String newVal, ProcedureParameter parameter) {
        ProjectUtil.setProcedureParameterName(parameternewVal.trim());
    }
    public Class getElementsClass() {
        return ProcedureParameter.class;
    }
    public int getColumnCount() {
        return .;
    }
    public Object getValueAt(int rowIndexint columnIndex) {
        ProcedureParameter parameter = getParameter(rowIndex);
        if (parameter == null) {
            return "";
        }
        switch (columnIndex) {
            case  :
                return getParameterNumber(rowIndexparameter);
            case  :
                return getParameterName(parameter);
            case  :
                return getParameterDirection(parameter);
            case  :
                return getParameterType(parameter);
            case  :
                return getParameterLength(parameter);
            case  :
                return getParameterPrecision(parameter);
            default :
                return "";
        }
    }
    protected Object getParameterNumber(int rowIndex, ProcedureParameter parameter) {
        boolean hasReturnValue = parameter.getProcedure().isReturningValue();
        if (hasReturnValue) {
            return (rowIndex == 0) ? "R" : "" + rowIndex;
        }
        else {
            return "" + (rowIndex + 1);
        }
    }
    protected Object getParameterPrecision(ProcedureParameter parameter) {
        return (parameter.getPrecision() >= 0)
            ? String.valueOf(parameter.getPrecision())
            : "";
    }
    protected Object getParameterLength(ProcedureParameter parameter) {
        return (parameter.getMaxLength() >= 0)
            ? String.valueOf(parameter.getMaxLength())
            : "";
    }
    protected Object getParameterType(ProcedureParameter parameter) {
        return TypesMapping.getSqlNameByType(parameter.getType());
    }
    protected Object getParameterDirection(ProcedureParameter parameter) {
        int direction = parameter.getDirection();
        switch (direction) {
            case ProcedureParameter.IN_PARAMETER :
                return .;
            case ProcedureParameter.OUT_PARAMETER :
                return .;
            case ProcedureParameter.IN_OUT_PARAMETER :
                return .;
            default :
                return "";
        }
    }
    protected Object getParameterName(ProcedureParameter parameter) {
        return parameter.getName();
    }
    public String getColumnName(int col) {
        return [col];
    }
    public Class getColumnClass(int col) {
        return String.class;
    }

    
Suppressed ordering operations defined in a superclass. Since stored procedure parameters are positional, no reordering is allowed.
    public void orderList() {
        // NOOP
    }
    public boolean isCellEditable(int rowint col) {
        return col != ;
    }
New to GrepCode? Check out our FAQ X