1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.issues.ui.contribution;
\r
14 import org.eclipse.jface.resource.FontDescriptor;
\r
15 import org.eclipse.swt.SWT;
\r
16 import org.simantics.browsing.ui.content.LabelDecorator;
\r
17 import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule;
\r
18 import org.simantics.db.ReadGraph;
\r
19 import org.simantics.db.Resource;
\r
20 import org.simantics.db.exception.DatabaseException;
\r
21 import org.simantics.issues.ontology.IssueResource;
\r
24 * @author Tuukka Lehtonen
\r
26 public enum IssueLabelDecorationRule implements LabelDecorationRule {
\r
30 public static IssueLabelDecorationRule get() {
\r
35 public boolean isCompatible(Class<?> contentType) {
\r
36 return contentType.equals(Resource.class);
\r
40 public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException {
\r
41 Resource issue = (Resource) content;
\r
43 final boolean hidden = graph.hasStatement(issue, IssueResource.getInstance(graph).Hidden);
\r
44 final boolean user = graph.hasStatement(issue, IssueResource.getInstance(graph).UserIssue);
\r
45 final boolean resolved = graph.hasStatement(issue, IssueResource.getInstance(graph).Resolved);
\r
46 if (!hidden && !user && !resolved)
\r
49 return new LabelDecorator.Stub() {
\r
50 @SuppressWarnings("unchecked")
\r
52 public <F> F decorateFont(F font, String column, int itemIndex) {
\r
54 style |= resolved ? SWT.ITALIC : 0;
\r
55 return style != 0 ? (F) ((FontDescriptor) font).setStyle(style) : font;
\r
57 @SuppressWarnings("unchecked")
\r
59 public <C> C decorateForeground(C color, String column, int itemIndex) {
\r
61 return (C) Constants.HIDDEN_FG;
\r
64 @SuppressWarnings("unchecked")
\r
66 public <C> C decorateBackground(C color, String column, int itemIndex) {
\r
68 return (C) Constants.USER_BG;
\r