Search in sources :

Example 1 with FunctionDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition in project hale by halestudio.

the class FunctionGraphContentProvider method getElements.

/**
 * @see ArrayContentProvider#getElements(Object)
 */
@Override
public Object[] getElements(Object inputElement) {
    Collection<Object> collection = new ArrayList<Object>();
    if (inputElement instanceof FunctionDefinition<?>) {
        FunctionDefinition<?> function = (FunctionDefinition<?>) inputElement;
        collection.add(function);
        if (inputElement instanceof TypeFunctionDefinition) {
            for (TypeParameterDefinition type : ((TypeFunctionDefinition) function).getSource()) {
                collection.add(new Pair<Object, Object>(type, function));
            }
            for (TypeParameterDefinition type : ((TypeFunctionDefinition) function).getTarget()) {
                collection.add(type);
            }
        }
        if (inputElement instanceof PropertyFunctionDefinition) {
            for (PropertyParameterDefinition prop : ((PropertyFunctionDefinition) function).getSource()) {
                collection.add(new Pair<Object, Object>(prop, function));
            }
            for (PropertyParameterDefinition prop : ((PropertyFunctionDefinition) function).getTarget()) {
                collection.add(prop);
            }
        }
        return collection.toArray();
    }
    return super.getElements(inputElement);
}
Also used : TypeFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition) TypeParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.TypeParameterDefinition) ArrayList(java.util.ArrayList) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition) TypeFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition) PropertyParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)

Example 2 with FunctionDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition in project hale by halestudio.

the class GraphLabelProvider method getText.

/**
 * @see LabelProvider#getText(Object)
 */
@Override
public String getText(Object element) {
    if (element instanceof Entity) {
        element = ((Entity) element).getDefinition();
    }
    if (element instanceof EntityDefinition) {
        // use definition text
        return definitionLabels.getText(element);
    }
    if (element instanceof Definition<?>) {
        // use definition text
        return definitionLabels.getText(element);
    }
    if (element instanceof Cell) {
        // use function name if possible
        Cell cell = (Cell) element;
        String functionId = cell.getTransformationIdentifier();
        FunctionDefinition<?> function = FunctionUtil.getFunction(functionId, serviceProvider);
        if (function != null) {
            return functionLabels.getText(function);
        }
        return functionId;
    }
    if (element instanceof FunctionDefinition) {
        return functionLabels.getText(element);
    }
    return super.getText(element);
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Definition(eu.esdihumboldt.hale.common.schema.model.Definition) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 3 with FunctionDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition in project hale by halestudio.

the class GraphLabelProvider method getImage.

/**
 * @see LabelProvider#getImage(Object)
 */
@Override
public Image getImage(Object element) {
    if (element instanceof Entity) {
        element = ((Entity) element).getDefinition();
    }
    if (element instanceof EntityDefinition || element instanceof Definition<?>) {
        // use definition image
        return definitionLabels.getImage(element);
    }
    if (element instanceof Cell) {
        // use function image if possible
        Cell cell = (Cell) element;
        String functionId = cell.getTransformationIdentifier();
        FunctionDefinition<?> function = FunctionUtil.getFunction(functionId, serviceProvider);
        if (function != null) {
            Image image = functionLabels.getImage(function);
            if (image == null) {
                // use a default image if none is available
                image = CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_FUNCTION);
            }
            if (cell.isBaseCell()) {
                Image baseAlignmentImage = baseAlignmentFunctionImages.get(functionId);
                if (baseAlignmentImage == null) {
                    baseAlignmentImage = new Image(image.getDevice(), image.getBounds());
                    GC gc = new GC(baseAlignmentImage);
                    try {
                        gc.drawImage(image, 0, 0);
                        gc.drawImage(baseAlignmentFunctionOverlay, 0, 0);
                    } finally {
                        gc.dispose();
                    }
                    baseAlignmentFunctionImages.put(functionId, baseAlignmentImage);
                }
                image = baseAlignmentImage;
            }
            return image;
        }
        return null;
    }
    if (element instanceof FunctionDefinition) {
        return functionLabels.getImage(element);
    }
    return super.getImage(element);
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition) Image(org.eclipse.swt.graphics.Image) GC(org.eclipse.swt.graphics.GC) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Example 4 with FunctionDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition in project hale by halestudio.

the class FunctionContentProvider method getChildren.

/**
 * @see ITreeContentProvider#getChildren(Object)
 */
@Override
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof Category) {
        Category category = (Category) parentElement;
        List<FunctionDefinition<?>> functions = new ArrayList<>();
        functions.addAll(Collections2.filter(FunctionUtil.getTypeFunctions(category.getId(), serviceProvider), this));
        functions.addAll(Collections2.filter(FunctionUtil.getPropertyFunctions(category.getId(), serviceProvider), this));
        return functions.toArray();
    }
    return null;
}
Also used : Category(eu.esdihumboldt.hale.common.align.extension.category.Category) ArrayList(java.util.ArrayList) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition)

Example 5 with FunctionDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition in project hale by halestudio.

the class FunctionContentProvider method getParent.

/**
 * @see ITreeContentProvider#getParent(Object)
 */
@Override
public Object getParent(Object element) {
    if (element instanceof FunctionDefinition<?>) {
        String catId = ((FunctionDefinition<?>) element).getCategoryId();
        Category cat = (catId == null) ? (null) : (CategoryExtension.getInstance().get(catId));
        if (cat == null) {
            cat = CAT_OTHER;
        }
        return cat;
    }
    return null;
}
Also used : Category(eu.esdihumboldt.hale.common.align.extension.category.Category) FunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition)

Aggregations

FunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition)8 Entity (eu.esdihumboldt.hale.common.align.model.Entity)4 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)4 Category (eu.esdihumboldt.hale.common.align.extension.category.Category)3 Cell (eu.esdihumboldt.hale.common.align.model.Cell)3 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)2 ArrayList (java.util.ArrayList)2 Function (com.google.common.base.Function)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Collections2 (com.google.common.collect.Collections2)1 ListMultimap (com.google.common.collect.ListMultimap)1 Multimaps (com.google.common.collect.Multimaps)1 AnnotationExtension (eu.esdihumboldt.hale.common.align.extension.annotation.AnnotationExtension)1 FunctionUtil (eu.esdihumboldt.hale.common.align.extension.function.FunctionUtil)1 PropertyFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition)1 PropertyParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)1 TypeFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition)1 TypeParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.TypeParameterDefinition)1 CustomPropertyFunction (eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)1 EntityResolver (eu.esdihumboldt.hale.common.align.io.EntityResolver)1