Search in sources :

Example 1 with GenericPropertyFunctionWizardFactory

use of eu.esdihumboldt.hale.ui.function.generic.GenericPropertyFunctionWizardFactory 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)

Aggregations

PropertyFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyFunctionDefinition)1 TypeFunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.TypeFunctionDefinition)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