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.editor.datanode;
 import  org.apache.cayenne.access.DataNode;
 import  org.apache.cayenne.dba.AutoAdapter;
 import  org.apache.cayenne.dba.DbAdapter;
 public class AdapterEditor extends CayenneController {
     protected AdapterView view;
     protected DataNode node;
     protected ObjectBinding adapterNameBinding;
     public AdapterEditor(CayenneController parent) {
         this. = new AdapterView();
     protected void initController() {
         // init bindings
         BindingBuilder builder = new BindingBuilder(
          = builder.bindToTextField(
         // init listeners–ö
                 .addDataNodeDisplayListener(new DataNodeDisplayListener() {
                     public void currentDataNodeChanged(DataNodeDisplayEvent e) {
         getView().addComponentListener(new ComponentAdapter() {
             public void componentShown(ComponentEvent e) {
                 refreshView( != null ?  : ((ProjectControllergetParent())
     protected void refreshView(DataNode node) {
         this. = node;
         if (node == null) {
     public Component getView() {
         return ;
     public String getAdapterName() {
         if ( == null) {
             return null;
        DbAdapter adapter = .getAdapter();
        // TODO, Andrus, 11/3/2005 - to simplify this logic, it would be nice to
        // consistently load CustomDbAdapter... this would require an ability to set a
        // load delegate in OpenProjectAction
        if (adapter == null) {
            return null;
        else if (adapter instanceof ModelerDbAdapter) {
            return ((ModelerDbAdapteradapter).getAdapterClassName();
        // don't do "instanceof" here, as we maybe dealing with a custom subclass...
        else if (adapter.getClass() == AutoAdapter.class) {
            return null;
        else {
            return adapter.getClass().getName();
    public void setAdapterName(String name) {
        if ( == null) {
        ModelerDbAdapter adapter = new ModelerDbAdapter(name.getDataSource());
        DataNodeEvent e = new DataNodeEvent(AdapterEditor.this);
New to GrepCode? Check out our FAQ X