本文整理汇总了Java中org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper类的典型用法代码示例。如果您正苦于以下问题:Java PropertyValueWrapper类的具体用法?Java PropertyValueWrapper怎么用?Java PropertyValueWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyValueWrapper类属于org.eclipse.emf.edit.provider.ItemPropertyDescriptor包,在下文中一共展示了PropertyValueWrapper类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertyValue
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
public static Object getPropertyValue(IItemPropertyDescriptor pd, Object model) {
Object value = pd.getPropertyValue(model);
if (value instanceof PropertyValueWrapper) {
value = ((PropertyValueWrapper)value).getEditableValue(model);
}
return value;
}
示例2: getText
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
protected String getText(EPlanElement pe, String key) {
if (TimelinePreferencePage.P_DECORATOR_TEXT_KEY_NONE.equals(key)) {
return null;
}
if (PlanTextDecoratorFieldProvider.P_DECORATOR_TEXT_KEY_NAME.equals(key)) {
return pe.getName();
}
if (PlanTextDecoratorFieldProvider.P_DECORATOR_TEXT_KEY_NOTES.equals(key)) {
return pe.getMember(CommonMember.class).getNotes();
}
EObject object = pe.getData();
IItemPropertySource source = EMFUtils.adapt(object, IItemPropertySource.class);
if (source != null) {
EStructuralFeature f = object.eClass().getEStructuralFeature(key);
if (f != null) {
IItemPropertyDescriptor pd = source.getPropertyDescriptor(object, f);
if (pd != null) {
IItemLabelProvider lp = pd.getLabelProvider(object);
if (lp != null) {
Object value = pd.getPropertyValue(object);
if (value instanceof PropertyValueWrapper) {
value = ((PropertyValueWrapper)value).getEditableValue(object);
}
return lp.getText(value);
}
}
}
}
return null;
}
示例3: updateValidityColor
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
/**
* Sets the validity color according to the current text.
*
* ShowTip, determines if a "tip" about the error should be displayed
*/
private void updateValidityColor(final Text text, final EObject eObject, IItemPropertyDescriptor pd, final IStringifier<Object> stringifier, final boolean showTip) {
try {
// Don't update the validity color if the Text has an associated error decoration from EMF validation
if (!EMFDetailUtils.hasErrorDecoration(text)) {
text.setForeground(VALID_COLOR);
// Default control tooltip description
EMFDetailUtils.addDescriptionTooltip(pd, eObject, text);
}
Object value = pd.getPropertyValue(eObject);
if (value instanceof PropertyValueWrapper) {
value = ((PropertyValueWrapper)value).getEditableValue(eObject);
}
Object parsedValue = null;
if (stringifier == null) {
text.setForeground(INVALID_INPUT_COLOR);
Logger.getLogger(TextBindingFactory.class).error("null stringifier for: " + pd.getDisplayName(eObject));
} else {
Object defaultValue = value;
if (defaultValue==null && (IStringifier)stringifier instanceof DateStringifier) {
Date smartDefault = DefaultDateUtil.tryHarderToFindDefaultDateIfApplicable(eObject, stringifier);
if (smartDefault != null) defaultValue = smartDefault;
}
parsedValue = stringifier.getJavaObject(text.getText(), defaultValue);
}
if (bubbleShowing()) {
bubble.setVisible(false);
}
if (parsedValue instanceof Date) {
String toolTipText = MissionCalendarUtils.formatToolTipDate((Date)parsedValue);
if (!toolTipText.equals(text.getText())) {
text.setToolTipText(toolTipText);
// SWT doesn't allow tooltips on disabled controls so add to parent as well
text.getParent().setToolTipText(toolTipText);
}
}
} catch (final ParseException pe) {
showError(text, pe.getMessage(), showTip);
}
}
示例4: unwrapPropertyDescriptors
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
private void unwrapPropertyDescriptors(Object target, List<IItemPropertyDescriptor> list, List<IItemPropertyDescriptor> pds) {
for (IItemPropertyDescriptor pd : pds) {
Object value = pd.getPropertyValue(target);
if (value instanceof PropertyValueWrapper) {
PropertyValueWrapper wrapper = (PropertyValueWrapper)value;
List<IItemPropertyDescriptor> unwrappedPropertyDescriptors = wrapper.getPropertyDescriptors(value);
if (!unwrappedPropertyDescriptors.isEmpty()) {
unwrapPropertyDescriptors(value, list, unwrappedPropertyDescriptors);
}
}
list.add(pd);
}
}
示例5: getRealValue
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
private String getRealValue(Object value) {
if (value instanceof PropertyValueWrapper) {
PropertyValueWrapper wrapper = (PropertyValueWrapper) value;
return wrapper.getText(wrapper);
}
return "";
}
示例6: getEditableValue
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Object getEditableValue() {
Object value = source.getEditableValue();
if (value instanceof PropertyValueWrapper) {
PropertyValueWrapper wrapper = (PropertyValueWrapper) value;
return wrapper.getEditableValue(null);
} else {
return source.getEditableValue();
}
}
示例7: getPropertyValue
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Object getPropertyValue(final Object id) {
final Object value = source.getPropertyValue(id);
if (value instanceof PropertyValueWrapper) {
PropertyValueWrapper wrapper = (PropertyValueWrapper) value;
return wrapper.getEditableValue(null);
} else {
return source.getPropertyValue(id);
}
}
示例8: createBinding
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
@Override
public Binding createBinding(DetailProviderParameter p) {
FormToolkit toolkit = p.getDetailFormToolkit();
Composite parent = p.getParent();
EObject target = p.getTarget();
IItemPropertyDescriptor pd = p.getPropertyDescriptor();
Object propertyValueObject = pd.getPropertyValue(target);
String propertyName = pd.getDisplayName(target);
String propertyValue = null;
if (propertyValueObject != null && propertyValueObject instanceof PropertyValueWrapper) {
PropertyValueWrapper propertyValueWrapper = (PropertyValueWrapper) propertyValueObject;
Object editableValue = propertyValueWrapper.getEditableValue(target);
propertyValue = editableValue.toString();
}
if (propertyValue == null) {
propertyValue = "";
}
EMFDetailUtils.createLabel(parent, toolkit, target, pd);
Composite rootComposite = createRootComposite(toolkit, parent);
Composite hyperlinkAndBrowseComposite = hyperlinkAndBrowseComposite(rootComposite);
Text hyperlinkTextField = createHyperlinkTextField(hyperlinkAndBrowseComposite, propertyValue);
@SuppressWarnings("unused")
Button browseButton = createBrowseButton(hyperlinkAndBrowseComposite, hyperlinkTextField);
Button openButton = createOpenButton(rootComposite, propertyName, hyperlinkTextField);
hyperlinkAndBrowseComposite.setData(BUTTON_KEY, openButton);
openButton.setEnabled(!hyperlinkTextField.getText().trim().equals(""));
StringifierUpdateValueStrategy targetToModel = new StringifierUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
StringifierUpdateValueStrategy modelToTarget = new StringifierUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
ISWTObservableValue observeText = SWTObservables.observeText(hyperlinkTextField, SWT.FocusOut);
EMFDetailUtils.bindValidatorDecoration(p, hyperlinkTextField);
EMFDetailUtils.bindControlViability(p, new Control[] { browseButton, openButton, hyperlinkTextField });
Binding binding = EMFDetailUtils.bindEMFUndoable(p, observeText, targetToModel, modelToTarget);
EMFDetailUtils.bindTextModifyUndoable(hyperlinkTextField, target, propertyName);
targetToModel.setBinding(binding);
return binding;
}
示例9: createBinding
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
@Override
public Binding createBinding(DetailProviderParameter p) {
FormToolkit toolkit = p.getDetailFormToolkit();
Composite parent = p.getParent();
EObject target = p.getTarget();
IItemPropertyDescriptor pd = p.getPropertyDescriptor();
Object propertyValueObject = pd.getPropertyValue(target);
String propertyName = pd.getDisplayName(target);
String propertyValue = null;
if (propertyValueObject != null && propertyValueObject instanceof PropertyValueWrapper) {
PropertyValueWrapper propertyValueWrapper = (PropertyValueWrapper) propertyValueObject;
Object editableValue = propertyValueWrapper.getEditableValue(target);
propertyValue = editableValue.toString();
}
if (propertyValue == null) {
propertyValue = "";
}
uriConverter = target.eResource().getResourceSet().getURIConverter();
projectUriStringfier = new URIStrigifier(uriConverter);
EMFDetailUtils.createLabel(parent, toolkit, target, pd);
Composite rootComposite = createRootComposite(toolkit, parent);
Composite hyperlinkAndBrowseComposite = hyperlinkAndBrowseComposite(rootComposite);
Text hyperlinkTextField = createHyperlinkTextField(hyperlinkAndBrowseComposite, propertyValue);
Button browseButton = createBrowseButton(hyperlinkAndBrowseComposite, hyperlinkTextField);
Button openButton = createOpenButton(rootComposite, propertyName, hyperlinkTextField);
hyperlinkAndBrowseComposite.setData(BUTTON_KEY, openButton);
openButton.setEnabled(!hyperlinkTextField.getText().trim().equals(""));
StringifierUpdateValueStrategy targetToModel = new ProjectUrlUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
StringifierUpdateValueStrategy modelToTarget = new ProjectUrlUpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
ISWTObservableValue observeText = SWTObservables.observeText(hyperlinkTextField, SWT.FocusOut);
EMFDetailUtils.bindValidatorDecoration(p, hyperlinkTextField);
EMFDetailUtils.bindControlViability(p, new Control[] { browseButton, openButton, hyperlinkTextField });
Binding binding = EMFDetailUtils.bindEMFUndoable(p, observeText, targetToModel, modelToTarget);
EMFDetailUtils.bindTextModifyUndoable(hyperlinkTextField, target, propertyName);
targetToModel.setBinding(binding);
return binding;
}
示例10: createBinding
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper; //导入依赖的package包/类
private void createBinding(Composite parent, EObject target, IItemPropertyDescriptor pd) {
if (pd instanceof OverrideableCommandOwner) {
EObject owner = EMFDetailUtils.getCommandOwner(pd, target);
if (owner != null) {
target = owner;
}
}
EStructuralFeature feature = (EStructuralFeature) pd.getFeature(target);
if (feature != null && EMFUtils.testBooleanAnnotation(feature, EMFDetailUtils.ANNOTATION_SOURCE_DETAIL, ANNOTATION_DETAIL_HIDDEN)) {
return;
}
IDetailProvider provider = CommonUtils.getAdapter(pd, IDetailProvider.class);
if (provider == null) {
provider = EMFUtils.adapt(target, IDetailProvider.class);
}
DetailProviderParameter parameter = createDetailProviderParameter(parent, target, pd);
if (provider != null && provider.canCreateBindings(parameter)) {
provider.createBinding(parameter);
return;
}
Object propertyValue = pd.getPropertyValue(target);
if (propertyValue instanceof PropertyValueWrapper) {
PropertyValueWrapper wrapper = (PropertyValueWrapper) propertyValue;
List<IItemPropertyDescriptor> propertyDescriptors = wrapper.getPropertyDescriptors(propertyValue);
if (!propertyDescriptors.isEmpty()) {
String text = wrapper.getText(propertyValue);
Object editableValue = wrapper.getEditableValue(propertyValue);
buildPropertySection(parent, (EObject)editableValue, propertyDescriptors, text, null);
return;
}
}
if (feature instanceof EReference) {
createReferenceBinding(parent, target, pd, (EReference)feature);
} else if (feature instanceof EAttribute){
createAttributeBinding(parent, target, pd, (EAttribute)feature);
} else if (pd instanceof MultiItemPropertyDescriptor) {
pd = ((MultiItemPropertyDescriptor)pd).getPrimaryDescriptor();
if (pd != null)
createBinding(parent, target, pd);
}
}