]> gerrit.simantics Code Review - simantics/platform.git/blob
1810722ae52be316f130c2c83bfc7d60ec067e1e
[simantics/platform.git] /
1 package org.simantics.diagram.profile.view;
2
3 import java.util.Collections;
4 import java.util.Map;
5
6 import org.simantics.browsing.ui.common.ColumnKeys;
7 import org.simantics.browsing.ui.model.labels.LabelRule;
8 import org.simantics.db.ReadGraph;
9 import org.simantics.db.common.utils.NameUtils;
10 import org.simantics.db.exception.DatabaseException;
11
12 public class ResourcePairLabelRule implements LabelRule {
13         
14     public static final ResourcePairLabelRule INSTANCE = new ResourcePairLabelRule();
15     
16     public ResourcePairLabelRule() {
17     }
18
19     @Override
20     public boolean isCompatible(Class<?> contentType) {
21         return contentType.equals(ResourcePair.class);
22     }
23
24     @Override
25     public Map<String,String> getLabel(ReadGraph graph, Object content) throws DatabaseException {
26         return Collections.singletonMap(ColumnKeys.SINGLE, 
27                 NameUtils.getSafeLabel(graph, ((ResourcePair)content).getSecond())
28                 );
29     }
30 }