]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/ArrayPropertyImagerFactory.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / ArrayPropertyImagerFactory.java
index 8acc81a5064b785fa047b433947caead43fcfe44..28dda813a8fe07162268306553b7954aef4e70eb 100644 (file)
@@ -1,88 +1,88 @@
-/*******************************************************************************\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.browsing.ui.swt;\r
-\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.BuiltinKeys.ImagerKey;\r
-import org.simantics.browsing.ui.DataSource;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.PrimitiveQueryUpdater;\r
-import org.simantics.browsing.ui.common.ColumnKeys;\r
-import org.simantics.browsing.ui.common.imagers.ContainerImager;\r
-import org.simantics.browsing.ui.common.property.IArrayProperty;\r
-import org.simantics.browsing.ui.content.Imager;\r
-import org.simantics.browsing.ui.content.ImagerFactory;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.ui.icons.ImageUtil;\r
-import org.simantics.utils.ui.BundleUtils;\r
-\r
-/**\r
- * A basic imager factory with support for both Resource and IArrayProperty.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public class ArrayPropertyImagerFactory implements ImagerFactory {\r
-\r
-    @SuppressWarnings("unchecked")\r
-    @Override\r
-    public Imager create(final PrimitiveQueryUpdater updater, final NodeContext context, final ImagerKey key) {\r
-        assert updater != null;\r
-        assert context != null;\r
-\r
-        @SuppressWarnings("rawtypes")\r
-        final ContainerImager result = new ContainerImager();\r
-        final DataSource<ReadGraph> source = updater.getDataSource(ReadGraph.class);\r
-        if (source == null)\r
-            return result;\r
-\r
-        Object o = context.getConstant(BuiltinKeys.INPUT);\r
-        if (o instanceof IArrayProperty) {\r
-            IArrayProperty prop = (IArrayProperty) o;\r
-\r
-            if (prop.getRange().size() > 1) {\r
-                // Only show the segment image for non-single-item slices of the\r
-                // property root node. Otherwise just use the image resolved\r
-                // through normal means.\r
-                if (prop.isSlice()) {\r
-                    result.setImage(ColumnKeys.PROPERTY,\r
-                            BundleUtils.getImageDescriptorFromPlugin(\r
-                                    "org.simantics.browsing.ui.common", "/icons/segment_edit.gif"));\r
-                    return result;\r
-                }\r
-            } else {\r
-                // No image for single-item slices of the property.\r
-                return result;\r
-            }\r
-        }\r
-\r
-        final Resource inputResource = (Resource) context.getAdapter(Resource.class);\r
-        if (inputResource == null)\r
-            return result;\r
-\r
-        source.schedule(graph -> {\r
-            ImageDescriptor descriptor;\r
-            try {\r
-                descriptor = ImageUtil.adaptImageDescriptor(graph, inputResource);\r
-                result.setImage(ColumnKeys.PROPERTY, descriptor);\r
-                updater.scheduleReplace(context, key, result);\r
-            } catch (DatabaseException e) {\r
-                e.printStackTrace();\r
-            }\r
-        });\r
-\r
-        return result;\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.browsing.ui.swt;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.simantics.browsing.ui.BuiltinKeys;
+import org.simantics.browsing.ui.BuiltinKeys.ImagerKey;
+import org.simantics.browsing.ui.DataSource;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.PrimitiveQueryUpdater;
+import org.simantics.browsing.ui.common.ColumnKeys;
+import org.simantics.browsing.ui.common.imagers.ContainerImager;
+import org.simantics.browsing.ui.common.property.IArrayProperty;
+import org.simantics.browsing.ui.content.Imager;
+import org.simantics.browsing.ui.content.ImagerFactory;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.ui.icons.ImageUtil;
+import org.simantics.utils.ui.BundleUtils;
+
+/**
+ * A basic imager factory with support for both Resource and IArrayProperty.
+ * 
+ * @author Tuukka Lehtonen
+ */
+public class ArrayPropertyImagerFactory implements ImagerFactory {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Imager create(final PrimitiveQueryUpdater updater, final NodeContext context, final ImagerKey key) {
+        assert updater != null;
+        assert context != null;
+
+        @SuppressWarnings("rawtypes")
+        final ContainerImager result = new ContainerImager();
+        final DataSource<ReadGraph> source = updater.getDataSource(ReadGraph.class);
+        if (source == null)
+            return result;
+
+        Object o = context.getConstant(BuiltinKeys.INPUT);
+        if (o instanceof IArrayProperty) {
+            IArrayProperty prop = (IArrayProperty) o;
+
+            if (prop.getRange().size() > 1) {
+                // Only show the segment image for non-single-item slices of the
+                // property root node. Otherwise just use the image resolved
+                // through normal means.
+                if (prop.isSlice()) {
+                    result.setImage(ColumnKeys.PROPERTY,
+                            BundleUtils.getImageDescriptorFromPlugin(
+                                    "org.simantics.browsing.ui.common", "/icons/segment_edit.gif"));
+                    return result;
+                }
+            } else {
+                // No image for single-item slices of the property.
+                return result;
+            }
+        }
+
+        final Resource inputResource = (Resource) context.getAdapter(Resource.class);
+        if (inputResource == null)
+            return result;
+
+        source.schedule(graph -> {
+            ImageDescriptor descriptor;
+            try {
+                descriptor = ImageUtil.adaptImageDescriptor(graph, inputResource);
+                result.setImage(ColumnKeys.PROPERTY, descriptor);
+                updater.scheduleReplace(context, key, result);
+            } catch (DatabaseException e) {
+                e.printStackTrace();
+            }
+        });
+
+        return result;
+    }
+
+}