Java 类org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper 实例源码

项目:OpenSPIFe    文件:EMFUtils.java   
public static Object getPropertyValue(IItemPropertyDescriptor pd, Object model) {
    Object value = pd.getPropertyValue(model);
    if (value instanceof PropertyValueWrapper) {
        value = ((PropertyValueWrapper)value).getEditableValue(model);
    }
    return value;
}
项目:OpenSPIFe    文件:TemporalNodeDecoratorTextEditPolicy.java   
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;
}
项目:OpenSPIFe    文件:TextBindingFactory.java   
/**
 * 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);
    }
}
项目:OpenSPIFe    文件:MultiItemIntersectionPropertySource.java   
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);
    }
}
项目:OpenSPIFe    文件:MultiItemUnionPropertySource.java   
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);
    }
}
项目:collaboro    文件:SyntaxElementPropertyDescriptor.java   
private String getRealValue(Object value) {
    if (value instanceof PropertyValueWrapper) {
        PropertyValueWrapper wrapper = (PropertyValueWrapper) value;
        return wrapper.getText(wrapper);
    }
    return "";
}
项目:FRaMED    文件:ORMGraphicalEditor.java   
/** {@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();
    }
}
项目:FRaMED    文件:ORMGraphicalEditor.java   
/** {@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);
    }
}
项目:OpenSPIFe    文件:URLBindingFactory.java   
@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;
}
项目:OpenSPIFe    文件:URIBindingFactory.java   
@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;
}
项目:OpenSPIFe    文件:EMFDetailFormPart.java   
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);
    }
}