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.dialog.codegen;
 
 
 
 import  org.apache.cayenne.map.DataMap;
A controller for the class generator dialog.
 
 public class CodeGeneratorController extends CodeGeneratorControllerBase {
    
Logger to print stack traces
 
     private static Log logObj = LogFactory.getLog(ErrorDebugDialog.class);
 
     protected CodeGeneratorDialog view;
 
     protected ClassesTabController clessSelector;
 
     public CodeGeneratorController(CayenneController parent, DataMap dataMap) {
         super(parentdataMap);
 
         this. = new ClassesTabController(this);
         this. = new GeneratorTabController(this);
     }
 
     @Override
     public Component getView() {
         return ;
     }
 
     public void startup() {
         // show dialog even on empty DataMap, as custom generation may still take
         // advantage of it
 
                 .getView());
         initBindings();
 
         .pack();
         .setModal(true);
         centerView();
         makeCloseableOnEscape();
         .setVisible(true);
     }
 
     protected void initBindings() {
         BindingBuilder builder = new BindingBuilder(
                 getApplication().getBindingFactory(),
                 this);
 
         builder.bindToAction(.getCancelButton(), "cancelAction()");
         builder.bindToAction(.getGenerateButton(), "generateAction()");
         builder.bindToAction(this"classesSelectedAction()");
         builder.bindToAction(
                 ,
                 "generatorSelectedAction()",
                 .);
 
         generatorSelectedAction();
     }
 
     public void generatorSelectedAction() {
         validate(controller);
 
         Predicate predicate = controller != null
                 ? controller.getDefaultClassFilter()
                : PredicateUtils.falsePredicate();
        updateSelection(predicate);
    }
    public void classesSelectedAction() {
        int size = getSelectedEntitiesSize();
        String label;
        if (size == 0) {
            label = "No entities selected";
        }
        else if (size == 1) {
            label = "One entity selected";
        }
        else {
            label = size + " entities selected";
        }
        label = label.concat("; ");
        
        int sizeEmb = getSelectedEmbeddablesSize();
        if (sizeEmb == 0) {
            label = label + "No embeddables selected";
        }
        else if (sizeEmb == 1) {
            label = label + "One embeddable selected";
        }
        else {
            label =label + sizeEmb + " embeddables selected";
        }
        
        .getClassesCount().setText(label);
    }
    public void cancelAction() {
        .dispose();
    }
    public void generateAction() {
        ClassGenerationAction generator = .getGenerator();
        if (generator != null) {
            try {
                generator.execute();
                JOptionPane.showMessageDialog(
                        this.getView(),
                        "Class generation finished");
            }
            catch (Exception e) {
                .error("Error generating classes"e);
                JOptionPane.showMessageDialog(
                        this.getView(),
                        "Error generating classes - " + e.getMessage());
            }
        }
        .dispose();
    }
New to GrepCode? Check out our FAQ X