Ejemplo n.º 1
0
    protected void initBindings() {
      final Realm realm = Realm.getDefault();
      final DataBindingContext dbc = new DataBindingContext(realm);

      addBindings(dbc, realm);
      WizardPageSupport.create(this, dbc);
    }
  public void testConstructor_SkipsRegisterListener() throws Exception {
    Bean bean = new Bean();
    IObservableList observable = PojoObservables.observeList(Realm.getDefault(), bean, "list");

    assertFalse(bean.hasListeners("list"));
    ChangeEventTracker.observe(observable);
    assertFalse(bean.hasListeners("list"));
  }
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   target = new ObservableValueStub(Realm.getDefault());
   oldValue = new Object();
   newValue = new Object();
   target.setValue(oldValue);
   delayed = Observables.observeDelayedValue(1, target);
 }
  @Override
  public TabItem doCreateForm(
      TabFolder folder, EditingDomain domain, DataBindingContext dbc, IObservableValue master) {

    TabItem item = new TabItem(folder, SWT.NONE);
    IValueProperty textProp = WidgetProperties.text();
    dbc.bindValue(
        textProp.observe(item),
        EMFEditObservables.observeDetailValue(
            Realm.getDefault(), domain, master, EXTLibraryPackage.Literals.LIBRARY__WRITERS),
        new UpdateValueStrategy(),
        new UpdateValueStrategy().setConverter(new LengthConverter()));

    Composite comp = new Composite(folder, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    comp.setLayout(layout);

    TableViewer writerViewer =
        new TableViewer(
            comp, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    writerViewer.getTable().setHeaderVisible(true);
    writerViewer.getTable().setLinesVisible(true);

    ObservableListContentProvider cp = new ObservableListContentProvider();
    writerViewer.setContentProvider(cp);

    CondiditionalTemplate[] tpl = new CondiditionalTemplate[3];
    tpl[0] =
        new CondiditionalTemplate("${0}") {

          @Override
          public boolean isTemplate(EObject element) {
            return element instanceof Writer && ((Writer) element).getFirstName() != null;
          }
        };
    tpl[1] =
        new CondiditionalTemplate("${0}") {

          @Override
          public boolean isTemplate(EObject element) {
            return element instanceof Writer && ((Writer) element).getLastName() != null;
          }
        };
    tpl[2] =
        new CondiditionalTemplate("-") {

          @Override
          public boolean isTemplate(EObject element) {
            return true;
          }
        };

    EStructuralFeature[] features = new EStructuralFeature[3];
    features[0] = EXTLibraryPackage.Literals.PERSON__FIRST_NAME;
    features[1] = EXTLibraryPackage.Literals.PERSON__LAST_NAME;

    IObservableMap[] map = EMFEditObservables.observeMaps(domain, cp.getKnownElements(), features);

    TableViewerColumn c = new TableViewerColumn(writerViewer, SWT.NONE);
    c.getColumn().setText("Firstname");
    layout.setColumnData(c.getColumn(), new ColumnWeightData(1, 120));
    c.setLabelProvider(
        new ObservableColumnLabelProvider(
            new IObservableMap[] {map[0]}, Arrays.asList(tpl[0], tpl[2])));

    c = new TableViewerColumn(writerViewer, SWT.NONE);
    c.getColumn().setText("Lastname");
    layout.setColumnData(c.getColumn(), new ColumnWeightData(1, 120));
    c.setLabelProvider(
        new ObservableColumnLabelProvider(
            new IObservableMap[] {map[1]}, Arrays.asList(tpl[1], tpl[2])));

    MenuManager mgr = new MenuManager();
    writerViewer.getControl().setMenu(mgr.createContextMenu(writerViewer.getControl()));
    getSite()
        .registerContextMenu(
            "org.eclipse.emf.examples.library.databinding.writer", mgr, writerViewer);

    writerViewer.setInput(
        EMFEditObservables.observeDetailList(
            Realm.getDefault(), domain, master, EXTLibraryPackage.Literals.LIBRARY__WRITERS));
    item.setControl(comp);

    return item;
  }
Ejemplo n.º 5
0
 /** @param wrappedMap */
 public ObservableMap(Map wrappedMap) {
   this(Realm.getDefault(), wrappedMap);
 }
Ejemplo n.º 6
0
 public Expression() {
   super(Realm.getDefault());
 }