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