From 4a9ccca7f18a3f816e514cefe9f9a8f5faeb03e4 Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 15 Apr 2011 08:35:53 +0000 Subject: [PATCH] Function libraries started git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@20506 ac1ea38d-2e2b-0410-8846-a27921b304fc --- org.simantics.sysdyn.ontology/graph.tg | Bin 53413 -> 53694 bytes .../graph/Sysdyn.pgraph | 14 +- .../graph/SysdynFunctions.pgraph | 2 +- .../graph/WorkModel.pgraph | 19 +- .../org/simantics/sysdyn/SysdynResource.java | 42 ++-- org.simantics.sysdyn.ui/icons/folder_link.png | Bin 0 -> 785 bytes .../actions/ShowInstantiatedModuleAction.java | 35 ++- .../contributions/FunctionLibraries.java | 104 +++++++++ .../contributions/FunctionLibraryLabeler.java | 20 ++ .../{Functions.java => LibraryFunctions.java} | 38 ++-- .../browser/contributions/SysdynProject.java | 39 ++++ .../ui/browser/nodes/FunctionLibraryNode.java | 97 ++++++++ .../sysdyn/ui/browser/nodes/FunctionNode.java | 83 ++++++- .../ui/browser/nodes/FunctionsFolder.java | 42 +++- .../nodes/SharedFunctionLibraryNode.java | 75 +++++++ .../ui/handlers/ExportFunctionLibrary.java | 108 +++++++++ .../ImportExternalFunctionFilesHandler.java | 15 +- .../ui/handlers/ImportFunctionLibrary.java | 178 +++++++++++++++ .../ui/handlers/NewFunctionHandler.java | 26 ++- .../handlers/NewFunctionLibraryHandler.java | 103 +++++++++ .../NewSharedFunctionLibraryHandler.java | 37 +++ .../ui/properties/FunctionLibraryTab.java | 49 ++++ .../externalFiles/ExternalFileNode.java | 17 +- .../ui/utils/OldTransferableGraph1.java | 76 +++++++ org.simantics.sysdyn/META-INF/MANIFEST.MF | 3 +- org.simantics.sysdyn/adapters.xml | 4 + .../sysdyn/manager/FunctionUtils.java | 210 ++++++++++++++++-- .../simantics/sysdyn/manager/SysdynModel.java | 101 +++++---- .../sysdyn/manager/SysdynModelManager.java | 14 +- 29 files changed, 1402 insertions(+), 149 deletions(-) create mode 100644 org.simantics.sysdyn.ui/icons/folder_link.png create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraries.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraryLabeler.java rename org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/{Functions.java => LibraryFunctions.java} (51%) create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SysdynProject.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionLibraryNode.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SharedFunctionLibraryNode.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportFunctionLibrary.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportFunctionLibrary.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionLibraryHandler.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSharedFunctionLibraryHandler.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionLibraryTab.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/OldTransferableGraph1.java diff --git a/org.simantics.sysdyn.ontology/graph.tg b/org.simantics.sysdyn.ontology/graph.tg index 70f588911261395275b73f94a76cb7f2a65d53fe..8f0c57d871e5ab8e8b6a338b2f2fa075a137ea7b 100644 GIT binary patch literal 53694 zcmd752bf&NvGzYfEA6gw0FfE8B$UZ{g#s)fB%~$B(eA7?FgvqMkhH|L0h^qY!35i6 z6AYMWV`O6!4K_Gn;{eV!#u@wCzV`L^zSUhl)kiXS@BjaNVV|d&{&iKoRi{s%K4;EK zXhh2Yw2ZD6YL!N{yD-1fDAzNoRC}?f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;B-jX{E8b z&&M`6rGJ{+ho%+h$hE#FX2d?j;W=-Rmx?a;<6F^%Kk`3X8L!+OXw2}TBfkeKhR9D% z@NNm-CBZutF7-hL`+#e(oAv-xcd2Mck4*;+*g^+Ti;7KCMeOq6>fW!|=!8`kt_!9dfPy zh`vpLgX`NaU2`TbKNAhEukPb#wmK8{;dgL-bzvX3-uKP^h05Ui>O6<@EB`IX;QDqH zC0^tFW`7%WT;AdE(|WQy;=20_YJ-dGb2WY68g$>YUXy^0^(?3c z`A-qe&c}Zk2;XO1-HHQ$PD)t>USA|80o!e?qW%riJZ$>yRC~2v>XJt(=TqFhxY&P!v7P+`T*gPD6OPC8iBF@g z4^!PafF~69+1Wi;vuAsCUUgd0JzUL$rmMp27nasmy8FAW^;G$wTbzXvJOTGzCU=+C zPMI~WNX_BZ?%uAleCvXzG)ZE59W@U3QHbSHPk!lRXj2*2UJdOJhV~s$Yi^y4Kiv<1 z`N5v2dw|D}+hjuFaTl1mty2a!_4sTS&&E_dnBko83ow3vFnQ-y^?L6CGiPq{#na5_ zs}?Sp|Dd(sO=WjLyX6)~@RMcVOm~=%#n8$51~ndK-+l1)V@G90rQF9y$6~doUhS%` zB&_*`z)u>bqBAb`x`j0Z!{=}2Y`@)<+48J>Tz{zxPv%p1wv^7Y2N!<&wyqiGrso_b(L>Da@L&KkC<@VMt+be#M!~{V%qj Bst^DG diff --git a/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph b/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph index 0161567e..f150ba43 100644 --- a/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph +++ b/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph @@ -19,6 +19,9 @@ SYSDYN.ImportedOntologies : PROJ.NamespaceRequirement PROJ.RequiresNamespace "http://www.simantics.org/Sysdyn-1.0" : L0.URI "http://www.simantics.org/Layer0-1.0" : L0.URI + +SYSDYN.SharedFunctionOntology SYSDYN = -FL = : L0.Library +FL = : SYSDYN.SysdynModelicaFunctionLibrary FL.xidz : SYSDYN.SysdynModelicaFunction diff --git a/org.simantics.sysdyn.ontology/graph/WorkModel.pgraph b/org.simantics.sysdyn.ontology/graph/WorkModel.pgraph index 4670d952..7d715409 100644 --- a/org.simantics.sysdyn.ontology/graph/WorkModel.pgraph +++ b/org.simantics.sysdyn.ontology/graph/WorkModel.pgraph @@ -12,21 +12,13 @@ PROJ = //###################################################################### /* -WM = : PROJ.Project - PROJ.HasFeature _ : PROJ.FeatureSpec - PROJ.HasGroupId "org.simantics.sysdyn.feature.group" - L0.PartOf -*/ - -WORKMODEL = : L0.Ontology +WM = : PROJ.Project @L0.new +*/ -WORKMODEL.WM : PROJ.Project - PROJ.HasFeature _ : PROJ.FeatureSpec - PROJ.HasGroupId "org.simantics.sysdyn.feature.group" - L0.PartOf +WM = : PROJ.Project + @L0.new -WM = WORKMODEL.WM TAGS = WM.Tags : L0.Library @@ -96,6 +88,9 @@ WM.WorkModel : SYSDYN.SysdynModel SIMU.HasConfiguration WC SYSDYN.HasStartTime 0.0 SYSDYN.HasStopTime 24.0 + L0.IsLinkedTo SYSDYN + L0.IsLinkedTo L0 + WM.WorkModel.Experiment : SYSDYN.Experiment L0.HasLabel "Experiment" diff --git a/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java b/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java index ad496fe5..5a2dfc43 100644 --- a/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java +++ b/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java @@ -13,11 +13,11 @@ public class SysdynResource { public final Resource Auxiliary; public final Resource AuxiliarySymbol; public final Resource BasicExperiment; - public final Resource BasicFunctions; - public final Resource BasicFunctions_interpolate; - public final Resource BasicFunctions_interpolateFull; - public final Resource BasicFunctions_xidz; - public final Resource BasicFunctions_zidz; + public final Resource Built$in_Functions; + public final Resource Built$in_Functions_interpolate; + public final Resource Built$in_Functions_interpolateFull; + public final Resource Built$in_Functions_xidz; + public final Resource Built$in_Functions_zidz; public final Resource Cloud; public final Resource CloudSymbol; public final Resource Configuration; @@ -124,6 +124,8 @@ public class SysdynResource { public final Resource ReplacingEnumeration; public final Resource ReplacingEnumeration_Inverse; public final Resource Result; + public final Resource SharedFunctionOntology; + public final Resource SharedModuleOntolofgy; public final Resource ShowEnumerationIndexInCharts; public final Resource ShowEnumerationIndexInCharts_Inverse; public final Resource SimulateOnChangeExperiment; @@ -137,6 +139,8 @@ public class SysdynResource { public final Resource SysdynDiagramModelingRules; public final Resource SysdynModel; public final Resource SysdynModelicaFunction; + public final Resource SysdynModelicaFunctionLibrary; + public final Resource SysdynModuleLibrary; public final Resource SysdynTerminal; public final Resource Valve; public final Resource ValveSymbol; @@ -151,11 +155,11 @@ public class SysdynResource { public static final String Auxiliary = "http://www.simantics.org/Sysdyn-1.0/Auxiliary"; public static final String AuxiliarySymbol = "http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"; public static final String BasicExperiment = "http://www.simantics.org/Sysdyn-1.0/BasicExperiment"; - public static final String BasicFunctions = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions"; - public static final String BasicFunctions_interpolate = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions/interpolate"; - public static final String BasicFunctions_interpolateFull = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions/interpolateFull"; - public static final String BasicFunctions_xidz = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions/xidz"; - public static final String BasicFunctions_zidz = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions/zidz"; + public static final String Built$in_Functions = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions"; + public static final String Built$in_Functions_interpolate = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/interpolate"; + public static final String Built$in_Functions_interpolateFull = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/interpolateFull"; + public static final String Built$in_Functions_xidz = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/xidz"; + public static final String Built$in_Functions_zidz = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/zidz"; public static final String Cloud = "http://www.simantics.org/Sysdyn-1.0/Cloud"; public static final String CloudSymbol = "http://www.simantics.org/Sysdyn-1.0/CloudSymbol"; public static final String Configuration = "http://www.simantics.org/Sysdyn-1.0/Configuration"; @@ -262,6 +266,8 @@ public class SysdynResource { public static final String ReplacingEnumeration = "http://www.simantics.org/Sysdyn-1.0/ReplacingEnumeration"; public static final String ReplacingEnumeration_Inverse = "http://www.simantics.org/Sysdyn-1.0/ReplacingEnumeration/Inverse"; public static final String Result = "http://www.simantics.org/Sysdyn-1.0/Result"; + public static final String SharedFunctionOntology = "http://www.simantics.org/Sysdyn-1.0/SharedFunctionOntology"; + public static final String SharedModuleOntolofgy = "http://www.simantics.org/Sysdyn-1.0/SharedModuleOntolofgy"; public static final String ShowEnumerationIndexInCharts = "http://www.simantics.org/Sysdyn-1.0/ShowEnumerationIndexInCharts"; public static final String ShowEnumerationIndexInCharts_Inverse = "http://www.simantics.org/Sysdyn-1.0/ShowEnumerationIndexInCharts/Inverse"; public static final String SimulateOnChangeExperiment = "http://www.simantics.org/Sysdyn-1.0/SimulateOnChangeExperiment"; @@ -275,6 +281,8 @@ public class SysdynResource { public static final String SysdynDiagramModelingRules = "http://www.simantics.org/Sysdyn-1.0/SysdynDiagramModelingRules"; public static final String SysdynModel = "http://www.simantics.org/Sysdyn-1.0/SysdynModel"; public static final String SysdynModelicaFunction = "http://www.simantics.org/Sysdyn-1.0/SysdynModelicaFunction"; + public static final String SysdynModelicaFunctionLibrary = "http://www.simantics.org/Sysdyn-1.0/SysdynModelicaFunctionLibrary"; + public static final String SysdynModuleLibrary = "http://www.simantics.org/Sysdyn-1.0/SysdynModuleLibrary"; public static final String SysdynTerminal = "http://www.simantics.org/Sysdyn-1.0/SysdynTerminal"; public static final String Valve = "http://www.simantics.org/Sysdyn-1.0/Valve"; public static final String ValveSymbol = "http://www.simantics.org/Sysdyn-1.0/ValveSymbol"; @@ -299,11 +307,11 @@ public class SysdynResource { Auxiliary = getResourceOrNull(graph, URIs.Auxiliary); AuxiliarySymbol = getResourceOrNull(graph, URIs.AuxiliarySymbol); BasicExperiment = getResourceOrNull(graph, URIs.BasicExperiment); - BasicFunctions = getResourceOrNull(graph, URIs.BasicFunctions); - BasicFunctions_interpolate = getResourceOrNull(graph, URIs.BasicFunctions_interpolate); - BasicFunctions_interpolateFull = getResourceOrNull(graph, URIs.BasicFunctions_interpolateFull); - BasicFunctions_xidz = getResourceOrNull(graph, URIs.BasicFunctions_xidz); - BasicFunctions_zidz = getResourceOrNull(graph, URIs.BasicFunctions_zidz); + Built$in_Functions = getResourceOrNull(graph, URIs.Built$in_Functions); + Built$in_Functions_interpolate = getResourceOrNull(graph, URIs.Built$in_Functions_interpolate); + Built$in_Functions_interpolateFull = getResourceOrNull(graph, URIs.Built$in_Functions_interpolateFull); + Built$in_Functions_xidz = getResourceOrNull(graph, URIs.Built$in_Functions_xidz); + Built$in_Functions_zidz = getResourceOrNull(graph, URIs.Built$in_Functions_zidz); Cloud = getResourceOrNull(graph, URIs.Cloud); CloudSymbol = getResourceOrNull(graph, URIs.CloudSymbol); Configuration = getResourceOrNull(graph, URIs.Configuration); @@ -410,6 +418,8 @@ public class SysdynResource { ReplacingEnumeration = getResourceOrNull(graph, URIs.ReplacingEnumeration); ReplacingEnumeration_Inverse = getResourceOrNull(graph, URIs.ReplacingEnumeration_Inverse); Result = getResourceOrNull(graph, URIs.Result); + SharedFunctionOntology = getResourceOrNull(graph, URIs.SharedFunctionOntology); + SharedModuleOntolofgy = getResourceOrNull(graph, URIs.SharedModuleOntolofgy); ShowEnumerationIndexInCharts = getResourceOrNull(graph, URIs.ShowEnumerationIndexInCharts); ShowEnumerationIndexInCharts_Inverse = getResourceOrNull(graph, URIs.ShowEnumerationIndexInCharts_Inverse); SimulateOnChangeExperiment = getResourceOrNull(graph, URIs.SimulateOnChangeExperiment); @@ -423,6 +433,8 @@ public class SysdynResource { SysdynDiagramModelingRules = getResourceOrNull(graph, URIs.SysdynDiagramModelingRules); SysdynModel = getResourceOrNull(graph, URIs.SysdynModel); SysdynModelicaFunction = getResourceOrNull(graph, URIs.SysdynModelicaFunction); + SysdynModelicaFunctionLibrary = getResourceOrNull(graph, URIs.SysdynModelicaFunctionLibrary); + SysdynModuleLibrary = getResourceOrNull(graph, URIs.SysdynModuleLibrary); SysdynTerminal = getResourceOrNull(graph, URIs.SysdynTerminal); Valve = getResourceOrNull(graph, URIs.Valve); ValveSymbol = getResourceOrNull(graph, URIs.ValveSymbol); diff --git a/org.simantics.sysdyn.ui/icons/folder_link.png b/org.simantics.sysdyn.ui/icons/folder_link.png new file mode 100644 index 0000000000000000000000000000000000000000..b9b75f6c398044761b2e211639a3b3ea5dffda06 GIT binary patch literal 785 zcmV+s1Md8ZP)aL6K`V-vR#JLK(X*jEKVNlbHxH0QOXN4CTjfvGt40I|M#Ku+)Yiq8d z;L28c;TGg(*&-*FfRgVFU3!q0bKn5y+w&YMOEeLrM3go2};w-m?^(jqeZAz2= zL*$E|+nBzw5`1~&d{HnejR`pp>Gc7meprxN9t68G0wK!~R}w-lLD(()XLo=+p9zi1 z=86KRES~3g$*>K{#fON0>%{i-Rcw831>-k@nY{~UrUN@)b%g6=XPXGQk0pwNVJV+w zqhRK2*zxsX)1w8u`H8F=|Ghf>#)>;2#|sV1xT0X_I4_<*pC+(CE+r1;*Z|TI8@M$i z*d-lO3zv}$G$5CpN9eh9kKmasBji}*;vbP^#=-v_K_>cy4EBLtz6Ex%6{+9_B)^|S z!hagM#0)}%dj*eV={z3?zdeTC)u(vt>V&z^2#3Rg-flhS-!~vKtwevfR?M0Edok2? zHY=CQ4-^D8DJSp@k{b>@wzk4zu^<|aA{-9Gfx%$lO768pBDvDi(!x+d zeSQ6SO-&82P$*DWS0_Sanxi!;puHu6!{kw^RP$!DnQ=Ou+itfTcDo&IZEa|8Zx>^l zqcz$?drJi6<>mXTtE;POYipO9nwpXtjfNv+)M|Aj;S`DEG)HT+hxYyg@Y?10VPWjL P00000NkvXXu0mjfBPD6B literal 0 HcmV?d00001 diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ShowInstantiatedModuleAction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ShowInstantiatedModuleAction.java index d28452ba..e66d38d7 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ShowInstantiatedModuleAction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ShowInstantiatedModuleAction.java @@ -18,10 +18,13 @@ import org.eclipse.ui.PartInitException; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.layer0.variable.Variables; import org.simantics.layer0.Layer0; import org.simantics.modeling.ModelingResources; import org.simantics.structural.stubs.StructuralResource2; import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.adapter.ChildVariable; import org.simantics.sysdyn.ui.browser.BrowserSelection; import org.simantics.sysdyn.ui.browser.nodes.ModuleNode; import org.simantics.ui.DoubleClickEvent; @@ -46,23 +49,39 @@ public class ShowInstantiatedModuleAction implements IDoubleClickAction { if(!bss.isEmpty()) { Layer0 l0 = Layer0.getInstance(g); for(BrowserSelection bs : bss) { - Resource instanceOf = g.getSingleObject((Resource)bs.getAdapter(Resource.class), l0.InstanceOf); + Resource configuration = (Resource)bs.getAdapter(Resource.class); + Resource instanceOf = g.getSingleObject(configuration, l0.InstanceOf); + SysdynResource sr = SysdynResource.getInstance(g); + StructuralResource2 sr2 = StructuralResource2.getInstance(g); if(g.isInheritedFrom(instanceOf, sr.Module)) { - StructuralResource2 sr2 = StructuralResource2.getInstance(g); - Resource conf = g.getSingleObject(instanceOf, sr2.IsDefinedBy); - addShowModuleAction(e, getResourceEditorInput(g, bs.getModel(), conf, bs.getURI())); - } + configuration = g.getSingleObject(instanceOf, sr2.IsDefinedBy); + ChildVariable variable = (ChildVariable) bs.getAdapter(Variable.class); + String rvi = variable.getRvi(g); + Resource model = Variables.getModel(g, variable); + addShowModuleAction(e, getResourceEditorInput(g, model, configuration, rvi)); + } } } else { ModuleNode moduleNode = ISelectionUtils.filterSingleSelection(e.getResource(), ModuleNode.class); if(moduleNode != null) { Layer0 l0 = Layer0.getInstance(g); StructuralResource2 sr2 = StructuralResource2.getInstance(g); - String rvi = moduleNode.getURI(g); - Resource instanceOf = g.getSingleObject(moduleNode.getResource() != null ? moduleNode.getResource() : moduleNode.data, l0.InstanceOf); + Resource model; + String rvi; + if(moduleNode.getVariable() != null) { + model = Variables.getModel(g, moduleNode.getVariable()); + ChildVariable var = (ChildVariable)moduleNode.getVariable(); + rvi = var.getRvi(g); + } else { + rvi = (String)g.getRelatedValue(moduleNode.data, Layer0.getInstance(g).HasName); + model = g.getSingleObject(moduleNode.data, l0.PartOf); + } + + Resource instanceOf = g.getSingleObject(moduleNode.data, l0.InstanceOf); Resource conf = g.getSingleObject(instanceOf, sr2.IsDefinedBy); - addShowModuleAction(e, getResourceEditorInput(g, moduleNode.getModel(), conf, rvi)); + + addShowModuleAction(e, getResourceEditorInput(g, model, conf, rvi)); } } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraries.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraries.java new file mode 100644 index 00000000..a0a250c3 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraries.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 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.sysdyn.ui.browser.contributions; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; + +import org.simantics.browsing.ui.common.node.AbstractNode; +import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.exception.DatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.scl.runtime.function.Function; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode; +import org.simantics.sysdyn.ui.browser.nodes.FunctionNode; +import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder; +import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode; + +public class FunctionLibraries extends ViewpointContributor { + + @SuppressWarnings("unchecked") + @Override + public Collection getContribution(ReadGraph graph, FunctionsFolder functionsFolder) + throws DatabaseException { + + Layer0 l0 = Layer0.getInstance(graph); + SysdynResource sr = SysdynResource.getInstance(graph); + + ArrayList> result = new ArrayList>(); + + // Find model functions + for(Resource function : graph.syncRequest(new ObjectsWithType(functionsFolder.data, l0.ConsistsOf, sr.SysdynModelicaFunction))) { + result.add(new FunctionNode(function)); + } + + // Find shared libraries + Function index = graph.adapt(L0.Dependencies, Function.class); + Collection> results = (Collection>)index.apply(graph, functionsFolder.data, "Types:SharedFunctionOntology"); + HashSet sharedLibraries = new HashSet(); + for(Map r : results) { + Resource sharedLibrary = (Resource)r.get("Resource"); + if(sharedLibrary == null) + continue; + sharedLibraries.add(sharedLibrary); + } + + // Find function libraries in model and sysdyn ontology + index = graph.adapt(L0.Dependencies, Function.class); + results = (Collection>)index.apply(graph, functionsFolder.data, "Types:SysdynModelicaFunctionLibrary"); + HashSet modelLibraries = new HashSet(); + for(Map r : results) { + Resource library = (Resource)r.get("Resource"); + if(library == null) + continue; + Resource root = graph.getPossibleObject(library, l0.PartOf); + while(!graph.isInstanceOf(root, sr.SysdynModel) && !graph.isInstanceOf(root, l0.Ontology)) { + library = root; + root = graph.getPossibleObject(library, l0.PartOf); + } + + // If the root is not a shared library (it is the model or sysdyn ontology) + if(!sharedLibraries.contains(root)) + modelLibraries.add(library); + } + + + for(Resource modelLibrary : modelLibraries) { + Resource partOf = graph.getPossibleObject(modelLibrary, l0.PartOf); + if(graph.isInstanceOf(partOf, sr.SysdynModel)) + // From the model + result.add(new FunctionLibraryNode(modelLibrary)); + else + // From sysdyn ontology, this is read only + result.add(new FunctionLibraryNode(modelLibrary)); + } + + for(Resource sharedLibrary : sharedLibraries) + result.add(new SharedFunctionLibraryNode(sharedLibrary)); + + return result; + + } + + @Override + public String getViewpointId() { + return "Standard"; + } + + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraryLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraryLabeler.java new file mode 100644 index 00000000..1ac513f1 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionLibraryLabeler.java @@ -0,0 +1,20 @@ +package org.simantics.sysdyn.ui.browser.contributions; + +import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.exception.DatabaseException; +import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode; + +public class FunctionLibraryLabeler extends LabelerContributor>{ + + @Override + public String getLabel(ReadGraph graph, FunctionLibraryNode input) + throws DatabaseException { + String name = NameUtils.getSafeName(graph, input.data); + return name; + } + + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Functions.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryFunctions.java similarity index 51% rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Functions.java rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryFunctions.java index 344f6af3..c37ea465 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Functions.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryFunctions.java @@ -13,32 +13,32 @@ package org.simantics.sysdyn.ui.browser.contributions; import java.util.ArrayList; import java.util.Collection; -import java.util.Map; import org.simantics.browsing.ui.common.node.AbstractNode; import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.exception.DatabaseException; -import org.simantics.scl.runtime.function.Function; +import org.simantics.layer0.Layer0; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode; import org.simantics.sysdyn.ui.browser.nodes.FunctionNode; -import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder; -public class Functions extends ViewpointContributor { - - @Override - public Collection getContribution(ReadGraph graph, FunctionsFolder functionsFolder) - throws DatabaseException { - - ArrayList> result = new ArrayList>(); - Function index = graph.adapt(L0.Dependencies, Function.class); - Collection> results = (Collection>)index.apply(graph, functionsFolder.data, "Types:SysdynModelicaFunction"); - for(Map r : results) { - Resource function = (Resource)r.get("Resource"); - if(function != null); - result.add(new FunctionNode(function)); - } - return result; +public class LibraryFunctions extends ViewpointContributor> { + + @Override + public Collection getContribution(ReadGraph graph, + FunctionLibraryNode library) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + ArrayList> result = new ArrayList>(); + for(Resource function : graph.syncRequest(new ObjectsWithType(library.data, l0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModelicaFunction))) { + result.add(new FunctionNode(function)); + } + for(Resource functionLibrary : graph.syncRequest(new ObjectsWithType(library.data, l0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModelicaFunctionLibrary))) { + result.add(new FunctionLibraryNode(functionLibrary)); + } + return result; } @@ -46,6 +46,4 @@ public class Functions extends ViewpointContributor { public String getViewpointId() { return "Standard"; } - - } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SysdynProject.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SysdynProject.java new file mode 100644 index 00000000..91c46b6a --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SysdynProject.java @@ -0,0 +1,39 @@ +package org.simantics.sysdyn.ui.browser.contributions; + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.exception.DatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode; +import org.simantics.sysdyn.SysdynResource; + +public class SysdynProject extends ViewpointContributor { + + @Override + public Collection getContribution(ReadGraph graph, Resource project) + throws DatabaseException { + + ArrayList result = new ArrayList(); + Layer0 L0 = Layer0.getInstance(graph); + for(Resource r : graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModel))) { + try { + result.add(graph.adapt(r, AbstractNode.class)); + } catch(DatabaseException e) { + e.printStackTrace(); + } + } + return result; + + } + + @Override + public String getViewpointId() { + return "Standard"; + } + +} \ No newline at end of file diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionLibraryNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionLibraryNode.java new file mode 100644 index 00000000..eddb126b --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionLibraryNode.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 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.sysdyn.ui.browser.nodes; + +import org.simantics.browsing.ui.common.node.AbstractNode; +import org.simantics.browsing.ui.common.node.DeleteException; +import org.simantics.browsing.ui.common.node.IDeletableNode; +import org.simantics.browsing.ui.common.node.IDropTargetNode; +import org.simantics.browsing.ui.common.node.IModifiableNode; +import org.simantics.browsing.ui.content.Labeler.Modifier; +import org.simantics.browsing.ui.graph.impl.LabelModifier; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.manager.FunctionUtils; +import org.simantics.ui.SimanticsUI; +import org.simantics.ui.utils.ResourceAdaptionUtils; + +public class FunctionLibraryNode extends AbstractNode implements IDeletableNode, IModifiableNode, IDropTargetNode { + + + public FunctionLibraryNode(Resource resource) { + super(resource); + } + + @Override + public Modifier getModifier(String columnId) { + try { + Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName; + LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) { + @Override + public String isValid(String label) { + if (label.isEmpty()) + return "Empty label not allowed"; + if (label.contains(" ")) + return "Spaces are not allowed"; + return null; + } + }; + return modifier; + } catch (DatabaseException e) { + e.printStackTrace(); + } + return null; + } + + @Override + public void delete() throws DeleteException { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + graph.deny(data, l0.PartOf); + } + }); + } + + @Override + public void drop(Object data) { + final Resource[] resources = ResourceAdaptionUtils.toResources(data); + final Resource library = this.data; + if(resources.length > 0) { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + for(Resource tobeMoved : resources) { + if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) || + graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) { + Resource oldLib = graph.getSingleObject(tobeMoved, l0.PartOf); + graph.deny(tobeMoved, l0.PartOf); + graph.claim(tobeMoved, l0.PartOf, library); + FunctionUtils.updateFunctionFileForLibrary(graph, oldLib); + FunctionUtils.updateFunctionFileForLibrary(graph, library); + } + } + } + }); + } + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionNode.java index 31589a4c..2f2baa23 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionNode.java @@ -11,13 +11,92 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.browser.nodes; -import org.simantics.browsing.ui.common.node.IDeletable; +import org.simantics.browsing.ui.common.node.DeleteException; +import org.simantics.browsing.ui.common.node.IDeletableNode; +import org.simantics.browsing.ui.common.node.IDropTargetNode; +import org.simantics.browsing.ui.common.node.IModifiableNode; +import org.simantics.browsing.ui.content.Labeler.Modifier; +import org.simantics.browsing.ui.graph.impl.LabelModifier; import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.manager.FunctionUtils; +import org.simantics.ui.SimanticsUI; +import org.simantics.ui.utils.ResourceAdaptionUtils; -public class FunctionNode extends VariableNode implements IDeletable { +public class FunctionNode extends VariableNode implements IDeletableNode, IModifiableNode, IDropTargetNode { public FunctionNode(final Resource resource) { super(resource); } + + @Override + public Modifier getModifier(String columnId) { + try { + Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName; + LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) { + @Override + public String isValid(String label) { + if (label.isEmpty()) + return "Empty label not allowed"; + if (label.contains(" ")) + return "Spaces are not allowed"; + return null; + } + }; + return modifier; + } catch (DatabaseException e) { + e.printStackTrace(); + } + return null; + } + @Override + public void delete() throws DeleteException { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + Resource partOf = graph.getSingleObject(data, l0.PartOf); + if(partOf != null) { + graph.deny(data, l0.PartOf, partOf); + } + } + }); + } + + @Override + public void drop(Object data) { + final Resource[] resources = ResourceAdaptionUtils.toResources(data); + final Resource thisFunction = this.data; + + if(resources.length > 0) { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + Resource library = null; + for(Resource tobeMoved : resources) { + if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) || + graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) { + if(library == null) { + library = graph.getSingleObject(thisFunction, l0.PartOf); + } + Resource oldLib = graph.getSingleObject(tobeMoved, l0.PartOf); + graph.deny(tobeMoved, l0.PartOf); + graph.claim(tobeMoved, l0.PartOf, library); + FunctionUtils.updateFunctionFileForLibrary(graph, oldLib); + FunctionUtils.updateFunctionFileForLibrary(graph, library); + } + } + } + }); + } + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionsFolder.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionsFolder.java index c8c57352..bbba4a0b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionsFolder.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionsFolder.java @@ -12,9 +12,18 @@ package org.simantics.sysdyn.ui.browser.nodes; import org.simantics.browsing.ui.common.node.AbstractNode; +import org.simantics.browsing.ui.common.node.IDropTargetNode; import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.manager.FunctionUtils; +import org.simantics.ui.SimanticsUI; +import org.simantics.ui.utils.ResourceAdaptionUtils; -public class FunctionsFolder extends AbstractNode { +public class FunctionsFolder extends AbstractNode implements IDropTargetNode{ public FunctionsFolder(Resource resource) { super(resource); @@ -27,4 +36,35 @@ public class FunctionsFolder extends AbstractNode { return null; return super.getAdapter(adapter); } + + @Override + public void drop(Object data) { + final Resource[] resources = ResourceAdaptionUtils.toResources(data); + final Resource library = this.data; + if(resources.length > 0) { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + for(Resource tobeMoved : resources) { + if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) || + graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) { + Resource oldLib = graph.getSingleObject(tobeMoved, l0.PartOf); + graph.deny(tobeMoved, l0.PartOf); + graph.claim(tobeMoved, l0.PartOf, library); + FunctionUtils.updateFunctionFileForLibrary(graph, oldLib); + FunctionUtils.updateFunctionFileForLibrary(graph, library); + } + } + } + }); + } + } + + + + + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SharedFunctionLibraryNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SharedFunctionLibraryNode.java new file mode 100644 index 00000000..7d764691 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SharedFunctionLibraryNode.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 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.sysdyn.ui.browser.nodes; + +import org.simantics.browsing.ui.common.node.DeleteException; +import org.simantics.browsing.ui.common.node.IDropTargetNode; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.manager.FunctionUtils; +import org.simantics.ui.SimanticsUI; +import org.simantics.ui.utils.ResourceAdaptionUtils; + +public class SharedFunctionLibraryNode extends FunctionLibraryNode implements IDropTargetNode { + + public SharedFunctionLibraryNode(Resource resource) { + super(resource); + } + + @Override + public void delete() throws DeleteException { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + + graph.deny(data, l0.PartOf); + graph.deny(data, l0.IsLinkedTo_Inverse); + + // TODO: remove file + } + }); + } + + @Override + public void drop(Object data) { + final Resource[] resources = ResourceAdaptionUtils.toResources(data); + final Resource library = this.data; + if(resources.length > 0) { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + for(Resource tobeMoved : resources) { + if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) || + graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) { + Resource oldLib = graph.getSingleObject(tobeMoved, l0.PartOf); + graph.deny(tobeMoved, l0.PartOf); + graph.claim(tobeMoved, l0.PartOf, library); + FunctionUtils.updateFunctionFileForLibrary(graph, oldLib); + FunctionUtils.updateFunctionFileForLibrary(graph, library); + } + } + + } + }); + } + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportFunctionLibrary.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportFunctionLibrary.java new file mode 100644 index 00000000..4ad047d1 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportFunctionLibrary.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 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.sysdyn.ui.handlers; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; +import org.simantics.databoard.Bindings; +import org.simantics.databoard.Files; +import org.simantics.databoard.binding.error.RuntimeBindingConstructionException; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.primitiverequest.PossibleRelatedValue; +import org.simantics.db.common.request.ReadRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.TransferableGraphRequest2; +import org.simantics.db.request.Read; +import org.simantics.graph.representation.TransferableGraph1; +import org.simantics.layer0.Layer0; +import org.simantics.ui.SimanticsUI; +import org.simantics.ui.utils.ResourceAdaptionUtils; +import org.simantics.utils.datastructures.Pair; + +public class ExportFunctionLibrary extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + ISelection sel = HandlerUtil.getCurrentSelection(event); + final Resource functionLibrary = ResourceAdaptionUtils.toSingleResource(sel); + if(functionLibrary == null) return null; + + String name = null; + try { + name = SimanticsUI.getSession().syncRequest(new Read() { + + @Override + public String perform(ReadGraph graph) throws DatabaseException { + if (!graph.hasStatement(functionLibrary, Layer0.getInstance(graph).PartOf)) + return null; + Layer0 l0 = Layer0.getInstance(graph); + String name = graph.syncRequest(new PossibleRelatedValue(functionLibrary, l0.HasName, Bindings.STRING )); + return name; + + } + + }); + } catch (DatabaseException e1) { + e1.printStackTrace(); + } + if(name == null) return null; + + Shell shell = HandlerUtil.getActiveShellChecked(event); + FileDialog fd = new FileDialog(shell, SWT.SAVE); + fd.setText("Export.."); + fd.setFileName(name); + fd.setFilterPath(Platform.getLocation().toOSString()); + String[] filterExt = {"*.tg"}; + fd.setFilterExtensions(filterExt); + final String selected = fd.open(); + if(selected == null) return null; + + + SimanticsUI.getSession().asyncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + String name = graph.syncRequest(new PossibleRelatedValue(functionLibrary, l0.HasName, Bindings.STRING )); + ArrayList> roots = new ArrayList>(); + roots.add(Pair.make(functionLibrary, name)); + TransferableGraph1 tg = graph.syncRequest(new TransferableGraphRequest2(roots, functionLibrary)); + + try { + Files.createFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class), tg); + } catch (RuntimeBindingConstructionException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + + } + }); + + return null; + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportExternalFunctionFilesHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportExternalFunctionFilesHandler.java index c8f30da2..21158257 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportExternalFunctionFilesHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportExternalFunctionFilesHandler.java @@ -22,9 +22,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.handlers.HandlerUtil; -import org.simantics.browsing.ui.platform.PropertyPageView; import org.simantics.databoard.Bindings; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; @@ -33,7 +31,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.Layer0; import org.simantics.layer0.utils.direct.GraphUtils; import org.simantics.sysdyn.SysdynResource; -import org.simantics.sysdyn.ui.properties.SysdynPropertyPage; +import org.simantics.sysdyn.manager.FunctionUtils; import org.simantics.ui.SimanticsUI; import org.simantics.utils.datastructures.Pair; @@ -42,13 +40,6 @@ public class ImportExternalFunctionFilesHandler extends AbstractHandler { public static final String[] C_EXTENSIONS = {"*.c","*.h","*.a","*.o"}; @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IWorkbenchPart part = HandlerUtil.getActivePart(event); - PropertyPageView ppv = (PropertyPageView)part; - SysdynPropertyPage page = (SysdynPropertyPage)ppv.getCurrentPage(); - Object o = page.getAdapter(Resource.class); - if (part == null) - return null; - Shell shell = HandlerUtil.getActiveShellChecked(event); Pair selected = importFiles(shell, "Import...", C_EXTENSIONS); if(selected.second == null || selected.second.length < 1) return null; @@ -101,12 +92,14 @@ public class ImportExternalFunctionFilesHandler extends AbstractHandler { FileInputStream fis = new FileInputStream(file); fis.read(fileBArray); graph.claimLiteral(externalFile, sr.HasExternalFile, fileBArray, Bindings.BYTE_ARRAY); + + FunctionUtils.createExternalFunctionFile(graph, externalFile); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportFunctionLibrary.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportFunctionLibrary.java new file mode 100644 index 00000000..422f3dc8 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportFunctionLibrary.java @@ -0,0 +1,178 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 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.sysdyn.ui.handlers; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; +import org.simantics.databoard.Bindings; +import org.simantics.databoard.Files; +import org.simantics.databoard.binding.error.RuntimeBindingConstructionException; +import org.simantics.db.Builtins; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.WriteOnlyGraph; +import org.simantics.db.common.request.ReadRequest; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.ResourceNotFoundException; +import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler; +import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor; +import org.simantics.db.request.Read; +import org.simantics.graph.representation.Root; +import org.simantics.graph.representation.TransferableGraph1; +import org.simantics.layer0.Layer0; +import org.simantics.layer0.utils.direct.GraphUtils; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.manager.FunctionUtils; +import org.simantics.ui.SimanticsUI; +import org.simantics.ui.utils.ResourceAdaptionUtils; + +public class ImportFunctionLibrary extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Resource project = SimanticsUI.getProject().get(); + if(project == null) return null; + + ISelection sel = HandlerUtil.getCurrentSelection(event); + final Resource functionLibrary = ResourceAdaptionUtils.toSingleResource(sel); + if(functionLibrary == null) return null; + + Shell shell = HandlerUtil.getActiveShellChecked(event); + FileDialog fd = new FileDialog(shell, SWT.OPEN); + fd.setText("Import Function Library"); + fd.setFilterPath(Platform.getLocation().toOSString()); + String[] filterExt = {"*.tg"}; + fd.setFilterExtensions(filterExt); + String selected = fd.open(); + if(selected == null) return null; + + TransferableGraph1 tg = null; + try { + tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class)); + } catch (RuntimeBindingConstructionException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + if(tg == null) return null; + + + try { + Boolean hasSharedOntologies; + hasSharedOntologies = SimanticsUI.getSession().syncRequest(new Read() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + try { + graph.getResource("http://SharedOntologies"); + } catch (ResourceNotFoundException e) { + return false; + } + return true; + } + }); + + if(!hasSharedOntologies) { + SimanticsUI.getSession().syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + GraphUtils.create2(graph, l0.Library, + l0.HasName, "SharedOntologies", + l0.PartOf, graph.getResource("http:/")); + } + }); + + } + } catch (DatabaseException e) { + e.printStackTrace(); + return null; + } + + + SysdynFunctionLibraryImportAdvisor ia = new SysdynFunctionLibraryImportAdvisor(functionLibrary); + try { + DefaultPasteHandler.defaultExecute(tg, functionLibrary, ia); + } catch (Exception e) { + e.printStackTrace(); + } + + SimanticsUI.getSession().asyncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + FunctionUtils.updateFunctionFileForLibrary(graph, functionLibrary); + } + }); + return null; + } + + private class SysdynFunctionLibraryImportAdvisor extends DefaultPasteImportAdvisor { + + + Resource model = null; + + public SysdynFunctionLibraryImportAdvisor(Resource library) { + super(library); + } + + @Override + public void analyzeType(ReadGraph graph, Root root) throws DatabaseException { + if(root.type.equals(SysdynResource.URIs.SharedFunctionOntology)) { + library = null; + try { + SysdynResource sr = SysdynResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + Resource r = library; + while(!graph.isInstanceOf(r, sr.SysdynModel) && graph.isInstanceOf(r, l0.Ontology)) + r = graph.getSingleObject(r, l0.PartOf); + if(graph.isInstanceOf(r, sr.SysdynModel)) + model = r; + + library = graph.getResource("http://SharedOntologies"); + } catch (ResourceNotFoundException e) { + e.printStackTrace(); + } + } + } + + @Override + public Resource createRoot(WriteOnlyGraph graph, Root root) throws DatabaseException { + Builtins b = graph.getBuiltins(); + this.root = graph.newResource(); + graph.claim(library, b.ConsistsOf, b.PartOf, this.root); + String name = root.name; + String newName = nameMappings.get(name); + graph.addLiteral(this.root, b.HasName, b.NameOf, b.String, newName, Bindings.STRING); + if(model != null && root.type.equals(SysdynResource.URIs.SharedFunctionOntology)) { + graph.claim(model, b.IsLinkedTo, b.IsLinkedTo_Inverse, this.root); + } + return this.root; + + } + + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionHandler.java index 926cde5d..41080156 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionHandler.java @@ -16,6 +16,7 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.handlers.HandlerUtil; +import org.simantics.browsing.ui.common.node.AbstractNode; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.common.request.WriteRequest; @@ -25,7 +26,6 @@ import org.simantics.layer0.Layer0; import org.simantics.layer0.utils.direct.GraphUtils; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.manager.FunctionUtils; -import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder; import org.simantics.ui.SimanticsUI; import org.simantics.ui.utils.AdaptionUtils; @@ -36,27 +36,39 @@ public class NewFunctionHandler extends AbstractHandler { ISelection sel = HandlerUtil.getCurrentSelection(event); - FunctionsFolder node = AdaptionUtils.adaptToSingle(sel, FunctionsFolder.class); + @SuppressWarnings("unchecked") + AbstractNode node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class); if (node == null) return null; - final Resource model = node.data; + final Resource data = node.data; SimanticsUI.getSession().asyncRequest(new WriteRequest() { @Override public void perform(WriteGraph g) throws DatabaseException { Layer0 l0 = Layer0.getInstance(g); - String name = NameUtils.findFreshName(g, "Function", model, l0.ConsistsOf, "%s%d"); - SysdynResource sr = SysdynResource.getInstance(g); + + Resource library = null; + if(g.isInstanceOf(data, sr.SysdynModel) || g.isInstanceOf(data, l0.Library)) + library = data; + else if (g.isInstanceOf(data, sr.SysdynModelicaFunction)) + library = g.getPossibleObject(data, l0.PartOf); + + if(library == null) + return; + + + String name = NameUtils.findFreshName(g, "Function", library, l0.ConsistsOf, "%s%d"); + GraphUtils.create2(g, sr.SysdynModelicaFunction, l0.HasName, name, l0.HasDescription, "", sr.HasModelicaFunctionCode, "", - l0.PartOf, model); + l0.PartOf, library); - FunctionUtils.updateFunctionFileForLibrary(g, model); + FunctionUtils.updateFunctionFileForLibrary(g, library); } }); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionLibraryHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionLibraryHandler.java new file mode 100644 index 00000000..3465aa12 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionLibraryHandler.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 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.sysdyn.ui.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.handlers.HandlerUtil; +import org.simantics.browsing.ui.common.node.AbstractNode; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.ResourceNotFoundException; +import org.simantics.layer0.Layer0; +import org.simantics.layer0.utils.direct.GraphUtils; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.manager.FunctionUtils; +import org.simantics.ui.SimanticsUI; +import org.simantics.ui.utils.AdaptionUtils; + +public class NewFunctionLibraryHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + ISelection sel = HandlerUtil.getCurrentSelection(event); + + @SuppressWarnings("unchecked") + AbstractNode node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class); + if (node == null) + return null; + + createLibrary(node.data, false); + return null; + } + + /** + * Create function library. Shared libraries are created to root, local libraries to the model. + * Shared libraries can be used in other models in the project. + * + * @param model The initial location of the command + * @param shared Shared libraries are created to root, local libraries to the model. + */ + protected void createLibrary(final Resource model, final boolean shared) { + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph g) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(g); + SysdynResource sr = SysdynResource.getInstance(g); + + if(!(g.isInstanceOf(model, sr.SysdynModel) || + g.isInstanceOf(model, sr.SysdynModelicaFunctionLibrary) || + g.isInstanceOf(model, sr.SharedFunctionOntology))) + return; + + Resource root = model; + + String name = "FunctionLibrary"; + Resource libraryType = sr.SysdynModelicaFunctionLibrary; + + if(shared) { + + try { + root = g.getResource("http://SharedOntologies"); + } catch (ResourceNotFoundException e) { + root = g.getResource("http:/"); + root = GraphUtils.create2(g, l0.Library, + l0.HasName, "SharedOntologies", + l0.PartOf, root); + } + + name = "Shared" + name; + libraryType = sr.SharedFunctionOntology; + } + + name = NameUtils.findFreshName(g, name, root, l0.ConsistsOf, "%s%d"); + + Resource functionLibrary = GraphUtils.create2(g, libraryType, + l0.HasName, name, + l0.HasDescription, "", + l0.PartOf, root); + + if(shared) + g.claim(model, l0.IsLinkedTo, functionLibrary); + + FunctionUtils.updateFunctionFileForLibrary(g, functionLibrary); + } + }); + } +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSharedFunctionLibraryHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSharedFunctionLibraryHandler.java new file mode 100644 index 00000000..83ab3442 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewSharedFunctionLibraryHandler.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 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.sysdyn.ui.handlers; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.handlers.HandlerUtil; +import org.simantics.browsing.ui.common.node.AbstractNode; +import org.simantics.db.Resource; +import org.simantics.ui.utils.AdaptionUtils; + +public class NewSharedFunctionLibraryHandler extends NewFunctionLibraryHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + ISelection sel = HandlerUtil.getCurrentSelection(event); + + @SuppressWarnings("unchecked") + AbstractNode node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class); + if (node == null) + return null; + + createLibrary(node.data, true); + return null; + } +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionLibraryTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionLibraryTab.java new file mode 100644 index 00000000..abbdacf4 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionLibraryTab.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 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.sysdyn.ui.properties; + +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbenchSite; +import org.simantics.browsing.ui.swt.PropertyTabContributorImpl; +import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory; +import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; +import org.simantics.browsing.ui.swt.widgets.TrackedText; +import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; +import org.simantics.db.management.ISessionContext; +import org.simantics.layer0.Layer0; + +public class FunctionLibraryTab extends PropertyTabContributorImpl { + + @Override + public void createControls(Composite body, IWorkbenchSite site, + ISessionContext context, WidgetSupport support) { + Composite composite = new Composite(body, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite); + + + TrackedText nameText = new TrackedText(composite, support, SWT.BORDER); + nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName)); + nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName)); + GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget()); + + + TrackedText information = new TrackedText(composite, support, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); + information.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasDescription)); + information.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasDescription)); + GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget()); + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileNode.java index 493a574b..409ee860 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileNode.java @@ -21,7 +21,9 @@ import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.request.Write; import org.simantics.layer0.Layer0; +import org.simantics.sysdyn.manager.FunctionUtils; import org.simantics.ui.SimanticsUI; public class ExternalFileNode extends AbstractNode implements IModifiableNode, IDeletableNode { @@ -33,7 +35,7 @@ public class ExternalFileNode extends AbstractNode implements IModifia @Override public Modifier getModifier(String columnId) { try { - Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName; + final Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName; LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) { @Override public String isValid(String label) { @@ -43,6 +45,18 @@ public class ExternalFileNode extends AbstractNode implements IModifia return "Spaces are not allowed"; return null; } + + @Override + protected Write getWriteRequest(final String label) { + return new WriteRequest() { + @Override + public void perform(WriteGraph g) throws DatabaseException { + FunctionUtils.removeExternalFunctionFile(g, data); + g.claimLiteral(data, hasName, label); + FunctionUtils.createExternalFunctionFile(g, data); + } + }; + } }; return modifier; } catch (DatabaseException e) { @@ -62,6 +76,7 @@ public class ExternalFileNode extends AbstractNode implements IModifia if(function != null) { graph.deny(data, l0.PartOf, function); } + FunctionUtils.removeExternalFunctionFile(graph, data); } }); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/OldTransferableGraph1.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/OldTransferableGraph1.java new file mode 100644 index 00000000..558f5a33 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/OldTransferableGraph1.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * 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.sysdyn.ui.utils; + +import org.simantics.databoard.Bindings; +import org.simantics.databoard.binding.Binding; +import org.simantics.databoard.serialization.Serializer; +import org.simantics.graph.representation.External; +import org.simantics.graph.representation.Identity; +import org.simantics.graph.representation.Internal; +import org.simantics.graph.representation.Root; +import org.simantics.graph.representation.TransferableGraph1; +import org.simantics.graph.representation.Value; + + +/** + * Transferable graph datatype. + * See specification. + * @author Hannu Niemistö + */ +public class OldTransferableGraph1 { + public static Binding BINDING = Bindings.getBindingUnchecked(TransferableGraph1.class); + public static Serializer SERIALIZER = Bindings.getSerializerUnchecked(BINDING); + + public int resourceCount; + public Identity[] identities; + public int[] statements; + public Value[] values; + + public OldTransferableGraph1() { + } + + public OldTransferableGraph1(int resourceCount, Identity[] identities, + int[] statements, Value[] values) { + this.resourceCount = resourceCount; + this.identities = identities; + this.statements = statements; + this.values = values; + } + + public void print() { + System.out.println("Identities"); + for(Identity id : identities) { + System.out.print(" " + id.resource + " = "); + if(id.definition instanceof Root) { + Root def = (Root)id.definition; + System.out.println("ROOT(" + def.name + ")"); + } + else if(id.definition instanceof External) { + External def = (External)id.definition; + System.out.println("EXTERNAL(" + def.parent + ", " + def.name + ")"); + } + else if(id.definition instanceof Internal) { + Internal def = (Internal)id.definition; + System.out.println("INTERNAL(" + def.parent + ", " + def.name + ")"); + } + } + System.out.println("Statements:"); + for(int i=0;i + + \ No newline at end of file diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/FunctionUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/FunctionUtils.java index aa06e2c7..def1fcbb 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/FunctionUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/FunctionUtils.java @@ -2,6 +2,8 @@ package org.simantics.sysdyn.manager; import java.io.File; import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Collection; @@ -10,12 +12,14 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.Simantics; import org.simantics.layer0.Layer0; import org.simantics.scl.runtime.function.Function; import org.simantics.simulation.ontology.SimulationResource; @@ -28,25 +32,21 @@ public class FunctionUtils { final ArrayList paths = new ArrayList(); try { - model.session.syncRequest(new ReadRequest() { + Simantics.getSession().syncRequest(new ReadRequest() { @Override public void run(ReadGraph graph) throws DatabaseException { SysdynResource sr = SysdynResource.getInstance(graph); - Layer0 l0 = Layer0.getInstance(graph); SimulationResource simu = SimulationResource.getInstance(graph); Set parents = getParents(graph, model); for(Resource parent : parents) { - Resource partof = graph.getPossibleObject(parent, l0.PartOf); if(graph.isInstanceOf(parent, sr.SysdynModel)) { Resource configuration = graph.getPossibleObject(parent, simu.HasConfiguration); - if(configuration.equals(model.configurationResource)) { + if(configuration.equals(model.getConfigurationResource())) { String parentName = NameUtils.getSafeName(graph, parent); paths.add(parentName + "_functions.mo"); } - } else if (graph.isInstanceOf(partof, sr.SysdynModel)) { - // TODO } else { String libraryname = NameUtils.getSafeName(graph, parent); paths.add("..\\\\..\\\\libraries\\\\functions\\\\" + libraryname + ".mo"); @@ -63,21 +63,80 @@ public class FunctionUtils { private static Set getParents(ReadGraph graph, SysdynModel model) throws DatabaseException{ HashSet parents = new HashSet(); + HashSet checked = new HashSet(); + ArrayList toCheck = new ArrayList(); Layer0 l0 = Layer0.getInstance(graph); + SysdynResource sr = SysdynResource.getInstance(graph); SimulationResource simu = SimulationResource.getInstance(graph); - Resource modelResource = graph.getPossibleObject(model.configurationResource, simu.IsConfigurationOf); + Resource modelResource = graph.getPossibleObject(model.getConfigurationResource(), simu.IsConfigurationOf); + + + // add model to parents and all the model libraries to checked + if(!graph.syncRequest(new ObjectsWithType(modelResource, l0.ConsistsOf, sr.SysdynModelicaFunction)).isEmpty() || + !graph.syncRequest(new ObjectsWithType(modelResource, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary)).isEmpty()) { + parents.add(modelResource); + toCheck.clear(); + toCheck.add(modelResource); + while(!toCheck.isEmpty()){ + Resource checkedLibrary = toCheck.get(0); + checked.add(checkedLibrary); + toCheck.addAll(graph.syncRequest(new ObjectsWithType(checkedLibrary, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))); + toCheck.remove(checkedLibrary); + } + } + + // add all linked function ontologies to parents and their children ontologies to checked + Function index = graph.adapt(l0.Dependencies, Function.class); + Collection> results = (Collection>)index.apply(graph, modelResource, "Types:SharedFunctionOntology"); + for(Map r : results) { + Resource sharedLibrary = (Resource)r.get("Resource"); + if(sharedLibrary == null) + continue; + if(graph.syncRequest(new ObjectsWithType(sharedLibrary, l0.ConsistsOf, sr.SysdynModelicaFunction)).isEmpty() && + graph.syncRequest(new ObjectsWithType(sharedLibrary, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary)).isEmpty()) + continue; + + parents.add(sharedLibrary); + toCheck.clear(); + toCheck.add(sharedLibrary); + while(!toCheck.isEmpty()){ + Resource checkedLibrary = toCheck.get(0); + checked.add(checkedLibrary); + toCheck.addAll(graph.syncRequest(new ObjectsWithType(checkedLibrary, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))); + toCheck.remove(checkedLibrary); + } + } + + // it is assumed that only built-in function libraries remain if(modelResource != null) { - Function index = graph.adapt(l0.Dependencies, Function.class); - Collection> results = (Collection>)index.apply(graph, modelResource, "Types:SysdynModelicaFunction"); + index = graph.adapt(l0.Dependencies, Function.class); + results = (Collection>)index.apply(graph, modelResource, "Types:SysdynModelicaFunctionLibrary"); for(Map r : results) { - Resource function = (Resource)r.get("Resource"); - if(function != null) { - parents.add(graph.getSingleObject(function, l0.PartOf)); + Resource library = (Resource)r.get("Resource"); + if(library != null && !checked.contains(library)) { + + while(!graph.isInstanceOf(library, sr.SysdynModel) && !graph.isInstanceOf(library, l0.Ontology)) { + library = graph.getPossibleObject(library, l0.PartOf); + } + + if(graph.syncRequest(new ObjectsWithType(library, l0.ConsistsOf, sr.SysdynModelicaFunction)).isEmpty() && + graph.syncRequest(new ObjectsWithType(library, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary)).isEmpty()) + continue; + + parents.add(library); + + toCheck.clear(); + toCheck.add(library); + while(!toCheck.isEmpty()){ + Resource checkedLibrary = toCheck.get(0); + checked.add(checkedLibrary); + toCheck.addAll(graph.syncRequest(new ObjectsWithType(checkedLibrary, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))); + toCheck.remove(checkedLibrary); + } } } } - return parents; } @@ -91,7 +150,7 @@ public class FunctionUtils { if(graph.isInstanceOf(parent, sr.SysdynModel)) { String parentName = NameUtils.getSafeName(graph, parent); File scriptFile = new File(model.getSimulationDir(), parentName + "_functions.mo"); - updateFunctionFile(graph, parent, scriptFile); + updateFunctionFile(graph, parent, scriptFile, false); } else { updateFunctionFileForLibrary(graph, parent); } @@ -99,8 +158,76 @@ public class FunctionUtils { return; } + private static File getDir(ReadGraph graph, Resource resource) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + + Resource library = resource; + while(!graph.isInstanceOf(library, sr.SysdynModel) && !graph.isInstanceOf(library, l0.Ontology)) { + library = graph.getSingleObject(resource, l0.PartOf); + } + + File dir = null; + + if(graph.isInstanceOf(library, sr.SysdynModel)) { + SimulationResource simu = SimulationResource.getInstance(graph); + Resource configuration = graph.getSingleObject(library, simu.HasConfiguration); + SysdynModelManager smm = SysdynModelManager.getInstance(graph.getSession()); + SysdynModel model = smm.getModel(graph, configuration); + dir = model.getSimulationDir(); + } else { + File librariesDir = Activator.getBundleContext().getDataFile("libraries"); + if (!librariesDir.exists()) { + librariesDir.mkdir(); + } + dir = new File(librariesDir, "functions"); + if (!dir.exists()) { + dir.mkdir(); + } + } + return dir; + } + + public static void createExternalFunctionFile(ReadGraph graph, Resource externalFunction) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + + Resource function = graph.getSingleObject(externalFunction, l0.PartOf); + File dir = getDir(graph, function); + + try { + String name = NameUtils.getSafeName(graph, externalFunction); + if(name.endsWith(".o") || name.endsWith(".a")) { + FileOutputStream fos = new FileOutputStream(dir + "\\" + name); + byte[] fileBArray = graph.getPossibleRelatedValue(externalFunction, sr.HasExternalFile, Bindings.BYTE_ARRAY); + fos.write(fileBArray); + fos.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void removeExternalFunctionFile(ReadGraph graph, Resource externalFunction) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + + Resource function = graph.getSingleObject(externalFunction, l0.PartOf); + File dir = getDir(graph, function); + String name = NameUtils.getSafeName(graph, externalFunction); + File file = new File(dir, name); + file.delete(); + } + + + public static void updateFunctionFileForLibrary(ReadGraph graph, Resource library) throws DatabaseException { SysdynResource sr = SysdynResource.getInstance(graph); + Layer0 l0 = Layer0.getInstance(graph); + + while(!graph.isInstanceOf(library, sr.SysdynModel) && !graph.isInstanceOf(library, l0.Ontology)) { + library = graph.getSingleObject(library, l0.PartOf); + } + if(graph.isInstanceOf(library, sr.SysdynModel)) { SimulationResource simu = SimulationResource.getInstance(graph); Resource configuration = graph.getSingleObject(library, simu.HasConfiguration); @@ -108,6 +235,7 @@ public class FunctionUtils { SysdynModel model = smm.getModel(graph, configuration); updateFunctionFilesForModel(graph, model); } else { + File librariesDir = Activator.getBundleContext().getDataFile("libraries"); if (!librariesDir.exists()) { librariesDir.mkdir(); @@ -118,16 +246,20 @@ public class FunctionUtils { } String parentName = NameUtils.getSafeName(graph, library); File scriptFile = new File(dir, parentName + ".mo"); - updateFunctionFile(graph, library, scriptFile); + + Resource sysdyn = graph.getResource("http://www.simantics.org/Sysdyn-1.0"); + + if(library.equals(sysdyn)) { + updateFunctionFile(graph, library, scriptFile, true); + } else { + updateFunctionFile(graph, library, scriptFile, false); + } } } - private static void updateFunctionFile(ReadGraph graph, Resource library, File scriptFile) throws DatabaseException { - Layer0 l0 = Layer0.getInstance(graph); - SysdynResource sr = SysdynResource.getInstance(graph); - + private static void updateFunctionFile(ReadGraph graph, Resource library, File scriptFile, boolean builtIn) throws DatabaseException { PrintStream s; try { s = new PrintStream(scriptFile); @@ -135,14 +267,44 @@ public class FunctionUtils { e.printStackTrace(); return; } - + + SysdynResource sr = SysdynResource.getInstance(graph); + String name = NameUtils.getSafeName(graph, library); + if(!builtIn && !graph.isInstanceOf(library, sr.SysdynModel)) + s.println("package " + name); + writeLibrary(graph, library, s, builtIn); + if(!builtIn && !graph.isInstanceOf(library, sr.SysdynModel)) + s.println("end " + name + ";\n"); + + s.close(); + } + + private static void writeLibrary(ReadGraph graph, Resource library, PrintStream stream, boolean builtIn) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + SysdynResource sr = SysdynResource.getInstance(graph); + writeLibraryFunctions(graph, library, stream); + for(Resource sublibrary : graph.syncRequest(new ObjectsWithType(library, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))) { + String name = NameUtils.getSafeName(graph, sublibrary); + if(!builtIn) + stream.println("encapsulated package " + name); + writeLibrary(graph, sublibrary, stream, builtIn); + if(!builtIn) + stream.println("end " + name + ";\n"); + } + } + + private static void writeLibraryFunctions(ReadGraph graph, Resource library, PrintStream stream) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + SysdynResource sr = SysdynResource.getInstance(graph); for(Resource function : graph.syncRequest(new ObjectsWithType(library, l0.ConsistsOf, sr.SysdynModelicaFunction))) { String name = NameUtils.getSafeName(graph, function); String functionCode = graph.getRelatedValue(function, sr.HasModelicaFunctionCode); - s.println("function " + name); - s.println(functionCode); - s.println("end " + name + ";\n"); + stream.println("function " + name); + stream.println(functionCode); + stream.println("end " + name + ";\n"); + for(Resource externalFunction : graph.syncRequest(new ObjectsWithType(function, l0.ConsistsOf, sr.ExternalFunctionFile))) { + createExternalFunctionFile(graph, externalFunction); + } } - s.close(); } } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java index 1b5df7ce..094d29a5 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java @@ -30,6 +30,8 @@ import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; +import org.simantics.db.exception.ServiceException; import org.simantics.layer0.Layer0; import org.simantics.modelica.IModelicaMonitor; import org.simantics.modelica.ModelicaException; @@ -65,32 +67,34 @@ import org.simantics.sysdyn.representation.expressions.ParameterExpression; */ public class SysdynModel implements IMappingListener, IModel { - Session session; + private Session session; - IMapping mapping; + private IMapping mapping; - Resource configurationResource; - Configuration configuration; + private Resource configurationResource; + private Resource modelResource; + + private Configuration configuration; - Set modules = new HashSet(); + private Set modules = new HashSet(); - Process process; - boolean canceled; - SimulationResult result; - SysdynResult sysdynResult; + private Process process; + private boolean canceled; + private SimulationResult result; + private SysdynResult sysdynResult; - CopyOnWriteArrayList modificationListeners = + private CopyOnWriteArrayList modificationListeners = new CopyOnWriteArrayList(); - CopyOnWriteArrayList resultListeners = + private CopyOnWriteArrayList resultListeners = new CopyOnWriteArrayList(); @SuppressWarnings("rawtypes") - Map services = new HashMap(); + private Map services = new HashMap(); - String previousModelStructure; - HashMap previousImportantInits = new HashMap(); + private String previousModelStructure; + private HashMap previousImportantInits = new HashMap(); - File simulationDir; + private File simulationDir; void readModules(ReadGraph graph, Resource configResource, Set result) throws DatabaseException { @@ -140,38 +144,14 @@ public class SysdynModel implements IMappingListener, IModel { sysdynResult.setResult(new SimulationResult()); previousModelStructure = ""; - - File modelsDir = Activator.getBundleContext().getDataFile("models"); - String configName = configuration.getName(); - List files = Arrays.asList(modelsDir.list()); - if (files.contains(configName)) { - int i = 2; - while (files.contains(configName + "_" + i)){ - i++; - } - configName += "_" + i; - } - - simulationDir = Activator.getBundleContext().getDataFile("models/" + configName); - if (!simulationDir.exists()) { - simulationDir.mkdir(); - } - - try { - FunctionUtils.updateFunctionFilesForModel(g, this); - } catch (DatabaseException e) { - System.err.println("Error creating functions"); - e.printStackTrace(); - } - } /* * some dummy(?) stuff for experiments */ - public SysdynModel(Resource configurationResource) { - this.configurationResource = configurationResource; + public SysdynModel(Resource modelResource) { + this.modelResource = modelResource; } public synchronized void simulate(IModelicaMonitor monitor, final IProgressMonitor progressMonitor, final Experiment experiment) throws IOException { @@ -209,7 +189,7 @@ public class SysdynModel implements IMappingListener, IModel { } final SimulationLocation simulationLocation = ModelicaManager.createInputFiles( - simulationDir, + getSimulationDir(), configuration.getName(), writer.toString(), inits, @@ -400,6 +380,10 @@ public class SysdynModel implements IMappingListener, IModel { public Configuration getConfiguration() { return configuration; } + + public Resource getConfigurationResource() { + return configurationResource; + } public IMapping getMapping() { return mapping; @@ -423,7 +407,21 @@ public class SysdynModel implements IMappingListener, IModel { @Override public IExperiment loadExperiment(ReadGraph g, Resource experiment, IExperimentActivationListener listener) { - SysdynExperiment exp = new SysdynExperiment(experiment, configurationResource); + + // Not good. IModel pushes only modelResource and it is assumed that + // SysdynModel is based on configuration + if(configurationResource == null && modelResource != null) { + SimulationResource simu = SimulationResource.getInstance(g); + try { + configurationResource = g.getPossibleObject(modelResource, simu.HasConfiguration); + } catch (ManyObjectsForFunctionalRelationException e) { + e.printStackTrace(); + } catch (ServiceException e) { + e.printStackTrace(); + } + } + + SysdynExperiment exp = new SysdynExperiment(experiment, modelResource); try { exp.init(g); ExperimentRuns.createRun(g.getSession(), experiment, exp, listener, null); @@ -491,6 +489,23 @@ public class SysdynModel implements IMappingListener, IModel { } public File getSimulationDir() { + if(simulationDir == null) { + File modelsDir = Activator.getBundleContext().getDataFile("models"); + String configName = configuration.getName(); + List files = Arrays.asList(modelsDir.list()); + if (files.contains(configName)) { + int i = 2; + while (files.contains(configName + "_" + i)){ + i++; + } + configName += "_" + i; + } + + simulationDir = Activator.getBundleContext().getDataFile("models/" + configName); + if (!simulationDir.exists()) { + simulationDir.mkdir(); + } + } return simulationDir; } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModelManager.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModelManager.java index 6c2a07e4..efa5578c 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModelManager.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModelManager.java @@ -18,6 +18,7 @@ import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; +import org.simantics.simulation.ontology.SimulationResource; /** * Manages system dynamic models. @@ -45,8 +46,9 @@ public class SysdynModelManager { @Override public void run(ReadGraph graph) throws DatabaseException { - models.put(resource, new SysdynModel(graph, resource)); - + SysdynModel model = new SysdynModel(graph, resource); + models.put(resource, model); + FunctionUtils.updateFunctionFilesForModel(graph, model); } }); } catch (DatabaseException e) { @@ -69,6 +71,14 @@ public class SysdynModelManager { if(model == null) { model = new SysdynModel(g, resource); models.put(resource, model); + try { + SimulationResource simu = SimulationResource.getInstance(g); + Resource modelResource = g.getPossibleObject(model.getConfigurationResource(), simu.IsConfigurationOf); + if(modelResource != null) + FunctionUtils.updateFunctionFilesForModel(g, model); + } catch (DatabaseException e) { + e.printStackTrace(); + } } return model; } -- 2.47.1