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.jboss.tools.jst.css.dialog.tabs.BaseTabControl.java

License:Open Source License

private void bind(Widget widget, String attribute, UpdateValueStrategy targetToModel,
        UpdateValueStrategy modelToTarget) {

    IObservableValue attributeValue = createAttributeObservableValue(attribute);

    if (targetToModel == null) {
        targetToModel = new UpdateValueStrategy();
    }//  www  .  j a  v  a 2s  . c om

    targetToModel.setBeforeSetValidator(CSSStyleValueValidator.getInstance());

    if (widget instanceof Text) {
        getBindingContext().bindValue(SWTObservables.observeText((Text) widget, SWT.Modify), attributeValue,
                targetToModel, modelToTarget);
    } else if ((widget instanceof Combo)) {
        getBindingContext().bindValue(SWTObservables.observeText(widget), attributeValue, targetToModel,
                modelToTarget);
    } else if (widget instanceof CSSWidget) {
        getBindingContext().bindValue(new CSSWidgetValueProperty().observe(widget), attributeValue,
                targetToModel, modelToTarget);
    } else if (widget instanceof TreeItem) {
        getBindingContext().bindValue(
                new CSSTreeItemWidgetValueProperty(VALUE_ATTRIBUTE_COLUMN).observe(widget), attributeValue,
                targetToModel, modelToTarget);
    }

}

From source file:org.kalypso.commons.databinding.swt.FileBinding.java

License:Open Source License

public Text createFileField(final Composite parent) {
    final Text field = new Text(parent, SWT.SINGLE | SWT.BORDER);
    field.setFont(parent.getFont());/*from   w  ww.  j  a  v a  2  s  . com*/

    final IObservableValue targetFile = SWTObservables.observeText(field, SWT.Modify);

    final DataBinder binder = new DataBinder(targetFile, m_fileValue);
    binder.setModelToTargetConverter(new FileToStringConverter());
    binder.setTargetToModelConverter(new StringToFileConverter());

    binder.addTargetAfterConvertValidator(new FileChooserValidator(m_delegate));

    m_binding.bindValue(binder);

    return field;
}

From source file:org.kalypso.gml.ui.internal.shape.ShapeFileNewFilePage.java

License:Open Source License

private void createFileBinding(final Text fileField, final Button fileButton) {
    final ISWTObservableValue fileText = SWTObservables.observeText(fileField, SWT.Modify);
    final IObservableValue pathValue = new ShapePathValue(m_input);

    fileButton.addSelectionListener(//from   w  w w . j  av  a2s. c om
            new FileSaveAsSelectionListener(pathValue, Messages.getString("ShapeFileNewPage_7"))); //$NON-NLS-1$

    final UpdateValueStrategy targetToModel = new UpdateValueStrategy();
    targetToModel.setConverter(new StringToPathConverter());

    final MultiValidator multiValidator = new MultiValidator();
    multiValidator.add(new PathIsProjectValidator(IStatus.ERROR));
    multiValidator.add(new PathIsDirectoryValidator(IStatus.ERROR));
    multiValidator.add(new PathShapeExistsValidator(IStatus.WARNING));
    targetToModel.setBeforeSetValidator(multiValidator);

    final UpdateValueStrategy modelToTarget = new UpdateValueStrategy();
    // AfterGet also works when new dialog sets the new path into the model
    modelToTarget.setAfterGetValidator(multiValidator);

    m_context.bindValue(fileText, pathValue, targetToModel, modelToTarget);
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.TriangulateGeometryComposite.java

License:Open Source License

private void createContents(final FormToolkit toolkit, final Composite parent) {
    final Section section = toolkit.createSection(parent,
            Section.EXPANDED | Section.DESCRIPTION | Section.TITLE_BAR);
    section.setText(Messages.getString("TriangulateGeometryWidget.5")); //$NON-NLS-1$
    section.setDescription(Messages.getString("TriangulateGeometryWidget.6")); //$NON-NLS-1$
    section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    final Composite sectionComposite = toolkit.createComposite(section, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(sectionComposite);
    section.setClient(sectionComposite);

    /* Check for triangle.exe */
    final IStatus statusTriangleExe = checkForTriangleExe();
    if (!statusTriangleExe.isOK()) {
        final StatusComposite triangleStatusComposite = new StatusComposite(sectionComposite, SWT.NONE);
        triangleStatusComposite.setStatus(statusTriangleExe);
        triangleStatusComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    }//from   w  w w.ja  v a 2 s .c  o m

    final IValueChangeListener valueChangedListener = new IValueChangeListener() {
        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            try {
                m_triangulationBuilder.finish();
            } catch (final Exception e) {
                final Shell shell = parent.getShell();
                final IStatus result = StatusUtilities.statusFromThrowable(e);
                StatusDialog.open(shell, result, event.getObservableValue().toString());
            }
        }
    };

    /* maximal Area */
    toolkit.createLabel(sectionComposite, Messages.getString("TriangulateGeometryWidget.7")); //$NON-NLS-1$

    final Text maxArea = toolkit.createText(sectionComposite, StringUtils.EMPTY, SWT.SINGLE | SWT.BORDER);
    maxArea.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));

    final ISWTObservableValue targetMaxArea = SWTObservables.observeText(maxArea, SWT.FocusOut);
    final IObservableValue modelMaxArea = BeansObservables.observeValue(m_triangulationBuilder,
            TriangulationBuilder.PROPERTY_MAX_AREA);
    final DataBinder maxAreaBinder = new DataBinder(targetMaxArea, modelMaxArea);
    maxAreaBinder.addTargetAfterConvertValidator(
            new NumberNotNegativeValidator(IStatus.ERROR, Messages.getString("TriangulateGeometryWidget.8"))); //$NON-NLS-1$
    m_binding.bindValue(maxAreaBinder);
    targetMaxArea.addValueChangeListener(valueChangedListener);

    /* Minimum Angle */
    toolkit.createLabel(sectionComposite, Messages.getString("TriangulateGeometryWidget.10")); //$NON-NLS-1$
    final Text minAngle = toolkit.createText(sectionComposite, "22", SWT.SINGLE | SWT.BORDER); //$NON-NLS-1$
    minAngle.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));

    final ISWTObservableValue targetMinAngle = SWTObservables.observeText(minAngle, SWT.FocusOut);
    final IObservableValue modelMinAngle = BeansObservables.observeValue(m_triangulationBuilder,
            TriangulationBuilder.PROPERTY_MIN_ANGLE);
    final DataBinder minAngleBinder = new DataBinder(targetMinAngle, modelMinAngle);
    minAngleBinder.addTargetAfterConvertValidator(
            new NumberRangeValidator(IStatus.ERROR, 0, 32, Messages.getString("TriangulateGeometryWidget.12"))); //$NON-NLS-1$
    m_binding.bindValue(minAngleBinder);
    targetMinAngle.addValueChangeListener(valueChangedListener);

    /* Steiner checkbox */
    final Button noSteinerButton = toolkit.createButton(sectionComposite,
            Messages.getString("TriangulateGeometryWidget.14"), SWT.CHECK); //$NON-NLS-1$
    noSteinerButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));

    final ISWTObservableValue targetSteiner = SWTObservables.observeSelection(noSteinerButton);
    final IObservableValue modelSteiner = BeansObservables.observeValue(m_triangulationBuilder,
            TriangulationBuilder.PROPERTY_NO_STEINER_ON_BOUNDARY);
    m_binding.bindValue(targetSteiner, modelSteiner);
    targetSteiner.addValueChangeListener(valueChangedListener);

    /* 'Apply To' button */
    final Composite buttonPanel = toolkit.createComposite(parent);
    GridLayoutFactory.swtDefaults().applyTo(buttonPanel);
    buttonPanel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final TriangulateGeometryApplyToAction convertToModelAction = new TriangulateGeometryApplyToAction(
            m_triangulationBuilder, m_workspace);
    final Button buttonConvertToModel = ActionButton.createButton(toolkit, buttonPanel, convertToModelAction);
    buttonConvertToModel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
}

From source file:org.kalypso.model.wspm.pdb.internal.connect.oracle.OracleSettingsControl.java

License:Open Source License

private void createPropertyControl(final String label, final int style, final String property,
        final IValidator... validators) {
    new Label(this, SWT.NONE).setText(label);

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

    final UpdateValueStrategy targetToModel = new UpdateValueStrategy();
    for (final IValidator validator : validators) {
        targetToModel.setAfterConvertValidator(validator);
    }/*  w  w w  . j av  a  2 s .  c  o  m*/

    final IObservableValue target = SWTObservables.observeText(field, new int[] { SWT.Modify });
    final IObservableValue model = new SettingsPropertyValue(m_settings, property);
    m_binding.bindValue(target, model, targetToModel, null);

    m_fields.add(field);
}

From source file:org.kalypso.model.wspm.pdb.internal.connect.postgis.PostGisSettingsControl.java

License:Open Source License

private void createPropertyControl(final String label, final int style, final String property,
        final IValidator... validators) {
    new Label(this, SWT.NONE).setText(label);

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

    final UpdateValueStrategy targetToModel = new UpdateValueStrategy();
    for (final IValidator validator : validators)
        targetToModel.setAfterConvertValidator(validator);

    final IObservableValue target = SWTObservables.observeText(field, new int[] { SWT.Modify });
    final IObservableValue model = new SettingsPropertyValue(m_settings, property);
    m_binding.bindValue(target, model, targetToModel, null);

    m_fields.add(field);//from  ww  w  .j  a v a 2 s. c  o m
}

From source file:org.kalypso.model.wspm.pdb.internal.update.UpdatePageBaseInfo.java

License:Open Source License

private void createDocumentPathControls(final Composite parent) {
    final Group group = new Group(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().applyTo(group);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    final String documentBaseLabel = Messages.getString("UpdatePageBaseInfo.3"); //$NON-NLS-1$
    group.setText(documentBaseLabel);//from w w  w. jav a  2 s .  com

    final Text field = new Text(group, SWT.BORDER | SWT.SINGLE);
    field.setMessage(Messages.getString("UpdatePageBaseInfo.4")); //$NON-NLS-1$
    field.setToolTipText(Messages.getString("UpdatePageBaseInfo.5")); //$NON-NLS-1$
    field.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final ISWTObservableValue targetBase = SWTObservables.observeText(field, SWT.Modify);
    final IObservableValue modelBase = new PropertiesObservaleValue(m_data.getVariables(),
            PdbInfo.PROPERTY_DOCUMENT_SERVER);

    final TestDocumentBaseAction testAction = new TestDocumentBaseAction(modelBase);
    final ImageHyperlink hyperlink = ActionHyperlink.createHyperlink(null, group, SWT.PUSH, testAction);
    hyperlink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final DataBinder binder = new DataBinder(targetBase, modelBase);
    binder.addTargetAfterGetValidator(new StringToUrlValidator(documentBaseLabel));

    final String endsWithMessage = String.format(Messages.getString("UpdatePageBaseInfo.6"), documentBaseLabel); //$NON-NLS-1$
    binder.addTargetAfterGetValidator(
            new StringMustEndWithValidator(IStatus.ERROR, endsWithMessage, new String[] { "/" })); //$NON-NLS-1$

    final String[] supportedProtocols = new String[] { "http://", "file:/" }; //$NON-NLS-1$ //$NON-NLS-2$
    final String protocolMessage = StringUtils.join(supportedProtocols,
            Messages.getString("UpdatePageBaseInfo.9")); //$NON-NLS-1$
    final String protocolWarning = String.format(Messages.getString("UpdatePageBaseInfo.10"), documentBaseLabel, //$NON-NLS-1$
            protocolMessage);

    binder.addTargetAfterGetValidator(
            new StringMustStartWithValidator(IStatus.ERROR, protocolWarning, supportedProtocols));

    m_binding.bindValue(binder);
}

From source file:org.kalypso.model.wspm.pdb.internal.update.UpdatePageExtent.java

License:Open Source License

private void createPropertyControl(final Composite parent, final String label, final String property) {
    new Label(parent, SWT.NONE).setText(label);

    final Text field = new Text(parent, SWT.BORDER | SWT.SINGLE);
    field.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final ISWTObservableValue target = SWTObservables.observeText(field, SWT.Modify);
    final IObservableValue model = new PropertiesObservaleValue(m_data.getVariables(), property);

    final DataBinder binder = new DataBinder(target, model);
    final String message = String.format(Messages.getString("UpdatePageExtent.10"), label); //$NON-NLS-1$
    binder.addTargetAfterGetValidator(new StringBlankValidator(IStatus.ERROR, message));
    binder.addTargetAfterGetValidator(new StringAsDoubleValidator(IStatus.ERROR, label));

    m_binding.bindValue(binder);/*w ww . j ava2s  . co m*/
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.admin.attachments.profiles.ProfilesAttachmentsOptionsPage.java

License:Open Source License

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

    final Text patternField = new Text(parent, SWT.SINGLE | SWT.BORDER);
    patternField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    patternField.setMessage(Messages.getString("ImportAttachmentsOptionsPage.7")); //$NON-NLS-1$
    patternField.setToolTipText(Messages.getString("ImportAttachmentsOptionsPage.8")); //$NON-NLS-1$

    final GuessStationPatternReplacer replacer = new GuessStationPatternReplacer();
    replacer.createPatternButton(parent, patternField);

    /* binding */
    final ISWTObservableValue targetField = SWTObservables.observeText(patternField, SWT.Modify);
    final IObservableValue modelField = BeansObservables.observeValue(m_data,
            ProfilesAttachmentsData.PROPERTY_IMPORT_PATTERN);

    final DataBinder binder = new DataBinder(targetField, modelField);
    binder.addTargetAfterConvertValidator(
            new StringBlankValidator(IStatus.ERROR, Messages.getString("ImportAttachmentsOptionsPage.9"))); //$NON-NLS-1$
    binder.addTargetAfterConvertValidator(new GuessStationPatternValidator());

    m_binding.bindValue(binder);//  www .j  av a  2s.  co m
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.admin.gaf.GafProfilesPage.java

License:Open Source License

private Composite createSaveLogControl(final Composite parent) {
    final Group panel = new Group(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(panel);
    panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    panel.setText(Messages.getString("GafProfilesPage.6")); //$NON-NLS-1$

    final Text fileField = new Text(panel, SWT.BORDER | SWT.SINGLE);
    fileField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    fileField.setMessage(Messages.getString("GafProfilesPage.7")); //$NON-NLS-1$

    final Button fileButton = new Button(panel, SWT.PUSH);
    fileButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    // FIXME: move string to common place
    fileButton.setText(Messages.getString("GafProfilesPage.8")); //$NON-NLS-1$

    /* field binding */
    final ISWTObservableValue target = SWTObservables.observeText(fileField, SWT.Modify);
    final IObservableValue model = BeansObservables.observeValue(m_data, ImportGafData.PROPERTY_LOG_FILE);
    final DataBinder binder = new DataBinder(target, model);

    binder.setTargetToModelConverter(new StringToFileConverter());
    binder.setModelToTargetConverter(new FileToStringConverter());

    binder.addTargetAfterGetValidator(/*  ww w  . j  av a  2s  .c  om*/
            new StringBlankValidator(IStatus.INFO, Messages.getString("GafProfilesPage.9"))); //$NON-NLS-1$
    binder.addTargetAfterConvertValidator(new FileShouldNotBeDirectoryValidator());
    binder.addTargetAfterConvertValidator(new FileCannotWriteValidator());
    binder.addTargetAfterConvertValidator(new FileAlreadyExistsValidator());

    m_binding.bindValue(binder);

    /* Button binding */
    final FileValueSelectionListener fileListener = new FileValueSelectionListener(model,
            Messages.getString("GafProfilesPage.10"), SWT.SAVE); //$NON-NLS-1$
    fileListener.addFilter(Messages.getString("GafProfilesPage.11"), "*.log"); //$NON-NLS-1$//$NON-NLS-2$
    fileListener.addAllFilter();
    fileButton.addSelectionListener(fileListener);

    return panel;
}