]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.event/src/org/simantics/event/view/contribution/EventImageRule.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.event / src / org / simantics / event / view / contribution / EventImageRule.java
index 141752fffd4d44948ab137b33cebff9bb1e5f63a..7c6b67f746e2b72d15a7688101d4f05698f780b0 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 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.event.view.contribution;\r
-\r
-import java.awt.Color;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.simantics.browsing.ui.model.images.ImageRule;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.event.Activator;\r
-import org.simantics.event.ontology.EventResource;\r
-import org.simantics.event.view.Constants;\r
-import org.simantics.utils.datastructures.ArrayMap;\r
-import org.simantics.utils.ui.BundleUtils;\r
-import org.simantics.utils.ui.gfx.AlphaAdjustmentImageDescriptor;\r
-import org.simantics.utils.ui.gfx.CompositionImageDescriptor;\r
-import org.simantics.utils.ui.gfx.TextImageDescriptor;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public enum EventImageRule implements ImageRule {\r
-\r
-    INSTANCE;\r
-\r
-    public static EventImageRule 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 Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {\r
-        Resource event = (Resource) content;\r
-\r
-        EventResource EVENT = EventResource.getInstance(graph);\r
-\r
-        ImageDescriptor eventIcon = null;\r
-        ImageDescriptor milestoneIcon = null;\r
-        ImageDescriptor returnIcon = null;\r
-\r
-        // Icon derived from event type\r
-        Resource eventType = graph.getPossibleObject(event, EVENT.Event_type);\r
-        if (eventType != null) {\r
-            eventIcon = graph.syncRequest(new EventTypeImageDescriptorRequest(eventType));\r
-        }\r
-\r
-        // Milestone Diamond Icon\r
-        if (graph.hasStatement(event, EVENT.Milestone)) {\r
-            String label = graph.getPossibleRelatedValue(event, EVENT.Event_milestoneLabel);\r
-            if (label == null) label = "?";\r
-\r
-            boolean isBasetime = graph.hasStatement(event, EVENT.EventLog_HasBaselineEvent_Inverse);\r
-            ImageDescriptor diamond = isBasetime ? Activator.DIAMOND2_ICON : Activator.DIAMOND_ICON;\r
-            int color = isBasetime ? 0 : Color.ORANGE.getRGB();\r
-            ImageDescriptor number = new TextImageDescriptor(label, 16, 16, "Tahoma", 8, 0, color);\r
-            milestoneIcon = CompositionImageDescriptor.compose( diamond, number );\r
-        }\r
-\r
-        if (!graph.hasStatement(event, EVENT.NoReturn)) {\r
-            if (graph.hasStatement(event, EVENT.ReturnedBy)) {\r
-                returnIcon = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/tick.png");\r
-            } else if (graph.hasStatement(event, EVENT.ReturnEvent)) {\r
-                returnIcon = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_undo.png");\r
-            } else {\r
-                returnIcon = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/cross.png");\r
-            }\r
-        }\r
-\r
-        boolean hidden = graph.hasStatement(event, EVENT.Hidden);\r
-\r
-        eventIcon = fade(eventIcon, hidden);\r
-        milestoneIcon = fade(milestoneIcon, hidden);\r
-        returnIcon = fade(returnIcon, hidden);\r
-\r
-        return ArrayMap.make(Constants.COLUMN_KEYS, new ImageDescriptor[] {\r
-                null,\r
-                null,\r
-                null,\r
-                milestoneIcon,\r
-                eventIcon,\r
-                returnIcon,\r
-                null,\r
-                null,\r
-                null,\r
-                null,\r
-                null\r
-        });\r
-    }\r
-\r
-    private static ImageDescriptor fade(ImageDescriptor desc, boolean doIt) {\r
-        return desc != null && doIt ? AlphaAdjustmentImageDescriptor.adjustAlpha(desc, 128) : desc;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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.event.view.contribution;
+
+import java.awt.Color;
+import java.util.Map;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.simantics.browsing.ui.model.images.ImageRule;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.event.Activator;
+import org.simantics.event.ontology.EventResource;
+import org.simantics.event.view.Constants;
+import org.simantics.utils.datastructures.ArrayMap;
+import org.simantics.utils.ui.BundleUtils;
+import org.simantics.utils.ui.gfx.AlphaAdjustmentImageDescriptor;
+import org.simantics.utils.ui.gfx.CompositionImageDescriptor;
+import org.simantics.utils.ui.gfx.TextImageDescriptor;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public enum EventImageRule implements ImageRule {
+
+    INSTANCE;
+
+    public static EventImageRule get() {
+        return INSTANCE;
+    }
+
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        return contentType.equals(Resource.class);
+    }
+
+    @Override
+    public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {
+        Resource event = (Resource) content;
+
+        EventResource EVENT = EventResource.getInstance(graph);
+
+        ImageDescriptor eventIcon = null;
+        ImageDescriptor milestoneIcon = null;
+        ImageDescriptor returnIcon = null;
+
+        // Icon derived from event type
+        Resource eventType = graph.getPossibleObject(event, EVENT.Event_type);
+        if (eventType != null) {
+            eventIcon = graph.syncRequest(new EventTypeImageDescriptorRequest(eventType));
+        }
+
+        // Milestone Diamond Icon
+        if (graph.hasStatement(event, EVENT.Milestone)) {
+            String label = graph.getPossibleRelatedValue(event, EVENT.Event_milestoneLabel);
+            if (label == null) label = "?";
+
+            boolean isBasetime = graph.hasStatement(event, EVENT.EventLog_HasBaselineEvent_Inverse);
+            ImageDescriptor diamond = isBasetime ? Activator.DIAMOND2_ICON : Activator.DIAMOND_ICON;
+            int color = isBasetime ? 0 : Color.ORANGE.getRGB();
+            ImageDescriptor number = new TextImageDescriptor(label, 16, 16, "Tahoma", 8, 0, color);
+            milestoneIcon = CompositionImageDescriptor.compose( diamond, number );
+        }
+
+        if (!graph.hasStatement(event, EVENT.NoReturn)) {
+            if (graph.hasStatement(event, EVENT.ReturnedBy)) {
+                returnIcon = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/tick.png");
+            } else if (graph.hasStatement(event, EVENT.ReturnEvent)) {
+                returnIcon = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_undo.png");
+            } else {
+                returnIcon = BundleUtils.getImageDescriptorFromPlugin("com.famfamfam.silk", "icons/cross.png");
+            }
+        }
+
+        boolean hidden = graph.hasStatement(event, EVENT.Hidden);
+
+        eventIcon = fade(eventIcon, hidden);
+        milestoneIcon = fade(milestoneIcon, hidden);
+        returnIcon = fade(returnIcon, hidden);
+
+        return ArrayMap.make(Constants.COLUMN_KEYS, new ImageDescriptor[] {
+                null,
+                null,
+                null,
+                milestoneIcon,
+                eventIcon,
+                returnIcon,
+                null,
+                null,
+                null,
+                null,
+                null
+        });
+    }
+
+    private static ImageDescriptor fade(ImageDescriptor desc, boolean doIt) {
+        return desc != null && doIt ? AlphaAdjustmentImageDescriptor.adjustAlpha(desc, 128) : desc;
+    }
+
+}