use of org.eclipse.zest.core.viewers.EntityConnectionData in project hale by halestudio.
the class TransformationTreeLabelProvider method getText.
/**
* @see GraphLabelProvider#getText(Object)
*/
@Override
public String getText(Object element) {
if (element instanceof IdentityWrapper<?>) {
element = ((IdentityWrapper<?>) element).getValue();
}
if (element instanceof EntityConnectionData) {
// text for connections
EntityConnectionData connection = (EntityConnectionData) element;
Set<String> names = null;
Object source = connection.source;
if (source instanceof IdentityWrapper<?>) {
source = ((IdentityWrapper<?>) source).getValue();
}
Object dest = connection.dest;
if (dest instanceof IdentityWrapper<?>) {
dest = ((IdentityWrapper<?>) dest).getValue();
}
if (source instanceof TargetNode && dest instanceof CellNode) {
names = ((TargetNode) source).getAssignmentNames((CellNode) dest);
}
if (source instanceof CellNode && dest instanceof SourceNode) {
names = ((CellNode) source).getSourceNames((SourceNode) dest);
}
if (names != null && !names.isEmpty()) {
if (names.contains(null)) {
names = new HashSet<String>(names);
names.remove(null);
if (!names.isEmpty()) {
names.add("(unnamed)");
}
}
// build name string
Joiner joiner = Joiner.on(',');
return joiner.join(names);
}
return "";
}
if (hasTransformationAnnotations(element)) {
if (element instanceof SourceNode) {
SourceNode node = (SourceNode) element;
if (node.isDefined()) {
Object value = node.getValue();
if (value == null) {
// no value
return "(not set)";
} else if (value instanceof Instance) {
// use the instance value if present
value = ((Instance) value).getValue();
}
if (value != null && !(value instanceof Group)) {
// TODO shorten if needed?
return value.toString();
}
// otherwise, just display the definition name
}
}
}
element = TransformationTreeUtil.extractObject(element);
return super.getText(element);
}
Aggregations