当前位置: 首页>>代码示例>>Java>>正文


Java ViewersObservables.observeSingleSelection方法代码示例

本文整理汇总了Java中org.eclipse.jface.databinding.viewers.ViewersObservables.observeSingleSelection方法的典型用法代码示例。如果您正苦于以下问题:Java ViewersObservables.observeSingleSelection方法的具体用法?Java ViewersObservables.observeSingleSelection怎么用?Java ViewersObservables.observeSingleSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.databinding.viewers.ViewersObservables的用法示例。


在下文中一共展示了ViewersObservables.observeSingleSelection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createIntervalCombo

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
private void createIntervalCombo() {
  final ComboViewer intervalComboViewer = new ComboViewer(this, SWT.NONE);
  intervalComboViewer.setContentProvider(ArrayContentProvider.getInstance());
  intervalComboViewer.setInput(TimeRange.values());
  final IViewerObservableValue intervalComboViewerObservable = ViewersObservables.observeSingleSelection(intervalComboViewer);
  DataBindings.createBinding(intervalComboViewerObservable, viewModel.getVisibleRange(), VisibleRangeViewModel.PROPERTY__RANGE);
}
 
开发者ID:sealuzh,项目名称:Permo,代码行数:8,代码来源:TimeSeriesToolbar.java

示例2: bindValue

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
/**
 * 对下拉列表和转换器列表进行绑定
 * @param context
 * @param comboViewer
 * @param model
 *            ;
 */
public static void bindValue(DataBindingContext context, ComboViewer comboViewer, ConverterViewModel model) {
	// ViewerSupport.bind(comboViewer, BeansObservables.observeList(
	// model, "supportTypes", String.class),
	// Properties.selfValue(String.class));
	//		
	//
	// context.bindValue(ViewersObservables
	// .observeSingleSelection(comboViewer), BeansObservables
	// .observeValue(model,
	// "selectedType"));

	// ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
	comboViewer.setContentProvider(new ArrayContentProvider());
	comboViewer.setComparator(new ViewerComparator());
	// IObservableMap[] attributeMaps = BeansObservables.observeMaps(
	// viewerContentProvider.getKnownElements(),
	// ConverterBean.class, new String[] { "description" });
	// comboViewer.setLabelProvider(new ObservableMapLabelProvider(
	// attributeMaps));
	// comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));

	comboViewer.setInput(model.getSupportTypes());
	IViewerObservableValue selection = ViewersObservables.observeSingleSelection(comboViewer);
	IObservableValue observableValue = BeansObservables.observeDetailValue(selection, PROPERTIES_NAME, null);
	context.bindValue(observableValue, BeansObservables.observeValue(model, PROPERTIES_SELECTED_TYPE));
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:34,代码来源:ConverterUtil.java

示例3: initDataBindings

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
private void initDataBindings() {
	DataBindingContext ctx = new DataBindingContext();

	IObservableValue widgetValue = ViewersObservables.observeSingleSelection(srcLangComboViewer);
	IObservableValue modelValue = BeanProperties.value(ProjectInfoBean.class, "sourceLang").observe(projCfgBean);
	ctx.bindValue(widgetValue, modelValue, null, null);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:8,代码来源:ProjectSettingLanguagePage.java

示例4: bindValue

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
public static void bindValue(DataBindingContext context,ComboViewer comboViewer,
			ConverterViewModel model) {
//		ViewerSupport.bind(comboViewer, BeansObservables.observeList(
//				model, "supportTypes", String.class),
//				Properties.selfValue(String.class));
//		
//
//		context.bindValue(ViewersObservables
//				.observeSingleSelection(comboViewer), BeansObservables
//				.observeValue(model,
//						"selectedType"));
		
//		ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
		comboViewer.setContentProvider(new ArrayContentProvider());
		comboViewer.setComparator(new ViewerComparator());
//		IObservableMap[] attributeMaps = BeansObservables.observeMaps(
//				viewerContentProvider.getKnownElements(),
//				ConverterBean.class, new String[] { "description" });
//		comboViewer.setLabelProvider(new ObservableMapLabelProvider(
//		attributeMaps));
//		comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));
		
		comboViewer.setInput(model.getSupportTypes());
		IViewerObservableValue selection=ViewersObservables.observeSingleSelection(comboViewer);
		IObservableValue observableValue=BeansObservables.observeDetailValue(selection, "name", ConverterBean.class);
		context.bindValue(observableValue, BeansObservables
				.observeValue(model,
						"selectedType"));
	}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:30,代码来源:ConverterUtil.java

示例5: initDataBinding

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
private void initDataBinding(){
	transientConditionValue = new WritableValue();
	DataBindingContext bindingContext = new DataBindingContext();
	
	IObservableValue targetObservable =
		ViewersObservables.observeSingleSelection(statusViewer);
	IObservableValue modelObservable = PojoObservables
		.observeDetailValue(transientConditionValue, "status", TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(startTxt, SWT.Modify);
	modelObservable = PojoObservables.observeDetailValue(transientConditionValue, "start",
		TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(endTxt, SWT.Modify);
	modelObservable = PojoObservables.observeDetailValue(transientConditionValue, "end",
		TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(textTxt, SWT.Modify);
	modelObservable =
		PojoObservables.observeDetailValue(transientConditionValue, "text",
			TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	setCondition(null);
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:29,代码来源:ConditionComposite.java

示例6: loadSelectConfigWidget

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
private void loadSelectConfigWidget(BTSConfigItem itemConfig2,
		BTSPassportEntry entry) {
	Label label = new Label(this, SWT.NONE);
	label.setText(getLabel(itemConfig));
	label.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false,
			BTSUIConstants.PASSPORT_COLUMN_NUMBER / 2, 1));
	((GridData) label.getLayoutData()).verticalIndent = 2;
	// label.pack();
	combo = new Combo(this, SWT.NONE | SWT.READ_ONLY); // SWT.READ_ONLY);
	combo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,
			BTSUIConstants.PASSPORT_COLUMN_NUMBER / 2, 1));
	((GridData) combo.getLayoutData()).horizontalIndent = 7;
	
	
	if (itemConfig2.getDescription() != null
			&& !itemConfig2.getDescription().getLanguages().isEmpty()) {
		final ControlDecoration deco = new ControlDecoration(combo,
				SWT.BOTTOM | SWT.LEFT);

		// re-use an existing image
		Image image = FieldDecorationRegistry
				.getDefault()
				.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION)
				.getImage();
		// set description and image
		deco.setDescriptionText(itemConfig2.getDescription()
				.getTranslation(lang));
		deco.setImage(image);
	}
	ComboViewer selectComboViewer = new ComboViewer(combo);
	ComposedAdapterFactory factory = new ComposedAdapterFactory(
			ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
	AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(
			factory);
	AdapterFactoryContentProvider contentProvider = new AdapterFactoryContentProvider(
			factory);

	selectComboViewer.setContentProvider(contentProvider);
	selectComboViewer.setLabelProvider(labelProvider);
	selectComboViewer.setInput(passportConfigurationController
			.getPathConfigItemProcessedClones(itemConfig2, corpusObject));

	DataBindingContext bindingContext = new DataBindingContext();

	EMFUpdateValueStrategy targetToModel = new EMFUpdateValueStrategy();
	targetToModel.setConverter(new BTSConfigItemToStringConverter());
	if (itemConfig.getPassportEditorConfig().isRequired()) {
		targetToModel.setBeforeSetValidator(new StringNotEmptyValidator());
	}
	EMFUpdateValueStrategy modelToTarget = new EMFUpdateValueStrategy();
	modelToTarget.setConverter(new BTSStringToConfigItemConverter(
			selectComboViewer));
	IObservableValue target_type_viewer = ViewersObservables
			.observeSingleSelection(selectComboViewer);
	Binding binding = bindingContext.bindValue(
			target_type_viewer,
			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);
	}
	
	//remove focus after selection to avoid mousewheel errors
	combo.addSelectionListener(new SelectionAdapter() {
		
		@Override
		public void widgetSelected(SelectionEvent e) {
			getParent().setFocus();
		}
	});
}
 
开发者ID:cplutte,项目名称:bts,代码行数:76,代码来源:PassportEntryItemEditor.java

示例7: init

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
protected void init() {
	prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");
	IEclipsePreferences defaultpref = DefaultScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");

	default_visibility = prefs.get(BTSCorpusConstants.PREF_LEMMA_DEFAULT_VISIBILITY, null);
	default_reviewState = prefs.get(BTSCorpusConstants.PREF_LEMMA_DEFAULT_REVIEWSTATE, null);
	
	object = BtsCorpusModelFactory.eINSTANCE.createBTSTCObject();
	object.setVisibility(default_visibility);
	object.setRevisionState(default_reviewState);
	
	DataBindingContext bindingContext = new DataBindingContext();
	
	// visibility
	EMFUpdateValueStrategy targetToModel_vis = new EMFUpdateValueStrategy();
	targetToModel_vis.setConverter(new BTSConfigItemToStringConverter());
	EMFUpdateValueStrategy modelToTarget_vis = new EMFUpdateValueStrategy();
	modelToTarget_vis.setConverter(new BTSStringToConfigItemConverter(
			visibility_viewer));
	IObservableValue target_vis_viewer = ViewersObservables
			.observeSingleSelection(visibility_viewer);
	Binding binding_vis = bindingContext
			.bindValue(
					target_vis_viewer,
					EMFProperties
							.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__VISIBILITY)
							.observe(object), targetToModel_vis,
					modelToTarget_vis);		
	
	// review status
	EMFUpdateValueStrategy targetToModel_rev = new EMFUpdateValueStrategy();
	targetToModel_rev.setConverter(new BTSConfigItemToStringConverter());
	EMFUpdateValueStrategy modelToTarget_rev = new EMFUpdateValueStrategy();
	modelToTarget_rev.setConverter(new BTSStringToConfigItemConverter(
			reviewState_viewer));
	IObservableValue target_rev_viewer = ViewersObservables
			.observeSingleSelection(reviewState_viewer);
	Binding binding_rev = bindingContext
			.bindValue(
					target_rev_viewer,
					EMFProperties
							.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__REVISION_STATE)
							.observe(object), targetToModel_rev,
					modelToTarget_rev);
	super.initialize();
}
 
开发者ID:cplutte,项目名称:bts,代码行数:47,代码来源:LemmaNavigatorSettingsPage.java

示例8: init

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
protected void init() {
	prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");
	IEclipsePreferences defaultpref = DefaultScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");

	default_visibility = prefs.get(BTSCorpusConstants.PREF_ATEXT_DEFAULT_VISIBILITY, null);
	default_reviewState = prefs.get(BTSCorpusConstants.PREF_ATEXT_DEFAULT_REVIEWSTATE, null);
	
	object = BtsCorpusModelFactory.eINSTANCE.createBTSTCObject();
	object.setVisibility(default_visibility);
	object.setRevisionState(default_reviewState);
	
	DataBindingContext bindingContext = new DataBindingContext();
	
	// visibility
	EMFUpdateValueStrategy targetToModel_vis = new EMFUpdateValueStrategy();
	targetToModel_vis.setConverter(new BTSConfigItemToStringConverter());
	EMFUpdateValueStrategy modelToTarget_vis = new EMFUpdateValueStrategy();
	modelToTarget_vis.setConverter(new BTSStringToConfigItemConverter(
			visibility_viewer));
	IObservableValue target_vis_viewer = ViewersObservables
			.observeSingleSelection(visibility_viewer);
	Binding binding_vis = bindingContext
			.bindValue(
					target_vis_viewer,
					EMFProperties
							.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__VISIBILITY)
							.observe(object), targetToModel_vis,
					modelToTarget_vis);		
	
	// review status
	EMFUpdateValueStrategy targetToModel_rev = new EMFUpdateValueStrategy();
	targetToModel_rev.setConverter(new BTSConfigItemToStringConverter());
	EMFUpdateValueStrategy modelToTarget_rev = new EMFUpdateValueStrategy();
	modelToTarget_rev.setConverter(new BTSStringToConfigItemConverter(
			reviewState_viewer));
	IObservableValue target_rev_viewer = ViewersObservables
			.observeSingleSelection(reviewState_viewer);
	Binding binding_rev = bindingContext
			.bindValue(
					target_rev_viewer,
					EMFProperties
							.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__REVISION_STATE)
							.observe(object), targetToModel_rev,
					modelToTarget_rev);
	super.initialize();
}
 
开发者ID:cplutte,项目名称:bts,代码行数:47,代码来源:ATextNavigatorSettingsPage.java

示例9: init

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
protected void init() {
	prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");
	IEclipsePreferences defaultpref = DefaultScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");

	default_visibility = prefs.get(BTSCorpusConstants.PREF_CORPUS_DEFAULT_VISIBILITY, null);
	default_reviewState = prefs.get(BTSCorpusConstants.PREF_CORPUS_DEFAULT_REVIEWSTATE, null);
	
	object = BtsCorpusModelFactory.eINSTANCE.createBTSTCObject();
	object.setVisibility(default_visibility);
	object.setRevisionState(default_reviewState);
	
	DataBindingContext bindingContext = new DataBindingContext();
	
	// visibility
	EMFUpdateValueStrategy targetToModel_vis = new EMFUpdateValueStrategy();
	targetToModel_vis.setConverter(new BTSConfigItemToStringConverter());
	EMFUpdateValueStrategy modelToTarget_vis = new EMFUpdateValueStrategy();
	modelToTarget_vis.setConverter(new BTSStringToConfigItemConverter(
			visibility_viewer));
	IObservableValue target_vis_viewer = ViewersObservables
			.observeSingleSelection(visibility_viewer);
	Binding binding_vis = bindingContext
			.bindValue(
					target_vis_viewer,
					EMFProperties
							.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__VISIBILITY)
							.observe(object), targetToModel_vis,
					modelToTarget_vis);		
	
	// review status
	EMFUpdateValueStrategy targetToModel_rev = new EMFUpdateValueStrategy();
	targetToModel_rev.setConverter(new BTSConfigItemToStringConverter());
	EMFUpdateValueStrategy modelToTarget_rev = new EMFUpdateValueStrategy();
	modelToTarget_rev.setConverter(new BTSStringToConfigItemConverter(
			reviewState_viewer));
	IObservableValue target_rev_viewer = ViewersObservables
			.observeSingleSelection(reviewState_viewer);
	Binding binding_rev = bindingContext
			.bindValue(
					target_rev_viewer,
					EMFProperties
							.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__REVISION_STATE)
							.observe(object), targetToModel_rev,
					modelToTarget_rev);
	super.initialize();
}
 
开发者ID:cplutte,项目名称:bts,代码行数:47,代码来源:CorpusNavigatorSettingsPage.java

示例10: init

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
protected void init() {
	prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");
	IEclipsePreferences defaultpref = DefaultScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");

	default_visibility = prefs.get(BTSCorpusConstants.PREF_THS_DEFAULT_VISIBILITY, null);
	default_reviewState = prefs.get(BTSCorpusConstants.PREF_THS_DEFAULT_REVIEWSTATE, null);
	
	object = BtsCorpusModelFactory.eINSTANCE.createBTSTCObject();
	object.setVisibility(default_visibility);
	object.setRevisionState(default_reviewState);
	
	DataBindingContext bindingContext = new DataBindingContext();
	
	// visibility
	EMFUpdateValueStrategy targetToModel_vis = new EMFUpdateValueStrategy();
	targetToModel_vis.setConverter(new BTSConfigItemToStringConverter());
	EMFUpdateValueStrategy modelToTarget_vis = new EMFUpdateValueStrategy();
	modelToTarget_vis.setConverter(new BTSStringToConfigItemConverter(
			visibility_viewer));
	IObservableValue target_vis_viewer = ViewersObservables
			.observeSingleSelection(visibility_viewer);
	Binding binding_vis = bindingContext
			.bindValue(
					target_vis_viewer,
					EMFProperties
							.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__VISIBILITY)
							.observe(object), targetToModel_vis,
					modelToTarget_vis);		
	
	// review status
	EMFUpdateValueStrategy targetToModel_rev = new EMFUpdateValueStrategy();
	targetToModel_rev.setConverter(new BTSConfigItemToStringConverter());
	EMFUpdateValueStrategy modelToTarget_rev = new EMFUpdateValueStrategy();
	modelToTarget_rev.setConverter(new BTSStringToConfigItemConverter(
			reviewState_viewer));
	IObservableValue target_rev_viewer = ViewersObservables
			.observeSingleSelection(reviewState_viewer);
	Binding binding_rev = bindingContext
			.bindValue(
					target_rev_viewer,
					EMFProperties
							.value(BtsmodelPackage.Literals.ADMINISTRATIV_DATA_OBJECT__REVISION_STATE)
							.observe(object), targetToModel_rev,
					modelToTarget_rev);
	super.initialize();
}
 
开发者ID:cplutte,项目名称:bts,代码行数:47,代码来源:ThsNavigatorSettingsPage.java

示例11: bindObjectToCCombo

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
/**
 * creates a binding for a combo
 *
 * @param combo
 *            widget that displays the information to the user
 * @param entity
 *            class that holds the model information
 * @param entityClass
 *            class of entity
 * @param propertyName
 *            name of the property that should be binded
 * @param propertyClass
 *            class of the property that should be binded
 * @param values
 *            all values of the property
 * @param bindingContext
 *            context of the binding
 * @param labelProvider
 *            the label provider that will be used to display the state in
 *            the combo. can be <code>null</code>
 * @param isRequired
 *            should the field be filled by the user?
 * @return binding
 */
public static <E, T> Binding bindObjectToCCombo(final CCombo combo, final IObservableValue inputObservable,
		final Class<E> entityClass, final String propertyName, final Class<T> propertyClass,
		final Collection<T> values, final IBaseLabelProvider labelProvider, final DataBindingContext bindingContext,
		final boolean isRequired) {
	final ComboViewer comboViewer = new ComboViewer(combo);
	comboViewer.setContentProvider(ArrayContentProvider.getInstance());
	comboViewer.setLabelProvider(labelProvider);
	comboViewer.setInput(values);

	final IViewerObservableValue targetObservable = ViewersObservables.observeSingleSelection(comboViewer);
	final IObservableValue modelObservable = BeansObservables.observeDetailValue(inputObservable, propertyName,
			entityClass);

	final UpdateValueStrategy targetToModel = isRequired
			? new UpdateValueStrategy().setAfterConvertValidator(new NotEmptyValue()) : null;

	final Binding binding = bindingContext.bindValue(targetObservable, modelObservable, targetToModel, null);

	// TODO add required binding

	return binding;

}
 
开发者ID:FI13,项目名称:afbb-bibo,代码行数:48,代码来源:BindingHelper.java

示例12: createPartControl

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
@PostConstruct
public void createPartControl(Composite parent) {
	parent.setLayout(new GridLayout(2, false));
	
	Label firstNameLabel = new Label(parent, SWT.NONE);
	firstNameLabel.setText("Firstname:");
	GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel);
	
	Text firstNameField = new Text(parent, SWT.BORDER);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField);
	
	Label lastNameLabel = new Label(parent, SWT.NONE);
	lastNameLabel.setText("Lastname:");
	GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel);
	
	Text lastNameField = new Text(parent, SWT.BORDER);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField);
	
	Label marriedLabel = new Label(parent, SWT.NONE);
	marriedLabel.setText("Married:");
	GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel);
	
	Button marriedButton = new Button(parent, SWT.CHECK);
	
	Label genderLabel = new Label(parent, SWT.NONE);
	genderLabel.setText("Gender:");
	GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel);
	
	ComboViewer genderCombo = new ComboViewer(parent);
	genderCombo.setContentProvider(ArrayContentProvider.getInstance());
	genderCombo.setLabelProvider(new LabelProvider() {
	  @Override
	  public String getText(Object element) {
	    return super.getText(element);
	  }
	});
	genderCombo.setInput(Gender.values());
	GridDataFactory.fillDefaults().grab(true, false).applyTo(genderCombo.getControl());
	
	// add bindings
	DataBindingContext ctx = new DataBindingContext();
	IObservableValue fnTarget = 
			WidgetProperties.text(SWT.Modify).observe(firstNameField);
    IObservableValue lnTarget = 
    		WidgetProperties.text(SWT.Modify).observe(lastNameField);
    IObservableValue mTarget = 
    		WidgetProperties.selection().observe(marriedButton);
    IObservableValue gTarget = 
    		ViewersObservables.observeSingleSelection(genderCombo);
	
    IObservableValue fnModel= BeanProperties.
    		  value(Person.class,"firstName").observe(activePerson);
    IObservableValue lnModel= BeanProperties.
    		  value(Person.class,"lastName").observe(activePerson);
    IObservableValue mModel= BeanProperties.
    		value(Person.class,"married").observe(activePerson);
    IObservableValue gModel= BeanProperties.
    		value(Person.class,"gender").observe(activePerson);
    
    ctx.bindValue(fnTarget, fnModel); 
    ctx.bindValue(lnTarget, lnModel); 
    ctx.bindValue(mTarget, mModel);
    ctx.bindValue(gTarget, gModel);
    
	// add the selection listener
	selectionService.addSelectionListener(selectionListener);
}
 
开发者ID:fipro78,项目名称:e4-cookbook-migration-guide,代码行数:68,代码来源:DetailView.java

示例13: createPartControl

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
@PostConstruct
public void createPartControl(Composite parent) {
	parent.setLayout(new GridLayout(2, false));

	Label firstNameLabel = new Label(parent, SWT.NONE);
	firstNameLabel.setText("Firstname:");
	GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel);

	Text firstNameField = new Text(parent, SWT.BORDER);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField);

	Label lastNameLabel = new Label(parent, SWT.NONE);
	lastNameLabel.setText("Lastname:");
	GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel);

	Text lastNameField = new Text(parent, SWT.BORDER);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField);

	Label marriedLabel = new Label(parent, SWT.NONE);
	marriedLabel.setText("Married:");
	GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel);

	Button marriedButton = new Button(parent, SWT.CHECK);

	Label genderLabel = new Label(parent, SWT.NONE);
	genderLabel.setText("Gender:");
	GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel);

	ComboViewer genderCombo = new ComboViewer(parent);
	genderCombo.setContentProvider(ArrayContentProvider.getInstance());
	genderCombo.setLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object element) {
			return super.getText(element);
		}
	});
	genderCombo.setInput(Gender.values());
	GridDataFactory.fillDefaults().grab(true, false).applyTo(genderCombo.getControl());

	// add bindings
	DataBindingContext ctx = new DataBindingContext();
	IObservableValue fnTarget = WidgetProperties.text(SWT.Modify).observe(firstNameField);
	IObservableValue lnTarget = WidgetProperties.text(SWT.Modify).observe(lastNameField);
	IObservableValue mTarget = WidgetProperties.selection().observe(marriedButton);
	IObservableValue gTarget = ViewersObservables.observeSingleSelection(genderCombo);

	IObservableValue fnModel = BeanProperties.value(Person.class, "firstName").observe(activePerson);
	IObservableValue lnModel = BeanProperties.value(Person.class, "lastName").observe(activePerson);
	IObservableValue mModel = BeanProperties.value(Person.class, "married").observe(activePerson);
	IObservableValue gModel = BeanProperties.value(Person.class, "gender").observe(activePerson);

	ctx.bindValue(fnTarget, fnModel);
	ctx.bindValue(lnTarget, lnModel);
	ctx.bindValue(mTarget, mModel);
	ctx.bindValue(gTarget, gModel);

	this.activePerson.addPropertyChangeListener(new PropertyChangeListener() {

		@Override
		public void propertyChange(PropertyChangeEvent evt) {
			dirtyable.setDirty(true);
		}
	});
}
 
开发者ID:fipro78,项目名称:e4-cookbook-migration-guide,代码行数:65,代码来源:PersonEditor.java

示例14: createPartControl

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
@Override
public void createPartControl(Composite parent) {
	parent.setLayout(new GridLayout(2, false));
	
	Label firstNameLabel = new Label(parent, SWT.NONE);
	firstNameLabel.setText("Firstname:");
	GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel);
	
	Text firstNameField = new Text(parent, SWT.BORDER);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField);
	
	Label lastNameLabel = new Label(parent, SWT.NONE);
	lastNameLabel.setText("Lastname:");
	GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel);
	
	Text lastNameField = new Text(parent, SWT.BORDER);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField);
	
	Label marriedLabel = new Label(parent, SWT.NONE);
	marriedLabel.setText("Married:");
	GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel);
	
	Button marriedButton = new Button(parent, SWT.CHECK);
	
	Label genderLabel = new Label(parent, SWT.NONE);
	genderLabel.setText("Gender:");
	GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel);
	
	ComboViewer genderCombo = new ComboViewer(parent);
	genderCombo.setContentProvider(ArrayContentProvider.getInstance());
	genderCombo.setLabelProvider(new LabelProvider() {
	  @Override
	  public String getText(Object element) {
	    return super.getText(element);
	  }
	});
	genderCombo.setInput(Gender.values());
	GridDataFactory.fillDefaults().grab(true, false).applyTo(genderCombo.getControl());
	
	// add bindings
	DataBindingContext ctx = new DataBindingContext();
	IObservableValue fnTarget = 
			WidgetProperties.text(SWT.Modify).observe(firstNameField);
    IObservableValue lnTarget = 
    		WidgetProperties.text(SWT.Modify).observe(lastNameField);
    IObservableValue mTarget = 
    		WidgetProperties.selection().observe(marriedButton);
    IObservableValue gTarget = 
    		ViewersObservables.observeSingleSelection(genderCombo);
	
    IObservableValue fnModel= BeanProperties.
    		  value(Person.class,"firstName").observe(activePerson);
    IObservableValue lnModel= BeanProperties.
    		  value(Person.class,"lastName").observe(activePerson);
    IObservableValue mModel= BeanProperties.
    		value(Person.class,"married").observe(activePerson);
    IObservableValue gModel= BeanProperties.
    		value(Person.class,"gender").observe(activePerson);
    
    ctx.bindValue(fnTarget, fnModel); 
    ctx.bindValue(lnTarget, lnModel); 
    ctx.bindValue(mTarget, mModel);
    ctx.bindValue(gTarget, gModel);
    
	// add the selection listener
	getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener);
}
 
开发者ID:fipro78,项目名称:e4-cookbook-migration-guide,代码行数:68,代码来源:DetailView.java

示例15: createPartControl

import org.eclipse.jface.databinding.viewers.ViewersObservables; //导入方法依赖的package包/类
@Override
public void createPartControl(Composite parent) {
	parent.setLayout(new GridLayout(2, false));
	
	Label firstNameLabel = new Label(parent, SWT.NONE);
	firstNameLabel.setText("Firstname:");
	GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel);
	
	Text firstNameField = new Text(parent, SWT.BORDER);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField);
	
	Label lastNameLabel = new Label(parent, SWT.NONE);
	lastNameLabel.setText("Lastname:");
	GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel);
	
	Text lastNameField = new Text(parent, SWT.BORDER);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField);
	
	Label marriedLabel = new Label(parent, SWT.NONE);
	marriedLabel.setText("Married:");
	GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel);
	
	Button marriedButton = new Button(parent, SWT.CHECK);
	
	Label genderLabel = new Label(parent, SWT.NONE);
	genderLabel.setText("Gender:");
	GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel);
	
	ComboViewer genderCombo = new ComboViewer(parent);
	genderCombo.setContentProvider(ArrayContentProvider.getInstance());
	genderCombo.setLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object element) {
			return super.getText(element);
		}
	});
	genderCombo.setInput(Gender.values());
	GridDataFactory.fillDefaults().grab(true, false).applyTo(genderCombo.getControl());
	
	// add bindings
	DataBindingContext ctx = new DataBindingContext();
	IObservableValue fnTarget = 
			WidgetProperties.text(SWT.Modify).observe(firstNameField);
	IObservableValue lnTarget = 
			WidgetProperties.text(SWT.Modify).observe(lastNameField);
	IObservableValue mTarget = 
			WidgetProperties.selection().observe(marriedButton);
	IObservableValue gTarget = 
			ViewersObservables.observeSingleSelection(genderCombo);
	
	IObservableValue fnModel= BeanProperties.
			value(Person.class,"firstName").observe(activePerson);
	IObservableValue lnModel= BeanProperties.
			value(Person.class,"lastName").observe(activePerson);
	IObservableValue mModel= BeanProperties.
			value(Person.class,"married").observe(activePerson);
	IObservableValue gModel= BeanProperties.
			value(Person.class,"gender").observe(activePerson);
	
	ctx.bindValue(fnTarget, fnModel); 
	ctx.bindValue(lnTarget, lnModel); 
	ctx.bindValue(mTarget, mModel);
	ctx.bindValue(gTarget, gModel);
	
	this.activePerson.addPropertyChangeListener(new PropertyChangeListener() {
		
		@Override
		public void propertyChange(PropertyChangeEvent evt) {
			dirty = true;
			firePropertyChange(IEditorPart.PROP_DIRTY);
		}
	});
}
 
开发者ID:fipro78,项目名称:e4-cookbook-migration-guide,代码行数:74,代码来源:PersonEditor.java


注:本文中的org.eclipse.jface.databinding.viewers.ViewersObservables.observeSingleSelection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。