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:com.rinke.solutions.pinball.PinDmdEditor.java

/**
 * Launch the application./*from  w w w.  j ava  2  s  .  c  o m*/
 * 
 * @param args
 */
public static void main(String[] args) {
    Display display = Display.getDefault();
    Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
        public void run() {
            try {
                PinDmdEditor window = new PinDmdEditor();
                window.open(args);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.runwaysdk.manager.general.MainWindow.java

License:Open Source License

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

    Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
        public void run() {
            MainWindow window = new MainWindow();
            window.run();/*from   w  w  w .  ja  v  a 2 s.c om*/
        }
    });
}

From source file:com.runwaysdk.manager.view.EntityView.java

License:Open Source License

public EntityView(IComponentObject entity, IAdminModule module) {
    this.entity = entity;
    this.controls = new LinkedHashMap<String, Object>();
    this.realm = SWTObservables.getRealm(module.getDisplay());
    this.bindingContext = new DataBindingContext(realm);
    this.module = module;
    this.message = null;
}

From source file:com.runwaysdk.manager.view.ExportDialog.java

License:Open Source License

private void bind() {
    Realm realm = SWTObservables.getRealm(getShell().getDisplay());
    DataBindingContext bindingContext = new DataBindingContext(realm);

    // Bind the type value
    bindingContext.bindValue(new RadioGroupObservableValue(realm, group),
            BeansObservables.observeValue(bean, "type"), null, null);

    // Bind the lower value
    bindingContext.bindValue(SWTObservables.observeText(startText, SWT.Modify),
            BeansObservables.observeValue(bean, "lower"), null, null);

    // Bind the location value
    bindingContext.bindValue(SWTObservables.observeText(fileText, SWT.Modify),
            BeansObservables.observeValue(bean, "location"), null, null);
}

From source file:com.runwaysdk.manager.view.ImportDialog.java

License:Open Source License

private void bind() {
    Realm realm = SWTObservables.getRealm(getShell().getDisplay());
    DataBindingContext bindingContext = new DataBindingContext(realm);

    // Bind the location value
    bindingContext.bindValue(SWTObservables.observeText(fileText, SWT.Modify),
            BeansObservables.observeValue(bean, "location"), null, null);
}

From source file:com.siemens.ct.mp3m.ui.editors.id3.databinding.Id3TagPage.java

License:Open Source License

@Override
protected void createFormContent(IManagedForm managedForm) {
    toolkit = managedForm.getToolkit();//from   w  ww  .  j  av  a  2  s  . co m

    String mp3Path = ((Id3Editor) getEditor()).getFullPath();
    section = createSection(managedForm, Messages.getString("Id3TagPage.Tags_Section"), Messages //$NON-NLS-2$
            .getString("Id3TagPage.For_filename") + mp3Path); //$NON-NLS-1$ 

    new Label(section, SWT.NONE);
    new Label(section, SWT.NONE);

    // data binding is done here
    Realm.runWithDefault(SWTObservables.getRealm(Display.getCurrent()), new Runnable() {

        // Java 6: @Override
        public void run() {
            DataBindingContext bindingContext = new DataBindingContext();

            try {
                if (info == TECH_INFO) {
                    addKeyValuePair(Messages.getString("Id3TagPage.Size_Label"), id3TagInfo, "size", //$NON-NLS-1$
                            bindingContext, false);
                    addKeyValuePair(Messages.getString("Id3TagPage.Duration_Label"), id3TagInfo, "duration", //$NON-NLS-1$
                            bindingContext, false);
                    addKeyValuePair(Messages.getString("Id3TagPage.Bitrate"), id3TagInfo, "bitrate", //$NON-NLS-1$
                            bindingContext, false);
                    addKeyValuePair(Messages.getString("Id3TagPage.Frequency"), id3TagInfo, "frequency", //$NON-NLS-1$
                            bindingContext, false);
                } else {
                    addKeyValuePair(Messages.getString("Id3TagPage.Title_Label"), id3TagInfo, "title", //$NON-NLS-1$
                            bindingContext, true);
                    addKeyValuePair(Messages.getString("Id3TagPage.Artist_Label"), id3TagInfo, "artist", //$NON-NLS-1$
                            bindingContext, true);
                    addKeyValuePair(Messages.getString("Id3TagPage.Album_Label"), id3TagInfo, "album", //$NON-NLS-1$
                            bindingContext, true);
                    addKeyValuePair(Messages.getString("Id3TagPage.Track_Label"), id3TagInfo, "track", //$NON-NLS-1$
                            bindingContext, true);
                    addKeyValuePair(Messages.getString("Id3TagPage.Year_Label"), id3TagInfo, "year", //$NON-NLS-1$
                            bindingContext, true);
                    addKeyValuePair(Messages.getString("Id3TagPage.Genre_Label"), id3TagInfo, "genre", //$NON-NLS-1$
                            bindingContext, true);
                    addKeyValuePair(Messages.getString("Id3TagPage.Comment_Label"), id3TagInfo, "comment", //$NON-NLS-1$
                            bindingContext, true);

                    // This can be used for aggregated errors
                    /*
                     * AggregateValidationStatus
                     * aggregateValidationStatus = new
                     * AggregateValidationStatus(
                     * bindingContext.getBindings(),
                     * AggregateValidationStatus.MAX_SEVERITY);
                     */

                    Composite composite = toolkit.createComposite(section);
                    composite.setLayout(new RowLayout());
                    GridData data = new GridData();
                    data.horizontalSpan = 2;
                    composite.setLayoutData(data);
                }
            } catch (Exception e) {
                LogUtil.logError("com.siemens.ct.mp3m.ui.editors.id3.databinding", //$NON-NLS-1$
                        "Could not create form content" //$NON-NLS-1$
                , e);
            }
        }

    });
}

From source file:com.toedter.e4.tools.modeleditor.OpenModelEditorHandler.java

License:Open Source License

@Execute
public void run(final MApplication application) {
    Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() {
        @Override/* w ww.  j  a va2s  . c o  m*/
        public void run() {
            Shell shell = new Shell(SWT.SHELL_TRIM);
            shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
            FillLayout layout = new FillLayout();
            layout.marginHeight = 5;
            layout.marginWidth = 5;
            shell.setLayout(layout);

            final IEclipseContext childContext = application.getContext().createChild("EditorContext");
            MemoryModelResource resource = new MemoryModelResource(application);
            childContext.set(IModelResource.class, resource);
            childContext.set(Composite.class.getCanonicalName(), shell);
            childContext.set(Display.class.getCanonicalName(), shell.getDisplay());

            ContextInjectionFactory.make(ApplicationModelEditor.class, childContext);

            shell.open();
            Display display = shell.getDisplay();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch()) {
                    display.sleep();
                }
            }
            childContext.dispose();
            shell = null;
        }
    });
}

From source file:com.toedter.e4.ui.workbench.swt.SWTPresentationEngine.java

License:Open Source License

@Override
public Object run(final MApplicationElement uiRoot, final IEclipseContext eclipseContext) {
    final Display display;
    if (eclipseContext.get(Display.class) != null) {
        display = eclipseContext.get(Display.class);
    } else {//from  www .  ja v a2 s.c o  m
        display = Display.getDefault();
        eclipseContext.set(Display.class, display);
    }

    Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() {
        @Override
        public void run() {
            if (uiRoot instanceof MApplication) {
                MApplication theApp = (MApplication) uiRoot;
                for (MWindow window : theApp.getChildren()) {
                    createGui(window);
                }
            }
        }
    });

    Shell appShell = null;
    if (uiRoot instanceof MApplication) {
        MApplication theApp = (MApplication) uiRoot;
        for (MWindow window : theApp.getChildren()) {
            if (window.getWidget() instanceof Shell) {
                appShell = (Shell) window.getWidget();
                break;
            }
        }

        if (appShell != null) {
            stopped = false;
            while (!stopped && appShell != null && !appShell.isDisposed()) {
                if (!display.readAndDispatch()) {
                    eclipseContext.processWaiting();
                    display.sleep();
                }
            }
        }
        if (!display.isDisposed()) {
            display.dispose();
        }
    }

    System.out.println("SWTPresentationEngine.run(): Finished");
    return IApplication.EXIT_OK;
}

From source file:de.prozesskraft.pkraft.PkraftPartUi1.java

/**
 * @param args//ww  w .  j  a v  a 2 s  .  c om
 */
public static void main(String[] args) {

    /*----------------------------
      get options from ini-file
    ----------------------------*/
    File inifile = new java.io.File(
            WhereAmI.getInstallDirectoryAbsolutePath(PkraftPartUi1.class) + "/" + "../etc/pkraft-gui.ini");

    if (inifile.exists()) {
        try {
            ini = new Ini(inifile);
        } catch (InvalidFileFormatException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    } else {
        System.err.println("ini file does not exist: " + inifile.getAbsolutePath());
        System.exit(1);
    }

    /*----------------------------
      create boolean options
    ----------------------------*/
    Option help = new Option("help", "print this message");
    Option v = new Option("v", "prints version and build-date");
    /*----------------------------
      create argument options
    ----------------------------*/

    /*----------------------------
      create options object
    ----------------------------*/
    Options options = new Options();

    options.addOption(help);
    options.addOption(v);

    /*----------------------------
      create the parser
    ----------------------------*/
    CommandLineParser parser = new GnuParser();
    try {
        // parse the command line arguments
        line = parser.parse(options, args);
    } catch (Exception exp) {
        // oops, something went wrong
        System.err.println("Parsing failed. Reason: " + exp.getMessage());
    }

    /*----------------------------
      usage/help
    ----------------------------*/
    if (line.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        //         formatter.printHelp("checkin --version [% version %]", options);
        formatter.printHelp("pkraft-gui", options);
        System.exit(0);
    }

    if (line.hasOption("v")) {
        System.err.println("author:  [% email %]");
        System.err.println("version: [% version %]");
        System.err.println("date:    [% date %]");
        System.exit(0);
    }

    /*----------------------------
      die lizenz ueberpruefen und ggf abbrechen
    ----------------------------*/

    // check for valid license
    ArrayList<String> allPortAtHost = new ArrayList<String>();
    allPortAtHost.add(ini.get("license-server", "license-server-1"));
    allPortAtHost.add(ini.get("license-server", "license-server-2"));
    allPortAtHost.add(ini.get("license-server", "license-server-3"));

    // muss final sein - wird sonst beim installieren mit maven angemeckert (nicht so aus eclipse heraus)
    final MyLicense lic = new MyLicense(allPortAtHost, "1", "user-edition", "0.1");

    // lizenz-logging ausgeben
    for (String actLine : (ArrayList<String>) lic.getLog()) {
        System.err.println(actLine);
    }

    // abbruch, wenn lizenz nicht valide
    if (!lic.isValid()) {
        System.exit(1);
    }

    /*----------------------------
      other things
    ----------------------------*/
    // gui
    final Display display = new Display();

    Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
        public void run() {
            try {
                // SPLASHSCREEN

                //                final Image image = new Image(display, 300, 300);
                Image image = null;

                // set an image. die 2 versionen sind dazu da um von eclipse aus und in der installierten version zu funktionieren
                if (this.getClass().getResourceAsStream("/logo_beschnitten_transparent_small.png") != null) {
                    image = new Image(display,
                            this.getClass().getResourceAsStream("/logo_beschnitten_transparent_small.png"));
                } else if ((new java.io.File("logo_beschnitten_transparent_small.png")).exists()) {
                    image = new Image(display, "logo_beschnitten_transparent_small.png");
                }

                final Shell splash = new Shell(SWT.ON_TOP);
                splash.setLayout(new GridLayout(1, false));
                splash.setSize(300, 300);
                splash.setBackground(new Color(display, 255, 255, 255)); // Weiss

                Label labelImage = new Label(splash, SWT.NONE);
                labelImage.setImage(image);
                //                labelImage.setLayout(new GridLayout(1, false));
                GridData gd_labelImage = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
                gd_labelImage.widthHint = 300;
                gd_labelImage.minimumWidth = 300;
                //               gd_labelImage.minimumHeight = 10;
                labelImage.setLayoutData(gd_labelImage);

                Label labelZeile1 = new Label(splash, SWT.NONE | SWT.BORDER | SWT.CENTER);
                String text = "version [% version %]";
                text += "\nlicense status: " + lic.getLicense().getValidationStatus();

                switch (lic.getLicense().getValidationStatus()) {
                case LICENSE_VALID:

                    text += "\nlicensee: " + lic.getLicense().getLicenseText().getUserEMail();
                    text += "\nexpires in: "
                            + lic.getLicense().getLicenseText().getLicenseExpireDaysRemaining(null)
                            + " day(s).";
                    break;
                case LICENSE_INVALID:
                    break;
                default:
                    text += "\nno valid license found";
                }
                text += "\nsupport: support@prozesskraft.de";

                Button buttonOk = new Button(splash, SWT.NONE);
                GridData gd_buttonOk = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
                gd_buttonOk.widthHint = 62;
                buttonOk.setLayoutData(gd_buttonOk);
                buttonOk.setText("Ok");
                buttonOk.addSelectionListener(new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent event) {
                        splash.close();
                    }
                });

                labelZeile1.setText(text);
                //                labelImage.setLayout(new GridLayout(1, false));
                GridData gd_labelZeile1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
                gd_labelZeile1.horizontalAlignment = SWT.CENTER;
                gd_labelZeile1.widthHint = 300;
                gd_labelZeile1.minimumWidth = 300;
                //               gd_labelImage.minimumHeight = 10;
                labelZeile1.setLayoutData(gd_labelZeile1);

                splash.pack();
                Rectangle splashRect = splash.getBounds();
                Rectangle displayRect = display.getBounds();
                int x = (displayRect.width - splashRect.width) / 2;
                int y = (displayRect.height - splashRect.height) / 2;
                splash.setLocation(x, y);
                splash.open();

                // DAS HAUPTFENSTER

                Shell shell = new Shell(display);
                //               shell.setSize(1200, 800);
                shell.setMaximized(true);
                shell.setText("pkraft " + "v[% version %]");

                // set an icon. die 2 versionen sind dazu da um von eclipse aus und in der installierten version zu funktionieren
                if (this.getClass().getResourceAsStream("/logoSymbol50Transp.png") != null) {
                    shell.setImage(
                            new Image(display, this.getClass().getResourceAsStream("/logoSymbol50Transp.png")));
                } else if ((new java.io.File("logoSymbol50Transp.png")).exists()) {
                    shell.setImage(new Image(display, "logoSymbol50Transp.png"));
                }

                shell.setLayout(new FillLayout());
                Composite composite = new Composite(shell, SWT.NO_FOCUS);
                GridLayout gl_composite = new GridLayout(2, false);
                gl_composite.marginWidth = 0;
                gl_composite.marginHeight = 0;
                new PkraftPartUi1(composite);

                try {
                    shell.open();

                    while (!shell.isDisposed()) {
                        if (!display.readAndDispatch()) {
                            display.sleep();
                        }
                    }

                } finally {
                    if (!shell.isDisposed()) {
                        shell.dispose();
                    }
                }

            } finally {
                display.dispose();
            }
        }
    });
    System.exit(0);

}

From source file:de.prozesskraft.pmodel.PmodelPartUi1.java

/**
 * @param args//  w  w w  .j  a  va2s .com
 */
public static void main(String[] args) {
    /*----------------------------
      create boolean options
    ----------------------------*/
    Option help = new Option("help", "print this message");
    Option v = new Option("v", "prints version and build-date");
    /*----------------------------
      create argument options
    ----------------------------*/
    Option definition = OptionBuilder.withArgName("definition").hasArg()
            .withDescription("[optional] process definition file")
            //            .isRequired()
            .create("definition");

    Option instance = OptionBuilder.withArgName("instance").hasArg()
            .withDescription("[optional] process instance file")
            //            .isRequired()
            .create("instance");
    /*----------------------------
      create options object
    ----------------------------*/
    Options options = new Options();

    options.addOption(help);
    options.addOption(v);
    options.addOption(definition);
    options.addOption(instance);

    /*----------------------------
      create the parser
    ----------------------------*/
    CommandLineParser parser = new GnuParser();
    try {
        // parse the command line arguments
        line = parser.parse(options, args);
    } catch (Exception exp) {
        // oops, something went wrong
        System.err.println("Parsing failed. Reason: " + exp.getMessage());
    }

    /*----------------------------
      usage/help
    ----------------------------*/
    if (line.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        //         formatter.printHelp("checkin --version [% version %]", options);
        formatter.printHelp("pmodel-gui", options);
        System.exit(0);
    }

    if (line.hasOption("v")) {
        System.err.println("author:  [% email %]");
        System.err.println("version: [% version %]");
        System.err.println("date:    [% date %]");
        System.exit(0);
    }

    /*----------------------------
      other things
    ----------------------------*/
    if (!(line.hasOption("definition")) && !(line.hasOption("instance"))) {
        System.err.println("either -definition or -instance needed.");
        System.err.println("either -definition or -instance needed. call -help for help.");
        System.exit(0);
    }

    // gui
    final Display display = new Display();

    Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
        public void run() {
            try {
                Shell shell = new Shell(display);
                shell.setText("pmodel-gui " + "v[% version %]");

                // set an icon
                if (this.getClass().getResourceAsStream("/logoSymbol50Transp.png") != null) {
                    shell.setImage(
                            new Image(display, this.getClass().getResourceAsStream("/logoSymbol50Transp.png")));
                } else if ((new java.io.File("logoSymbol50Transp.png")).exists()) {
                    shell.setImage(new Image(display, "logoSymbol50Transp.png"));
                }

                shell.setLayout(new FillLayout());
                Composite composite = new Composite(shell, SWT.NO_FOCUS);
                GridLayout gl_composite = new GridLayout(2, false);
                gl_composite.marginWidth = 0;
                gl_composite.marginHeight = 0;
                if (line.hasOption("definition")) {
                    System.err.println("definition is " + line.getOptionValue("definition"));
                    new PmodelPartUi1(composite, line.getOptionValue("definition"));
                } else if (line.hasOption("instance")) {
                    System.err.println("instance is " + line.getOptionValue("instance"));
                    new PmodelPartUi1(composite, line.getOptionValue("instance"));
                }

                try {
                    shell.open();

                    while (!shell.isDisposed()) {
                        if (!display.readAndDispatch()) {
                            display.sleep();
                        }
                    }

                } finally {
                    if (!shell.isDisposed()) {
                        shell.dispose();
                    }
                }

            } finally {
                display.dispose();
            }
        }
    });

    System.exit(0);
}