Example usage for org.eclipse.jface.databinding.swt SWTObservables getRealm

List of usage examples for org.eclipse.jface.databinding.swt SWTObservables getRealm

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.swt SWTObservables getRealm.

Prototype

@Deprecated
public static Realm getRealm(final Display display) 

Source Link

Document

Returns the realm representing the UI thread for the given display.

Usage

From source file:org.eclipse.riena.internal.ui.ridgets.swt.TableRidgetTableViewerTest.java

License:Open Source License

@Override
public void setUp() throws Exception {

    super.setUp();

    final Display display = Display.getDefault();
    final Realm realm = SWTObservables.getRealm(display);
    assertNotNull(realm);/*from  w ww .  j av  a 2 s  . co  m*/
    ReflectionUtils.invokeHidden(realm, "setDefault", realm); //$NON-NLS-1$

    shell = new Shell(SWT.SYSTEM_MODAL | SWT.ON_TOP);
    table = new Table(shell, SWT.NONE);

    ridget = new TableRidget();
    ridget.setUIControl(table);

    manager = new PersonManager(createPersonList());
    final Iterator<Person> it = manager.getPersons().iterator();
    person1 = it.next();
    person2 = it.next();
    person3 = it.next();

}

From source file:org.eclipse.riena.internal.ui.ridgets.swt.TextRidgetSharedViewTest.java

License:Open Source License

@Override
protected void setUp() throws Exception {
    super.setUp();

    final Display display = Display.getDefault();

    final Realm realm = SWTObservables.getRealm(display);
    assertNotNull(realm);/* w ww .ja va 2  s  .c  o  m*/
    ReflectionUtils.invokeHidden(realm, "setDefault", realm);

    shell = new Shell(SWT.SYSTEM_MODAL | SWT.ON_TOP);
    shell.setLayout(new RowLayout(SWT.VERTICAL));

    widget = new Text(shell, SWT.NONE);

    textRidget1 = new TextRidget();
    textRidget1.setUIControl(widget);

    textRidget2 = new TextRidget();

    shell.setSize(130, 100);
    shell.setLocation(0, 0);
    shell.open();
}

From source file:org.eclipse.riena.internal.ui.ridgets.swt.TreeRidget.java

License:Open Source License

private ObservableListTreeContentProvider createContentProvider(final TreeStructureAdvisor structureAdvisor) {
    final Realm realm = SWTObservables.getRealm(Display.getDefault());
    // how to obtain an observable list of children from a given object (expansion)
    final IObservableFactory listFactory = new IObservableFactory() {
        public IObservable createObservable(final Object target) {
            if (target instanceof Object[]) {
                return Observables.staticObservableList(realm, Arrays.asList((Object[]) target));
            }//from   www .j  a  v a2 s  .c  o m
            Object value;
            if (target instanceof FakeRoot) {
                value = ((FakeRoot) target).getRoot();
                if (value == null) {
                    return new ObservableList(Collections.EMPTY_LIST, treeElementClass) {
                        // empty list
                    };
                }
            } else {
                value = target;
            }
            if (AbstractSWTWidgetRidget.isBean(treeElementClass)) {
                return BeansObservables.observeList(realm, value, childrenAccessor, treeElementClass);
            } else {
                return PojoObservables.observeList(realm, value, childrenAccessor, treeElementClass);
            }
        }
    };

    // how to create the content/structure for the tree
    return new ObservableListTreeContentProvider(listFactory, structureAdvisor);
}

From source file:org.eclipse.riena.internal.ui.ridgets.swt.TreeRidgetLabelProviderTest.java

License:Open Source License

@Override
protected void setUp() throws Exception {
    final Display display = Display.getDefault();
    final Realm realm = SWTObservables.getRealm(display);
    ReflectionUtils.invokeHidden(realm, "setDefault", realm);
    colorA = display.getSystemColor(SWT.COLOR_RED);
    colorB = display.getSystemColor(SWT.COLOR_GREEN);
    fontA = new Font(display, "Arial", 12, SWT.NORMAL);
    fontB = new Font(display, "Courier", 12, SWT.NORMAL);

    shell = new Shell(display);
    viewer = new TreeViewer(createTree(shell));

    final IObservableSet elements = createElements();
    formatters = new IColumnFormatter[] { new TestColumnFormatter(), null };
    noFormatters = new IColumnFormatter[COLUMN_PROPERTIES.length];
    labelProvider = TreeRidgetLabelProvider.createLabelProvider(viewer, WordNode.class, elements,
            COLUMN_PROPERTIES, null, null, null, noFormatters);

    viewer.setContentProvider(new FTTreeContentProvider());
    viewer.setLabelProvider(labelProvider);
    viewer.setInput(elements.toArray());
}

From source file:org.eclipse.riena.navigation.ui.controllers.NavigationNodeControllerTest.java

License:Open Source License

@Override
protected void setUp() throws Exception {

    final Display display = Display.getDefault();
    shell = new Shell(display);
    shell.pack();//from  w  w w .  jav  a  2 s  . c  o  m
    shell.setVisible(true);

    final Realm realm = SWTObservables.getRealm(display);
    assertNotNull(realm);
    ReflectionUtils.invokeHidden(realm, "setDefault", realm); //$NON-NLS-1$

    node = new SubModuleNode(new NavigationNodeId(SUBMODULE1_TYPE_ID));
    navigationProcessor = new NavigationProcessor();
    node.setNavigationProcessor(navigationProcessor);
    controller = new MyNavigationNodeController(node);
}

From source file:org.eclipse.riena.navigation.ui.controllers.NavigationUIFilterApplierTest.java

License:Open Source License

@Override
protected void setUp() throws Exception {
    final Display display = Display.getDefault();
    final Realm realm = SWTObservables.getRealm(display);
    assertNotNull(realm);//  w  ww.j ava 2s  .c om
    ReflectionUtils.invokeHidden(realm, "setDefault", realm);
}

From source file:org.eclipse.riena.navigation.ui.controllers.SubApplicationControllerTest.java

License:Open Source License

@Override
protected void setUp() throws Exception {

    final Display display = Display.getDefault();
    final Realm realm = SWTObservables.getRealm(display);
    assertNotNull(realm);/*from   w w  w  .  j a v  a  2s.  c o m*/
    ReflectionUtils.invokeHidden(realm, "setDefault", realm); //$NON-NLS-1$

    node = new SubApplicationNode();
    controller = new SubApplicationController(node);

}

From source file:org.eclipse.riena.navigation.ui.controllers.SubModuleControllerTest.java

License:Open Source License

public void testRestoreFocusFromRidgetAfterBlock() {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.pack();/*from   www .ja  v  a2 s .c  o  m*/
    shell.setVisible(true);

    final Realm realm = SWTObservables.getRealm(display);
    assertNotNull(realm);
    ReflectionUtils.invokeHidden(realm, "setDefault", realm); //$NON-NLS-1$

    final SubModuleNode node = new SubModuleNode();
    node.setNavigationProcessor(new NavigationProcessor());
    final SubModuleController controller = new SubModuleController(node);

    final LabelRidget labelRidget = new LabelRidget();
    labelRidget.setRetryRequestFocus(true);
    controller.addRidget("label", labelRidget); //$NON-NLS-1$

    controller.setBlocked(true);
    labelRidget.setRetryRequestFocus(true);
    controller.setBlocked(false);
    assertFalse(labelRidget.isRetryRequestFocus());
    SwtUtilities.dispose(shell);
}

From source file:org.eclipse.riena.navigation.ui.controllers.SubModuleControllerTest.java

License:Open Source License

public void testUpdateAllRidgetsFromModel() {

    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.pack();/*from  w w  w .  j  a v a  2 s  .  co m*/
    shell.setVisible(true);

    final Realm realm = SWTObservables.getRealm(display);
    assertNotNull(realm);
    ReflectionUtils.invokeHidden(realm, "setDefault", realm); //$NON-NLS-1$

    final SubModuleNode node = new SubModuleNode();
    node.setNavigationProcessor(new NavigationProcessor());
    final SubModuleController controller = new SubModuleController(node);

    final LabelRidget labelRidget = new LabelRidget();
    controller.addRidget("label", labelRidget); //$NON-NLS-1$
    assertNotNull(controller.getRidgets());
    assertEquals(1, controller.getRidgets().size());

    final ComboRidget comboRidget = new ComboRidget();
    controller.addRidget("combo ridget", comboRidget); //$NON-NLS-1$
    assertNotNull(controller.getRidgets());
    assertEquals(2, controller.getRidgets().size());

    try {
        controller.updateAllRidgetsFromModel();
    } catch (final BindingException e) {
        fail("unexpected BindingException: " + e.getMessage()); //$NON-NLS-1$
    }

    final MultipleChoiceRidget multipleChoiceRidget = new MultipleChoiceRidget();
    controller.addRidget("multi choice ridget", multipleChoiceRidget); //$NON-NLS-1$
    assertNotNull(controller.getRidgets());
    assertEquals(3, controller.getRidgets().size());

    multipleChoiceRidget.setIgnoreBindingError(false);
    try {
        controller.updateAllRidgetsFromModel();
        fail("BindingException expected!"); //$NON-NLS-1$
    } catch (final BindingException e) {
        Nop.reason("BindingException is expected"); //$NON-NLS-1$
    }

    multipleChoiceRidget.setIgnoreBindingError(true);
    try {
        controller.updateAllRidgetsFromModel();
    } catch (final BindingException e) {
        fail("unexpected BindingException: " + e.getMessage()); //$NON-NLS-1$
    }
    SwtUtilities.dispose(shell);

}

From source file:org.eclipse.riena.navigation.ui.swt.application.SwtApplication.java

License:Open Source License

@Override
protected Object doPerformLogin(final IApplicationContext context) {
    final Realm realm = SWTObservables.getRealm(getDisplay());
    // TODO Is really necessary that the loginDialogViewExtension is used here. Shouldnt it be done it the super class??
    final ILoginDialogView loginDialogView = loginDialogViewExtension.createViewClass();
    do {//from  w  w w .  ja v  a2  s  .co m
        Realm.runWithDefault(realm, new Runnable() {
            public void run() {
                loginDialogView.build();
            }
        });
    } while (EXIT_RESTART.equals(loginDialogView.getResult()));

    return loginDialogView.getResult();
}