Search in sources :

Example 1 with TypeFunctionDefinition

use of eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition 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 TypeFunctionDefinition

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

the class FunctionWizardExtension method getWizardDescriptor.

/**
 * Get the wizard descriptor for the given function ID. If no wizard
 * descriptor is available for the function in the extension, a generic
 * wizard descriptor will be created.
 *
 * @param functionId the function ID
 * @return the wizard descriptor
 */
public FunctionWizardDescriptor<?> getWizardDescriptor(final String functionId) {
    // retrieve matching wizards from extension
    List<FunctionWizardDescriptor<?>> factories = getFactories(new FactoryFilter<FunctionWizardFactory, FunctionWizardDescriptor<?>>() {

        @Override
        public boolean acceptFactory(FunctionWizardDescriptor<?> factory) {
            return factory.getFunctionId().equals(functionId);
        }

        @Override
        public boolean acceptCollection(ExtensionObjectFactoryCollection<FunctionWizardFactory, FunctionWizardDescriptor<?>> collection) {
            return true;
        }
    });
    if (factories != null && !factories.isEmpty()) {
        return factories.get(0);
    }
    // try to create descriptor for generic wizard
    // check if type function
    TypeFunctionDefinition typeFunction = FunctionUtil.getTypeFunction(functionId, HaleUI.getServiceProvider());
    if (typeFunction != null) {
        return new FactoryWizardDescriptor<TypeFunctionDefinition>(new GenericTypeFunctionWizardFactory(functionId), typeFunction);
    }
    // check if property function
    PropertyFunctionDefinition propertyFunction = FunctionUtil.getPropertyFunction(functionId, HaleUI.getServiceProvider());
    if (propertyFunction != null) {
        return new FactoryWizardDescriptor<PropertyFunctionDefinition>(new GenericPropertyFunctionWizardFactory(functionId), propertyFunction);
    }
    throw new IllegalArgumentException("Function with ID " + functionId + " is unknown");
}
Also used : TypeFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition) GenericPropertyFunctionWizardFactory(eu.esdihumboldt.hale.ui.function.generic.GenericPropertyFunctionWizardFactory) GenericTypeFunctionWizardFactory(eu.esdihumboldt.hale.ui.function.generic.GenericTypeFunctionWizardFactory) GenericPropertyFunctionWizardFactory(eu.esdihumboldt.hale.ui.function.generic.GenericPropertyFunctionWizardFactory) FactoryWizardDescriptor(eu.esdihumboldt.hale.ui.function.extension.impl.FactoryWizardDescriptor) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition) GenericTypeFunctionWizardFactory(eu.esdihumboldt.hale.ui.function.generic.GenericTypeFunctionWizardFactory)

Example 3 with TypeFunctionDefinition

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

the class AbstractFunctionWizardContribution method getFunctionWizardDescriptors.

/**
 * Get the currently applicable function wizard descriptors
 *
 * @return the function wizard descriptors
 */
protected Collection<FunctionWizardDescriptor<?>> getFunctionWizardDescriptors() {
    FunctionWizardExtension fwe = FunctionWizardExtension.getInstance();
    Collection<FunctionWizardDescriptor<?>> result = new ArrayList<FunctionWizardDescriptor<?>>();
    // add wizards for type functions
    for (TypeFunctionDefinition function : FunctionUtil.getTypeFunctions(HaleUI.getServiceProvider())) {
        result.add(fwe.getWizardDescriptor(function.getId()));
    }
    // add wizards for property functions
    for (PropertyFunctionDefinition function : FunctionUtil.getPropertyFunctions(HaleUI.getServiceProvider())) {
        result.add(fwe.getWizardDescriptor(function.getId()));
    }
    return result;
// return FunctionWizardExtension.getInstance().getFactories();
}
Also used : FunctionWizardExtension(eu.esdihumboldt.hale.ui.function.extension.FunctionWizardExtension) TypeFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition) ArrayList(java.util.ArrayList) FunctionWizardDescriptor(eu.esdihumboldt.hale.ui.function.extension.FunctionWizardDescriptor) PropertyFunctionDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition)

Aggregations

PropertyFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition)3 TypeFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition)3 ArrayList (java.util.ArrayList)2 FunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition)1 PropertyParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)1 TypeParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.TypeParameterDefinition)1 FunctionWizardDescriptor (eu.esdihumboldt.hale.ui.function.extension.FunctionWizardDescriptor)1 FunctionWizardExtension (eu.esdihumboldt.hale.ui.function.extension.FunctionWizardExtension)1 FactoryWizardDescriptor (eu.esdihumboldt.hale.ui.function.extension.impl.FactoryWizardDescriptor)1 GenericPropertyFunctionWizardFactory (eu.esdihumboldt.hale.ui.function.generic.GenericPropertyFunctionWizardFactory)1 GenericTypeFunctionWizardFactory (eu.esdihumboldt.hale.ui.function.generic.GenericTypeFunctionWizardFactory)1