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

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

Introduction

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

Prototype

@Deprecated
public static ISWTObservableValue observeText(Control control) 

Source Link

Document

Returns an observable observing the text attribute of the provided control.

Usage

From source file:org.eclipse.rcptt.internal.launching.ext.ui.wizards.NewAUTPage.java

License:Open Source License

private void createControlAutolaunch(Composite parent) {
    Button autolaunch = new Button(parent, SWT.CHECK);
    GridDataFactory.fillDefaults().span(3, 1).grab(true, false).applyTo(autolaunch);
    autolaunch.setText("to del");
    autolaunch.setSelection(true);/*from w w w.jav  a  2 s  .com*/

    dbc.bindValue(SWTObservables.observeSelection(autolaunch), autolaunchValue);
    dbc.bindValue(SWTObservables.observeText(autolaunch), autolaunchLabel);
}

From source file:org.eclipse.rcptt.internal.launching.ext.ui.wizards.NewAUTPage.java

License:Open Source License

private void createControlWarning(final Composite parent) {
    Label warning = new Label(parent, SWT.WRAP);
    warning.setText("");
    GridDataFactory.fillDefaults().span(3, 1).grab(true, false).applyTo(warning);

    ISWTObservableValue warningObservable = SWTObservables.observeText(warning);
    warningObservable.addChangeListener(new IChangeListener() {
        public void handleChange(ChangeEvent event) {
            // Corrects size of the label
            parent.layout(false);// w  ww .  ja va  2s . c o  m
        }
    });

    dbc.bindValue(warningObservable, warningMessageValue);
}

From source file:org.eclipse.riena.sample.snippets.SnippetComboRidget002.java

License:Open Source License

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

    try {//from  w  w  w . j a v a2 s . c om
        final Shell shell = UIControlsFactory.createShell(display);
        shell.setLayout(new GridLayout(2, false));
        shell.setText(SnippetComboRidget002.class.getSimpleName());

        UIControlsFactory.createLabel(shell, "ComboRidget:"); //$NON-NLS-1$
        final Combo combo = UIControlsFactory.createCombo(shell);

        UIControlsFactory.createLabel(shell, "Selection:"); //$NON-NLS-1$
        final Label label = UIControlsFactory.createLabel(shell, ""); //$NON-NLS-1$
        GridDataFactory.fillDefaults().grab(true, false).applyTo(label);

        final IComboRidget comboRidget = (IComboRidget) SwtRidgetFactory.createRidget(combo);
        final WritableList values = new WritableList(Arrays.asList(Answer.YES, Answer.NO, Answer.MAYBE),
                Answer.class);
        final WritableValue selection = new WritableValue(Answer.YES, Answer.class);

        final ConverterFactory<?, ?> factory = new ConverterFactory<Answer, String>(Answer.class, String.class)
                .add(Answer.YES, "Yes").add(Answer.NO, "No").add(Answer.MAYBE, "Maybe").add(null, ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        comboRidget.setModelToUIControlConverter(factory.createFromToConverter());
        comboRidget.setUIControlToModelConverter(factory.createToFromConverter());
        comboRidget.bindToModel(values, Answer.class, null, selection);
        comboRidget.updateFromModel();

        final DataBindingContext dbc = new DataBindingContext();
        dbc.bindValue(SWTObservables.observeText(label), selection);

        shell.pack();
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    } finally {
        display.dispose();
    }
}

From source file:org.eclipse.riena.sample.snippets.SnippetComboRidget003.java

License:Open Source License

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

    try {/*from w ww. j a  v a 2  s .  c o  m*/
        final Shell shell = UIControlsFactory.createShell(display);
        shell.setText(SnippetComboRidget003.class.getSimpleName());
        GridLayoutFactory.swtDefaults().numColumns(2).spacing(5, 5).applyTo(shell);

        UIControlsFactory.createLabel(shell, "CCombo:"); //$NON-NLS-1$
        final CCombo ccombo = UIControlsFactory.createCCombo(shell);

        UIControlsFactory.createLabel(shell, "Selection:"); //$NON-NLS-1$
        final Label lblSelection = UIControlsFactory.createLabel(shell, ""); //$NON-NLS-1$

        final Button button = UIControlsFactory.createButton(shell, "&Reset"); //$NON-NLS-1$
        GridDataFactory.fillDefaults().span(2, 1).applyTo(button);

        // data model
        final String emptySelection = "<no selection>"; //$NON-NLS-1$
        final IObservableList input = createInput(emptySelection);

        final IComboRidget ccomboRidget = (IComboRidget) SwtRidgetFactory.createRidget(ccombo);
        ccomboRidget.setMandatory(true);
        ccomboRidget.setEmptySelectionItem(emptySelection);
        ccomboRidget.bindToModel(input, String.class, null, SWTObservables.observeText(lblSelection));
        ccomboRidget.updateFromModel();

        final IActionRidget actionRidget = (IActionRidget) SwtRidgetFactory.createRidget(button);
        actionRidget.addListener(new IActionListener() {
            public void callback() {
                ccomboRidget.setSelection(emptySelection);
            }
        });

        shell.pack();
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    } finally {
        display.dispose();
    }
}

From source file:org.eclipse.scada.ui.chart.viewer.controller.actions.ScaleActionController.java

License:Open Source License

public ScaleActionController(final ControllerManager controllerManager, final ChartContext chartContext,
        final ScaleAction controller) {
    super(controllerManager.getContext(), chartContext, controller);

    final DataBindingContext ctx = controllerManager.getContext();

    final Composite space = chartContext.getExtensionSpaceProvider().getExtensionSpace();
    if (space != null) {
        this.button = new Button(space, SWT.PUSH);
        this.button.addSelectionListener(new SelectionAdapter() {
            @Override//  w ww  . j  av  a 2s.  c  o m
            public void widgetSelected(final SelectionEvent e) {
                action();
            };
        });

        addBinding(ctx.bindValue(PojoObservables.observeValue(this, "milliseconds"), //$NON-NLS-1$
                EMFObservables.observeValue(controller, ChartPackage.Literals.SCALE_ACTION__TIMESPAN)));
        addBinding(ctx.bindValue(SWTObservables.observeText(this.button),
                EMFObservables.observeValue(controller, ChartPackage.Literals.SCALE_ACTION__LABEL)));
        addBinding(ctx.bindValue(SWTObservables.observeTooltipText(this.button),
                EMFObservables.observeValue(controller, ChartPackage.Literals.SCALE_ACTION__DESCRIPTION)));

        this.layoutListener = new IValueChangeListener() {

            @Override
            public void handleValueChange(final ValueChangeEvent event) {
                space.layout();
            }
        };

        this.labelProperty = EMFObservables.observeValue(controller, ChartPackage.Literals.SCALE_ACTION__LABEL);
        this.labelProperty.addValueChangeListener(this.layoutListener);

        space.layout();
    } else {
        this.button = null;
    }
}

From source file:org.eclipse.scada.ui.chart.viewer.controller.actions.TimeShiftActionController.java

License:Open Source License

public TimeShiftActionController(final ControllerManager controllerManager, final ChartContext chartContext,
        final TimeShiftAction controller) {
    super(controllerManager.getContext(), chartContext, controller);

    final DataBindingContext ctx = controllerManager.getContext();

    final Composite space = chartContext.getExtensionSpaceProvider().getExtensionSpace();
    if (space != null) {
        this.button = new Button(space, SWT.PUSH);
        this.button.addSelectionListener(new SelectionAdapter() {
            @Override/*from  w w w  .  j av  a 2s  .c  o m*/
            public void widgetSelected(final SelectionEvent e) {
                action();
            };
        });
        addBinding(ctx.bindValue(PojoObservables.observeValue(this, "milliseconds"), //$NON-NLS-1$
                EMFObservables.observeValue(controller, ChartPackage.Literals.TIME_SHIFT_ACTION__DIFF)));
        addBinding(ctx.bindValue(SWTObservables.observeText(this.button),
                EMFObservables.observeValue(controller, ChartPackage.Literals.TIME_SHIFT_ACTION__LABEL)));
        addBinding(ctx.bindValue(SWTObservables.observeTooltipText(this.button),
                EMFObservables.observeValue(controller, ChartPackage.Literals.TIME_SHIFT_ACTION__DESCRIPTION)));

        this.layoutListener = new IValueChangeListener() {

            @Override
            public void handleValueChange(final ValueChangeEvent event) {
                space.layout();
            }
        };

        this.labelProperty = EMFObservables.observeValue(controller,
                ChartPackage.Literals.TIME_SHIFT_ACTION__LABEL);
        this.labelProperty.addValueChangeListener(this.layoutListener);

        space.layout();
    } else {
        this.button = null;
    }
}

From source file:org.eclipse.scada.ui.chart.viewer.profile.ButtonProfileEntry.java

License:Open Source License

public ButtonProfileEntry(final DataBindingContext dbc, final Composite parent,
        final ProfileManager profileManager, final Profile profile, final ChartContext chartContext) {
    super(dbc, profileManager, profile, chartContext);

    this.widget = new Button(parent, SWT.TOGGLE);

    addBinding(dbc.bindValue(SWTObservables.observeText(this.widget),
            EMFObservables.observeValue(profile, ChartPackage.Literals.PROFILE__LABEL)));

    this.widget.addSelectionListener(new SelectionAdapter() {
        @Override//ww  w . j  a v a  2s.  c  o m
        public void widgetSelected(final SelectionEvent e) {
            fireSelection(ButtonProfileEntry.this.widget.getSelection());
        };
    });
}

From source file:org.eclipse.scada.ui.chart.viewer.profile.CheckProfileEntry.java

License:Open Source License

public CheckProfileEntry(final DataBindingContext dbc, final Composite parent,
        final ProfileManager profileManager, final Profile profile, final ChartContext chartContext) {
    super(dbc, profileManager, profile, chartContext);

    this.widget = new Button(parent, SWT.CHECK);
    addBinding(dbc.bindValue(SWTObservables.observeText(this.widget),
            EMFObservables.observeValue(profile, ChartPackage.Literals.PROFILE__LABEL)));

    this.widget.addSelectionListener(new SelectionAdapter() {
        @Override//w  w w  .j  a v a 2s . c  o  m
        public void widgetSelected(final SelectionEvent e) {
            fireSelection(CheckProfileEntry.this.widget.getSelection());
        };
    });
}

From source file:org.eclipse.scada.ui.chart.viewer.profile.RadioProfileEntry.java

License:Open Source License

public RadioProfileEntry(final DataBindingContext dbc, final Composite parent,
        final ProfileManager profileManager, final Profile profile, final ChartContext chartContext) {
    super(dbc, profileManager, profile, chartContext);

    this.widget = new Button(parent, SWT.RADIO);
    addBinding(dbc.bindValue(SWTObservables.observeText(this.widget),
            EMFObservables.observeValue(profile, ChartPackage.Literals.PROFILE__LABEL)));

    this.widget.addSelectionListener(new SelectionAdapter() {
        @Override/*from  w ww.  j a v  a 2 s  .  c  om*/
        public void widgetSelected(final SelectionEvent e) {
            fireSelection(RadioProfileEntry.this.widget.getSelection());
        };
    });
}

From source file:org.eclipse.scada.utils.ui.server.internal.app.MainEntryPoint.java

License:Open Source License

private Composite createHeader(final Composite parent) {
    final Composite header = new Composite(parent, SWT.NONE);

    header.setLayout(new GridLayout(2, false));

    header.setData(RWT.CUSTOM_VARIANT, "header"); //$NON-NLS-1$
    header.setBackgroundMode(SWT.INHERIT_DEFAULT);

    this.headerLabel = new Label(header, SWT.NONE);
    this.headerLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    this.headerLabel.setData(RWT.CUSTOM_VARIANT, "headerLabel"); //$NON-NLS-1$

    this.dbc.bindValue(SWTObservables.observeText(this.headerLabel), this.manager.getPageName());

    this.logonButton = new Button(header, SWT.PUSH);
    this.logonButton.setVisible(false);
    this.logonButton.setText("Logon");
    this.logonButton.addSelectionListener(new SelectionAdapter() {
        private static final long serialVersionUID = 1L;

        @Override/*from  ww  w.j  a v a2  s.  c om*/
        public void widgetSelected(final SelectionEvent e) {
            handleLogon();
        }
    });

    this.logoutButton = new Button(header, SWT.PUSH);
    this.logoutButton.setVisible(false);
    this.logoutButton.setText("Logout");
    this.logoutButton.addSelectionListener(new SelectionAdapter() {
        private static final long serialVersionUID = 1L;

        @Override
        public void widgetSelected(final SelectionEvent e) {
            handleLogout();
        }
    });

    return header;
}