X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=org.simantics.proconf.processeditor%2Fsrc%2Forg%2Fsimantics%2Fprocesseditor%2Fdialogs%2FLibraryComponentDialog.java;h=c7df9e1294a5fdc297bef99572fefc3162b74c42;hb=9ad91ae4a059a4c7b219d2560c5b8b8ed1c5f184;hp=f6b9473c5c58bb25e61deaf5af658e1958616404;hpb=570ba60e83221385f16bb2a7abb33cfc15ac2b06;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 f6b9473c..c7df9e12 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 @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2007- VTT Technical Research Centre of Finland. + * 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.processeditor.dialogs; import java.util.ArrayList; @@ -105,8 +115,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 +144,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)) {