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