本文整理汇总了Java中org.eclipse.core.databinding.Binding类的典型用法代码示例。如果您正苦于以下问题:Java Binding类的具体用法?Java Binding怎么用?Java Binding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Binding类属于org.eclipse.core.databinding包,在下文中一共展示了Binding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bind
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
public static Collection<Binding> bind ( final DataBindingContext dbc, final IObservableValue lineInputObservable, final IObservableValue linePropertiesObservable )
{
final Collection<Binding> result = new LinkedList<Binding> ();
try
{
result.add ( dbc.bindValue ( PojoObservables.observeDetailValue ( lineInputObservable, "lineWidth", null ), EMFObservables.observeDetailValue ( dbc.getValidationRealm (), linePropertiesObservable, ChartPackage.Literals.LINE_PROPERTIES__WIDTH ) ) ); //$NON-NLS-1$
result.add ( dbc.bindValue ( PojoObservables.observeDetailValue ( lineInputObservable, "lineColor", null ), EMFObservables.observeDetailValue ( dbc.getValidationRealm (), linePropertiesObservable, ChartPackage.Literals.LINE_PROPERTIES__COLOR ) ) ); //$NON-NLS-1$
}
catch ( final Exception e )
{
logger.warn ( "Failed to bind line properties", e ); //$NON-NLS-1$
}
return result;
}
示例2: bindEditabilityAndCalculatedVariable
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
private void bindEditabilityAndCalculatedVariable(DataBindingContext dbc, EObject target, Object feature, Control control) {
ISWTObservableValue textEditability = SWTObservables.observeEnabled(control);
IObservableValue calculatedVariableValue = observeCalculatedVariable(target);
final CalculatedVariable calculatedVariable = getCalculatedVariable(feature);
UpdateValueStrategy calculatedVariableToEditability = new UpdateValueStrategy() {
@Override
public Object convert(Object value) {
if (value instanceof Set) {
return !(((Set) value).contains(calculatedVariable));
}
if (value == calculatedVariable) {
return false;
}
return true;
}
};
Binding editabilityBinding = dbc.bindValue(textEditability, calculatedVariableValue, null, calculatedVariableToEditability);
dbc.addBinding(editabilityBinding);
}
示例3: createBinding
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
@Override
public Binding createBinding(DetailProviderParameter p) {
FormToolkit toolkit = p.getDetailFormToolkit();
Composite parent = p.getParent();
EObject target = p.getTarget();
IItemPropertyDescriptor pd = p.getPropertyDescriptor();
EStructuralFeature feature = (EStructuralFeature) pd.getFeature(target);
if (feature == null) {
return null;
}
boolean isEditable = pd.canSetProperty(target);
EMFDetailUtils.createLabel(parent, toolkit, target, pd);
Composite composite = createPaddingComposite(toolkit, parent);
ColorSelector colorSelector = new ColorSelector(composite);
Button button = colorSelector.getButton();
button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true));
button.setEnabled(isEditable);
toolkit.adapt(button, true, true);
EMFDetailUtils.bindControlViability(p, new Control[] {button});
return EMFDetailUtils.bindEMFUndoable(p, new RGBSelectorObservableValue(colorSelector, ERGB.class == feature.getEType().getInstanceClass()));
}
示例4: createBinding
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
public Binding createBinding(Composite parent, boolean createLabel, DetailProviderParameter p) {
FormToolkit toolkit = p.getDetailFormToolkit();
EObject target = p.getTarget();
IItemPropertyDescriptor pd = p.getPropertyDescriptor();
EStructuralFeature feature = (EStructuralFeature) pd.getFeature(target);
if (feature == null) {
return null;
}
boolean isEditable = pd.canSetProperty(target);
if (createLabel) {
EMFDetailUtils.createLabel(parent, toolkit, target, pd);
}
CDateTime cdt = new CDateTime(parent, CDT.BORDER | CDT.TAB_FIELDS | CDT.SPINNER);
cdt.setPattern(formatPattern);
cdt.setTimeZone("GMT");
cdt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
cdt.setEnabled(isEditable);
EMFDetailUtils.bindControlViability(p, new Control[] {cdt});
DurationUpdateValueStrategy targetToModel = new DurationUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
DurationUpdateValueStrategy modelToTarget = new DurationUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
return EMFDetailUtils.bindEMFUndoable(p, new CDateTimeObservableValue(cdt), targetToModel, modelToTarget);
}
示例5: createEditor
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
/**
* Creates the editor for the given target's property descriptor.
*
* @param parent
* component to contribute UI information to
* @param target
* EObject that gets edited
* @param pd
* descriptor to create editor for
* @return the Binding of the object, this requires disposal
*/
private Binding createEditor(final Composite parent, final EObject target, final IItemPropertyDescriptor pd) {
Object genericFeature = pd.getFeature(target);
if (genericFeature == null) {
return null;
}
if (genericFeature instanceof EReference[]) {
Logger.getLogger(EMFDetailFormPart.class).error("cannot create editor for an array of references");
return null;
}
if (genericFeature instanceof EStructuralFeature) {
// Extensibility point to allow custom binding to be used
//
DetailProviderParameter parameter = createDetailProviderParameter(parent, target, pd);
IBindingFactory bindingFactory = EMFDetailUtils.getBindingFactory(parameter);
if (bindingFactory != null) {
Binding binding = bindingFactory.createBinding(parameter);
if (binding != null) {
return binding;
}
}
}
return null;
}
示例6: bindField
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
protected <S> Binding bindField(DataBindingContext dbCtx, BField field, IObservableValue master,
BFormInstance<S, ?> formInstance, boolean immediate, IObservableValue presenterValue) {
IObservableValue model = getObservableValue(field, presenterValue);
IObservableValue target = AbstractFormProperties.field(field.getId()).observe(formInstance);
UpdateValueStrategy modelToTarget = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
UpdateValueStrategy targetToModel = new UpdateValueStrategy(immediate ? UpdateValueStrategy.POLICY_UPDATE
: UpdateValueStrategy.POLICY_CONVERT);
if (field.isRequired()) {
targetToModel.setAfterConvertValidator(RequiredValidator.INSTANCE);
}
if (field.getValidator() != null) {
targetToModel.setBeforeSetValidator(new ValidatorSTub(field.getValidator()));
}
return dbCtx.bindValue(target, model, targetToModel, modelToTarget);
}
示例7: dispose
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
public void dispose ()
{
for ( final Binding binding : this.bindings )
{
binding.dispose ();
}
this.bindings.clear ();
}
示例8: dispose
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
public void dispose ()
{
deactivate ();
for ( final Binding b : this.bindings )
{
b.dispose ();
}
this.bindings.clear ();
}
示例9: bindWidgetValue
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
private Binding bindWidgetValue(Object obj, String property, Object objWidget, UpdateValueStrategy targetToModel,
UpdateValueStrategy modelToTarget) {
IObservableValue model = BeanProperties.value(obj.getClass(), property).observe(obj);
IObservableValue widget = null;
if (objWidget instanceof Text) {
widget = WidgetProperties.text(SWT.Modify).observe(objWidget);
} else if (objWidget instanceof Button || objWidget instanceof Combo) {
widget = WidgetProperties.selection().observe(objWidget);
}
return dataBindingContext.bindValue(widget, model, targetToModel, modelToTarget);
}
示例10: setupAccountEmailDataBinding
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
private void setupAccountEmailDataBinding() {
AccountSelectorObservableValue accountSelectorObservableValue =
new AccountSelectorObservableValue(accountSelector);
UpdateValueStrategy modelToTarget =
new UpdateValueStrategy().setConverter(new Converter(String.class, String.class) {
@Override
public Object convert(Object savedEmail) {
Preconditions.checkArgument(savedEmail instanceof String);
if (accountSelector.isEmailAvailable((String) savedEmail)) {
return savedEmail;
} else if (requireValues && accountSelector.getAccountCount() == 1) {
return accountSelector.getFirstEmail();
} else {
return null;
}
}
});
final IObservableValue accountEmailModel = PojoProperties.value("accountEmail").observe(model);
Binding binding = bindingContext.bindValue(accountSelectorObservableValue, accountEmailModel,
new UpdateValueStrategy(), modelToTarget);
/*
* Trigger an explicit target -> model update for the auto-select-single-account case. When the
* model has a null account but there is exactly 1 login account, then the AccountSelector
* automatically selects that account. That change means the AccountSelector is at odds with the
* model.
*/
binding.updateTargetToModel();
bindingContext.addValidationStatusProvider(new AccountSelectorValidator(
requireValues, accountSelector, accountSelectorObservableValue));
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:33,代码来源:AppEngineDeployPreferencesPanel.java
示例11: bindBeanToWidgetSelection
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
public Binding bindBeanToWidgetSelection(String property, Object bean, Widget w) {
if (SWTUtil.isDisposed(w) || bean == null || property == null)
return null;
IObservableValue v1 = BeanProperties.value(property).observe(bean);
IObservableValue v2 = SWTObservables.observeSelection(w);
return ctx.bindValue(v2, v1);
}
示例12: initializeDBCollectionBindings
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
private DataBindingContext initializeDBCollectionBindings(BTSProjectDBCollection dbCollection)
{
EditingDomain editingDomain = getEditingDomain(dbCollection);
if (dbColl_bindingContext != null)
{
dbColl_bindingContext.dispose();
}
DataBindingContext bindingContext = new DataBindingContext();
// db collection name - cannot be changed
IObservableValue model_na = EMFProperties.value(
BtsmodelPackage.Literals.BTS_PROJECT_DB_COLLECTION__COLLECTION_NAME).observe(dbCollection);
bindingContext.bindValue(WidgetProperties.text(SWT.Modify)
.observeDelayed(BTSUIConstants.DELAY, roles_dbColl_name_text),
model_na, null, null);
// sync
IObservableValue model_sy = EMFEditProperties.value(editingDomain,
BtsmodelPackage.Literals.BTS_PROJECT_DB_COLLECTION__SYNCHRONIZED).observe(dbCollection);
Binding binding_sy = bindingContext.bindValue(
WidgetProperties.selection().observeDelayed(
BTSUIConstants.DELAY, roles_dbColl_sync_btn), model_sy,
null, null);
bindingContext.addValidationStatusProvider(binding_sy);
// index
IObservableValue model_in = EMFEditProperties.value(editingDomain,
BtsmodelPackage.Literals.BTS_PROJECT_DB_COLLECTION__INDEXED).observe(dbCollection);
Binding binding_in = bindingContext.bindValue(
WidgetProperties.selection().observeDelayed(
BTSUIConstants.DELAY, roles_dbColl_index_btn),
model_in, null, null);
bindingContext.addValidationStatusProvider(binding_in);
return bindingContext;
}
示例13: initializeConfigurationEditBindings
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
private DataBindingContext initializeConfigurationEditBindings(
BTSConfiguration configuration) {
if (configurationEditBindings != null) {
configurationEditBindings.dispose();
}
EditingDomain editingDomain = getEditingDomain(configuration);
DataBindingContext bindingContext = new DataBindingContext();
EMFUpdateValueStrategy us = new EMFUpdateValueStrategy();
us.setBeforeSetValidator(new StringNotEmptyValidator());
IObservableValue model = EMFEditProperties.value(editingDomain,
BtsmodelPackage.Literals.BTS_NAMED_TYPED_OBJECT__NAME).observe(
configuration);
Binding binding = bindingContext.bindValue(
WidgetProperties.text(SWT.Modify).observeDelayed(
BTSUIConstants.DELAY, nameText_ConfigurationEdit),
model, us, null);
BackgroundControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT);
bindingContext.addValidationStatusProvider(binding);
IObservableValue model2 = EMFEditProperties.value(editingDomain,
BtsmodelPackage.Literals.BTS_CONFIGURATION__PROVIDER).observe(
configuration);
Binding binding2 = bindingContext.bindValue(
WidgetProperties.text(SWT.Modify).observeDelayed(
BTSUIConstants.DELAY, providerText), model2, us, null);
bindingContext.addValidationStatusProvider(binding2);
BackgroundControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT);
return bindingContext;
}
示例14: loadBooleanWidget
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
private void loadBooleanWidget(BTSConfigItem itemConfig2,
BTSPassportEntry entry) {
checkBox = new Button(this, SWT.CHECK);
checkBox.setText(itemConfig.getValue());
checkBox.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false,
BTSUIConstants.PASSPORT_COLUMN_NUMBER, 1));
// checkBox.pack();
DataBindingContext bindingContext = new DataBindingContext();
EMFUpdateValueStrategy targetToModel = new EMFUpdateValueStrategy();
targetToModel.setConverter(new BTSBooleanToStringConverter());
if (itemConfig.getPassportEditorConfig().isRequired()) {
targetToModel.setBeforeSetValidator(new StringNotEmptyValidator());
}
EMFUpdateValueStrategy modelToTarget = new EMFUpdateValueStrategy();
modelToTarget.setConverter(new BTSStringToBooleanConverter());
Binding binding = bindingContext.bindValue(
WidgetProperties.selection().observeDelayed(
BTSUIConstants.DELAY, checkBox),
EMFEditProperties.value(editingDomain,
BtsCorpusModelPackage.Literals.BTS_PASSPORT_ENTRY__VALUE)
.observe(entry), targetToModel, modelToTarget);
if (itemConfig.getPassportEditorConfig().isRequired()) {
bindingContext.addValidationStatusProvider(binding);
BackgroundControlDecorationSupport.create(binding, SWT.TOP
| SWT.LEFT);
}
}
示例15: bindStringToTextField
import org.eclipse.core.databinding.Binding; //导入依赖的package包/类
public static Binding bindStringToTextField(final Text textField, final IObservableValue modelObservable,
final DataBindingContext bindingContext, final boolean isRequired) {
final ISWTObservableValue targetObservable = SWTObservables.observeText(textField, SWT.Modify);
final UpdateValueStrategy targetToModel = isRequired
? new UpdateValueStrategy().setAfterConvertValidator(new NotEmptyValue()) : null;
final Binding binding = bindingContext.bindValue(targetObservable, modelObservable, targetToModel, null);
if (isRequired) {
createControlDecoration(textField, NotEmptyValue.MSG, isRequired);
}
return binding;
}