1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 Association for Decentralized Information Management in
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;
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;
24 public class IssueLabelRule implements LabelRule {
26 public static final IssueLabelRule INSTANCE = new IssueLabelRule();
28 private static final String[] COLS = new String[] { ColumnKeys.SINGLE, "Resource", "Path" };
30 public IssueLabelRule() {
34 public boolean isCompatible(Class<?> contentType) {
35 return contentType.equals(Variable.class);
39 public Map<String,String> getLabel(ReadGraph graph, Object content) throws DatabaseException {
41 Variable issue = (Variable)content;
42 String description = StringUtils.safeString( (String) issue.getPossiblePropertyValue(graph, "HasDescription") );
43 String resource = StringUtils.safeString( (String) issue.getPossiblePropertyValue(graph, "resource") );
44 String path = StringUtils.safeString( (String) issue.getPossiblePropertyValue(graph, "path") );
46 String[] result = new String[] { description, resource, path };
47 return new ArrayMap<String, String>(COLS, result);