Search in sources :

Example 21 with FeatureDescriptor

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

the class XsiModelTemplate method applyAttributes.

protected void applyAttributes(IEntity entity, int fromIndex) {
    final int size = entity.wSize();
    for (int i = fromIndex; i < size; i++) {
        EntityDescriptor<?> context = entity.wGetEntityDescriptor();
        FeatureDescriptor fd = entity.wGetFeatureDescriptor(i);
        IEntity child = entity.wGet(i);
        EntityDescriptor<?> ed = child.wGetEntityDescriptor();
        String languageURI = ed.getLanguageKit().getURI();
        // FIXME workaround for resolvers and other adapted entities
        if (CommonsLanguageKit.URI.equals(ed.getLanguageKit().getURI())) {
            ed = child.wGetParent().wGetEntityDescriptor();
            languageURI = ed.getLanguageKit().getURI();
        }
        IMappingStrategy strategy = getXsiMappingStrategy(languageURI);
        if (isAttributeMapping(strategy, context, ed, fd)) {
            if (!EntityUtils.isResolver(child) || !fd.isOptional()) {
                builder.Attribute_();
                String attrName = getAttributeNCName(strategy, context, ed, fd);
                // TODO add any attribute support
                boolean needNamespacePrefix = strategy.isAttributesFormQualified() && !NamespaceUtils.isInternalNamespace(languageURI);
                if (needNamespacePrefix) {
                    String prefix = getNamespacePrefix(child, languageURI);
                    builder.QualifiedName_();
                    builder.NameSpace(prefix);
                    builder.Name(attrName);
                    builder._QualifiedName();
                } else
                    builder.Name(attrName);
                builder.Value(toAttributeValue(child, strategy));
                builder._Attribute();
            }
        }
    }
}
Also used : IMappingStrategy(org.whole.lang.xsd.codebase.IMappingStrategy) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IEntity(org.whole.lang.model.IEntity)

Example 22 with FeatureDescriptor

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

the class AbstractUIBuilder method addMigrateItem.

@Override
public void addMigrateItem() {
    FeatureDescriptor menu = ActionsFeatureDescriptorEnum.migrateMenuActions;
    VisibilityExpression expression = new ActionsVisibleWhen(menu);
    IContributionItem ici = new ActionsCompositeContributionItem(this, menu);
    addActionsItem(MIGRATE_LABEL, expression, ici);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ActionsVisibleWhen(org.whole.lang.e4.ui.expressions.ActionsVisibleWhen) IContributionItem(org.eclipse.jface.action.IContributionItem) VisibilityExpression(org.whole.lang.e4.ui.expressions.VisibilityExpression) ActionsCompositeContributionItem(org.whole.lang.e4.ui.menu.ActionsCompositeContributionItem)

Example 23 with FeatureDescriptor

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

the class AbstractUIBuilder method addRefactorItem.

@Override
public void addRefactorItem() {
    FeatureDescriptor menu = ActionsFeatureDescriptorEnum.refactorMenuActions;
    VisibilityExpression expression = new ActionsVisibleWhen(menu);
    IContributionItem ici = new ActionsCompositeContributionItem(this, menu);
    addActionsItem(REFACTOR_LABEL, expression, ici);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ActionsVisibleWhen(org.whole.lang.e4.ui.expressions.ActionsVisibleWhen) IContributionItem(org.eclipse.jface.action.IContributionItem) VisibilityExpression(org.whole.lang.e4.ui.expressions.VisibilityExpression) ActionsCompositeContributionItem(org.whole.lang.e4.ui.menu.ActionsCompositeContributionItem)

Example 24 with FeatureDescriptor

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

the class AbstractUIBuilder method addAnalyzeItem.

@Override
public void addAnalyzeItem() {
    FeatureDescriptor menu = ActionsFeatureDescriptorEnum.analyzeMenuActions;
    VisibilityExpression expression = new ActionsVisibleWhen(menu);
    IContributionItem ici = new ActionsCompositeContributionItem(this, menu);
    addActionsItem(ANALYZE_LABEL, expression, ici);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ActionsVisibleWhen(org.whole.lang.e4.ui.expressions.ActionsVisibleWhen) IContributionItem(org.eclipse.jface.action.IContributionItem) VisibilityExpression(org.whole.lang.e4.ui.expressions.VisibilityExpression) ActionsCompositeContributionItem(org.whole.lang.e4.ui.menu.ActionsCompositeContributionItem)

Example 25 with FeatureDescriptor

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

the class CommonsDataTypePresentationParser method parseFeatureDescriptor.

public static FeatureDescriptor parseFeatureDescriptor(String value) {
    int index = value.indexOf('#');
    if (index > 0) {
        String languageUri = value.substring(0, index);
        ILanguageKit lk = /*= null;
			if (ReflectionFactory.hasLanguageKit(languageUri)) {
    			for (ILanguageKit lk2 : ReflectionFactory.getLanguageKits(true))
    				if (lk2.getName().equalsIgnoreCase(languageUri)) {
    					lk = lk2; 
    					break;
    				}
    		}
    		if (lk == null)
    			lk*/
        ReflectionFactory.getLanguageKit(languageUri);
        FeatureDescriptor fd = lk.getFeatureDescriptorEnum().valueOf(value.substring(index + 1));
        if (fd != null)
            return fd;
    }
    throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

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