]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/IssueLabelRule.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.issues.ui / src / org / simantics / issues / ui / IssueLabelRule.java
1 /*******************************************************************************\r
2  * Copyright (c) 2010, 2011 Association for Decentralized Information Management in\r
3  * 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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.issues.ui;\r
13 \r
14 import java.util.Map;\r
15 \r
16 import org.simantics.browsing.ui.common.ColumnKeys;\r
17 import org.simantics.browsing.ui.model.labels.LabelRule;\r
18 import org.simantics.db.ReadGraph;\r
19 import org.simantics.db.exception.DatabaseException;\r
20 import org.simantics.db.layer0.variable.Variable;\r
21 import org.simantics.utils.datastructures.ArrayMap;\r
22 import org.simantics.utils.strings.StringUtils;\r
23 \r
24 public class IssueLabelRule implements LabelRule {\r
25 \r
26     public static final IssueLabelRule INSTANCE = new IssueLabelRule();\r
27 \r
28     private static final String[] COLS = new String[] { ColumnKeys.SINGLE, "Resource", "Path" };\r
29 \r
30     public IssueLabelRule() {\r
31     }\r
32 \r
33     @Override\r
34     public boolean isCompatible(Class<?> contentType) {\r
35         return contentType.equals(Variable.class);\r
36     }\r
37 \r
38     @Override\r
39     public Map<String,String> getLabel(ReadGraph graph, Object content) throws DatabaseException {\r
40 \r
41         Variable issue = (Variable)content;\r
42         //Layer0 L0 = Layer0.getInstance(graph);\r
43         //IssueResource ISSUE = IssueResource.getInstance(graph);\r
44         String description = StringUtils.safeString( (String) issue.getPossiblePropertyValue(graph, "HasDescription") );\r
45         String resource = StringUtils.safeString( (String) issue.getPossiblePropertyValue(graph, "resource") );\r
46         String path = StringUtils.safeString( (String) issue.getPossiblePropertyValue(graph, "path") );\r
47 \r
48         String[] result = new String[] { description, resource, path };\r
49         return new ArrayMap<String, String>(COLS, result);\r
50 \r
51     }\r
52 }\r