org.simantics.browsing.ui.model.labels.LabelContribution.getLabel used
to log all DatabaseExceptions which filled logs with very uninformative
PendingVariableException prints in normal operation.
PendingVariableExceptions are expected to happen in this context and
therefore should simply be ignored by returning empty labeling results.
refs #7011
Change-Id: Iec164d65682da038646c9fbfbee074016546095e
import org.simantics.browsing.ui.model.visuals.VisualsContribution;
import org.simantics.db.ReadGraph;
import org.simantics.db.exception.DatabaseException;
import org.simantics.browsing.ui.model.visuals.VisualsContribution;
import org.simantics.db.ReadGraph;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.exception.PendingVariableException;
/**
* Produces labels for nodes of given node type.
/**
* Produces labels for nodes of given node type.
*/
public class LabelContribution extends VisualsContribution {
LabelRule labelRule;
*/
public class LabelContribution extends VisualsContribution {
LabelRule labelRule;
public LabelContribution(NodeType nodeType, Test test, LabelRule labelRule, double priority) throws InvalidContribution {
super(nodeType, test, priority);
if(!labelRule.isCompatible(
public LabelContribution(NodeType nodeType, Test test, LabelRule labelRule, double priority) throws InvalidContribution {
super(nodeType, test, priority);
if(!labelRule.isCompatible(
throw new InvalidContribution("Label rule is not compatible with the content type.");
this.labelRule = labelRule;
}
throw new InvalidContribution("Label rule is not compatible with the content type.");
this.labelRule = labelRule;
}
/**
* Returns a label for the node or null, if contribution is
* not suitable for the input.
/**
* Returns a label for the node or null, if contribution is
* not suitable for the input.
public Map<String, String> getLabel(ReadGraph graph, NodeContext context) {
Object content = context.getConstant(BuiltinKeys.INPUT);
try {
public Map<String, String> getLabel(ReadGraph graph, NodeContext context) {
Object content = context.getConstant(BuiltinKeys.INPUT);
try {
- if(test == null || test.test(graph, content))
+ if(test == null || test.test(graph, content))
return labelRule.getLabel(graph, content);
else
return null;
return labelRule.getLabel(graph, content);
else
return null;
+ } catch(PendingVariableException e) {
+ return Collections.singletonMap(ColumnKeys.SINGLE, "");
} catch(DatabaseException e) {
ErrorLogger.defaultLogError(e);
} catch(DatabaseException e) {
ErrorLogger.defaultLogError(e);
- //Logger.defaultLogError(e);
- // TODO reconsider
return Collections.singletonMap(ColumnKeys.SINGLE, "");
}
return Collections.singletonMap(ColumnKeys.SINGLE, "");
}