1 package org.simantics.modeling.ui.scl.imports;
3 import java.util.ArrayList;
5 import org.eclipse.jface.dialogs.Dialog;
6 import org.eclipse.swt.widgets.Shell;
7 import org.simantics.scl.compiler.commands.CommandSessionImportEntry;
8 import org.simantics.scl.ui.imports.ImportModulesAction;
10 public class OntologyImportModulesAction extends ImportModulesAction {
12 public static final OntologyImportModulesAction INSTANCE = new OntologyImportModulesAction();
14 public OntologyImportModulesAction() {
15 super("Add ontology", 10.0);
19 public boolean editImports(Shell shell, ArrayList<CommandSessionImportEntry> imports) {
20 ModuleSelectionDialog dialog = new ModuleSelectionDialog(shell, OntologiesQuery.INSTANCE);
21 if(dialog.open() == Dialog.OK) {
22 for(Object r : dialog.getResult()) {
23 String uri = (String)r;
24 new CommandSessionImportEntry(uri, getDefaultLocalName(uri), true).addTo(imports);
32 public String getDefaultLocalName(String ontologyUri) {
33 if(ontologyUri.contains("/Layer0-"))
35 if(ontologyUri.contains("/Structural-"))
37 if(ontologyUri.contains("/Modeling-"))