X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.model%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fmodel%2Flabeldecorators%2FConstantLabelDecorationRule.java;h=5ba9ced6ed3fa07ca9ae71f96e8661818cb00044;hb=HEAD;hp=3bb2db942095c6a34390377a2d69488c57d2c094;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java index 3bb2db942..5ba9ced6e 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java @@ -14,6 +14,7 @@ package org.simantics.browsing.ui.model.labeldecorators; import org.eclipse.jface.resource.ColorDescriptor; import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; import org.simantics.browsing.ui.content.LabelDecorator; import org.simantics.databoard.Bindings; @@ -21,6 +22,8 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; import org.simantics.viewpoint.ontology.ViewpointResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Constant label decoration rule decorates the label in a fixed way. @@ -28,6 +31,12 @@ import org.simantics.viewpoint.ontology.ViewpointResource; */ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implements LabelDecorationRule { + private static final Logger LOGGER = LoggerFactory.getLogger(ConstantLabelDecorationRule.class); + /** + * For headless instances where no Display is available + */ + private static final FontDescriptor DEFAULT_FONT_DESCRIPTOR = FontDescriptor.createFrom(new FontData("Arial", 11, 0)); + String prefix; String postfix; ColorDescriptor foregroundColor; @@ -63,7 +72,7 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen this.style |= SWT.ITALIC; break; default: - System.err.println("Invalid character '" + c + "' in style string. Only B and I recognized."); + LOGGER.info("Invalid character '" + c + "' in style string. Only B and I recognized."); } } @@ -133,6 +142,8 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen return font; else { FontDescriptor desc = (FontDescriptor)font; + if(desc == null) + desc = DEFAULT_FONT_DESCRIPTOR; return (Font)desc.withStyle(style); } }