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

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

Introduction

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

Prototype

@Deprecated
public static ISWTObservableValue observeBackground(Control control) 

Source Link

Document

Returns an observable value tracking the background color of the given control

Usage

From source file:org.kalypso.ui.editor.styleeditor.stroke.StrokeComposite.java

License:Open Source License

private void createColorControl(final FormToolkit toolkit, final Composite parent) {
    toolkit.createLabel(parent, Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.16")); //$NON-NLS-1$

    final Label colorLabel = toolkit.createLabel(parent, StringUtils.EMPTY, SWT.BORDER);
    final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    gridData.widthHint = 16;/*w ww. j a v a  2  s  .c  om*/
    colorLabel.setLayoutData(gridData);

    final IObservableValue target = SWTObservables.observeBackground(colorLabel);
    final IObservableValue model = new StrokeColorValue(m_input);

    m_binding.bindValue(target, model, new SwrToAwtColorConverter(),
            new AwtToSwtColorConverter(JFaceResources.getColorRegistry(), toString()));

    colorLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(final MouseEvent e) {
            final ColorDialog colorDialog = new ColorDialog(getShell());
            colorDialog.setRGB(ColorUtilities.toRGB((Color) model.getValue()));
            final RGB chosenColor = colorDialog.open();
            if (chosenColor != null)
                model.setValue(ColorUtilities.toAwtColor(chosenColor));
        }
    });

    colorLabel.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_HAND));
}

From source file:org.reap.internal.core.binding.BindingManager.java

License:Open Source License

private IObservable createSWTObservable(final Control control, final BindingConfig binding) {
    IObservable obs = null;/* w w w . j  a va  2 s. c o  m*/
    switch (binding.getType()) {
    case BACKGROUND:
        obs = SWTObservables.observeBackground(control);
        break;
    case EDITABLE:
        obs = SWTObservables.observeEditable(control);
        break;
    case ENABLED:
        obs = SWTObservables.observeEnabled(control);
        break;
    case FONT:
        obs = SWTObservables.observeFont(control);
        break;
    case FOREGROUND:
        obs = SWTObservables.observeForeground(control);
        break;
    case ITEMS:
        obs = SWTObservables.observeItems(control);
        break;
    case MAX:
        obs = SWTObservables.observeMax(control);
        break;
    case MIN:
        obs = SWTObservables.observeMin(control);
        break;
    case SELECTION:
        obs = SWTObservables.observeSelection(control);
        break;
    case SINGLESELECTIONINDEX:
        obs = SWTObservables.observeSingleSelectionIndex(control);
        break;
    case TEXT:
        obs = SWTObservables.observeText(control);
        break;
    case TEXTFOCUSOUT:
        obs = SWTObservables.observeText(control, SWT.FocusOut);
        break;
    case TEXTMODIFY:
        obs = SWTObservables.observeText(control, SWT.Modify);
        break;
    case TEXTNONE:
        obs = SWTObservables.observeText(control, SWT.None);
        break;
    case TOOLTIPTEXT:
        obs = SWTObservables.observeTooltipText(control);
        break;
    case VISIBLE:
        obs = SWTObservables.observeVisible(control);
        break;
    default:
        throw new IllegalArgumentException();
    }
    return obs;
}