X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.issues.ui%2Fsrc%2Forg%2Fsimantics%2Fissues%2Fui%2Fcontribution%2FIssueLabelDecorationRule.java;fp=bundles%2Forg.simantics.issues.ui%2Fsrc%2Forg%2Fsimantics%2Fissues%2Fui%2Fcontribution%2FIssueLabelDecorationRule.java;h=7f77719678fec7bb07e20f23a770b70a460379f0;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=6547dd6792b370f09d07e682d330bafa7f7ab13d;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git 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 6547dd679..7f7771967 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 @@ -1,74 +1,74 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.issues.ui.contribution; - -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.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.issues.ontology.IssueResource; - -/** - * @author Tuukka Lehtonen - */ -public enum IssueLabelDecorationRule implements LabelDecorationRule { - - INSTANCE; - - public static IssueLabelDecorationRule get() { - return INSTANCE; - } - - @Override - public boolean isCompatible(Class contentType) { - return contentType.equals(Resource.class); - } - - @Override - public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException { - Resource issue = (Resource) 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; - - 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; - } - }; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.issues.ui.contribution; + +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.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.issues.ontology.IssueResource; + +/** + * @author Tuukka Lehtonen + */ +public enum IssueLabelDecorationRule implements LabelDecorationRule { + + INSTANCE; + + public static IssueLabelDecorationRule get() { + return INSTANCE; + } + + @Override + public boolean isCompatible(Class contentType) { + return contentType.equals(Resource.class); + } + + @Override + public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException { + Resource issue = (Resource) 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; + + 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; + } + }; + } + +}