Search in sources :

Example 16 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class AbstractPersistenceProvider method initBindingManager.

public void initBindingManager() {
    bindingManager.wDefValue("inputStream", (Object) null);
    bindingManager.wGet("inputStream").wAddRequestEventHandler(new IdentityRequestEventHandler() {

        public Object notifyRequested(IEntity source, FeatureDescriptor feature, Object value) {
            return inputStream;
        }
    });
    bindingManager.wDefValue("outputStream", (Object) null);
    bindingManager.wGet("outputStream").wAddRequestEventHandler(new IdentityRequestEventHandler() {

        public Object notifyRequested(IEntity source, FeatureDescriptor feature, Object value) {
            return outputStream;
        }
    });
    if (!bindingManager.wIsSet("encoding")) {
        bindingManager.wDefValue("encoding", "");
        bindingManager.wGet("encoding").wAddRequestEventHandler(new IdentityRequestEventHandler() {

            public String notifyRequested(IEntity source, FeatureDescriptor feature, String value) {
                return getDefaultEncoding();
            }
        });
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IdentityRequestEventHandler(org.whole.lang.events.IdentityRequestEventHandler)

Example 17 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class GrammarsContentAssistVisitor method calculateAsNameValues.

public static Set<String> calculateAsNameValues(IEntity e) {
    Grammar grammar = Matcher.findAncestor(Grammar, e);
    if (grammar != null) {
        Production production = Matcher.findAncestor(Production, e);
        String entityName = production.getName().getValue();
        ILanguageKit languageKit = getLanguageKitIfExists(grammar);
        if (languageKit != null) {
            EntityDescriptor<?> ed = languageKit.getEntityDescriptorEnum().valueOf(entityName);
            if (ed != null) {
                Set<String> names = new HashSet<String>();
                for (FeatureDescriptor fd : ed.getEntityFeatureDescriptors()) names.add(fd.getName());
                return names;
            }
        }
    }
    return Collections.emptySet();
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) Production(org.whole.lang.grammars.reflect.GrammarsEntityDescriptorEnum.Production) Production(org.whole.lang.grammars.model.Production) Grammar(org.whole.lang.grammars.reflect.GrammarsEntityDescriptorEnum.Grammar) Grammar(org.whole.lang.grammars.model.Grammar) ILanguageKit(org.whole.lang.reflect.ILanguageKit) HashSet(java.util.HashSet)

Example 18 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class XmlSpecific2XsdBuilderAdapter method elementEntity_.

@Override
public MappingContext elementEntity_(EntityDescriptor<?> context, QName name, Attributes attributes) {
    if (containsReferenceAttribute(attributes)) {
        EntityDescriptor<?> ed = null;
        if (Particles.equals(context) && matches("element", name))
            ed = ElementRef;
        else if (matches("attribute", name))
            ed = AttributeUseRef;
        else if (matches("attributeGroup", name))
            ed = AttributeGroupRef;
        else if (matches("group", name))
            ed = ModelGroupRef;
        FeatureDescriptor fd = calculateFeatureDescriptor(context, name);
        if (!EntityUtils.isComposite(context))
            builder.wFeature(fd);
        builder.wEntity_(ed);
        attributeEntities(ed, attributes);
        return MappingContext.create(ed, fd, false);
    } else
        return super.elementEntity_(context, name, attributes);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Example 19 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class XmlSpecific2XsiBuilderAdapter method attributeEntities.

protected void attributeEntities(EntityDescriptor<?> context, Attributes attributes) {
    String uri = context.getLanguageKit().getURI();
    boolean isAttributeFormQualified = MappingStrategyUtils.hasMappingStrategy(uri) && MappingStrategyUtils.getMappingStrategy(uri).isAttributesFormQualified();
    IEntityIterator<Attribute> iterator = IteratorFactory.<Attribute>childIterator();
    iterator.reset(attributes);
    // add attribute features
    while (iterator.hasNext()) {
        Attribute attribute = iterator.next();
        QName name = QName.create(ns, isAttributeFormQualified ? NamespaceUtils.getDefaultNamespace(ns) : uri, attribute.getName());
        String value = attribute.getValue().getValue();
        if (hasAttributeEntityMapping(context, name)) {
            FeatureDescriptor fd = getAttributeFeatureMapping(context, name);
            EntityDescriptor<?> ed = getAttributeEntityMapping(context, name);
            attributeEntity(fd, ed, value);
            iterator.remove();
        }
    }
    // add any attributes feature
    anyAttributeEntities(context, attributes);
}
Also used : Attribute(org.whole.lang.xml.model.Attribute) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) QName(org.whole.lang.xml.util.QName)

Example 20 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class XmlSpecific2XsiBuilderAdapter method structuralEntity_.

protected MappingContext structuralEntity_(EntityDescriptor<?> context, QName name) {
    if (!hasStructuralEntityMapping(context, name))
        return null;
    FeatureDescriptor fd = getStructuralFeatureMapping(context, name);
    EntityDescriptor<?> ed = getStructuralEntityMapping(context, name);
    if (!EntityUtils.isComposite(context))
        builder.wFeature(fd);
    builder.wEntity_(ed);
    return MappingContext.create(ed, fd, true);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Aggregations

FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)100 IEntity (org.whole.lang.model.IEntity)43 InternalIEntity (org.whole.lang.model.InternalIEntity)6 ILanguageKit (org.whole.lang.reflect.ILanguageKit)6 HashSet (java.util.HashSet)5 IContributionItem (org.eclipse.jface.action.IContributionItem)5 ActionsVisibleWhen (org.whole.lang.e4.ui.expressions.ActionsVisibleWhen)5 VisibilityExpression (org.whole.lang.e4.ui.expressions.VisibilityExpression)5 ActionsCompositeContributionItem (org.whole.lang.e4.ui.menu.ActionsCompositeContributionItem)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 HashMap (java.util.HashMap)3 IBindingManager (org.whole.lang.bindings.IBindingManager)3 ITransactionScope (org.whole.lang.bindings.ITransactionScope)3 IdentityRequestEventHandler (org.whole.lang.events.IdentityRequestEventHandler)3 IMappingStrategy (org.whole.lang.xsd.codebase.IMappingStrategy)3 IEntityFactory (org.whole.lang.factories.IEntityFactory)2 ArrayType (org.whole.lang.pojo.model.ArrayType)2 CollectionType (org.whole.lang.pojo.model.CollectionType)2 MapType (org.whole.lang.pojo.model.MapType)2