-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in 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.structural.ui.modelBrowser.contributions;\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.db.layer0.request.PossibleModel;\r
-import org.simantics.operation.Layer0X;\r
-import org.simantics.simulation.ontology.SimulationResource;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public enum RunLabelDecorationRule implements LabelDecorationRule {\r
-\r
- INSTANCE;\r
-\r
- public static RunLabelDecorationRule get() {\r
- return INSTANCE;\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 run = (Resource) content;\r
-\r
- Resource model = graph.syncRequest(new PossibleModel(run));\r
- if (model == null)\r
- return null;\r
- if (!graph.hasStatement(model, Layer0X.getInstance(graph).IsActivatedBy))\r
- return null;\r
- if (!graph.hasStatement(run, SimulationResource.getInstance(graph).IsActive))\r
- return null;\r
-\r
- return new LabelDecorator.Stub() {\r
- @Override\r
- public String decorateLabel(String label, String column, int itemIndex) {\r
- return label + " [ACTIVE]";\r
- }\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public <F> F decorateFont(F font, String column, int itemIndex) {\r
- return (F) ((FontDescriptor) font).withStyle(SWT.BOLD);\r
- }\r
- };\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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.structural.ui.modelBrowser.contributions;
+
+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.db.layer0.request.PossibleModel;
+import org.simantics.operation.Layer0X;
+import org.simantics.simulation.ontology.SimulationResource;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public enum RunLabelDecorationRule implements LabelDecorationRule {
+
+ INSTANCE;
+
+ public static RunLabelDecorationRule get() {
+ return INSTANCE;
+ }
+
+ @Override
+ public boolean isCompatible(Class<?> contentType) {
+ return contentType.equals(Resource.class);
+ }
+
+ @Override
+ public LabelDecorator getLabelDecorator(ReadGraph graph, Object content) throws DatabaseException {
+ Resource run = (Resource) content;
+
+ Resource model = graph.syncRequest(new PossibleModel(run));
+ if (model == null)
+ return null;
+ if (!graph.hasStatement(model, Layer0X.getInstance(graph).IsActivatedBy))
+ return null;
+ if (!graph.hasStatement(run, SimulationResource.getInstance(graph).IsActive))
+ return null;
+
+ return new LabelDecorator.Stub() {
+ @Override
+ public String decorateLabel(String label, String column, int itemIndex) {
+ return label + " [ACTIVE]";
+ }
+ @SuppressWarnings("unchecked")
+ @Override
+ public <F> F decorateFont(F font, String column, int itemIndex) {
+ return (F) ((FontDescriptor) font).withStyle(SWT.BOLD);
+ }
+ };
+ }
+
+}