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.swing;
 
 import java.util.Map;
 
A builder for component bindings that delegates the creation of the binding to the underlying factory, and itself configures a number of binding parameters.

Author(s):
Andrei Adamchik
 
 public class BindingBuilder {
 
     protected BindingFactory factory;
     protected BindingDelegate delegate;
     protected Object context;
     protected Map actionsMap;

    
Constructs BindingBuilder with a BindingFactory and a root model object (or context) of the binding.
 
     public BindingBuilder(BindingFactory factoryObject context) {
         this. = factory;
         this. = context;
     }
 
     public BindingDelegate getDelegate() {
         return ;
     }

    
Sets BindingDelegate that will be assigned to all bindings created via this BindingBuilder.
 
     public void setDelegate(BindingDelegate delegate) {
         this. = delegate;
     }
 
     public Object getContext() {
         return ;
     }

    
Sets the context object that will be used by all bindings created via this BindingBuilder. Context is a root of the domain model for the given binding.
 
     public void setContext(Object context) {
         this. = context;
     }
 
     public BindingFactory getFactory() {
         return ;
     }

    
Binds to an instance of BoundComponent.

Since:
1.2
 
     public ObjectBinding bindToProperty(
             BoundComponent component,
             String property,
             String boundProperty) {
         ObjectBinding binding = 
                 .bindToProperty(componentpropertyboundProperty);
         return initBinding(binding);
     }
 
     public ObjectBinding bindToAction(
             BoundComponent component,
             String action,
             String boundProperty) {
         ObjectBinding binding = .bindToAction(componentactionboundProperty);
        return initBinding(binding);
    }
    public ObjectBinding bindToStateChange(AbstractButton buttonString property) {
        ObjectBinding binding = .bindToStateChange(buttonproperty);
        return initBinding(binding);
    }
            AbstractButton button,
            String property,
            String action) {
        ObjectBinding binding = .bindToStateChange(buttonproperty);
        return initBinding(bindinggetActionDelegate(action));
    }
    public ObjectBinding bindToAction(AbstractButton buttonString action) {
        ObjectBinding binding = .bindToAction(buttonaction);
        return initBinding(binding);
    }
    public ObjectBinding bindToAction(Component componentString action) {
        ObjectBinding binding = .bindToAction(componentaction);
        return initBinding(binding);
    }
    public ObjectBinding bindToComboSelection(JComboBox componentString property) {
        ObjectBinding binding = .bindToComboSelection(componentpropertynull);
        return initBinding(binding);
    }
            JComboBox component,
            String property,
            String noSelectionValue) {
        ObjectBinding binding = .bindToComboSelection(
                component,
                property,
                noSelectionValue);
        return initBinding(binding);
    }
            JComboBox component,
            String property,
            String action,
            String noSelectionValue) {
        ObjectBinding binding = .bindToComboSelection(
                component,
                property,
                noSelectionValue);
        return initBinding(bindinggetActionDelegate(action));
    }
    public ObjectBinding bindToTextArea(JTextArea componentString property) {
        ObjectBinding binding = .bindToTextArea(componentproperty);
        return initBinding(binding);
    }
    public ObjectBinding bindToTextField(JTextField componentString property) {
        ObjectBinding binding = .bindToTextField(componentproperty);
        return initBinding(binding);
    }
    protected ObjectBinding initBinding(ObjectBinding bindingBindingDelegate delegate) {
        binding.setDelegate(delegate);
        binding.setContext();
        return binding;
    }
    protected BindingDelegate getActionDelegate(String action) {
        BindingDelegate delegate = null;
        if ( == null) {
             = new HashMap();
        }
        else {
            delegate = (BindingDelegate.get(action);
        }
        if (delegate == null) {
            delegate = new ActionDelegate(action);
            .put(actiondelegate);
        }
        return delegate;
    }
New to GrepCode? Check out our FAQ X