+/*******************************************************************************\r
+ * Copyright (c) 2007, 2012 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.charts.ui;\r
+\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.model.modifiers.NoModifierRule;\r
+import org.simantics.browsing.ui.model.modifiers.StringPropertyModifierRule;\r
+import org.simantics.charts.ontology.ChartResource;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class ChartItemNameModifierRule extends StringPropertyModifierRule {\r
+\r
+ public ChartItemNameModifierRule(ReadGraph graph) throws DatabaseException {\r
+ super(graph, Layer0.URIs.HasLabel);\r
+ }\r
+\r
+ @Override\r
+ public Modifier getModifier(ReadGraph graph, Object content, String columnKey) throws DatabaseException {\r
+ if (!ColumnKeys.SINGLE.equals(columnKey))\r
+ return null;\r
+ if (!(content instanceof Resource))\r
+ return null;\r
+\r
+ Resource resource = (Resource)content;\r
+ ChartResource CHART = ChartResource.getInstance(graph);\r
+ Resource subscriptionItemResource = graph.getPossibleObject(resource, CHART.Chart_Item_HasSubscriptionItem);\r
+ if (subscriptionItemResource == null)\r
+ return NoModifierRule.NO_MODIFIER;\r
+\r
+ return super.getModifier(graph, subscriptionItemResource, columnKey);\r
+ }\r
+\r
+}
\ No newline at end of file