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;
14 import java.util.Collections;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.simantics.browsing.ui.common.ColumnKeys;
19 import org.simantics.browsing.ui.model.images.ImageRule;
20 import org.simantics.db.ReadGraph;
21 import org.simantics.db.Resource;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.db.layer0.variable.Variable;
24 import org.simantics.issues.ontology.IssueResource;
25 import org.simantics.silk.SilkResources;
28 * @author Tuukka Lehtonen
30 public class IssueImageRule implements ImageRule {
32 private final String DESCRIPTION = ColumnKeys.SINGLE;
35 public boolean isCompatible(Class<?> contentType) {
36 return contentType.equals(Variable.class);
40 public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {
42 Variable issue = (Variable)content;
44 IssueResource ISSUE = IssueResource.getInstance(graph);
45 SilkResources SILK = SilkResources.getInstance(graph);
46 String severity = issue.getPropertyValue(graph, "severity");
48 // TODO: now to do this with variables?
49 Resource issueResource = issue.getPossibleRepresents(graph);
50 boolean resolved = issueResource != null ? graph.hasStatement(issueResource, ISSUE.Resolved) : false;
52 return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.tick, ImageDescriptor.class));
54 if("Fatal".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.bomb, ImageDescriptor.class));
55 else if("Error".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.exclamation, ImageDescriptor.class));
56 else if("Warning".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.error, ImageDescriptor.class));
57 else if("Info".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.information, ImageDescriptor.class));
58 else if("Note".equals(severity)) return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.note, ImageDescriptor.class));
59 else return Collections.singletonMap(DESCRIPTION, graph.adapt(SILK.help, ImageDescriptor.class));