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:de.uniluebeck.itm.spyglass.gui.databinding.StringFormatter.java

License:Open Source License

public void setDataBinding(final DataBindingContext dbc, final PluginXMLConfig config) {

    // default string fmt

    final IObservableValue modelDefStrFmt = BeansObservables.observeValue(dbc.getValidationRealm(), config,
            PluginWithStringFormatterXMLConfig.PROPERTYNAME_DEFAULT_STRING_FORMATTER);

    final UpdateValueStrategy strategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
    strategy.setAfterGetValidator(new StringFormatterValidator());

    dbc.bindValue(SWTObservables.observeText(this.defaultStringFmt, SWT.Modify), modelDefStrFmt, strategy,
            null);/*  w  w  w  .  j  a  v a  2s  .co m*/

    // dbc.bindValue(SWTObservables.observeText(this.defaultStringFmt, SWT.Modify),
    // modelDefStrFmt, new UpdateValueStrategy(
    // UpdateValueStrategy.POLICY_CONVERT), null);

    // table

    columnFormatString.setEditingSupport(new StringFormatterEditingSupport(table, dbc));

    final ObservableSetContentProvider contentProvider = new ObservableSetContentProvider();
    table.setContentProvider(contentProvider);

    final IObservableMap typeMap = BeansObservables.observeMap(contentProvider.getKnownElements(),
            ObservableEntry.class, "key");
    final IObservableMap fmtStringMap = BeansObservables.observeMap(contentProvider.getKnownElements(),
            ObservableEntry.class, "value");

    final IObservableMap[] columnMaps = new IObservableMap[] { typeMap, fmtStringMap };
    table.setLabelProvider(new ObservableMapLabelProvider(columnMaps));

}

From source file:de.uniluebeck.itm.spyglass.gui.SelectPacketSourceDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    startArea = new Composite(parent, SWT.NONE);
    final FillLayout thisLayout = new FillLayout(org.eclipse.swt.SWT.HORIZONTAL);
    startArea.setLayout(thisLayout);//from w ww  .j  a  v  a  2  s  . c o m
    final GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    startArea.setLayoutData(gridData);

    final Group group1 = new Group(startArea, SWT.NONE);
    final GridLayout group1Layout = new GridLayout();
    group1Layout.makeColumnsEqualWidth = false;
    group1Layout.numColumns = 3;
    group1.setLayout(group1Layout);
    group1.setText("Sources");

    buttoniShell = new Button(group1, SWT.RADIO);
    buttoniShell.setText("iShell");

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

    buttonWiseBed = new Button(group1, SWT.RADIO);
    buttonWiseBed.setText("Testbed");

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

    buttonFile = new Button(group1, SWT.RADIO);
    buttonFile.setText("File");

    // disable the button if we're running standalone
    if (!SpyglassEnvironment.isIshellPlugin()) {
        buttoniShell.setEnabled(false);
    }

    final Composite wrapper = new Composite(group1, SWT.BORDER);
    wrapper.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
    textPath2File = new Text(wrapper, SWT.BORDER);
    textPath2File.setEditable(false);
    final GC gc = new GC(textPath2File);
    final FontMetrics fm = gc.getFontMetrics();
    final int width = 60 * fm.getAverageCharWidth();
    final int height = fm.getHeight();
    gc.dispose();
    textPath2File.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
    textPath2File.setSize(textPath2File.computeSize(width, height));

    buttonOpenFileDialog = new Button(group1, SWT.NONE);
    buttonOpenFileDialog.setText("...");
    buttonOpenFileDialog.addListener(SWT.Selection, new Listener() {
        @SuppressWarnings("synthetic-access")
        public void handleEvent(final Event event) {
            final FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
            fd.setFilterExtensions(new String[] { "*.rec" });
            fd.setFilterPath(new File(defaultDir).getAbsoluteFile().toString());
            final String path = fd.open();
            if (path != null) {
                textPath2File.setText(path);
            }
        }
    });

    // set up data-binding
    {

        myvalues.setUseIShell(!(spyglass.getPacketReader().getSourceType().equals(SOURCE_TYPE.FILE)));
        final DataBindingContext dbc = new DataBindingContext(
                SWTObservables.getRealm(getParentShell().getDisplay()));

        // binding of select button to use a file and text file with its path
        dbc.bindValue(SWTObservables.observeSelection(buttonFile), SWTObservables.observeEnabled(textPath2File),
                null, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));

        // binding of select button to use a file and open a file selection dialog
        dbc.bindValue(SWTObservables.observeSelection(buttonFile),
                SWTObservables.observeEnabled(buttonOpenFileDialog), null,
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));

        // binding of select button to use a file and the select button to use iShell
        dbc.bindValue(SWTObservables.observeSelection(buttonFile),
                SWTObservables.observeSelection(buttoniShell),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT)
                        .setConverter(new BooleanInversionConverter()),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT)
                        .setConverter(new BooleanInversionConverter()));

        // bind the button to select iShell to the corresponding property
        final IObservableValue modelObservableIsIshell = BeansObservables.observeValue(dbc.getValidationRealm(),
                myvalues, "useIShell");
        final IObservableValue modelObservableIsTestbed = BeansObservables
                .observeValue(dbc.getValidationRealm(), myvalues, "useTestbed");
        dbc.bindValue(SWTObservables.observeSelection(buttoniShell), modelObservableIsIshell, null, null);
        dbc.bindValue(SWTObservables.observeSelection(buttonWiseBed), modelObservableIsTestbed, null, null);

        // binding of the text field which contains the path to the file to the corresponding
        // string value
        final IObservableValue modelObservable1 = BeansObservables.observeValue(dbc.getValidationRealm(),
                myvalues, "path2File");
        dbc.bindValue(SWTObservables.observeText(textPath2File, SWT.Modify), modelObservable1, null, null);
    }
    initializeValues();
    group1.pack();
    startArea.pack();
    return startArea;
}

From source file:de.uniluebeck.itm.spyglass.plugin.gridpainter.GridPainterOptionsComposite.java

License:Open Source License

private void updateLockNumberOfRowsNCols() {

    final boolean locked = config.getLockNumberOfRowsNCols();

    if (locked) {

        numColsText.setText(numRowsText.getText());

        if (lockBindingNumberOfRowsNCols == null) {

            // bind the two fields together
            lockBindingNumberOfRowsNCols = dbc.bindValue(SWTObservables.observeText(numRowsText, SWT.Modify),
                    SWTObservables.observeText(numColsText, SWT.Modify), null, null);
        }// w  w w  . j  a v  a 2 s. c o  m

        buttonLockNumberOfRowsNCols.setImage(SWTResourceManager
                .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_closed_hor.png"));

    } else {
        if (lockBindingNumberOfRowsNCols != null) {
            // Kill the binding (it will be automatically removed from the dbc)
            lockBindingNumberOfRowsNCols.dispose();
            lockBindingNumberOfRowsNCols = null;
        }

        buttonLockNumberOfRowsNCols.setImage(SWTResourceManager
                .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_open_hor.png"));

    }
}

From source file:de.uniluebeck.itm.spyglass.plugin.gridpainter.GridPainterOptionsComposite.java

License:Open Source License

private void updateGridElementsSquare() {

    final boolean locked = config.getLockGridElementsSquare();

    if (locked) {
        gridElementHeightText.setText(gridElementWidthText.getText());

        if (lockBindingElementsSquare == null) {

            // bind the two fields together
            lockBindingElementsSquare = dbc.bindValue(
                    SWTObservables.observeText(gridElementWidthText, SWT.Modify),
                    SWTObservables.observeText(gridElementHeightText, SWT.Modify), null, null);
        }/*from  w  w w  .  j ava  2 s. c om*/

        buttonLockGridElementsSquare.setImage(SWTResourceManager
                .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_closed_hor.png"));

    } else {
        if (lockBindingElementsSquare != null) {
            // Kill the binding (it will be automatically removed from the dbc)
            lockBindingElementsSquare.dispose();
            lockBindingElementsSquare = null;
        }

        buttonLockGridElementsSquare.setImage(SWTResourceManager
                .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_open_hor.png"));

    }
}

From source file:de.uniluebeck.itm.spyglass.plugin.gridpainter.GridPainterOptionsComposite.java

License:Open Source License

public void setDatabinding(final DataBindingContext dbc, final GridPainterXMLConfig config,
        final GridPainterPreferencePage page, final Spyglass spyglass) {

    this.page = page;
    this.config = config;
    this.dbc = dbc;

    IObservableValue obsModel;//from ww w . ja  v a 2 s  . c o  m
    ISWTObservableValue obsWidget;
    UpdateValueStrategy usTargetToModel;
    UpdateValueStrategy usModelToTarget;

    {
        obsWidget = SWTObservables.observeText(lowerLeftPointXText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                GridPainterXMLConfig.PROPERTYNAME_GRID_LOWER_LEFT_POINT_X);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeText(lowerLeftPointYText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                GridPainterXMLConfig.PROPERTYNAME_GRID_LOWER_LEFT_POINT_Y);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeText(gridElementHeightText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                GridPainterXMLConfig.PROPERTYNAME_GRID_ELEMENT_HEIGHT);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeText(gridElementWidthText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                GridPainterXMLConfig.PROPERTYNAME_GRID_ELEMENT_WIDTH);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeText(this.lineWidth, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                GridPainterXMLConfig.PROPERTYNAME_LINE_WIDTH);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeBackground(colorExample);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                GridPainterXMLConfig.PROPERTYNAME_LINE_COLOR_R_G_B);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        usTargetToModel.setConverter(new ColorToArrayConverter());
        usModelToTarget = new UpdateValueStrategy();
        usModelToTarget.setConverter(new ArrayToColorConverter(this.getDisplay()));
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, usModelToTarget);
    }
    {
        obsWidget = SWTObservables.observeText(numColsText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                GridPainterXMLConfig.PROPERTYNAME_NUM_COLS);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeText(numRowsText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                GridPainterXMLConfig.PROPERTYNAME_NUM_ROWS);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }

    final MetricsXMLConfig metrics = spyglass.getConfigStore().getSpyglassConfig().getGeneralSettings()
            .getMetrics();
    {
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), metrics,
                MetricsXMLConfig.PROPERTYNAME_UNIT);
        dbc.bindValue(SWTObservables.observeText(lowerLeftPointXUnitLabel), obsModel, null, null);
        dbc.bindValue(SWTObservables.observeText(lowerLeftPointYUnitLabel), obsModel, null, null);
        dbc.bindValue(SWTObservables.observeText(gridElementWidthUnitLabel), obsModel, null, null);
        dbc.bindValue(SWTObservables.observeText(gridElementHeightUnitLabel), obsModel, null, null);
    }

    updateGridElementsSquare();
    updateLockNumberOfRowsNCols();

}

From source file:de.uniluebeck.itm.spyglass.plugin.imagepainter.ImagePainterOptionsComposite.java

License:Open Source License

private void updateLock() {

    final boolean locked = config.isKeepProportions();

    if (locked) {

        final int newWidth = config.getImageSizeX();
        final int newHeight = (int) Math.floor(newWidth / imgRatio);
        config.setImageSizeY(newHeight);

        if (lockBinding == null) {

            // bind the two fields together
            final UpdateValueStrategy uvs = new UpdateValueStrategy() {
                @Override/* w w w . j  a  va2 s  .  com*/
                public Object convert(final Object value) {
                    // Exception occurs when user has entered an empty string, in this
                    // case we'll return 0
                    if ((value != null) && !value.equals("")) {
                        final int intValue = Integer.parseInt(((String) value).replaceAll("\\.", ""));
                        return (int) Math.ceil(intValue / imgRatio);
                    }
                    return 0;
                }
            };
            final UpdateValueStrategy uvs2 = new UpdateValueStrategy() {
                @Override
                public Object convert(final Object value) {
                    // Exception occurs when user has entered an empty string, in this
                    // case we'll return 0
                    if ((value != null) && !value.equals("")) {
                        final int intValue = Integer.parseInt(((String) value).replaceAll("\\.", ""));
                        return (int) Math.ceil(intValue * imgRatio);
                    }
                    return 0;

                }
            };
            lockBinding = dbc.bindValue(SWTObservables.observeText(imageSizeWidthText, SWT.Modify),
                    SWTObservables.observeText(imageSizeHeightText, SWT.Modify), uvs, uvs2);
        }
    } else {
        if (lockBinding != null) {
            // Kill the binding (it will be automatically removed from the dbc)
            lockBinding.dispose();
            lockBinding = null;
        }
    }
}

From source file:de.uniluebeck.itm.spyglass.plugin.imagepainter.ImagePainterOptionsComposite.java

License:Open Source License

public void setDatabinding(final DataBindingContext dbc, final ImagePainterXMLConfig config,
        final Spyglass spyglass) {

    this.dbc = dbc;
    this.config = config;

    IObservableValue obsModel;//from  ww  w.  j  av a  2s  .c o  m
    ISWTObservableValue obsWidget;
    UpdateValueStrategy usTargetToModel;

    {
        obsWidget = SWTObservables.observeText(imageFileText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                ImagePainterXMLConfig.PROPERTYNAME_IMAGE_FILE_NAME);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT)
                .setAfterGetValidator(new FileReadableValidator());
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeText(lowerLeftXText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                ImagePainterXMLConfig.PROPERTYNAME_LOWER_LEFT_X);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeText(lowerLeftYText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                ImagePainterXMLConfig.PROPERTYNAME_LOWER_LEFT_Y);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeText(imageSizeWidthText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                ImagePainterXMLConfig.PROPERTYNAME_IMAGE_SIZE_X);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        usTargetToModel.setAfterConvertValidator(new IntegerRangeValidator("Image Size", 0, Integer.MAX_VALUE));
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeText(imageSizeHeightText, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                ImagePainterXMLConfig.PROPERTYNAME_IMAGE_SIZE_Y);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        usTargetToModel.setAfterConvertValidator(new IntegerRangeValidator("Image Size", 0, Integer.MAX_VALUE));
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeSelection(keepProportionsButton);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                ImagePainterXMLConfig.PROPERTYNAME_KEEP_PROPORTIONS);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }

    final MetricsXMLConfig metrics = spyglass.getConfigStore().getSpyglassConfig().getGeneralSettings()
            .getMetrics();
    {
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), metrics,
                MetricsXMLConfig.PROPERTYNAME_UNIT);
        dbc.bindValue(SWTObservables.observeText(xUnitLabel), obsModel, null, null);
        dbc.bindValue(SWTObservables.observeText(yUnitLabel), obsModel, null, null);
        dbc.bindValue(SWTObservables.observeText(widthUnitLabel), obsModel, null, null);
        dbc.bindValue(SWTObservables.observeText(heightUnitLabel), obsModel, null, null);
    }

    updateLock();

}

From source file:de.uniluebeck.itm.spyglass.plugin.linepainter.LinePainterOptionsComposite.java

License:Open Source License

public void setDatabinding(final DataBindingContext dbc, final LinePainterXMLConfig config,
        final LinePainterPreferencePage page) {

    this.page = page;

    IObservableValue obsModel;/*from   www . j a  va  2  s  .  com*/
    ISWTObservableValue obsWidget;
    UpdateValueStrategy usTargetToModel;
    UpdateValueStrategy usModelToTarget;

    {
        obsWidget = SWTObservables.observeText(lineWidth, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                LinePainterXMLConfig.PROPERTYNAME_LINE_WIDTH);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }
    {
        obsWidget = SWTObservables.observeBackground(lineColor);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                LinePainterXMLConfig.PROPERTYNAME_LINE_COLOR_R_G_B);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        usTargetToModel.setConverter(new ColorToArrayConverter());
        usModelToTarget = new UpdateValueStrategy();
        usModelToTarget.setConverter(new ArrayToColorConverter(this.getDisplay()));
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, usModelToTarget);
    }
    {
        obsWidget = SWTObservables.observeText(ttl, SWT.Modify);
        obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                PluginXMLConfig.PROPERTYNAME_TIMEOUT);
        usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        usTargetToModel
                .setAfterConvertValidator(new IntegerRangeValidator("Time To Live", 0, Integer.MAX_VALUE));
        dbc.bindValue(obsWidget, obsModel, usTargetToModel, null);
    }

    stringFormatter.setDataBinding(dbc, config);

}

From source file:de.uniluebeck.itm.spyglass.plugin.mappainter.MapPainterPrefComposite.java

License:Open Source License

public void setDatabinding(final DataBindingContext dbc, final MapPainterXMLConfig config,
        final Spyglass spyglass, final MapPainterPreferencePage page) {

    this.page = page;
    this.config = config;
    this.dbc = dbc;

    {// w w w . jav a2 s.c o  m
        dbc.bindValue(SWTObservables.observeText(this.lowerLeftX, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_LOWER_LEFT_X),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);
    }
    {
        dbc.bindValue(SWTObservables.observeText(this.lowerLeftY, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_LOWER_LEFT_Y),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);
    }
    {
        dbc.bindValue(SWTObservables.observeText(this.width, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_WIDTH),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator(
                        new IntegerRangeValidator("Width", 1, Integer.MAX_VALUE)),
                null);
    }
    {

        dbc.bindValue(SWTObservables.observeText(this.height, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_HEIGHT),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator(
                        new IntegerRangeValidator("Height", 1, Integer.MAX_VALUE)),
                null);
    }
    {

        dbc.bindValue(SWTObservables.observeText(this.blockWidth, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_GRID_ELEMENT_WIDTH),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator(
                        new IntegerRangeValidator("Block width", 1, Integer.MAX_VALUE)),
                null);
    }
    {

        dbc.bindValue(SWTObservables.observeText(this.blockHeight, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_GRID_ELEMENT_HEIGHT),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator(
                        new IntegerRangeValidator("Block height", 1, Integer.MAX_VALUE)),
                null);

    }
    {
        dbc.bindValue(SWTObservables.observeText(this.minValue, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_MIN_VALUE),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);

    }
    {
        dbc.bindValue(SWTObservables.observeText(this.maxValue, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_MAX_VALUE),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);

    }
    {
        dbc.bindValue(SWTObservables.observeText(this.defaultValue, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_DEFAULT_VALUE),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);

    }
    {
        dbc.bindValue(SWTObservables.observeText(this.framePointsX, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_NUM_FRAME_POINTS_HORIZONTAL),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator(
                        new IntegerRangeValidator("Framepoints x", 1, Integer.MAX_VALUE)),
                null);

    }
    {
        dbc.bindValue(SWTObservables.observeText(this.framePointsY, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_NUM_FRAME_POINTS_VERTICAL),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator(
                        new IntegerRangeValidator("Framepoints y", 1, Integer.MAX_VALUE)),
                null);

    }
    {
        dbc.bindValue(SWTObservables.observeBackground(minValueColor),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_MIN_COLOR_R_G_B),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT)
                        .setConverter(new ColorToArrayConverter()),
                new UpdateValueStrategy().setConverter(new ArrayToColorConverter(this.getDisplay())));

    }
    {
        dbc.bindValue(SWTObservables.observeBackground(maxValueColor),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_MAX_COLOR_R_G_B),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT)
                        .setConverter(new ColorToArrayConverter()),
                new UpdateValueStrategy().setConverter(new ArrayToColorConverter(this.getDisplay())));

    }
    {
        dbc.bindValue(SWTObservables.observeText(this.kNN, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_K),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator(
                        new IntegerRangeValidator("Neighbors (for kNN)", 1, Integer.MAX_VALUE)),
                null);

    }
    {
        dbc.bindValue(SWTObservables.observeText(this.text1, SWT.Modify),
                BeansObservables.observeValue(dbc.getValidationRealm(), config,
                        MapPainterXMLConfig.PROPERTYNAME_REFRESH_FREQUENCY),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator(
                        new IntegerRangeValidator("Update frequency (1/s)", 1, 25)),
                null);

    }
    {
        final MetricsXMLConfig mConf = spyglass.getConfigStore().getSpyglassConfig().getGeneralSettings()
                .getMetrics();
        dbc.bindValue(SWTObservables.observeText(this.label11space), BeansObservables
                .observeValue(dbc.getValidationRealm(), mConf, MetricsXMLConfig.PROPERTYNAME_UNIT), null, null);
        dbc.bindValue(SWTObservables.observeText(this.label3space), BeansObservables
                .observeValue(dbc.getValidationRealm(), mConf, MetricsXMLConfig.PROPERTYNAME_UNIT), null, null);
        dbc.bindValue(SWTObservables.observeText(this.label8space), BeansObservables
                .observeValue(dbc.getValidationRealm(), mConf, MetricsXMLConfig.PROPERTYNAME_UNIT), null, null);
        dbc.bindValue(SWTObservables.observeText(this.labelspace), BeansObservables
                .observeValue(dbc.getValidationRealm(), mConf, MetricsXMLConfig.PROPERTYNAME_UNIT), null, null);

    }
    updateScaleLinkBlock();
    updateScaleLinkDim();
}

From source file:de.uniluebeck.itm.spyglass.plugin.mappainter.MapPainterPrefComposite.java

License:Open Source License

private void updateScaleLinkDim() {
    final boolean locked = config.getLockNumberOfRowsNCols();

    if (locked) {
        height.setText(width.getText());

        if (lockBinding == null) {

            // bind the two fields together
            lockBinding = dbc.bindValue(SWTObservables.observeText(width, SWT.Modify),
                    SWTObservables.observeText(height, SWT.Modify), null, null);
        }/*w  w  w . jav  a2s .  c o m*/

        button1.setImage(SWTResourceManager
                .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_closed_hor.png"));

    } else {
        if (lockBinding != null) {
            // Kill the binding (it will be automatically removed from the dbc)
            lockBinding.dispose();
            lockBinding = null;
        }

        button1.setImage(SWTResourceManager
                .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_open_hor.png"));

    }
}