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 javax.swing.*;

A factory for a number of common bindings.
 
 public class BindingFactory {
 
     protected boolean usingNullForEmptyStrings;
     protected boolean checkingForValueChange;
 
     public BindingFactory() {
         // init defaults...
          = true;
          = true;
     }
 
     public ObjectBinding bindToTable(
             JTable table,
             String listBinding,
             String[] headers,
             BindingExpression[] columns,
             Class[] columnClass,
             boolean[] editableState,
             Object[] sampleLongValues) {
 
         TableBinding binding = new TableBinding(
                 table,
                 listBinding,
                 headers,
                 columns,
                 columnClass,
                 editableState,
                 sampleLongValues);
         return prepareBinding(binding);
     }
 
     public ObjectBinding bindToProperty(
             BoundComponent component,
             String property,
             String boundProperty) {
         PropertyBinding binding = new PropertyBinding(componentpropertyboundProperty);
         return prepareBinding(binding);
     }

    
Binds to AbstractButton item state change events. Most common AbstractButton subclasses are JButton, JCheckBox, JRadioButton.
 
     public ObjectBinding bindToStateChange(AbstractButton buttonString property) {
         ItemEventBinding binding = new ItemEventBinding(buttonproperty);
         return prepareBinding(binding);
     }

    
Binds to AbstractButton action events. Most common AbstractButton subclasses are JButton, JCheckBox, JRadioButton.
 
     public ObjectBinding bindToAction(AbstractButton buttonString action) {
         ActionBinding binding = new ActionBinding(buttonaction);
         return prepareBinding(binding);
     }

    
Binds to a generic component. Action events support is discovered via introspection. If component class does not define action events, an exception is thrown.
 
     public ObjectBinding bindToAction(Component componentString action) {
         BeanActionBinding binding = new BeanActionBinding(componentaction);
         return prepareBinding(binding);
     }
 
     public ObjectBinding bindToAction(
             BoundComponent component,
             String action,
            String boundExpression) {
        ActionBinding binding = new ActionBinding(componentactionboundExpression);
        return prepareBinding(binding);
    }
            JComboBox component,
            String property,
            String noSelectionValue) {
        ComboSelectionBinding binding = new ComboSelectionBinding(
                component,
                property,
                noSelectionValue);
        return prepareBinding(binding);
    }
    public ObjectBinding bindToTextArea(JTextArea componentString property) {
        TextBinding binding = new TextBinding(componentproperty);
        return prepareBinding(binding);
    }

    
Creates a binding that updates a property on text field text changes.
    public ObjectBinding bindToTextField(JTextField componentString property) {
        TextBinding binding = new TextBinding(componentproperty);
        return prepareBinding(binding);
    }
    public ObjectBinding bindToCheckBox(JCheckBox componentString property) {
        CheckBoxBinding binding = new CheckBoxBinding(componentproperty);
        return prepareBinding(binding);
    }

    
Configures binding with factory default settings.
    protected ObjectBinding prepareBinding(BindingBase binding) {
        return binding;
    }
    public boolean isCheckingForValueChange() {
        return ;
    }
    public void setCheckingForValueChange(boolean callingSetForEqual) {
        this. = callingSetForEqual;
    }
    public boolean isUsingNullForEmptyStrings() {
        return ;
    }
    public void setUsingNullForEmptyStrings(boolean usingNullForEmptyStrings) {
        this. = usingNullForEmptyStrings;
    }
New to GrepCode? Check out our FAQ X