/**
   * Tests that Undo = Ctrl-Z works as escape.
   *
   * @param runnable the runnable to get the
   */
  private void testUndoAsCancel(final Runnable runnable) {
    final String oldName = myCellA1.getDetails();
    assertNoLog(
        new Runnable() {
          @Override
          public void run() {
            runnable.run();
            yield();
          }
        });
    assertNoLog(
        new Runnable() {
          @Override
          public void run() {
            assertEquals(what, true, myGridBinding.isEditing());

            final EList<IBinding> bindings = myContext.getBindings();

            final IValueBinding editBinding = (IValueBinding) bindings.get(bindings.size() - 1);

            final Text t = (Text) editBinding.getControl();
            t.setText("dummy");
            yield();
            assertEquals(what, "dummy", myCellA1.getDetails());

            postKeyStroke(t, "M1+Z");
            yield();
            assertEquals(what, false, myGridBinding.isEditing());

            assertEquals(what, oldName, myCellA1.getDetails());
          }
        });
  }
  /**
   * Tests that the specified runnable can get the table into edit mode (or not).
   *
   * @param editExpected whether edit mode is expected
   * @param expectedValue the value expected in the edit box
   * @param runnable the runnable to get the
   */
  private void testEditStrategy(
      final boolean editExpected, final String expectedValue, final Runnable runnable) {

    assertNoLog(
        new Runnable() {
          @Override
          public void run() {
            runnable.run();
            yield();
          }
        });
    assertNoLog(
        new Runnable() {

          @Override
          public void run() {
            assertEquals(what, editExpected, myGridBinding.isEditing());

            if (editExpected) {
              testBindingValue(expectedValue);

              final EList<IBinding> bindings = myContext.getBindings();

              final IValueBinding editBinding = (IValueBinding) bindings.get(bindings.size() - 1);

              final Text t = (Text) editBinding.getControl();

              postKeyStroke(t, "ESCAPE");
              yield();
              assertEquals(what, false, myGridBinding.isEditing());
            }
          }
        });
  }
  @Test
  public void testUIAttribute() {
    final Label widget = createWidget(Label.class, SWT.NONE);

    assertNoLog(
        new Runnable() {
          @Override
          public void run() {
            attribute = IManager.Factory.getManager().createUIAttribute(widget, "");
          }
        });

    assertNotNull(attribute);

    assertEquals("", attribute.getAttribute());
    assertEquals(widget, attribute.getWidget());

    testObservableValue(widget, "", attribute.getBackgroundValue(), Color.class, "background");
    testObservableValue(widget, "", attribute.getForegroundValue(), Color.class, "foreground");
    testObservableValue(widget, "", attribute.getFontValue(), Font.class, "font");
    testObservableValue(widget, "", attribute.getCursorValue(), Cursor.class, "cursor");
    testObservableValue(widget, "", attribute.getCurrentValue(), String.class, "text");
    testObservableValue(widget, "", attribute.getEnabledValue(), Boolean.TYPE, "enabled");
    testObservableValue(widget, "", attribute.getTooltipValue(), String.class, "toolTipText");
    assertEquals(null, attribute.getMinValue());
    assertEquals(null, attribute.getMaxValue());
    assertEquals(null, attribute.getFieldAssistAdapter());
    assertEquals(null, attribute.getPossibleValuesList());
    assertEquals(null, attribute.getStyleRangeList());

    widget.dispose();
  }
Ejemplo n.º 4
0
  /** Binds the UI */
  public void bindUI() {
    assertNoLog(
        new Runnable() {
          @Override
          public void run() {
            myContext = IBindingContext.Factory.createContext(myView.getScrolledForm());

            myContext.addBinding(myShopName, myShop, IMOAOPackage.Literals.NAMED_OBJECT__NAME);
            myContext.finish();
            yield();
          }
        });
  }
Ejemplo n.º 5
0
  /** Test for file widget creation */
  @Test
  public void testValueBindingWidgetCreation() {
    assertNoLog(
        new Runnable() {

          @Override
          public void run() {
            b =
                myForm
                    .addField("name")
                    .type(myType)
                    .arg(Constants.ARG_NEW_ALLOWED, myNewAllowed)
                    .arg(Constants.ARG_EXTENSIONS, myExtensions);
            myForm.finish();
          }
        });

    assertTrue(b.getControl() instanceof FileNameControl);

    testFunction(b);
  }
Ejemplo n.º 6
0
  /** Test for binding to a Text */
  @Test
  public void testValueBindingText() {
    assertNoLog(
        new Runnable() {
          @Override
          public void run() {
            final Text w = new Text(myForm.addComposite(), SWT.SINGLE | SWT.LEAD | SWT.BORDER);
            w.setText("");

            b =
                myForm
                    .getContext()
                    .addBinding(w, myShop, IMOAOPackage.Literals.NAMED_OBJECT__NAME)
                    .type(myType)
                    .arg(Constants.ARG_NEW_ALLOWED, myNewAllowed)
                    .arg(Constants.ARG_EXTENSIONS, myExtensions);
            myForm.finish();
          }
        });

    testFunction(b);
  }
 private void testTABTraversal(
     final String expectedValue,
     final String afterTabExpectedValue,
     final String afterTabTabExpectedValue,
     final String afterTabTabTabExpectedValue,
     final Runnable runnable) {
   assertNoLog(
       new Runnable() {
         @Override
         public void run() {
           runnable.run();
           yield();
           testBindingValue(expectedValue);
         }
       });
   assertNoLog(
       new Runnable() {
         @Override
         public void run() {
           postKeyStroke(myGrid, "TAB");
           yield();
           testBindingValue(afterTabExpectedValue);
         }
       });
   // assertNoLog(new Runnable() {
   // public void run() {
   // postKeyDown(myTable, "TAB");
   // yield();
   // testBindingValue(afterTabTabExpectedValue);
   // }
   // });
   assertNoLog(
       new Runnable() {
         @Override
         public void run() {
           postKeyStroke(myGrid, "TAB");
           yield();
           testBindingValue(afterTabTabTabExpectedValue);
         }
       });
   // assertNoLog(new Runnable() {
   // public void run() {
   // postKeyDown(myTable, "M2+TAB");
   // yield();
   // testBindingValue(afterTabTabExpectedValue);
   // }
   // });
   assertNoLog(
       new Runnable() {
         @Override
         public void run() {
           postKeyStroke(myGrid, "M2+TAB");
           yield();
           testBindingValue(afterTabExpectedValue);
         }
       });
   assertNoLog(
       new Runnable() {
         @Override
         public void run() {
           postKeyStroke(myGrid, "M2+TAB");
           yield();
           testBindingValue(expectedValue);
         }
       });
 }