Search in sources :

Example 1 with TypeCondition

use of eu.esdihumboldt.hale.common.align.model.condition.TypeCondition in project hale by halestudio.

the class TypeParameter method createConditions.

private static List<TypeCondition> createConditions(IConfigurationElement conf) {
    List<TypeCondition> result = new ArrayList<TypeCondition>();
    IConfigurationElement[] children = conf.getChildren();
    if (children != null) {
        for (IConfigurationElement child : children) {
            String name = child.getName();
            if (name.equals("typeCondition")) {
                try {
                    TypeCondition condition = (TypeCondition) child.createExecutableExtension("class");
                    result.add(condition);
                } catch (CoreException e) {
                    log.error("Error creating property condition from extension", e);
                }
            } else {
            // ignore
            // log.error("Unrecognized property condition");
            }
        }
    }
    return result;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) TypeCondition(eu.esdihumboldt.hale.common.align.model.condition.TypeCondition) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 2 with TypeCondition

use of eu.esdihumboldt.hale.common.align.model.condition.TypeCondition in project hale by halestudio.

the class TypeEntitySelector method createFilters.

private static ViewerFilter[] createFilters(TypeParameterDefinition field) {
    if (field == null) {
        return null;
    }
    List<TypeCondition> conditions = field.getConditions();
    if (conditions == null)
        return new ViewerFilter[0];
    ViewerFilter[] filters = new ViewerFilter[conditions.size()];
    int i = 0;
    for (final TypeCondition condition : conditions) {
        filters[i] = new ViewerFilter() {

            @Override
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                if (element instanceof TypeEntityDefinition) {
                    Type property = new DefaultType((TypeEntityDefinition) element);
                    return condition.accept(property);
                } else
                    return false;
            }
        };
    }
    return filters;
}
Also used : TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) Type(eu.esdihumboldt.hale.common.align.model.Type) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) DefaultType(eu.esdihumboldt.hale.common.align.model.impl.DefaultType) TypeCondition(eu.esdihumboldt.hale.common.align.model.condition.TypeCondition) Viewer(org.eclipse.jface.viewers.Viewer)

Aggregations

TypeCondition (eu.esdihumboldt.hale.common.align.model.condition.TypeCondition)2 Type (eu.esdihumboldt.hale.common.align.model.Type)1 DefaultType (eu.esdihumboldt.hale.common.align.model.impl.DefaultType)1 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1