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, int event) 

Source Link

Document

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

Usage

From source file:org.kalypso.model.wspm.pdb.ui.internal.admin.waterbody.WaterBodyControl.java

License:Open Source License

private void createNameControls(final Composite parent) {
    new Label(parent, SWT.NONE).setText(Messages.getString("EditWaterBodyPage.7")); //$NON-NLS-1$

    final Text field = new Text(parent, SWT.BORDER);
    field.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    field.setMessage(Messages.getString("EditWaterBodyPage.8")); //$NON-NLS-1$
    field.setTextLimit(WaterBodyConstants.NAME_LIMIT);

    field.setEnabled(isEditable());//from  w w w . j  a v a2s  . c  o m

    final IObservableValue target = SWTObservables.observeText(field, SWT.Modify);
    final IObservableValue model = BeansObservables.observeValue(m_waterBody, WaterBody.PROPERTY_NAME);

    final DataBinder binder = new DataBinder(target, model);
    binder.addTargetAfterGetValidator(
            new StringBlankValidator(IStatus.ERROR, Messages.getString("EditWaterBodyPage.9"))); //$NON-NLS-1$

    final String ignoreName = m_mode == Mode.EDIT ? m_waterBody.getName() : null;

    if (m_existingWaterbodies != null)
        binder.addTargetAfterGetValidator(new UniqueWaterBodyNameValidator(m_existingWaterbodies, ignoreName));

    m_binding.bindValue(binder);
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.admin.waterbody.WaterBodyControl.java

License:Open Source License

private void createLabelControls(final Composite parent) {
    new Label(parent, SWT.NONE).setText(Messages.getString("EditWaterBodyPage.10")); //$NON-NLS-1$

    final Text field = new Text(parent, SWT.BORDER);
    field.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    field.setMessage(Messages.getString("EditWaterBodyPage.11")); //$NON-NLS-1$
    field.setTextLimit(WaterBody.NAME_LIMIT);

    field.setEnabled(isEditable());/*from  w  w  w  . jav a2s .c om*/

    final IObservableValue target = SWTObservables.observeText(field, SWT.Modify);
    final IObservableValue model = BeansObservables.observeValue(m_waterBody, WaterBody.PROPERTY_LABEL);
    final DataBinder binder = new DataBinder(target, model);

    final String ignoreLabel = m_mode == Mode.EDIT ? m_waterBody.getLabel() : null;

    binder.addTargetAfterGetValidator(
            new StringBlankValidator(IStatus.ERROR, Messages.getString("EditWaterBodyPage.12"))); //$NON-NLS-1$

    if (m_existingWaterbodies != null)
        binder.addTargetAfterGetValidator(
                new UniqueWaterBodyLabelValidator(m_existingWaterbodies, ignoreLabel));

    m_binding.bindValue(binder);
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.admin.waterbody.WaterBodyControl.java

License:Open Source License

private void createDescriptionControls(final Composite parent) {
    final Label label = new Label(parent, SWT.NONE);
    label.setText(Messages.getString("EditWaterBodyPage.15")); //$NON-NLS-1$
    label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));

    final Text field = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.WRAP);
    field.setTextLimit(WaterBodyConstants.DESCRIPTION_LIMIT);
    field.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
    field.setMessage(Messages.getString("EditWaterBodyPage.16")); //$NON-NLS-1$

    field.setEnabled(isEditable());/*from  w  w  w.j  a va 2  s  .  c  om*/

    final IObservableValue target = SWTObservables.observeText(field, SWT.Modify);
    final IObservableValue model = BeansObservables.observeValue(m_waterBody, WaterBody.PROPERTY_DESCRIPTION);

    m_binding.bindValue(target, model);
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.content.filter.StateFilterControl.java

License:Open Source License

private void createNameField(final FormToolkit toolkit, final Composite parent) {
    final Text nameField = new Text(parent, SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
    nameField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    nameField.setMessage(Messages.getString("StateFilterControl.0")); //$NON-NLS-1$
    nameField.addFocusListener(new SelectAllFocusListener());

    addResetListener(nameField);/*  w w w  .  j  a v  a  2s  . co m*/

    final ISWTObservableValue target = SWTObservables.observeText(nameField,
            new int[] { SWT.Modify, SWT.DefaultSelection });
    final IObservableValue model = PojoObservables.observeValue(m_filter, StatesFilter.PROPERTY_NAME);
    m_binding.bindValue(target, model);

    if (toolkit != null)
        toolkit.adapt(nameField, true, true);

    nameField.setBackground(m_yellow);
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.content.filter.WaterBodyFilterControl.java

License:Open Source License

private void createGknField(final FormToolkit toolkit, final Composite parent) {
    final Text gknField = new Text(parent, SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
    gknField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    gknField.setMessage(Messages.getString("WaterBodyFilterControl_0")); //$NON-NLS-1$
    gknField.addFocusListener(new SelectAllFocusListener());

    addResetListener(gknField);//from  w w w . j  a va2 s.c om

    final ISWTObservableValue target = SWTObservables.observeText(gknField,
            new int[] { SWT.Modify, SWT.DefaultSelection });
    final IObservableValue model = PojoObservables.observeValue(m_filter, WaterBodiesFilter.PROPERTY_GKN);
    m_binding.bindValue(target, model);

    if (toolkit != null)
        toolkit.adapt(gknField, true, true);

    gknField.setBackground(m_yellow);
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.content.filter.WaterBodyFilterControl.java

License:Open Source License

private void createNameField(final FormToolkit toolkit, final Composite parent) {
    final Text nameField = new Text(parent, SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
    nameField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    nameField.setMessage(Messages.getString("WaterBodyFilterControl_1")); //$NON-NLS-1$
    nameField.addFocusListener(new SelectAllFocusListener());

    addResetListener(nameField);// www  . ja va 2 s.co  m

    final ISWTObservableValue target = SWTObservables.observeText(nameField,
            new int[] { SWT.Modify, SWT.DefaultSelection });
    final IObservableValue model = PojoObservables.observeValue(m_filter, WaterBodiesFilter.PROPERTY_NAME);
    m_binding.bindValue(target, model);

    if (toolkit != null)
        toolkit.adapt(nameField, true, true);

    nameField.setBackground(m_yellow);
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.preferences.SettingsPage.java

License:Open Source License

private void createNameControl(final Composite parent) {
    new Label(parent, SWT.NONE).setText(Messages.getString("SettingsPage.1")); //$NON-NLS-1$

    final Text field = new Text(parent, SWT.BORDER);
    field.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    field.setMessage(Messages.getString("SettingsPage.2")); //$NON-NLS-1$

    final IObservableValue target = SWTObservables.observeText(field, new int[] { SWT.Modify });
    final IObservableValue model = new SettingsNameValue(m_settings);

    final DataBinder binder = new DataBinder(target, model);

    binder.addTargetAfterGetValidator(//from  w w  w.  ja  va 2  s  . c  o  m
            new StringBlankValidator(IStatus.WARNING, StringBlankValidator.DEFAULT_WARNING_MESSAGE));
    binder.addTargetAfterGetValidator(new UniqueSettingsNameValidator(m_initialName));

    model.addValueChangeListener(new IValueChangeListener() {
        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            setTitle((String) event.diff.getNewValue());
        }
    });

    m_binding.bindValue(binder);
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.tin.DhmIndexComposite.java

License:Open Source License

private void createTextControl(final Composite main, final IDataBinding dataBinding, final String displayLabel,
        final String property, final boolean editable) {
    final Label label = new Label(main, SWT.NONE);
    label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    label.setText(displayLabel);//  w w  w.j  ava2  s . c  o  m

    final Text text = new Text(main, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    text.setEnabled(editable);

    final ISWTObservableValue targetValue = SWTObservables.observeText(text, SWT.Modify);
    final IObservableValue modelValue = BeansObservables.observeValue(m_dhmIndex, property);
    dataBinding.bindValue(targetValue, modelValue);
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.tin.imports.SearchDhmIndexPage.java

License:Open Source License

@Override
public void createControl(final Composite parent) {
    /* Create the databinding. */
    final DatabindingWizardPage dataBinding = new DatabindingWizardPage(this, null);

    /* Create the main composite. */
    final Composite main = new Composite(parent, SWT.NONE);
    final GridLayout mainLayout = new GridLayout(1, false);
    mainLayout.marginHeight = 0;/*from   w w  w . j a  va 2  s  .  c  o  m*/
    mainLayout.marginWidth = 0;
    main.setLayout(mainLayout);

    /* Create the filter group. */
    final Group filterGroup = new Group(main, SWT.NONE);
    filterGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    filterGroup.setLayout(new GridLayout(1, false));
    filterGroup.setText(Messages.getString("SearchDhmIndexPage_2")); //$NON-NLS-1$

    /* Create the filter textbox. */
    final Text filterText = new Text(filterGroup, SWT.BORDER | SWT.SEARCH);
    filterText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    /* Create the filter button. */
    final Button filterButton = new Button(filterGroup, SWT.CHECK);
    filterButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    filterButton.setText(Messages.getString("SearchDhmIndexPage_3")); //$NON-NLS-1$

    /* Create a tree viewer. */
    m_searchViewer = new TreeViewer(main,
            SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    final GridData treeData = new GridData(SWT.FILL, SWT.FILL, true, true);
    treeData.heightHint = 200;

    final Tree tree = m_searchViewer.getTree();
    tree.setLayoutData(treeData);
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);

    configureTreeViewer(m_searchViewer);
    m_searchViewer.setContentProvider(new SearchDhmIndexContentProvider());

    /* Add the column resize control listener. */
    tree.addControlListener(new ColumnsResizeControlListener());

    /* Create a scrolled form. */
    final ScrolledForm scrolledForm = new ScrolledForm(main);
    scrolledForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    scrolledForm.setExpandHorizontal(true);
    scrolledForm.setExpandVertical(true);

    /* Get the body. */
    final Composite body = scrolledForm.getBody();
    final GridLayout bodyLayout = new GridLayout(1, false);
    bodyLayout.marginHeight = 0;
    bodyLayout.marginWidth = 0;
    body.setLayout(bodyLayout);

    /* Add the dhm index composite. */
    m_dhmIndexComposite = new DhmIndexComposite(body, SWT.NONE, m_settingsData.getDhmIndex(), false,
            dataBinding);
    m_dhmIndexComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    /* Reflow. */
    scrolledForm.reflow(true);

    /* Create the filter. */
    final String dbCoordinateSystem = m_settingsData.getDbCoordinateSystem();
    final DhmIndexFilter filter = new DhmIndexFilter(m_searchViewer, dbCoordinateSystem, StringUtils.EMPTY,
            false);
    m_searchViewer.setFilters(new ViewerFilter[] { filter });

    /* Do the data binding. */
    final ISWTObservableValue textTarget = SWTObservables.observeText(filterText, new int[] { SWT.Modify });
    final IObservableValue textModel = PojoObservables.observeValue(filter,
            DhmIndexFilter.PROPERTY_FILTER_TEXT);
    dataBinding.bindValue(textTarget, textModel);

    /* Do the data binding. */
    final ISWTObservableValue buttonTarget = SWTObservables.observeSelection(filterButton);
    final IObservableValue buttonModel = PojoObservables.observeValue(filter,
            DhmIndexFilter.PROPERTY_FILTER_QUERY);
    dataBinding.bindValue(buttonTarget, buttonModel);

    /* Do the data binding. */
    final IObservableValue targetViewer = ViewersObservables.observeInput(m_searchViewer);
    final IObservableValue modelViewer = BeansObservables.observeValue(m_settingsData,
            PdbImportConnectionChooserData.PROPERTY_DHM_INDEXES);
    dataBinding.bindValue(targetViewer, modelViewer);

    /* Do the data binding. */
    final IObservableValue targetIndex = ViewersObservables.observeSinglePostSelection(m_searchViewer);
    final IObservableValue modelIndex = BeansObservables.observeValue(m_settingsData,
            PdbImportConnectionChooserData.PROPERTY_DHM_INDEX);

    final DataBinder dhmIndexBinder = new DataBinder(targetIndex, modelIndex);
    dhmIndexBinder.addTargetBeforeSetValidator(
            new NotNullValidator<>(DhmIndex.class, IStatus.ERROR, Messages.getString("SearchDhmIndexPage.0"))); //$NON-NLS-1$
    dhmIndexBinder.addTargetBeforeSetValidator(new ExistsValidator(DhmIndex.class, IStatus.ERROR,
            Messages.getString("SearchDhmIndexPage.1"), m_settingsData, m_dataContainer)); //$NON-NLS-1$
    dataBinding.bindValue(dhmIndexBinder);

    /* Add a listener. */
    modelIndex.addValueChangeListener(new IValueChangeListener() {
        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            /* Parent is disposed. */
            if (body.isDisposed())
                return;

            /* Get the dhm index from the selection. */
            final DhmIndex dhmIndex = (DhmIndex) event.getObservableValue().getValue();

            /* The dhm index composite needs to get the new object set. */
            if (m_dhmIndexComposite != null && !m_dhmIndexComposite.isDisposed())
                m_dhmIndexComposite.dispose();

            /* Add the dhm index composite. */
            m_dhmIndexComposite = new DhmIndexComposite(body, SWT.NONE, dhmIndex, false, dataBinding);
            m_dhmIndexComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

            ColumnsResizeControlListener.refreshColumnsWidth(tree);

            /* Reflow. */
            scrolledForm.reflow(true);
        }
    });

    /* Set the control to the page. */
    setControl(main);

    /* the user needs to do something first! */
    setPageComplete(false);
}

From source file:org.kalypso.model.wspm.tuhh.ui.export.bankline.BanklineExportOptionsPage.java

License:Open Source License

private void createDensifyControls(final Composite parent) {
    final Composite panel = new Composite(parent, SWT.NONE);
    panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(panel);

    final Button checkbox = new Button(panel, SWT.CHECK);
    checkbox.setText(Messages.getString("BanklineExportOptionsPage.0")); //$NON-NLS-1$
    checkbox.setToolTipText(Messages.getString("BanklineExportOptionsPage.1")); //$NON-NLS-1$

    final Text densifyField = new Text(panel, SWT.BORDER | SWT.RIGHT);
    densifyField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    densifyField.setText(Messages.getString("BanklineExportOptionsPage.2")); //$NON-NLS-1$

    /* binding */
    final ISWTObservableValue targetCheckbox = SWTObservables.observeSelection(checkbox);
    final ISWTObservableValue targetFieldEnablement = SWTObservables.observeEnabled(densifyField);
    final ISWTObservableValue targetFieldValue = SWTObservables.observeText(densifyField, SWT.Modify);

    final IObservableValue modelDensifyEnabled = BeansObservables.observeValue(m_data,
            BanklineExportData.PROPERTY_DENSIFY_ENABLED);
    final IObservableValue modelDensifyValue = BeansObservables.observeValue(m_data,
            BanklineExportData.PROPERTY_DENSIFY_DISTANCE);

    m_binding.bindValue(targetCheckbox, modelDensifyEnabled);
    m_binding.bindValue(targetFieldEnablement, modelDensifyEnabled);
    m_binding.bindValue(targetFieldValue, modelDensifyValue);
}