-/*******************************************************************************\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
+/*******************************************************************************
+ * Copyright (c) 2012 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.ui.modelBrowser2.label;
+
+import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.swt.SWT;
+import org.simantics.browsing.ui.content.LabelDecorator;
+import org.simantics.browsing.ui.model.labeldecorators.LabelDecorationRule;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.modeling.ModelingResources;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ConnectionRelationLabelDecorationRule implements LabelDecorationRule {
+
+ public static final ConnectionRelationLabelDecorationRule INSTANCE = new ConnectionRelationLabelDecorationRule();
+
+ static LabelDecorator DECO = new LabelDecorator.Stub() {
+ @SuppressWarnings("unchecked")
+ public <F> F decorateFont(F font, String column, int itemIndex) {
+ return font != null ? (F) ((FontDescriptor) font).withStyle(SWT.BOLD) : null;
+ }
+ };
+
+ @Override
+ public boolean isCompatible(Class<?> contentType) {
+ return contentType.equals(Resource.class);
+ }
+
+ @Override
+ public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException {
+ Resource cr = (Resource) content;
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+
+ for (Resource dcr : graph.getObjects(cr, MOD.ConnectionRelationToDiagramConnectionRelation)) {
+ for (Resource terminal : graph.getObjects(dcr, DIA.HasConnectionPoint_Inverse)) {
+ if (graph.isInstanceOf(terminal, DIA.Terminal))
+ return DECO;
+ }
+ }
+
+ return null;
+ }
+
+}