/** Tests the different supported patterns */ @Test public void filterPatternTest() { IFilteringTableAdapter.Factory.adapt(myViewer, myFilter); // Empty // myFilter.setText(""); // yield(); // assertEquals(myShop.getCountries().size(), myTable.getItemCount()); // Plain myFilter.setText("A"); yield(); assertEquals(1, myTable.getItemCount()); // Star myFilter.setText("*A"); yield(); assertEquals(2, myTable.getItemCount()); // CamelCase myFilter.setText("BB"); yield(); assertEquals(1, myTable.getItemCount()); // Empty myFilter.setText(""); yield(); assertEquals(myShop.getCountries().size(), myTable.getItemCount()); }
/** Tests the navigation between the filter and the table. */ @Test public void navigationTest() { IFilteringTableAdapter.Factory.adapt(myViewer, myFilter); myFilter.setText(""); assertEquals(myShop.getCountries().size(), myTable.getItemCount()); myFilter.setFocus(); postKeyStroke(myFilter, "ARROW_DOWN"); yield(); assertTrue(myTable.isFocusControl()); assertEquals(0, myTable.getSelectionIndex()); postKeyStroke(myTable, "ARROW_DOWN"); yield(); assertTrue(myTable.isFocusControl()); assertEquals(1, myTable.getSelectionIndex()); postKeyStroke(myTable, "ARROW_UP"); yield(); assertTrue(myTable.isFocusControl()); assertEquals(0, myTable.getSelectionIndex()); postKeyStroke(myTable, "ARROW_UP"); yield(); assertTrue(myFilter.isFocusControl()); }
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(); }
/** * Source values for a column binding for a simple feature after the previous column has been * deleted. */ @Test public void testSimpleColumnBindingAfterDelete() { postMouse(myTable, 0 + myViewerBinding.getFirstTableColumnOffset(), 0); final IColumnBindingCellInformation ci = myViewerBinding.getCell(0, myViewerBinding.getList().get(1)); assertNotNull(ci); /* * When the element is deleted, the current selected cell is changed, and this must be * monitored. */ final MySourceProviderListener listener = new MySourceProviderListener(); try { myProvider.addSourceProviderListener(listener); myContact1.setShop(null); yield(); } finally { myProvider.removeSourceProviderListener(listener); } assertSource(Constants.SOURCES_THE_MANAGER, IManager.Factory.getManager()); assertSource(Constants.SOURCES_ACTIVE_CONTEXT, myContext); assertSource(Constants.SOURCES_ACTIVE_CONTAINER_BINDING, myViewerBinding); assertSource(Constants.SOURCES_ACTIVE_BINDING, ci.getLabelBinding()); assertSource(Constants.SOURCES_ACTIVE_BINDING_RO, false); assertSource(Constants.SOURCES_ACTIVE_BINDING_TYPE, ""); assertSource(Constants.SOURCES_ACTIVE_BINDING_MODEL_OBJECT, myContact2); assertSource( Constants.SOURCES_ACTIVE_BINDING_FEATURE, IMOAOPackage.Literals.NAMED_OBJECT__NAME); assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE, myContact2.getName()); assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE_DISPLAY, myContact2.getName()); }
/** 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(); }
/** 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(); }
/** * 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()); }