]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java
First version of fixed nozzle positions
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / utils / P3DUtil.java
index b34f4f0739e817230b784009349433e09c5646f0..e6e3385f3a2967aaee826a684136ac98be7dce50 100644 (file)
@@ -1,6 +1,8 @@
 package org.simantics.plant3d.utils;
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import org.simantics.Simantics;
@@ -92,6 +94,15 @@ public class P3DUtil {
                });
        }
        
+       public static List<Item> filterUserComponents(List<Item> items) {
+           List<Item> result = new ArrayList<Item>(items.size());
+           for (Item i : items) {
+               if (!i.isCode())
+                   result.add(i);
+           }
+           return result;
+       }
+       
        private static List<Item> getItems(ReadGraph graph, Resource lib, Resource type) throws DatabaseException{
                Plant3D p3d = Plant3D.getInstance(graph);
                Layer0 l0 = Layer0.getInstance(graph);
@@ -117,10 +128,16 @@ public class P3DUtil {
                                }
                        }
                }
+               Collections.sort(result, new Comparator<Item>() {
+                   @Override
+                   public int compare(Item o1, Item o2) {
+                       return o1.getName().compareTo(o2.getName());
+                   }
+        });
                return result;
        }
        
-       private static Item createItem(ReadGraph graph, Resource r) throws DatabaseException {
+       public static Item createItem(ReadGraph graph, Resource r) throws DatabaseException {
                Layer0 l0 = Layer0.getInstance(graph);
                Plant3D p3d = Plant3D.getInstance(graph);
                String name = graph.getRelatedValue(r, l0.HasName);