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