List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties text
public static IWidgetValueProperty text()
From source file:at.bestsolution.efxclipse.tooling.ui.wizards.AbstractHtmlElementPage.java
License:Open Source License
public void createControl(Composite parent) { parent = new Composite(parent, SWT.NULL); parent.setLayoutData(new GridData(GridData.FILL_BOTH)); parent.setLayout(new GridLayout(3, false)); clazz = createInstance();//from w ww. j a v a 2s. c om clazz.setFragmentRoot(froot); clazz.setPackageFragment(fragment); DataBindingContext dbc = new DataBindingContext(); { Label l = new Label(parent, SWT.NONE); l.setText("Source folder"); Text t = new Text(parent, SWT.BORDER); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); t.setEditable(false); final Binding bd = dbc.bindValue(WidgetProperties.text().observe(t), BeanProperties.value("fragmentRoot").observe(clazz), new UpdateValueStrategy(), new UpdateValueStrategy().setConverter(new PackageFragmentRootToStringConverter())); Button b = new Button(parent, SWT.PUSH); b.setText("Browse ..."); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IPackageFragmentRoot root = choosePackageRoot(); if (root != null) { froot = root; clazz.setFragmentRoot(root); } bd.updateModelToTarget(); //TODO Find out why this is needed } }); } { Label l = new Label(parent, SWT.NONE); l.setText("Package"); Text t = new Text(parent, SWT.BORDER); t.setEditable(false); t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final Binding bd = dbc.bindValue(WidgetProperties.text().observe(t), BeanProperties.value("packageFragment").observe(clazz), new UpdateValueStrategy(), new UpdateValueStrategy().setConverter(new PackageFragmentToStringConverter())); Button b = new Button(parent, SWT.PUSH); b.setText("Browse ..."); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IPackageFragment fragment = choosePackage(); if (fragment != null) { clazz.setPackageFragment(fragment); } bd.updateModelToTarget(); //TODO Find out why this is needed } }); } { IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); Label l = new Label(parent, SWT.NONE); l.setText("Name"); nameField = new Text(parent, SWT.BORDER); nameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(textProp.observe(nameField), BeanProperties.value("name", String.class).observe(clazz)); new Label(parent, SWT.NONE); } { Label l = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); l.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 3, 1)); } createFields(parent, dbc); setControl(parent); clazz.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { revalidate(); } }); setPageComplete(false); }
From source file:at.medevit.ch.artikelstamm.ui.DetailComposite.java
License:Open Source License
protected DataBindingContext initDataBindings() { DataBindingContext bindingContext = new DataBindingContext(); ////from ww w . j a va 2 s. c o m IObservableValue observeTextLblDSCRObserveWidget = WidgetProperties.text().observe(lblDSCR); IObservableValue itemDSCRObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "label", String.class).observeDetail(item); bindingContext.bindValue(observeTextLblDSCRObserveWidget, itemDSCRObserveDetailValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); // IObservableValue observeTextLblGTINObserveWidget = WidgetProperties.text().observe(txtGTIN); IObservableValue itemGTINObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "GTIN", String.class).observeDetail(item); bindingContext.bindValue(observeTextLblGTINObserveWidget, itemGTINObserveDetailValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); // IObservableValue observeTextLblPHZNRObserveWidget = WidgetProperties.text().observe(txtPHZNR); IObservableValue itemPHARObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "PHAR", String.class).observeDetail(item); bindingContext.bindValue(observeTextLblPHZNRObserveWidget, itemPHARObserveDetailValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); IObservableValue observeTextProductNrObserveWidget = WidgetProperties.text().observe(txtProductNr); IObservableValue itemProductNrObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "productId", String.class).observeDetail(item); bindingContext.bindValue(observeTextProductNrObserveWidget, itemProductNrObserveDetailValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); // IObservableValue observeTextLblHERSTELLERObserveWidget = WidgetProperties.text().observe(lblHERSTELLER); IObservableValue itemManufacturerLabelObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "manufacturerLabel", String.class).observeDetail(item); bindingContext.bindValue(observeTextLblHERSTELLERObserveWidget, itemManufacturerLabelObserveDetailValue, null, null); // IObservableValue observeTextLblEXFACTORYPRICEObserveWidget = WidgetProperties.text() .observe(lblEXFACTORYPRICE); IObservableValue itemExFactoryPriceObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "exFactoryPrice", Double.class).observeDetail(item); bindingContext.bindValue(observeTextLblEXFACTORYPRICEObserveWidget, itemExFactoryPriceObserveDetailValue, null, null); // IObservableValue observeTextLblPUBLICPRICEObserveWidget = WidgetProperties .text(new int[] { SWT.Modify, SWT.FocusOut }).observeDelayed(100, txtPUBLICPRICE); IObservableValue itemPublicPriceObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "publicPrice", Double.class).observeDetail(item); UpdateValueStrategy strategy_2 = new UpdateValueStrategy(); bindingContext.bindValue(observeTextLblPUBLICPRICEObserveWidget, itemPublicPriceObserveDetailValue, strategy_2, null); // IObservableValue observeTextLblABGABEKATEGORIEObserveWidget = WidgetProperties.text() .observe(txtABGABEKATEGORIE); IObservableValue itemSwissmedicCategoryObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "swissmedicCategory", String.class).observeDetail(item); bindingContext.bindValue(observeTextLblABGABEKATEGORIEObserveWidget, itemSwissmedicCategoryObserveDetailValue, null, null); // IObservableValue observeTextLblSELBSTBEHALTObserveWidget = WidgetProperties.text().observe(lblSELBSTBEHALT); IObservableValue itemDeductibleObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "deductible", Integer.class).observeDetail(item); UpdateValueStrategy strategy_1 = new UpdateValueStrategy(); strategy_1.setConverter(new IntToStringConverterSelbstbehalt()); bindingContext.bindValue(observeTextLblSELBSTBEHALTObserveWidget, itemDeductibleObserveDetailValue, null, strategy_1); // IObservableValue observeSelectionBtnCheckIsNarcoticObserveWidget = WidgetProperties.selection() .observe(btnCheckIsNarcotic); IObservableValue itemNarcoticObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "narcotic", Boolean.class).observeDetail(item); bindingContext.bindValue(observeSelectionBtnCheckIsNarcoticObserveWidget, itemNarcoticObserveDetailValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); // IObservableValue observeTextLblLIMITATIONTEXTObserveWidget = WidgetProperties.text() .observe(txtLIMITATIONTEXT); IObservableValue itemLimitationTextObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "limitationText", String.class).observeDetail(item); bindingContext.bindValue(observeTextLblLIMITATIONTEXTObserveWidget, itemLimitationTextObserveDetailValue, null, null); // IObservableValue observeTextLblLIMITATIONPOINTSObserveWidget = WidgetProperties.text() .observe(txtLIMITATIONPOINTS); IObservableValue itemLimitationPointsObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "limitationPoints", String.class).observeDetail(item); bindingContext.bindValue(observeTextLblLIMITATIONPOINTSObserveWidget, itemLimitationPointsObserveDetailValue, null, null); // IObservableValue observeSelectionBtnLPPVEntryObserveWidget = WidgetProperties.selection() .observe(btnLPPVEntry); IObservableValue itemInLPPVObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "inLPPV", Boolean.class).observeDetail(item); bindingContext.bindValue(observeSelectionBtnLPPVEntryObserveWidget, itemInLPPVObserveDetailValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); // IObservableValue observeSelectionBtnlLimitationObserveWidget = WidgetProperties.selection() .observe(btnlLimitation); IObservableValue itemLimitedObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "limited", Boolean.class).observeDetail(item); bindingContext.bindValue(observeSelectionBtnlLimitationObserveWidget, itemLimitedObserveDetailValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); // IObservableValue observeSizeLblLIMITATIONTEXTObserveWidget = WidgetProperties.size() .observe(txtLIMITATIONTEXT); IObservableValue observeTextLblLIMITATIONTEXTObserveWidget_1 = WidgetProperties.text(SWT.Modify) .observe(txtLIMITATIONTEXT); UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setConverter(new DatabindingTextResizeConverter(txtLIMITATIONTEXT)); bindingContext.bindValue(observeSizeLblLIMITATIONTEXTObserveWidget, observeTextLblLIMITATIONTEXTObserveWidget_1, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), strategy); // IObservableValue observeSelectionBtnUserDefinedPriceObserveWidget = WidgetProperties.selection() .observe(btnUserDefinedPrice); IObservableValue itemCalculatedPriceObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "userDefinedPrice", Boolean.class).observeDetail(item); bindingContext.bindValue(observeSelectionBtnUserDefinedPriceObserveWidget, itemCalculatedPriceObserveDetailValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); // IObservableValue observeEditableTxtPUBLICPRICEObserveWidget = WidgetProperties.editable() .observe(txtPUBLICPRICE); IObservableValue itemUserDefinedPriceObserveDetailValue = PojoProperties .value(IArtikelstammItem.class, "userDefinedPrice", Boolean.class).observeDetail(item); bindingContext.bindValue(observeEditableTxtPUBLICPRICEObserveWidget, itemUserDefinedPriceObserveDetailValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); // return bindingContext; }
From source file:com.amitinside.e4.rcp.todo.parts.SampleFormUsingFormsAPI.java
License:Apache License
private void updateTheUI(Todo todo) { part = partService.findPart("com.amitinside.e4.rcp.todo.part.samplePart.formsAPI"); // System.out.println(handlerService.promptToSave(part)); if (todo == null) { activateTheUI(false);/*from w w w .j a v a 2s . co m*/ return; } else { activateTheUI(true); } if (textTo != null && !textTo.isDisposed()) { // Deregister change listener to the old binding IObservableList providers = dbc.getValidationStatusProviders(); for (final Object o : providers) { final Binding b = (Binding) o; b.getTarget().removeChangeListener(listener); } // Remove bindings dbc.dispose(); final IObservableValue target = WidgetProperties.text().observe(textTo); final IObservableValue model = BeanProperties.value(Todo.FIELD_SUMMARY).observe(todo); dbc.bindValue(target, model); // register listener for any changes providers = dbc.getValidationStatusProviders(); for (final Object o : providers) { final Binding b = (Binding) o; b.getTarget().addChangeListener(listener); } } }
From source file:com.nextep.designer.dbgm.mysql.ui.impl.MySQLColumnFormEditor.java
License:Open Source License
@Override protected void doBindModel(DataBindingContext context) { IObservableValue selectionValue = ViewersObservables.observeSingleSelection(getSelectionProvider()); // Binding charset IObservableValue widgetValue = WidgetProperties.text().observe(charsetCombo); IObservableValue modelValue = PojoObservables.observeDetailValue(selectionValue, "characterSet", //$NON-NLS-1$ String.class); UpdateValueStrategy modelUpdateStrategy = new UpdateValueStrategy(); modelUpdateStrategy.setConverter(MySQLConverterFactory.createNameToCodeCharsetConverter(collationCombo)); UpdateValueStrategy targetUpdateStrategy = new UpdateValueStrategy(); targetUpdateStrategy.setConverter(MySQLConverterFactory.createCodeToNameCharsetConverter()); context.bindValue(widgetValue, modelValue, modelUpdateStrategy, targetUpdateStrategy); // Binding autoinc widgetValue = WidgetProperties.selection().observe(autoIncButton); modelValue = PojoObservables.observeDetailValue(selectionValue, "autoIncremented", Boolean.class); //.value(IBasicColumn.class, "name").observe( //$NON-NLS-1$ context.bindValue(widgetValue, modelValue, null, null); // Binding unsigned widgetValue = WidgetProperties.selection().observe(unsignedButton); modelValue = PojoObservables.observeDetailValue(selectionValue, "datatype.unsigned", //$NON-NLS-1$ Boolean.class); context.bindValue(widgetValue, modelValue, null, null); // Binding collation widgetValue = WidgetProperties.text().observe(collationCombo); modelValue = PojoObservables.observeDetailValue(selectionValue, "collation", String.class); //$NON-NLS-1$ context.bindValue(widgetValue, modelValue, null, null); }
From source file:com.nextep.designer.dbgm.mysql.ui.impl.MySQLTableFormEditor.java
License:Open Source License
@Override protected void doBindModel(DataBindingContext context) { final IMySQLTable table = getModel(); // Engine binding IObservableValue widgetValue = WidgetProperties.text().observe(engineCombo); IObservableValue modelValue = PojoProperties.value(IMySQLTable.class, "engine").observe( //$NON-NLS-1$ table);/* w w w . j a v a2s .c o m*/ context.bindValue(widgetValue, modelValue); // Charset binding widgetValue = WidgetProperties.text().observe(charsetCombo); modelValue = PojoProperties.value(IMySQLTable.class, "characterSet").observe(table); //$NON-NLS-1$ UpdateValueStrategy modelUpdateStrategy = new UpdateValueStrategy(); modelUpdateStrategy.setConverter(MySQLConverterFactory.createNameToCodeCharsetConverter(collationCombo)); UpdateValueStrategy targetUpdateStrategy = new UpdateValueStrategy(); targetUpdateStrategy.setConverter(MySQLConverterFactory.createCodeToNameCharsetConverter()); context.bindValue(widgetValue, modelValue, modelUpdateStrategy, targetUpdateStrategy); // Collation binding widgetValue = WidgetProperties.text().observe(collationCombo); modelValue = PojoProperties.value(IMySQLTable.class, "collation").observe(table); //$NON-NLS-1$ context.bindValue(widgetValue, modelValue); }
From source file:com.planetmayo.debrief.satc_rcp.ui.contributions.BaseContributionView.java
License:Open Source License
/** * binds model value to specified slider, label and checkBox with specified * converters returns writable value which is used to store direct ui value *//*w w w .j a v a 2s .c om*/ protected WritableValue bindSliderLabelCheckbox(DataBindingContext context, final IObservableValue modelValue, Scale slider, Label label, Button checkBox, PrefixSuffixLabelConverter labelValueConverter, BooleanToNullConverter<?> checkBoxValueConverter, UnitConverter unitConverter) { final WritableValue uiProxy = new WritableValue(modelValue.getValue(), modelValue.getValueType()); IObservableValue sliderValue = WidgetProperties.selection().observe(slider); IObservableValue labelValue = WidgetProperties.text().observe(label); if (unitConverter != null) { IConverter modelToUI = new CompoundConverter(unitConverter.getModelToUI(), new IntegerConverter()); context.bindValue(sliderValue, uiProxy, UIUtils.converterStrategy(unitConverter.getUIToModel()), UIUtils.converterStrategy(modelToUI)); } else { context.bindValue(sliderValue, uiProxy); } if (checkBox != null) { IObservableValue sliderEnabled = WidgetProperties.enabled().observe(slider); IObservableValue checkBoxValue = WidgetProperties.selection().observe(checkBox); context.bindValue(checkBoxValue, modelValue, UIUtils.converterStrategy(checkBoxValueConverter), UIUtils.converterStrategy(new NullToBooleanConverter())); context.bindValue(sliderEnabled, modelValue, null, UIUtils.converterStrategy(new NullToBooleanConverter())); } context.bindValue(labelValue, uiProxy, null, UIUtils.converterStrategy(labelValueConverter)); context.bindValue(uiProxy, modelValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); slider.addListener(SWT.MouseUp, new Listener() { @Override public void handleEvent(Event arg0) { modelValue.setValue(uiProxy.getValue()); } }); slider.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if ((e.stateMask & SWT.BUTTON1) == 0) { modelValue.setValue(uiProxy.getValue()); } } }); return uiProxy; }
From source file:com.planetmayo.debrief.satc_rcp.ui.contributions.BaseContributionView.java
License:Open Source License
/** * Utility base method which binds common header widgets: "active" checkbox, * hardconstrains label, estimate label, weight spinner. Must be called if * necessary from implementation of bindValues method in child class * /* www . ja v a 2s.com*/ * @param context * @param contribution * @param labelsConverter */ protected final void bindCommonHeaderWidgets(DataBindingContext context, IObservableValue hardContraint, IObservableValue estimateValue, IConverter estimateConverter, IConverter hardConstraintsConverter) { IObservableValue activeValue = BeansObservables.observeValue(contribution, BaseContribution.ACTIVE); IObservableValue activeButton = WidgetProperties.selection().observe(activeCheckBox); context.bindValue(activeButton, activeValue); if (hardContraint != null) { IObservableValue hardContraintLabel = WidgetProperties.text().observe(hardConstraintLabel); context.bindValue(hardContraintLabel, hardContraint, null, UIUtils.converterStrategy(hardConstraintsConverter)); } if (estimateValue != null) { IObservableValue estimateLabel = WidgetProperties.text().observe(this.estimateLabel); context.bindValue(estimateLabel, estimateValue, null, UIUtils.converterStrategy(estimateConverter)); } IObservableValue weightValue = BeansObservables.observeValue(contribution, BaseContribution.WEIGHT); IObservableValue weightWidget = WidgetProperties.selection().observe(weightSpinner); context.bindValue(weightWidget, weightValue); }
From source file:com.planetmayo.debrief.satc_rcp.ui.contributions.RangeForecastContributionView.java
License:Open Source License
protected void bindSliderForRange(DataBindingContext context, IObservableValue modelValue, Scale slider, Label label, Button checkBox, boolean maxValue) { IObservableValue sliderValue = WidgetProperties.selection().observe(slider); IObservableValue sliderEnabled = WidgetProperties.enabled().observe(slider); IObservableValue labelValue = WidgetProperties.text().observe(label); double MAX_SELECTABLE_RANGE_YDS = new MeterToYds() .safeConvert(new Double(RangeForecastContribution.MAX_SELECTABLE_RANGE_M)); // here are the original values. We had to change them to allow range out to 100kyds // int[] borders = {0, 1000, 3000, 7000, 17000, (int)MAX_SELECTABLE_RANGE_YDS}; // int[] increments = {50, 100, 200, 500, 1000}; int[] borders = { 0, 1000, 3000, 7000, 10000, (int) MAX_SELECTABLE_RANGE_YDS }; int[] increments = { 50, 100, 500, 1000, 2000 }; context.bindValue(sliderValue, modelValue, UIUtils.converterStrategy(new ScaleConverterFrom(increments, borders)), UIUtils.converterStrategy(new ScaleConverterTo(increments, borders))); double defaultValue = maxValue ? MAX_SELECTABLE_RANGE_YDS : 0; context.bindValue(sliderEnabled, modelValue, null, UIUtils.converterStrategy(new NullToBooleanConverter())); if (checkBox != null) { IObservableValue checkBoxValue = WidgetProperties.selection().observe(checkBox); context.bindValue(checkBoxValue, modelValue, UIUtils.converterStrategy(new BooleanToNullConverter<Double>(defaultValue)), UIUtils.converterStrategy(new NullToBooleanConverter())); }// w w w . j a va 2 s. com PrefixSuffixLabelConverter labelsConverter = new PrefixSuffixLabelConverter(Object.class, "", " Yds", new DecimalFormat("0")); labelsConverter.setNestedUnitConverter(UnitConverter.RANGE_YDS.getModelToUI()); context.bindValue(labelValue, modelValue, null, UIUtils.converterStrategy(labelsConverter)); }
From source file:de.metadocks.lambdaui.swt.SwtUI.java
License:Open Source License
public SwtUI<T> text(String text) { return prop(WidgetProperties.text(), text); }
From source file:de.prozesskraft.pmodel.PmodelPartUi1.java
protected DataBindingContext initDataBindingsMarked() { DataBindingContext bindingContextMarked = new DataBindingContext(); ////w w w .ja va2 s . co m IObservableValue targetObservableMarked = WidgetProperties.text().observe(label_marked); IObservableValue modelObservableMarked = BeanProperties.value("markedStepName").observe(einstellungen); bindingContextMarked.bindValue(targetObservableMarked, modelObservableMarked, null, null); // return bindingContextMarked; }