use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class CellGraphContentProvider method getEdges.
/**
* Get all edges for the given cells.
*
* @param cells an iterable of {@link Cell}s, other objects will be ignored
* @return the array of edges
*/
protected Object[] getEdges(Iterable<?> cells) {
List<Edge> edges = new ArrayList<Edge>();
for (Object object : cells) {
if (object instanceof Cell) {
Cell cell = (Cell) object;
addEdges(cell, edges);
}
}
return edges.toArray();
}
use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class TransformationTreeContentProvider method getElements.
/**
* @see ArrayContentProvider#getElements(Object)
*/
@SuppressWarnings("unchecked")
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof TransformationTree)
return collectNodes((TransformationTree) inputElement).toArray();
Collection<Instance> instances = null;
if (inputElement instanceof Pair<?, ?>) {
Pair<?, ?> pair = (Pair<?, ?>) inputElement;
inputElement = pair.getFirst();
if (pair.getSecond() instanceof Collection<?>) {
instances = (Collection<Instance>) pair.getSecond();
}
}
if (inputElement instanceof Alignment) {
Alignment alignment = (Alignment) inputElement;
// input contained specific instances
if (instances != null && !instances.isEmpty()) {
Collection<Object> result = new ArrayList<Object>();
// create transformation trees for each instance
for (Instance instance : instances) {
// find type cells matching the instance
Collection<? extends Cell> typeCells = alignment.getActiveTypeCells();
Collection<Cell> associatedTypeCells = new LinkedList<Cell>();
for (Cell typeCell : typeCells) for (Entity entity : typeCell.getSource().values()) {
TypeEntityDefinition type = (TypeEntityDefinition) entity.getDefinition();
if (type.getDefinition().equals(instance.getDefinition()) && (type.getFilter() == null || type.getFilter().match(instance))) {
associatedTypeCells.add(typeCell);
break;
}
}
// for each type cell one tree
for (Cell cell : associatedTypeCells) {
TransformationTree tree = createInstanceTree(instance, cell, alignment);
if (tree != null)
result.addAll(collectNodes(tree));
}
}
return result.toArray();
}
// input was alignment only, show trees for all type cells
Collection<? extends Cell> typeCells = alignment.getActiveTypeCells();
Collection<Object> result = new ArrayList<Object>(typeCells.size());
for (Cell typeCell : typeCells) {
// create tree and add nodes for each cell
result.addAll(collectNodes(new TransformationTreeImpl(alignment, typeCell)));
}
return result.toArray();
}
return super.getElements(inputElement);
}
use of eu.esdihumboldt.hale.common.align.model.Cell 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.model.Cell 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.model.Cell in project hale by halestudio.
the class ClassificationMappingParameterPage method onShowPage.
@Override
protected void onShowPage(boolean firstShow) {
super.onShowPage(firstShow);
Cell unfinishedCell = getWizard().getUnfinishedCell();
sourceEntity = (PropertyEntityDefinition) unfinishedCell.getSource().values().iterator().next().getDefinition();
sourceProperty = sourceEntity.getDefinition();
targetEntity = (PropertyEntityDefinition) unfinishedCell.getTarget().values().iterator().next().getDefinition();
targetProperty = targetEntity.getDefinition();
if (fixedValueText == null || fixedValueText.getText() != null)
setPageComplete(true);
}
Aggregations