X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.issues.ui%2Fsrc%2Forg%2Fsimantics%2Fissues%2Fui%2Fcontribution%2FIssueLabelDecorationRule.java;h=eb78ecc22f2ecd80910da183c1f93d57fd9e9467;hp=7f77719678fec7bb07e20f23a770b70a460379f0;hb=47269fe0acb894f346810417d950a1ab59cdc0ea;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07 diff --git a/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/contribution/IssueLabelDecorationRule.java b/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/contribution/IssueLabelDecorationRule.java index 7f7771967..eb78ecc22 100644 --- a/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/contribution/IssueLabelDecorationRule.java +++ b/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/contribution/IssueLabelDecorationRule.java @@ -15,9 +15,11 @@ import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.swt.SWT; import org.simantics.browsing.ui.content.LabelDecorator; import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; import org.simantics.issues.ontology.IssueResource; /** @@ -33,42 +35,75 @@ public enum IssueLabelDecorationRule implements LabelDecorationRule { @Override public boolean isCompatible(Class contentType) { - return contentType.equals(Resource.class); + return contentType.equals(Variable.class); } @Override public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException { - Resource issue = (Resource) content; + Variable issue = (Variable) content; - final boolean hidden = graph.hasStatement(issue, IssueResource.getInstance(graph).Hidden); - final boolean user = graph.hasStatement(issue, IssueResource.getInstance(graph).UserIssue); - final boolean resolved = graph.hasStatement(issue, IssueResource.getInstance(graph).Resolved); - if (!hidden && !user && !resolved) - return null; + boolean hidden = false; + boolean user = false; + boolean resolved = false; - return new LabelDecorator.Stub() { - @SuppressWarnings("unchecked") - @Override - public F decorateFont(F font, String column, int itemIndex) { - int style = 0; - style |= resolved ? SWT.ITALIC : 0; - return style != 0 ? (F) ((FontDescriptor) font).setStyle(style) : font; - } - @SuppressWarnings("unchecked") - @Override - public C decorateForeground(C color, String column, int itemIndex) { - if (hidden) - return (C) Constants.HIDDEN_FG; - return color; - } - @SuppressWarnings("unchecked") - @Override - public C decorateBackground(C color, String column, int itemIndex) { - if (user) - return (C) Constants.USER_BG; - return color; - } - }; + Resource issueR = issue.getPossibleRepresents(graph); + if (issueR != null) { + IssueResource ISSUE = IssueResource.getInstance(graph); + hidden = graph.hasStatement(issueR, ISSUE.Hidden); + user = graph.hasStatement(issueR, ISSUE.UserIssue); + resolved = graph.hasStatement(issueR, ISSUE.Resolved); + } else { + hidden = Boolean.TRUE.equals(issue.getPossiblePropertyValue(graph, "hidden", Bindings.BOOLEAN)); //$NON-NLS-1$ + } + + int index = (hidden ? 1 : 0) + (user ? 2 : 0) + (resolved ? 4 : 0); + return DECORATORS[index]; } + private static final Decorator[] DECORATORS = { + null, + new Decorator(true, false, false), + new Decorator(false, true, false), + new Decorator(true, true, false), + new Decorator(false, false, true), + new Decorator(true, false, true), + new Decorator(false, true, true), + new Decorator(true, true, true), + }; + + private static class Decorator extends LabelDecorator.Stub { + private boolean hidden; + private boolean user; + private boolean resolved; + + public Decorator(boolean hidden, boolean user, boolean resolved) { + this.hidden = hidden; + this.user = user; + this.resolved = resolved; + } + + @SuppressWarnings("unchecked") + @Override + public F decorateFont(F font, String column, int itemIndex) { + int style = 0; + style |= resolved ? SWT.ITALIC : 0; + //style |= hidden ? SWT.BOLD : 0; + return style != 0 ? (F) ((FontDescriptor) font).setStyle(style) : font; + } + @SuppressWarnings("unchecked") + @Override + public C decorateForeground(C color, String column, int itemIndex) { + if (hidden) + return (C) Constants.HIDDEN_FG; + return color; + } + @SuppressWarnings("unchecked") + @Override + public C decorateBackground(C color, String column, int itemIndex) { + if (user) + return (C) Constants.USER_BG; + return color; + } + }; + }