>-- SYSDYN.Result.resultFile --> L0.String <R L0.HasProperty
>-- SYSDYN.Result.showResult --> SYSDYN.Result <R L0.IsRelatedTo : L0.Tag
@L0.symmetric
+ >-- SYSDYN.Result.time --> L0.Long <R L0.HasProperty : L0.FunctionalRelation
+
SYSDYN.HistoryDataset <T SYSDYN.Result
@L0.singleProperty L0.HasName
public final Resource Result_resultFile;\r
public final Resource Result_resultFile_Inverse;\r
public final Resource Result_showResult;\r
+ public final Resource Result_time;\r
+ public final Resource Result_time_Inverse;\r
public final Resource Right;\r
public final Resource SelectedSharedFunctionLibraries;\r
public final Resource SensitivityAnalysisExperiment;\r
public static final String Result_resultFile = "http://www.simantics.org/Sysdyn-1.1/Result/resultFile";\r
public static final String Result_resultFile_Inverse = "http://www.simantics.org/Sysdyn-1.1/Result/resultFile/Inverse";\r
public static final String Result_showResult = "http://www.simantics.org/Sysdyn-1.1/Result/showResult";\r
+ public static final String Result_time = "http://www.simantics.org/Sysdyn-1.1/Result/time";\r
+ public static final String Result_time_Inverse = "http://www.simantics.org/Sysdyn-1.1/Result/time/Inverse";\r
public static final String Right = "http://www.simantics.org/Sysdyn-1.1/Right";\r
public static final String SelectedSharedFunctionLibraries = "http://www.simantics.org/Sysdyn-1.1/SelectedSharedFunctionLibraries";\r
public static final String SensitivityAnalysisExperiment = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment";\r
Result_resultFile = getResourceOrNull(graph, URIs.Result_resultFile);\r
Result_resultFile_Inverse = getResourceOrNull(graph, URIs.Result_resultFile_Inverse);\r
Result_showResult = getResourceOrNull(graph, URIs.Result_showResult);\r
+ Result_time = getResourceOrNull(graph, URIs.Result_time);\r
+ Result_time_Inverse = getResourceOrNull(graph, URIs.Result_time_Inverse);\r
Right = getResourceOrNull(graph, URIs.Right);\r
SelectedSharedFunctionLibraries = getResourceOrNull(graph, URIs.SelectedSharedFunctionLibraries);\r
SensitivityAnalysisExperiment = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment);\r
import org.simantics.graph.db.TransferableGraphs;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
fd.setText("Export Function Library");\r
fd.setFileName(name);\r
- String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTFUNCTIONLIBRARYPATH);\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTFUNCTIONLIBRARYPATH);\r
if(path.isEmpty() || !(new File(path).exists()))\r
path = Platform.getLocation().toOSString();\r
fd.setFilterPath(path);\r
if(selected == null) return null;\r
\r
// Save location to preference store\r
- Activator.getDefault().getPreferenceStore().setValue(ImportUtils.IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
+ Activator.getDefault().getPreferenceStore().setValue(ImportUtilsUI.IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
\r
// Asynchronously create the file using transferable graph\r
SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
import org.simantics.graph.db.TransferableGraphs;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
fd.setText("Export Model");\r
fd.setFileName(name);\r
- String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODELTPATH);\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODELTPATH);\r
if(path.isEmpty() || !(new File(path).exists()))\r
path = Platform.getLocation().toOSString();\r
fd.setFilterPath(path);\r
if(selected == null) return null;\r
\r
// Save location to preference store\r
- Activator.getDefault().getPreferenceStore().setValue(ImportUtils.IMPORTMODELTPATH, (new File(selected)).getParent());\r
+ Activator.getDefault().getPreferenceStore().setValue(ImportUtilsUI.IMPORTMODELTPATH, (new File(selected)).getParent());\r
\r
// Asynchronously create the file using transferable graph\r
SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.datastructures.Pair;\r
FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
fd.setText("Export Module");\r
fd.setFileName(name);\r
- String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODULETPATH);\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODULETPATH);\r
if(path.isEmpty() || !(new File(path).exists()))\r
path = Platform.getLocation().toOSString();\r
fd.setFilterPath(path);\r
if(selected == null) return null;\r
\r
// Save location to preference store\r
- Activator.getDefault().getPreferenceStore().setValue(ImportUtils.IMPORTMODULETPATH, (new File(selected)).getParent());\r
+ Activator.getDefault().getPreferenceStore().setValue(ImportUtilsUI.IMPORTMODULETPATH, (new File(selected)).getParent());\r
\r
// Asynchronously create the file using transferable graph\r
SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
import org.simantics.db.Resource;\r
import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.ui.AdaptionUtils;\r
\r
\r
\r
// Get a transferable graph file\r
- final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
fd.setText("Import Function Library");\r
\r
- String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTFUNCTIONLIBRARYPATH);\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTFUNCTIONLIBRARYPATH);\r
if(path.isEmpty() || !(new File(path).exists()))\r
path = Platform.getLocation().toOSString();\r
fd.setFilterPath(path);\r
\r
@Override\r
protected IStatus run(IProgressMonitor monitor) {\r
- IStatus status = ImportUtils.importFunctionLibrary(functionLibrary, selected, shell, monitor);\r
+ IStatus status = ImportUtilsUI.importFunctionLibrary(functionLibrary, selected, monitor);\r
return status;\r
}\r
};\r
import org.eclipse.ui.handlers.HandlerUtil;\r
import org.simantics.DatabaseJob;\r
import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
\r
/**\r
* Imports models from exported transferable graph files.\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
\r
// Get imported transferable graph file using FileDialog\r
- final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
fd.setText("Import Model");\r
\r
- String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODELTPATH);\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODELTPATH);\r
if(path.isEmpty() || !(new File(path).exists()))\r
path = Platform.getLocation().toOSString();\r
fd.setFilterPath(path);\r
\r
@Override\r
protected IStatus run(IProgressMonitor monitor) {\r
- IStatus status = ImportUtils.importModelFile(selected, shell, monitor);\r
+ IStatus status = ImportUtilsUI.importModelFile(selected, monitor);\r
return status;\r
}\r
};\r
import org.simantics.browsing.ui.common.node.AbstractNode;\r
import org.simantics.db.Resource;\r
import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
import org.simantics.utils.ui.AdaptionUtils;\r
\r
/**\r
final Resource model = node.data;\r
\r
// Get imported transferable graph file using FileDialog\r
- final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
fd.setText("Import Module");\r
\r
- String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODULETPATH);\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODULETPATH);\r
if(path.isEmpty() || !(new File(path).exists()))\r
path = Platform.getLocation().toOSString();\r
fd.setFilterPath(path);\r
\r
@Override\r
protected IStatus run(IProgressMonitor monitor) {\r
- IStatus status = ImportUtils.importModuleFile(model, selected, shell, monitor);\r
+ IStatus status = ImportUtilsUI.importModuleFile(model, selected, monitor);\r
return status;\r
}\r
};\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2012 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ * Semantum Oy - Bug #4192\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.utils.imports;\r
+\r
+import java.io.File;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.simantics.db.Resource;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.utils.imports.ImportUtils;\r
+\r
+/**\r
+ * Utilities for importing tg files: Models, Modules and Function libraries\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class ImportUtilsUI {\r
+\r
+ public static String IMPORTMODELTPATH = "IMPORT_MODEL_PATH";\r
+ public static String IMPORTMODULETPATH = "IMPORT_MODULE_PATH";\r
+ public static String IMPORTFUNCTIONLIBRARYPATH = "IMPORT_FUNCTION_LIBRARY_PATH";\r
+\r
+\r
+ /* ********************************* */\r
+ /* ******* IMPORT MODEL ********* */\r
+ /* ********************************* */\r
+ public static IStatus importModelFile(String path, IProgressMonitor monitor) {\r
+ Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(path)).getParent());\r
+ return ImportUtils.importModelFile(path, monitor);\r
+ }\r
+\r
+\r
+ /* ********************************* */\r
+ /* ******* IMPORT MODULE ********* */\r
+ /* ********************************* */\r
+ public static IStatus importModuleFile(Resource model, String path, IProgressMonitor monitor) {\r
+ Activator.getDefault().getPreferenceStore().setValue(IMPORTMODULETPATH, (new File(path)).getParent());\r
+ return ImportUtils.importModuleFile(model, path, monitor);\r
+ }\r
+\r
+\r
+\r
+ /* ********************************* */\r
+ /* *** IMPORT FUNCTION LIBRARY *** */\r
+ /* ********************************* */\r
+\r
+ public static IStatus importFunctionLibrary(Resource functionLibrary, String path, IProgressMonitor monitor) {\r
+ Activator.getDefault().getPreferenceStore().setValue(IMPORTFUNCTIONLIBRARYPATH, (new File(path)).getParent());\r
+ return ImportUtils.importFunctionLibrary(functionLibrary, path, monitor);\r
+ }\r
+\r
+}\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.request.Read;\r
import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.datastructures.ArrayMap;\r
\r
return false;\r
}\r
\r
- IStatus status = ImportUtils.importFunctionLibrary(selectedModel, selected, shell, null);\r
+ IStatus status = ImportUtilsUI.importFunctionLibrary(selectedModel, selected, null);\r
\r
/*\r
TransferableGraph1 tg = null;\r
import org.simantics.db.Resource;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
import org.simantics.ui.SimanticsUI;\r
\r
public class WizardModelsImportPage extends WizardPage{\r
\r
dialog.setText("Import Model");\r
\r
- String path = Activator.getDefault().getPreferenceStore().getString(ImportUtils.IMPORTMODELTPATH);\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODELTPATH);\r
if(path.isEmpty() || !(new File(path).exists()))\r
path = Platform.getLocation().toOSString();\r
dialog.setFilterPath(path);\r
return false;\r
}\r
\r
- IStatus status = ImportUtils.importModelFile(selected, shell, null);\r
+ IStatus status = ImportUtilsUI.importModelFile(selected, null);\r
\r
/*\r
TransferableGraph1 tg = null;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.request.Read;\r
import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.utils.imports.ImportUtils;\r
+import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.datastructures.ArrayMap;\r
\r
return false;\r
}\r
\r
- IStatus status = ImportUtils.importModuleFile(selectedModel, selected, shell, null);\r
+ IStatus status = ImportUtilsUI.importModuleFile(selectedModel, selected, null);\r
\r
/*\r
TransferableGraph1 tg = null;\r
org.eclipse.jface.text;bundle-version="3.6.1",
org.simantics.spreadsheet.ontology;bundle-version="1.2.0",
org.simantics.fmu;bundle-version="1.0.0",
- org.simantics.fmu.me.win32;bundle-version="1.0.0"
+ org.simantics.fmu.me.win32;bundle-version="1.0.0",
+ org.simantics.issues;bundle-version="1.1.0",
+ org.simantics.issues.common;bundle-version="1.1.0"
Export-Package: org.simantics.sysdyn,
org.simantics.sysdyn.adapter,
org.simantics.sysdyn.expressionParser,
org.simantics.sysdyn.representation.utils,
org.simantics.sysdyn.representation.visitors,
org.simantics.sysdyn.simulation,
- org.simantics.sysdyn.tableParser
+ org.simantics.sysdyn.tableParser,
+ org.simantics.sysdyn.utils.imports
Bundle-Activator: org.simantics.sysdyn.Activator
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.ui
\r
private static BundleContext bundleContext;\r
\r
+ // The plug-in ID\r
+ public static final String PLUGIN_ID = "org.simantics.sysdyn";\r
+ \r
+ // The shared instance\r
+ private static Activator plugin;\r
+ \r
@Override\r
public void start(BundleContext context) throws Exception {\r
bundleContext = context;\r
if (!modelsDir.exists()) {\r
modelsDir.mkdir();\r
}\r
+ plugin = this;\r
}\r
\r
@Override\r
if (modelsDir.exists()) {\r
recursiveDelete(modelsDir);\r
}\r
+ plugin = null;\r
+\r
+ }\r
+\r
+ public static Activator getDefault() {\r
+ return plugin;\r
}\r
\r
public static BundleContext getBundleContext() {\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.manager;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ActiveResults implements Read<Collection<Resource>>{\r
+ \r
+ private Resource resource;\r
+ \r
+ public ActiveResults(Resource resource) {\r
+ this.resource = resource;\r
+ }\r
+\r
+ @Override\r
+ public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ SysdynResource SR = SysdynResource.getInstance(graph);\r
+ ModelingResources MR = ModelingResources.getInstance(graph);\r
+ \r
+ Collection<Resource> result = new ArrayList<Resource>();\r
+ \r
+ Collection<Resource> experiments;\r
+ if(graph.isInstanceOf(resource, MR.StructuralModel))\r
+ experiments = graph.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, SR.Experiment));\r
+ else {\r
+ experiments = new ArrayList<Resource>();\r
+ experiments.add(resource);\r
+ }\r
+ \r
+ for(Resource experiment : experiments) {\r
+ Collection<Resource> experimentResults = graph.getObjects(experiment, SR.Experiment_result);\r
+ for(Resource r : experimentResults) {\r
+ if(graph.hasStatement(r, SR.Result_showResult)) {\r
+ result.add(r);\r
+ }\r
+ }\r
+ }\r
+ \r
+ return result;\r
+ }\r
+\r
+}\r
l0.HasLabel, name,\r
l0.HasName, name,\r
l0.PartOf, model,\r
- sr.Result_resultFile, file.getAbsolutePath());\r
+ sr.Result_resultFile, file.getAbsolutePath(),\r
+ sr.Result_time, System.currentTimeMillis());\r
graph.claim(experiment.getResource(), sr.Experiment_result, res);\r
}\r
});\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.Session;\r
-import org.simantics.db.common.request.ObjectsWithType;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
Resource model = graph.getPossibleObject(getConfigurationResource(), SIMU.IsConfigurationOf);\r
if(model == null)\r
return null;\r
- Collection<Resource> experiments = graph.syncRequest(new ObjectsWithType(model, l0.ConsistsOf, sr.Experiment));\r
- for(Resource experiment : experiments) {\r
- Collection<Resource> experimentResults = graph.getObjects(experiment, sr.Experiment_result);\r
- for(Resource result : experimentResults) {\r
- if(graph.hasStatement(result, sr.Result_showResult)) {\r
- SysdynResult sysdynResult = null;\r
- if(graph.isInstanceOf(result, sr.HistoryDataset)) {\r
- HistoryDatasetResult r = new HistoryDatasetResult();\r
- listeningHistories.add(r);\r
- sysdynResult = new MemoryResult(r, NameUtils.getSafeLabel(graph, result));\r
- r.read((MemoryResult)sysdynResult, result);\r
- } else {\r
- sysdynResult = new FileResult(\r
- (String) graph.getPossibleRelatedValue(result, l0.HasLabel),\r
- (String) graph.getPossibleRelatedValue(result, sr.Result_resultFile));\r
- }\r
- \r
- if(sysdynResult != null)\r
- displayedResults.add(sysdynResult);\r
-\r
+ \r
+ Collection<Resource> results = graph.syncRequest(new ActiveResults(model));\r
+ for(Resource result : results) {\r
+ if(graph.hasStatement(result, sr.Result_showResult)) {\r
+ SysdynResult sysdynResult = null;\r
+ if(graph.isInstanceOf(result, sr.HistoryDataset)) {\r
+ HistoryDatasetResult r = new HistoryDatasetResult();\r
+ listeningHistories.add(r);\r
+ sysdynResult = new MemoryResult(r, NameUtils.getSafeLabel(graph, result));\r
+ r.read((MemoryResult)sysdynResult, result);\r
+ } else {\r
+ sysdynResult = new FileResult(\r
+ (String) graph.getPossibleRelatedValue(result, l0.HasLabel),\r
+ (String) graph.getPossibleRelatedValue(result, sr.Result_resultFile));\r
}\r
+\r
+ if(sysdynResult != null)\r
+ displayedResults.add(sysdynResult);\r
}\r
}\r
} catch (Exception e) {\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
* Semantum Oy - Bug #4192\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.utils.imports;\r
+package org.simantics.sysdyn.utils.imports;\r
\r
import java.io.File;\r
import java.io.IOException;\r
import org.eclipse.core.runtime.IStatus;\r
import org.eclipse.core.runtime.Status;\r
import org.eclipse.core.runtime.SubMonitor;\r
-import org.eclipse.swt.widgets.Shell;\r
import org.simantics.Simantics;\r
import org.simantics.databoard.container.DataContainers;\r
import org.simantics.databoard.container.DataFormatException;\r
import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.ui.SimanticsUI;\r
+import org.simantics.sysdyn.Activator;\r
\r
/**\r
* Utilities for importing tg files: Models, Modules and Function libraries\r
*/\r
public class ImportUtils {\r
\r
- public static String IMPORTMODELTPATH = "IMPORT_MODEL_PATH";\r
- public static String IMPORTMODULETPATH = "IMPORT_MODULE_PATH";\r
- public static String IMPORTFUNCTIONLIBRARYPATH = "IMPORT_FUNCTION_LIBRARY_PATH";\r
-\r
/**\r
* Null-checked begin task for monitor\r
* @param monitor\r
/* ********************************* */\r
/* ******* IMPORT MODEL ********* */\r
/* ********************************* */\r
- public static IStatus importModelFile(String path, final Shell shell, final IProgressMonitor monitor) {\r
- final Resource project = SimanticsUI.getProject().get();\r
+ public static IStatus importModelFile(String path, final IProgressMonitor monitor) {\r
+ final Resource project = Simantics.getProject().get();\r
if(project == null) return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model: project not found", null);\r
\r
beginTask(monitor, "Import model", 9);\r
\r
- Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(path)).getParent());\r
-\r
MigrationState state = MigrationUtils.newState();\r
state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
state.setProperty(MigrationStateKeys.UPDATE_DEPENDENCIES, Boolean.FALSE);\r
\r
Resource result = null;\r
try {\r
- result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(project), project);\r
+ result = MigrationUtils.importMigrated(monitor, Simantics.getSession(), new File(path), state, new DefaultPasteImportAdvisor(project), project);\r
} catch (Exception e1) {\r
e1.printStackTrace();\r
}\r
} else {\r
try {\r
final Resource ModelRoot = result;\r
- IStatus status = SimanticsUI.getSession().syncRequest(new WriteResultRequest<IStatus>() {\r
+ IStatus status = Simantics.getSession().syncRequest(new WriteResultRequest<IStatus>() {\r
\r
@Override\r
public IStatus perform(WriteGraph graph) throws DatabaseException {\r
return status;\r
\r
subTask(monitor, "Validate model");\r
- Collection<Resource> confs = SimanticsUI.getSession().syncRequest(new Read<Collection<Resource>>() {\r
+ Collection<Resource> confs = Simantics.getSession().syncRequest(new Read<Collection<Resource>>() {\r
\r
@Override\r
public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
/* ********************************* */\r
/* ******* IMPORT MODULE ********* */\r
/* ********************************* */\r
- public static IStatus importModuleFile(final Resource model, String path, final Shell shell, final IProgressMonitor monitor) {\r
+ public static IStatus importModuleFile(final Resource model, String path, final IProgressMonitor monitor) {\r
beginTask(monitor, "Import Module", 3);\r
\r
-\r
- Activator.getDefault().getPreferenceStore().setValue(IMPORTMODULETPATH, (new File(path)).getParent());\r
-\r
MigrationState state = MigrationUtils.newState();\r
state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
state.setProperty(MigrationStateKeys.UPDATE_DEPENDENCIES, Boolean.FALSE);\r
\r
Resource result = null;\r
try {\r
- result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(model), model);\r
+ result = MigrationUtils.importMigrated(monitor, Simantics.getSession(), new File(path), state, new DefaultPasteImportAdvisor(model), model);\r
} catch (Exception e1) {\r
e1.printStackTrace();\r
}\r
// Check that the imported file actually was a module. Display error message otherwise.\r
try {\r
subTask(monitor, "Validate model");\r
- IStatus status = SimanticsUI.getSession().syncRequest(new WriteResultRequest<IStatus>() {\r
+ IStatus status = Simantics.getSession().syncRequest(new WriteResultRequest<IStatus>() {\r
\r
@Override\r
public IStatus perform(WriteGraph graph) throws DatabaseException {\r
/* *** IMPORT FUNCTION LIBRARY *** */\r
/* ********************************* */\r
\r
- public static IStatus importFunctionLibrary(final Resource functionLibrary, final String path, final Shell shell, final IProgressMonitor monitor) {\r
+ public static IStatus importFunctionLibrary(final Resource functionLibrary, final String path, final IProgressMonitor monitor) {\r
beginTask(monitor, "Import Module", 3);\r
\r
- Activator.getDefault().getPreferenceStore().setValue(IMPORTFUNCTIONLIBRARYPATH, (new File(path)).getParent());\r
-\r
// Ensure that shared functions ontology exists\r
ensureSharedOntologies();\r
\r
\r
Resource result = null;\r
try {\r
- result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(functionLibrary), functionLibrary);\r
+ result = MigrationUtils.importMigrated(monitor, Simantics.getSession(), new File(path), state, new DefaultPasteImportAdvisor(functionLibrary), functionLibrary);\r
} catch (Exception e1) {\r
e1.printStackTrace();\r
}\r
// Link the imported library to the selected resource (functionLibrary)\r
try {\r
subTask(monitor, "Validate model");\r
- IStatus status = SimanticsUI.getSession().syncRequest(new WriteResultRequest<IStatus>() {\r
+ IStatus status = Simantics.getSession().syncRequest(new WriteResultRequest<IStatus>() {\r
\r
/**\r
* Link the imported library to the selected resource (functionLibrary)\r
// Make sure the "http://SharedOntologies resource exists\r
try {\r
Boolean hasSharedOntologies;\r
- hasSharedOntologies = SimanticsUI.getSession().syncRequest(new Read<Boolean>() {\r
+ hasSharedOntologies = Simantics.getSession().syncRequest(new Read<Boolean>() {\r
\r
@Override\r
public Boolean perform(ReadGraph graph) throws DatabaseException {\r
});\r
\r
if(!hasSharedOntologies) {\r
- SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ Simantics.getSession().syncRequest(new WriteRequest() {\r
\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.utils.imports;\r
+package org.simantics.sysdyn.utils.imports;\r
\r
import org.simantics.databoard.Bindings;\r
import org.simantics.db.ReadGraph;\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.utils.imports;\r
+package org.simantics.sysdyn.utils.imports;\r
\r
import org.eclipse.core.runtime.IProgressMonitor;\r
import org.eclipse.core.runtime.IStatus;\r
import org.simantics.db.layer0.migration.MigrationStep;\r
import org.simantics.db.layer0.migration.MigrationUtils;\r
import org.simantics.graph.representation.TransferableGraph1;\r
-import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.Activator;\r
\r
/**\r
* Handler for migrating a tg and importing it to database\r