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

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

Introduction

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

Prototype

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:com.google.cloud.tools.eclipse.appengine.login.ui.AccountSelectorObservableValue.java

License:Apache License

public AccountSelectorObservableValue(final AccountSelector accountSelector) {
    super(DisplayRealm.getRealm(accountSelector.getDisplay()));
    this.accountSelector = accountSelector;

    accountSelector.addSelectionListener(new SelectionAdapter() {
        @Override// w  ww.ja  va  2s .co  m
        public void widgetSelected(SelectionEvent event) {
            String newValue = accountSelector.getSelectedEmail();
            fireValueChange(Diffs.createValueDiff(oldValue, newValue));
            oldValue = newValue;
        }
    });
}

From source file:com.google.cloud.tools.eclipse.appengine.newproject.maven.MavenArchetypeProjectWizardTest.java

License:Apache License

@Test
public void testAutoPackageNameSetterOnGroupIdChange_whitespaceInGroupId() {
    Realm.runWithDefault(DisplayRealm.getRealm(Display.getDefault()), new Runnable() {
        @Override/*  ww  w .  j  a v  a 2s.  com*/
        public void run() {
            wizard.setContainer(mock(IWizardContainer.class));
            wizard.createPageControls(shell);
            MavenAppEngineStandardWizardPage page = (MavenAppEngineStandardWizardPage) wizard
                    .getPage("basicNewProjectPage");

            page.groupIdField.setText(" "); // setText() triggers VerifyEvent.
            assertEquals("", page.javaPackageField.getText());

            page.groupIdField.setText(" a");
            assertEquals("a", page.javaPackageField.getText());

            page.groupIdField.setText(" a ");
            assertEquals("a", page.javaPackageField.getText());

            page.groupIdField.setText(" a b");
            assertEquals("a", page.javaPackageField.getText());

            page.groupIdField.setText(" a ");
            assertEquals("a", page.javaPackageField.getText());

            page.groupIdField.setText(" a");
            assertEquals("a", page.javaPackageField.getText());

            page.groupIdField.setText(" ac");
            assertEquals("ac", page.javaPackageField.getText());
        }
    });
}

From source file:com.google.cloud.tools.eclipse.appengine.newproject.maven.MavenArchetypeProjectWizardTest.java

License:Apache License

@Test
public void testAutoPackageNameSetterOnGroupIdChange_disbledOnUserChange() {
    Realm.runWithDefault(DisplayRealm.getRealm(Display.getDefault()), new Runnable() {
        @Override//from   w  ww . jav a 2s .  co  m
        public void run() {
            wizard.setContainer(mock(IWizardContainer.class));
            wizard.createPageControls(shell);
            MavenAppEngineStandardWizardPage page = (MavenAppEngineStandardWizardPage) wizard
                    .getPage("basicNewProjectPage");
            assertTrue(page.autoGeneratePackageName);

            page.groupIdField.setText("abc");
            assertEquals("abc", page.javaPackageField.getText());
            assertTrue(page.autoGeneratePackageName);

            page.javaPackageField.setText("def");
            assertFalse(page.autoGeneratePackageName);

            // javaPackageField should no longer auto-gen
            page.groupIdField.setText("xyz");
            assertEquals("def", page.javaPackageField.getText());

            // we shouldn't auto-gen even if the user clears the contents
            page.javaPackageField.setText("");
            assertFalse(page.autoGeneratePackageName);
            page.groupIdField.setText("abc");
            assertEquals("", page.javaPackageField.getText());
        }
    });
}

From source file:com.google.cloud.tools.eclipse.appengine.ui.AppEngineLibrariesSelectorGroup.java

License:Apache License

private Realm getDisplayRealm() {
    return DisplayRealm.getRealm(parentContainer.getDisplay());
}

From source file:com.google.cloud.tools.eclipse.login.ui.AccountSelectorObservableValue.java

License:Apache License

public AccountSelectorObservableValue(final AccountSelector accountSelector) {
    super(DisplayRealm.getRealm(accountSelector.getDisplay()));
    this.accountSelector = accountSelector;

    accountSelector.addSelectionListener(new Runnable() {
        @Override/* w w w .j ava2s  . co m*/
        public void run() {
            String newValue = accountSelector.getSelectedEmail();
            fireValueChange(Diffs.createValueDiff(oldValue, newValue));
            oldValue = newValue;
        }
    });
}

From source file:com.maccasoft.composer.DatabindingTestCase.java

License:Open Source License

@Override
public void run(final TestResult result) {
    capturedShells = new LinkedList<Shell>();
    capturedShells.addAll(asList(captureShells()));

    Realm.runWithDefault(DisplayRealm.getRealm(getDisplay()), new Runnable() {

        @Override//www. j  a  va 2 s. c o m
        public void run() {
            DatabindingTestCase.super.run(result);
        }
    });

    dispose();
}

From source file:com.maccasoft.composer.Main.java

License:Open Source License

public static void main(String[] args) {
    final Display display = new Display();

    Realm.runWithDefault(DisplayRealm.getRealm(display), new Runnable() {

        @Override/*from   w  w w.jav a  2s.c om*/
        public void run() {
            try {
                final Shell shell = new Shell(display);
                shell.setText(APP_TITLE);

                Image[] images = new Image[] { ImageRegistry.getImageFromResources("app64.png"),
                        ImageRegistry.getImageFromResources("app48.png"),
                        ImageRegistry.getImageFromResources("app32.png"),
                        ImageRegistry.getImageFromResources("app16.png"), };
                shell.setImages(images);

                Rectangle screen = display.getClientArea();

                Rectangle rect = new Rectangle(0, 0, (int) (screen.width * 0.85), (int) (screen.height * 0.85));
                rect.x = (screen.width - rect.width) / 2;
                rect.y = (screen.height - rect.height) / 2;
                if (rect.y < 0) {
                    rect.height += rect.y * 2;
                    rect.y = 0;
                }

                shell.setLocation(rect.x, rect.y);
                shell.setSize(rect.width, rect.height);

                new Main(shell);

                shell.open();

                while (display.getShells().length != 0) {
                    if (!display.readAndDispatch()) {
                        display.sleep();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }
        }
    });

    display.dispose();
}

From source file:com.maccasoft.template.DatabindingTestCase.java

License:Open Source License

@Override
public void run(final TestResult result) {
    Display display = Display.getDefault();
    Realm.runWithDefault(DisplayRealm.getRealm(display), new Runnable() {

        @Override/*from www  . j  a v  a  2  s.c o m*/
        public void run() {
            DatabindingTestCase.super.run(result);
        }
    });
}

From source file:com.maccasoft.template.Main.java

License:Open Source License

public static void main(String[] args) {
    final Display display = new Display();
    Realm.runWithDefault(DisplayRealm.getRealm(display), new Runnable() {

        @Override//from  ww w.  j a va 2 s. co m
        public void run() {
            Main main = new Main();
            main.open();
        }
    });
    display.dispose();
}

From source file:de.metadocks.lambdaui.swt.SwtUI.java

License:Open Source License

public static void openInShell(Consumer<SwtUI<Shell>> uiConsumer) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    Realm.runWithDefault(DisplayRealm.getRealm(display), () -> {
        uiConsumer.accept(SwtUI.wrap(shell));
        shell.open();/*w  w  w .  java  2s.com*/
        shell.layout();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    });
}