]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.event/src/org/simantics/event/view/contribution/EventTypeImageDescriptorRequest.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.event / src / org / simantics / event / view / contribution / EventTypeImageDescriptorRequest.java
diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/contribution/EventTypeImageDescriptorRequest.java b/bundles/org.simantics.event/src/org/simantics/event/view/contribution/EventTypeImageDescriptorRequest.java
new file mode 100644 (file)
index 0000000..611da72
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 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
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.event.view.contribution;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ResourceRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.ui.icons.GraphImageDescriptor;\r
+import org.simantics.viewpoint.ontology.ViewpointResource;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class EventTypeImageDescriptorRequest extends ResourceRead<ImageDescriptor> {\r
+\r
+    public EventTypeImageDescriptorRequest(Resource eventType) {\r
+        super(eventType);\r
+    }\r
+\r
+    @Override\r
+    public ImageDescriptor perform(ReadGraph graph) throws DatabaseException {\r
+        ViewpointResource VP = ViewpointResource.getInstance(graph);\r
+        Resource image = graph.getPossibleObject(resource, VP.ConstantImageRule_HasImage);\r
+        if (image == null)\r
+            return null;\r
+        return new GraphImageDescriptor(graph, image);\r
+    }\r
+\r
+}
\ No newline at end of file