/** Binds the UI */
  public void bindUI() {
    myContext = IBindingContext.Factory.createContext(myView.getScrolledForm());

    myViewerBinding =
        myContext.addViewer(myTableViewer, myShop, ShopPackage.Literals.SHOP__CONTACTS);
    myNameColumnBinding =
        myViewerBinding.addColumn(myNameColumn, IMOAOPackage.Literals.NAMED_OBJECT__NAME);
    myCountryColumnBinding =
        myViewerBinding
            .addColumn(myCountryColumn, ShopPackage.Literals.CONTACT__COUNTRY)
            .arg(Constants.ARG_FEATURE_NAME, "abbreviation")
            .validValues(myShop, ShopPackage.Literals.SHOP__COUNTRIES);
    myCountryNameColumnBinding =
        myCountryColumnBinding
            .addColumn(myCountryNameColumn, IMOAOPackage.Literals.NAMED_OBJECT__NAME)
            .readonly();

    final IObservableValue selection = myViewerBinding.getSingleSelection();

    myNameBinding =
        myContext.addBinding(myNameText, selection, IMOAOPackage.Literals.NAMED_OBJECT__NAME);

    myContext.finish();
    yield();
  }
Пример #2
0
  /** Binds the UI */
  public void bindUI() {
    myContext = IBindingContext.Factory.createContext(myView.getScrolledForm());

    myViewer = myContext.addViewer(myTable, myShop, ShopPackage.Literals.SHOP__COUNTRIES);
    myViewer.addColumn(myNameColumn, IMOAOPackage.Literals.NAMED_OBJECT__NAME);
    myViewer.addColumn(myAbbreviationColumn, ShopPackage.Literals.COUNTRY__ABBREVIATION);

    myContext.finish();
    yield();
  }
  private void createView() {
    myView = BaseUIBTestUtils.createUIBTestView(this);

    myGrid = new Grid(myView.getBody(), SWT.NONE);
    myContext = IBindingContext.Factory.createContext(myView.getBody());
    myGridBinding = IGridBinding.Factory.createGrid(myContext, myGrid, myModel);
    myContext.finish();
    yield();

    myView.getSite().getPage().activate(myView);
    myView.getBody().layout();

    yield();
  }
  /**
   * Tests the bindings are properly disposed - both the primary binding and any additional bindings
   */
  @Test
  public void testControlDispose() {
    final IBindingContext context = IBindingContext.Factory.createContext(myView.getScrolledForm());

    final IValueBinding binding1 =
        context.addBinding(myText, myShop, IMOAOPackage.Literals.NAMED_OBJECT__NAME);
    final IValueBinding binding2 =
        context.addBinding().ui(myText, Constants.ATTR_ENABLED).model(myBoolOV);
    context.finish();
    yield();

    assertEquals(BindingState.OK, binding1.getState());
    assertEquals(BindingState.OK, binding2.getState());

    myText.dispose();
    yield();

    assertEquals(BindingState.DISPOSED, binding1.getState());
    assertEquals(BindingState.DISPOSED, binding2.getState());
  }