Codota Logo
Bound
Code IndexAdd Codota to your IDE (free)

How to use
Bound
in
com.palantir.ptoss.cinch.swing

Best Java code snippets using com.palantir.ptoss.cinch.swing.Bound (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Point p =
  • Codota Iconnew Point(x, y)
  • Codota Iconnew Point()
  • Codota IconMouseEvent e;e.getPoint()
  • Smart code suggestions by Codota
}
origin: palantir/Cinch

class CommentsView extends BaseView<CommentableModel> {
  @Bound(to = "comment")
  private JLabel countLabel = new JLabel();
  public CommentsView(CommentableModel model) {
    super(model);
    panel.add(countLabel, BorderLayout.EAST);
    bindings.bind(this);
  }
}
origin: palantir/Cinch

public Collection<Binding> wire(Bound bound, BindingContext context, Field field) throws IllegalAccessException, IntrospectionException {
  String target = bound.to();
  JComboBox combo = context.getFieldObject(field, JComboBox.class);
  Mutator mutator = Mutator.create(context, target);
  final String nullValue = (String)Utilities.getNullValue(context, bound.nullValue());
  return ImmutableList.of(bindJComboBox(bound, mutator, combo, nullValue));
}
origin: palantir/Cinch

public Collection<Binding> wire(Bound bound, BindingContext context, Field field)
    throws IllegalAccessException, IntrospectionException {
  String target = bound.to();
  Mutator mutator = Mutator.create(context, target);
  JToggleButton toggle = context.getFieldObject(field, JToggleButton.class);
  Class<?>[] paramTypes = mutator.getSetter().getMethod().getParameterTypes();
  if (paramTypes.length == 1 && paramTypes[0].isEnum()) {
    Class<?> enumType = paramTypes[0];
    String value = bound.value();
    return ImmutableList.of(bindJToggleButtonToEnum(value, enumType, mutator, toggle));
  } else if (paramTypes.length == 1 && paramTypes[0] == boolean.class) {
    String value = bound.value();
    if (Strings.isNullOrEmpty(value)) {
      return ImmutableList.of(AbstractButtonWiringHarness.bindAbstractButton(mutator, toggle));
    } else {
      return ImmutableList.of(bindJToggleButtonToBoolean(bound.value(), mutator, toggle));
    }
  } else {
    throw new BindingException("can only bind JToggleButtons to enums or booleans"); //$NON-NLS-1$
  }
}
origin: palantir/Cinch

public Collection<Binding> wire(Bound bound, BindingContext context, Field field) throws IllegalAccessException, IntrospectionException {
  JTextComponent textComponent = context.getFieldObject(field, JTextComponent.class);
  Mutator mutator = Mutator.create(context, bound.to());
  Binding binding = bindJTextComponent(mutator, textComponent);
  if (binding == null) {
    return ImmutableList.of();
  }
  return ImmutableList.of(binding);
}
origin: palantir/Cinch

private Binding bindJComboBox(final Bound bound, final Mutator mutator, final JComboBox combo, final String nullValue) {
  final List<Object> ons = BindingContext.getOnObjects(bound.on(), mutator.getModel());
  Binding binding = new Binding() {
    public <T extends Enum<?> & ModelUpdate> void update(T... changed) {
      if (!BindingContext.isOn(ons, changed)) {
        return;
      }
      try {
        updateComboModel(combo, (List<?>)mutator.get(), nullValue);
      } catch (Exception ex) {
        Wiring.logger.error("exception in JList binding", ex);
      }
    }
  };
  mutator.getModel().bind(binding);
  return binding;
}
origin: palantir/Cinch

public Collection<Binding> wire(Bound bound, BindingContext context, Field field)
    throws IllegalAccessException, IntrospectionException {
  Mutator mutator = Mutator.create(context, bound.to());
  AbstractButton abstractButton = context.getFieldObject(field, AbstractButton.class);
  return ImmutableList.of(bindAbstractButton(mutator, abstractButton));
}
origin: palantir/Cinch

private Binding bindJList(final Bound bound, final Mutator mutator, final JList list) {
  final List<Object> ons = BindingContext.getOnObjects(bound.on(), mutator.getModel());
  Binding binding = new Binding() {
    public <T extends Enum<?> & ModelUpdate> void update(T... changed) {
      if (!BindingContext.isOn(ons, changed)) {
        return;
      }
      try {
        updateListModel(list, (List<?>)mutator.get());
      } catch (Exception ex) {
        Wiring.logger.error("exception in JList binding", ex);
      }
    }
  };
  mutator.getModel().bind(binding);
  return binding;
}
origin: palantir/Cinch

public class CommentsView2 extends BaseView<CommentableModel> {
  private final CommentableModel commentableModel;
  @Bound(to="comment")
  private JLabel countLabel = new JLabel();
  private Bindings bindings = new Bindings();
  public CommentsView2(CommentableModel model) {
    super(model);
    this.commentableModel = model;
    panel.add(countLabel, BorderLayout.EAST);
    bindings.bind(this);
  }
}
origin: palantir/Cinch

public Collection<Binding> wire(Bound bound, BindingContext context, Field field) throws IllegalAccessException, IntrospectionException {
  String target = bound.to();
  Mutator mutator = Mutator.create(context, target);
  JSlider slider = context.getFieldObject(field, JSlider.class);
  return ImmutableList.of(bindJSlider(mutator, slider));
}
origin: palantir/Cinch

class BaseView<T extends BaseModel> {
  protected final T model;
  protected Bindings bindings = new Bindings();
  protected JPanel panel = new JPanel(new BorderLayout());
  // "model." is required to prevent subclasses from clobbering
  @Bound(to = "model.displayText")
  private final JLabel label = new JLabel();
  public BaseView(T model) {
    this.model = model;
    panel.add(label, BorderLayout.CENTER);
  }
}
origin: palantir/Cinch

public Collection<Binding> wire(Bound bound, BindingContext context, Field field)
    throws IllegalAccessException, IntrospectionException {
  JList list = context.getFieldObject(field, JList.class);
  Mutator mutator = Mutator.create(context, bound.to());
  return ImmutableList.of(bindJList(bound, mutator, list));
}
origin: palantir/Cinch

public class CantFindGetterSetterTest extends TestCase {

  final NegativeModel model = new NegativeModel();

  @Bound(to = "cantFind")
  private final JRadioButton button = new JRadioButton("button");

  final Bindings bindings = new Bindings();

  public void testFailure() {
    try {
      bindings.bind(this);
      fail("should not allow binding if can't find getter or setter");
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
  }
}

origin: palantir/Cinch

public Collection<Binding> wire(Bound bound, BindingContext context, Field field)
    throws IllegalAccessException, IntrospectionException {
  JLabel label = context.getFieldObject(field, JLabel.class);
  Mutator mutator = Mutator.create(context, bound.to());
  return ImmutableList.of(bindJLabel(mutator, label));
}
origin: palantir/Cinch

public class WrongTypeTest extends TestCase {

  final NegativeModel model = new NegativeModel();

  @Bound(to = "badEnum")
  private final JRadioButton button = new JRadioButton("button");

  final Bindings bindings = new Bindings();

  public void testFailure() {
    try {
      bindings.bind(this);
      fail("should not allow binding to wrong type");
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
  }
}

origin: palantir/Cinch

    public Collection<Binding> wire(Bound bound, BindingContext context, Field field) throws IllegalAccessException, IntrospectionException {
      String target = bound.to();
      JProgressBar bar = context.getFieldObject(field, JProgressBar.class);
//            ObjectFieldMethod setter = context.findSetter(target);
      ObjectFieldMethod getter = context.findGetter(target);
      if (getter == null) {
        throw new IllegalArgumentException("could not find getter/setter for " + target);
      }
      BindableModel model = context.getFieldObject(getter.getField(), BindableModel.class);
      // verify type parameters
      return bindJProgressBar(model, bar, getter.getMethod());
    }

origin: palantir/Cinch

private static class BooleanComponent {
  final BooleanModel model;
  @Bound(to = "state")
  final JCheckBox box = new JCheckBox("State");
  final Bindings bindings = new Bindings();
  public BooleanComponent(BooleanModel model) {
    this.model = model;
    this.bindings.bind(this);
  }
  public JComponent getDisplayComponent() {
    return box;
  }
  public void dispose() {
    bindings.release(model);
  }
}
 
origin: palantir/Cinch

public Collection<Binding> wire(Bound bound, BindingContext context, Field field) throws IllegalAccessException, IntrospectionException {
  String target = bound.to();
  JPasswordField pwdField = context.getFieldObject(field, JPasswordField.class);
  ObjectFieldMethod setter = context.findSetter(target);
  ObjectFieldMethod getter = context.findGetter(target);
  if (setter == null || getter == null) {
    throw new IllegalArgumentException("could not find getter/setter for " + target);
  }
  BindableModel model1 = context.getFieldObject(setter.getField(), BindableModel.class);
  BindableModel model2 = context.getFieldObject(getter.getField(), BindableModel.class);
  Preconditions.checkArgument(model1 == model2, "setter not bound to same field as getter");
  // verify type parameters
  return bindJPasswordField(model1, pwdField, getter.getMethod(), setter.getMethod());
}
origin: palantir/Cinch

public class BoundJCheckBoxMenuItemTest extends TestCase {

  final BooleanModel model = new BooleanModel();

  @Bound(to = "state")
  final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem();

  final Bindings bindings = Bindings.standard();

  @Override
  protected void setUp() throws Exception {
    bindings.bind(this);
  }

  public void testSimple() {
    assertFalse(model.isState());
    assertFalse(menuItem.isSelected());
    model.setState(true);
    assertTrue(menuItem.isSelected());
    assertTrue(model.isState());
    menuItem.doClick();
    assertFalse(model.isState());
    assertFalse(menuItem.isSelected());
  }
}

origin: palantir/Cinch

public class BoundJCheckBoxTest extends TestCase {

  final BooleanModel model = new BooleanModel();

  @Bound(to = "state")
  final JCheckBox box = new JCheckBox();

  final Bindings bindings = Bindings.standard();

  @Override
  protected void setUp() throws Exception {
    bindings.bind(this);
  }

  public void testSimple() {
    assertFalse(model.isState());
    assertFalse(box.isSelected());
    model.setState(true);
    assertTrue(box.isSelected());
    assertTrue(model.isState());
    box.doClick();
    assertFalse(model.isState());
    assertFalse(box.isSelected());
  }
}

origin: palantir/Cinch

@Bound(to = "string")
private final JLabel label = new JLabel();
com.palantir.ptoss.cinch.swingBound

Most used methods

  • <init>
  • nullValue
  • on
  • to
  • value

Popular in Java

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • runOnUiThread (Activity)
  • Kernel (java.awt.image)
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • JCheckBox (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now