--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 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.modeling.ui.modelBrowser2.label;\r
+\r
+import org.eclipse.jface.resource.FontDescriptor;\r
+import org.eclipse.swt.SWT;\r
+import org.simantics.browsing.ui.content.LabelDecorator;\r
+import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.modeling.ModelingResources;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class ConnectionRelationLabelDecorationRule implements LabelDecorationRule {\r
+\r
+ public static final ConnectionRelationLabelDecorationRule INSTANCE = new ConnectionRelationLabelDecorationRule();\r
+\r
+ static LabelDecorator DECO = new LabelDecorator.Stub() {\r
+ @SuppressWarnings("unchecked")\r
+ public <F> F decorateFont(F font, String column, int itemIndex) {\r
+ return (F) ((FontDescriptor) font).withStyle(SWT.BOLD); \r
+ }\r
+ };\r
+\r
+ @Override\r
+ public boolean isCompatible(Class<?> contentType) {\r
+ return contentType.equals(Resource.class);\r
+ }\r
+\r
+ @Override\r
+ public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException {\r
+ Resource cr = (Resource) content;\r
+ DiagramResource DIA = DiagramResource.getInstance(graph);\r
+ ModelingResources MOD = ModelingResources.getInstance(graph);\r
+\r
+ for (Resource dcr : graph.getObjects(cr, MOD.ConnectionRelationToDiagramConnectionRelation)) {\r
+ for (Resource terminal : graph.getObjects(dcr, DIA.HasConnectionPoint_Inverse)) {\r
+ if (graph.isInstanceOf(terminal, DIA.Terminal))\r
+ return DECO;\r
+ }\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
+}\r