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);
}
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");
}
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();
}
Aggregations