X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.proconf.processeditor%2Fsrc%2Forg%2Fsimantics%2Fprocesseditor%2Fdialogs%2FLibraryComponentDialog.java;h=18263b92ffb5fe001d0229e80fb54f82e4602770;hb=c58f0db363a3f2881577f84fb905e07775f65002;hp=daee341c5a05f6389018c8dbfcc18fdb76e5f7b1;hpb=b4fddf5cd72860d3f99f4b3d2e1a52b7c6f948d2;p=simantics%2F3d.git diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/dialogs/LibraryComponentDialog.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/dialogs/LibraryComponentDialog.java index daee341c..18263b92 100644 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/dialogs/LibraryComponentDialog.java +++ b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/dialogs/LibraryComponentDialog.java @@ -24,7 +24,7 @@ import org.simantics.layer0.utils.EntityFactory; import org.simantics.layer0.utils.IEntity; import org.simantics.processeditor.ProcessResource; import org.simantics.proconf.ui.ProConfUI; -import org.simantics.utils.ErrorLogger; +import org.simantics.utils.ui.ErrorLogger; public class LibraryComponentDialog extends Dialog{ @@ -105,8 +105,10 @@ public class LibraryComponentDialog extends Dialog{ public void run() { getShell().setText(title); if (selectedType == null) { - typeList.select(0); - selectedType = (Resource)typeList.getData(typeList.getItem(0)); + if (typeList.getItemCount() > 0) { + typeList.select(0); + selectedType = (Resource)typeList.getData(typeList.getItem(0)); + } } } @@ -132,6 +134,25 @@ public class LibraryComponentDialog extends Dialog{ Resource projectResource = ProConfUI.getProject().getResource(); Stack handling = new Stack(); handling.push(projectResource); + + // this is just a hack to get equipment defined in ontologies + Resource projectsLib = g.getObjects(projectResource, g.getBuiltins().PartOf).iterator().next(); + Collection projects = g.getObjects(projectsLib, g.getBuiltins().ConsistsOf); + Resource typeSystemProject = null; + for (Resource project : projects) { + IEntity ent = EntityFactory.create(g,project); + String name = ent.getName(); + if(name.equals("Type System Project")) { + typeSystemProject = project; + break; + } + } + Collection ontologies = g.getObjects(typeSystemProject, g.getBuiltins().ConsistsOf); + for (Resource ontology : ontologies) { + if(g.isInstanceOf(ontology, g.getBuiltins().Ontology)) + handling.add(ontology); + } + while (!handling.isEmpty()) { final Resource node = handling.pop(); if (g.isInstanceOf(node,primaryType)) {