1 package org.simantics.tests.modelled.ui.rules;
3 import java.util.Collections;
6 import org.eclipse.jface.resource.ImageDescriptor;
7 import org.simantics.browsing.ui.common.ColumnKeys;
8 import org.simantics.browsing.ui.model.images.ImageRule;
9 import org.simantics.databoard.Bindings;
10 import org.simantics.db.ReadGraph;
11 import org.simantics.db.Resource;
12 import org.simantics.db.exception.DatabaseException;
13 import org.simantics.tests.modelled.ontology.TestsResource;
14 import org.simantics.tests.modelled.ui.ontology.TestsUIResource;
16 public class TestImageRule implements ImageRule {
18 private ImageDescriptor testImage;
19 private ImageDescriptor testIgnoredImage;
21 public TestImageRule(ReadGraph graph) throws DatabaseException {
22 TestsUIResource TESTS = TestsUIResource.getInstance(graph);
23 testImage = graph.adapt(TESTS.testImage, ImageDescriptor.class);
24 testIgnoredImage = graph.adapt(TESTS.testIgnoredImage, ImageDescriptor.class);
28 public boolean isCompatible(Class<?> contentType) {
29 return Resource.class.equals(contentType);
33 public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {
34 Resource resource = (Resource) content;
35 Boolean ignored = graph.getPossibleRelatedValue2(resource, TestsResource.getInstance(graph).ignore,
37 if (ignored != null && ignored)
38 return Collections.singletonMap(ColumnKeys.SINGLE, testIgnoredImage);
39 return Collections.singletonMap(ColumnKeys.SINGLE, testImage);