refs #7393
Change-Id: Ifd473d11d0987f112c2bf616f2619d05cdf7c055
import org.simantics.layer0.Layer0;
public class DescriptionTooltipRule implements TooltipRule {
import org.simantics.layer0.Layer0;
public class DescriptionTooltipRule implements TooltipRule {
public static final DescriptionTooltipRule INSTANCE = new DescriptionTooltipRule();
public static final DescriptionTooltipRule INSTANCE = new DescriptionTooltipRule();
public DescriptionTooltipRule() {
}
public DescriptionTooltipRule() {
}
public boolean isCompatible(Class<?> contentType) {
return (contentType == Resource.class || contentType == Variable.class);
}
public boolean isCompatible(Class<?> contentType) {
return (contentType == Resource.class || contentType == Variable.class);
}
private static String getToolTipContent(ReadGraph graph, NodeContext nodeContext) throws DatabaseException {
Object input = nodeContext.getConstant(BuiltinKeys.INPUT);
private static String getToolTipContent(ReadGraph graph, NodeContext nodeContext) throws DatabaseException {
Object input = nodeContext.getConstant(BuiltinKeys.INPUT);
if (input instanceof Variable) {
Variable var = (Variable) input;
if (input instanceof Variable) {
Variable var = (Variable) input;
- Resource res = var.getPredicateResource(graph);
- Layer0 L0 = Layer0.getInstance(graph);
- String description = graph.getPossibleRelatedValue2(res, L0.HasDescription);
- return description;
+ Resource res = var.getPossiblePredicateResource(graph);
+ if (res != null) {
+ Layer0 L0 = Layer0.getInstance(graph);
+ return graph.getPossibleRelatedValue2(res, L0.HasDescription);
+ }
} else if (input instanceof Resource) {
Resource res = (Resource) input;
} else if (input instanceof Resource) {
Resource res = (Resource) input;
Layer0 L0 = Layer0.getInstance(graph);
Layer0 L0 = Layer0.getInstance(graph);
- String description = graph.getPossibleRelatedValue2(res, L0.HasDescription);
- return description;
+ return graph.getPossibleRelatedValue2(res, L0.HasDescription);
- public boolean shouldCreateToolTip(ReadGraph graph , NodeContext context, Map<Object, Object> auxiliary) throws DatabaseException {
+ public boolean shouldCreateToolTip(ReadGraph graph, NodeContext context, Map<Object, Object> auxiliary) throws DatabaseException {
String content = getToolTipContent(graph, context);
if (content == null || content.isEmpty())
return false;
String content = getToolTipContent(graph, context);
if (content == null || content.isEmpty())
return false;