本文整理汇总了Java中org.eclipse.core.databinding.conversion.IConverter类的典型用法代码示例。如果您正苦于以下问题:Java IConverter类的具体用法?Java IConverter怎么用?Java IConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConverter类属于org.eclipse.core.databinding.conversion包,在下文中一共展示了IConverter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convert
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T convert(Object propValue, Class<T> valueType) {
if (propValue == null) {
return null;
}
if (valueType.equals(propValue.getClass())) {
return (T) propValue;
}
IConverter converter = getConverter(propValue.getClass(), valueType);
if (converter != null) {
T convertedValue = (T) converter.convert(propValue);
return convertedValue;
}
throw new UnsupportedOperationException(
"Could not convert from '" + propValue.getClass() + "' to '" + valueType + "'");
}
开发者ID:erdalkaraca,项目名称:lambda-ui,代码行数:21,代码来源:ConvertersRegistry.java
示例2: initBindings
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
public void initBindings(IObservableList modelObservable){
if(currentObservable == modelObservable){
return;
}
if(bindingContext != null){
bindingContext.dispose();
bindingContext = null;
}
bindingContext = new DataBindingContext();
CompositeContainerChildProperty childrenProp = new CompositeContainerChildProperty();
IObservableList childObs = childrenProp.observe(this);
IConverter[] converter = getCompositeContainerChildConverter(modelObservable.getElementType());
UpdateListStrategy t2mStrategy = new UpdateListStrategy(UpdateListStrategy.POLICY_UPDATE);
t2mStrategy.setConverter(converter[0]);
UpdateListStrategy m2tStrategy = new UpdateListStrategy(UpdateListStrategy.POLICY_UPDATE);
m2tStrategy.setConverter(converter[1]);
bindingContext.bindList(childObs, modelObservable, t2mStrategy, m2tStrategy);
bindingContext.updateTargets();
currentObservable = modelObservable;
}
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:27,代码来源:ListComposite.java
示例3: getConverter
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
public IConverter getConverter(Class<?> from, Class<?> to) {
IConverter converter = strategy.createConverter(from, to);
if (converter != null) {
return converter;
}
// TODO allow for user registered converters lookup
return null;
}
开发者ID:erdalkaraca,项目名称:lambda-ui,代码行数:11,代码来源:ConvertersRegistry.java
示例4: bindWidgets
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
@Override
protected void bindWidgets(DataAdapter dataAdapter) {
bindingContext.bindValue(
SWTObservables.observeText(hostname, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "hostname")); //$NON-NLS-1$
bindingContext.bindValue(
SWTObservables.observeText(keyspace, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "keyspace")); //$NON-NLS-1$
NumberFormat numberFormat = NumberFormat.getIntegerInstance();
numberFormat.setGroupingUsed(false);
IConverter targetToModelConverter = StringToNumberConverter.toInteger(numberFormat, true);
IConverter modelToTargetConverter = NumberToStringConverter.fromInteger(numberFormat, true);
bindingContext.bindValue(
SWTObservables.observeText(port, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "port"),
new UpdateValueStrategy().setConverter(targetToModelConverter),
new UpdateValueStrategy().setConverter(modelToTargetConverter)); //$NON-NLS-1$
bindingContext.bindValue(
SWTObservables.observeText(username, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "username")); //$NON-NLS-1$
bindingContext.bindValue(
SWTObservables.observeText(password, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "password")); //$NON-NLS-1$
port.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
for (char c : e.text.toCharArray()){
if (!Character.isDigit(c)) {
e.doit = false;
return;
}
}
}
});
}
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:37,代码来源:CassandraDataAdapterComposite.java
示例5: createConverter
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
@Override
protected IConverter createConverter(Object fromType, Object toType) {
if (fromType instanceof EAttribute && toType == String.class) {
return new RelativePathToStringConverter();
} else if (fromType == String.class && toType instanceof EAttribute) {
return new StringToRelativePathConverter();
}
return super.createConverter(fromType, toType);
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:10,代码来源:PathUpdateValueStrategy.java
示例6: bindText
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
/**
* Returns an observable observing the text attribute of the provided <code>control</code>. The supported types
* are:
* <ul>
* <li>org.eclipse.swt.widgets.Text</li>
* <li>org.eclipse.swt.custom.StyledText (as of 1.3)</li>
* </ul>
*
* @param control
* @param event event type to register for change events {@literal SWT.FocusOut SWT.Modify or SWT.NONE}
* @param bean
* @param propertyName
* @param validator
* @param converter
* @return binding
* @throws IllegalArgumentException if <code>control</code> type is unsupported
*/
public DecoratedBinding bindText(Control control, int event, Object bean, String propertyName,
IValidator validator, IConverter targetToModelConverter, IConverter modelToTargetConverter) {
// IObservableValue widgetValue =
// WidgetProperties.text(SWT.Modify).observe(serverUriText);
// IObservableValue modelValuea = BeanProperties.value(Connection.class,
// "serverURI").observe(connection);
// observe
IObservableValue widgetValue = SWTObservables.observeText(control, event);
IObservableValue modelValue = BeansObservables.observeValue(bean, propertyName);
UpdateValueStrategy targetToModel = new UpdateValueStrategy();
UpdateValueStrategy modelToTarget = new UpdateValueStrategy();
// targetToModel
// validator
if (validator != null) {
targetToModel.setBeforeSetValidator(validator);
}
// converter
if (targetToModelConverter != null) {
targetToModel.setConverter(targetToModelConverter);
}
// modelToTarget
if (modelToTargetConverter != null) {
modelToTarget.setConverter(modelToTargetConverter);
}
Binding bindValue = context.bindValue(widgetValue, modelValue, targetToModel, modelToTarget);
// decoration
ControlDecorationSupport decorationSupport = ControlDecorationSupport.create(bindValue, SWT.TOP | SWT.LEFT);
return new DecoratedBinding(bindValue, decorationSupport);
}
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:55,代码来源:DataBindings.java
示例7: getConverter
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
public IConverter getConverter() {
return converter;
}
开发者ID:erdalkaraca,项目名称:lambda-ui,代码行数:4,代码来源:Binding.java
示例8: setConverter
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
public void setConverter(IConverter converter) {
this.converter = converter;
}
开发者ID:erdalkaraca,项目名称:lambda-ui,代码行数:4,代码来源:Binding.java
示例9: createConverter
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
public IConverter createConverter(Object fromType, Object toType) {
return super.createConverter(fromType, toType);
}
开发者ID:erdalkaraca,项目名称:lambda-ui,代码行数:4,代码来源:ConvertersRegistry.java
示例10: createPartControl
import org.eclipse.core.databinding.conversion.IConverter; //导入依赖的package包/类
@PostConstruct
@SuppressWarnings("unchecked")
public void createPartControl(Composite parent) {
// create the Person model with programming skills
Person person = new Person();
person.setName("John");
person.setProgrammingSkills(new String[] { "Java", "JavaScript", "Groovy" });
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(parent);
Label programmingSkillsLabel = new Label(parent, SWT.NONE);
programmingSkillsLabel.setText("Programming Skills");
GridDataFactory.swtDefaults().applyTo(programmingSkillsLabel);
Text programmingSkillsText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(programmingSkillsText);
// Do the actual binding and conversion
DataBindingContext dbc = new DataBindingContext();
// define converters
IConverter convertToStringArray = IConverter.create(String.class, String[].class,
(o1) -> ((String) o1).split(","));
IConverter convertToString = IConverter.create(String[].class, String.class, (o1) -> convert((String[]) o1));
;
// create the observables, which should be bound
IObservableValue<Text> programmingSkillsTarget = WidgetProperties.text(SWT.Modify)
.observe(programmingSkillsText);
IObservableValue<Person> programmingSkillsModel = BeanProperties.value("programmingSkills").observe(person);
UpdateValueStrategy updateStrategy = UpdateValueStrategy.create(convertToStringArray);
updateStrategy.setAfterGetValidator((o1) -> {
String s = (String) o1;
if (!s.contains("Perl")) {
return ValidationStatus.ok();
}
return ValidationStatus.error("Perl is not a programming language");
});
// bind observables together with the appropriate UpdateValueStrategies
dbc.bindValue(programmingSkillsTarget, programmingSkillsModel,
updateStrategy,
UpdateValueStrategy.create(convertToString));
// button to check the data model
Button button = new Button(parent, SWT.PUSH);
button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
button.setText("Show data model");
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
for (String string : person.getProgrammingSkills()) {
System.out.println(string);
}
}
});
}
开发者ID:vogellacompany,项目名称:codeexamples-eclipse,代码行数:58,代码来源:SamplePart.java
注:本文中的org.eclipse.core.databinding.conversion.IConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论