Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.pentaho.ui.xul.gwt.binding;
 
 import java.util.List;
 import java.util.Map;
 
public class GwtBindingContext implements BindingContext {
    private List<Bindingbindings = new ArrayList<Binding>();
    
    public static TypeController typeController;
    static{
      try{
         = GWT.create(TypeController.class);
      } catch (Exception e){
        ..println(e);
        e.printStackTrace();
      }
    }
    //internal map of Binding to PropChangeListeners, used to cleanup upon removal
    public GwtBindingContext() {
    }
    public void add(XulComponent sourceString expr) {
//      BindingExpression expression = BindingExpression.parse(expr);
//      XulComponent target = container.getDocumentRoot().getElementById(expression.target);
//      
//      TODO: bindingFactory.createBinding
//      Binding newBinding = new GwtBinding(source, expression.sourceAttr, target, expression.targetAttr);
//      add(newBinding);
    }
    public void remove(Binding bind) {
      if (!.containsKey(bind) && !.contains(bind)) {
        return;
      }
      bind.destroyBindings();
      .remove(bind);
      .remove(bind);
    }
    /*
     * 1. inits the binding defined by the bind object
     * 2. registers binding listeners
     */
    public void add(Binding bind) {
      try {
        .add(bind);
        bind.bindForward();
        if (!.containsKey(bind)) {
          .put(bindnew ArrayList<PropertyChangeListener>());
        }
        .get(bind).add(bind.getForwardListener());
        if (bind.getBindingType() == ..) {
          bind.bindReverse();
          .get(bind).add(bind.getReverseListener());
        }
        
        bind.setContext(this);
      } catch (Throwable t) {
        throw new BindingException("Binding failed: " + bind.getSource() + "." + bind.getSourceAttr() + " <==> "
            + bind.getTarget() + "." + bind.getTargetAttr(), t);
      }
    }
    
    public void addInitializedBinding(Binding binding) {
      try {
        .add(binding);
        if (!.containsKey(binding)) {
          .put(bindingnew ArrayList<PropertyChangeListener>());
        }
        .get(binding).addAll(binding.getListeneners());
        
        binding.setContext(this);
      } catch (Throwable t) {
        throw new BindingException("Binding failed: " + binding.getSource() + "." + binding.getSourceAttr() + " <==> "
            + binding.getTarget() + "." + binding.getTargetAttr(), t);
      }
    }
  }
  
New to GrepCode? Check out our FAQ X