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 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.action;
 import  org.apache.cayenne.util.NameConverter;

Base class for creating callback methods

1.0 Oct 28, 2007
 public abstract class AbstractCreateCallbackMethodAction extends CayenneAction {



actionName unique action name
application Application instance
     public AbstractCreateCallbackMethodAction(String actionNameApplication application) {


CallbackMap instance where to create a method
     public abstract CallbackMap getCallbackMap();


icon file name for button
     public String getIconName() {
         return "icon-create-method.gif";

performs adding new callback method

e event
     public final void performAction(ActionEvent e) {
         CallbackType callbackType = getProjectController().getCurrentCallbackType();
         // generate methodName
         String methodNamePrefix = toMethodName(callbackType.getType());
         String methodName;
         // now that we're generating the method names based on the callback type, check to
         // see if the
         // raw prefix, no numbers, is taken.
         if (!getCallbackMap()
                 .contains(methodNamePrefix)) {
             methodName = methodNamePrefix;
         else {
             int counter = 1;
             do {
                 methodName = methodNamePrefix + counter;
             } while (getCallbackMap()
         createCallbackMethod(getCallbackMap(), callbackTypemethodName);
                 new CreateCallbackMethodUndoableEdit(
    public void createCallbackMethod(
            CallbackMap map,
            CallbackType callbackType,
            String methodName) {
        CallbackMethodEvent ce = new CallbackMethodEvent(
    private String toMethodName(LifecycleEvent event) {
        return "on" + NameConverter.underscoredToJava(, true);
New to GrepCode? Check out our FAQ X