Tabnine Logo
Bound
Code IndexAdd Tabnine 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)

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 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 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 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

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 {
  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

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 {
  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 = "value")
private final JSlider slider = new JSlider();
com.palantir.ptoss.cinch.swingBound

Most used methods

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

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getResourceAsStream (ClassLoader)
  • setScale (BigDecimal)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now