import org.simantics.db.request.Read;\r
import org.simantics.graph.representation.TransferableGraph1;\r
import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.datastructures.Pair;\r
\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
- fd.setText("Export..");\r
+ fd.setText("Export Function Library");\r
fd.setFileName(name);\r
- fd.setFilterPath(Platform.getLocation().toOSString());\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportFunctionLibrary.IMPORTFUNCTIONLIBRARYPATH);\r
+ if(path.isEmpty() || !(new File(path).exists()))\r
+ path = Platform.getLocation().toOSString();\r
+ fd.setFilterPath(path);\r
String[] filterExt = {"*.tg"};\r
fd.setFilterExtensions(filterExt);\r
final String selected = fd.open();\r
if(selected == null) return null;\r
\r
- \r
+ Activator.getDefault().getPreferenceStore().setValue(ImportFunctionLibrary.IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
+\r
SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
\r
@Override\r
import org.simantics.db.request.Read;\r
import org.simantics.graph.representation.TransferableGraph1;\r
import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.datastructures.Pair;\r
\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
- fd.setText("Export..");\r
+ fd.setText("Export Model");\r
fd.setFileName(name);\r
- fd.setFilterPath(Platform.getLocation().toOSString());\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportModelHandler.IMPORTMODELTPATH);\r
+ if(path.isEmpty() || !(new File(path).exists()))\r
+ path = Platform.getLocation().toOSString();\r
+ fd.setFilterPath(path);\r
String[] filterExt = {"*.tg"};\r
fd.setFilterExtensions(filterExt);\r
final String selected = fd.open();\r
if(selected == null) return null;\r
\r
+ Activator.getDefault().getPreferenceStore().setValue(ImportModelHandler.IMPORTMODELTPATH, (new File(selected)).getParent());\r
\r
SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
\r
import org.simantics.modeling.ModelingResources;\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.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.datastructures.Pair;\r
\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
- fd.setText("Export..");\r
+ fd.setText("Export Module");\r
fd.setFileName(name);\r
- fd.setFilterPath(Platform.getLocation().toOSString());\r
+ String path = Activator.getDefault().getPreferenceStore().getString(ImportModuleHandler.IMPORTMODULETPATH);\r
+ if(path.isEmpty() || !(new File(path).exists()))\r
+ path = Platform.getLocation().toOSString();\r
+ fd.setFilterPath(path);\r
String[] filterExt = {"*.tg"};\r
fd.setFilterExtensions(filterExt);\r
final String selected = fd.open();\r
if(selected == null) return null;\r
\r
+ Activator.getDefault().getPreferenceStore().setValue(ImportModuleHandler.IMPORTMODULETPATH, (new File(selected)).getParent());\r
\r
SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
\r
import org.simantics.layer0.utils.direct.GraphUtils;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.AdaptionUtils;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
public class ImportFunctionLibrary extends AbstractHandler {\r
+ \r
+ public static String IMPORTFUNCTIONLIBRARYPATH = "IMPORT_FUNCTION_LIBRARY_PATH";\r
\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
fd.setText("Import Function Library");\r
- fd.setFilterPath(Platform.getLocation().toOSString());\r
+ \r
+ String path = Activator.getDefault().getPreferenceStore().getString(IMPORTFUNCTIONLIBRARYPATH);\r
+ if(path.isEmpty() || !(new File(path).exists()))\r
+ path = Platform.getLocation().toOSString();\r
+ fd.setFilterPath(path);\r
String[] filterExt = {"*.tg"};\r
fd.setFilterExtensions(filterExt);\r
String selected = fd.open();\r
if(selected == null) return null;\r
\r
+ Activator.getDefault().getPreferenceStore().setValue(IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
+ \r
TransferableGraph1 tg = null;\r
try {\r
tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.Platform;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.FileDialog;\r
import org.eclipse.swt.widgets.Shell;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.sysdyn.mdlImport.MdlParser;\r
import org.simantics.sysdyn.mdlImport.mdlElements.Model;\r
+import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.ui.SimanticsUI;\r
\r
public class ImportMdlHandler extends AbstractHandler {\r
\r
+ public static String IMPORTMDLTPATH = "IMPORT_MDL_PATH";\r
+\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
fd.setText("Import .mdl");\r
- fd.setFilterPath("D:\\DATA\\Openprod\\vensim-malleja");\r
+ String path = Activator.getDefault().getPreferenceStore().getString(IMPORTMDLTPATH);\r
+ if(path.isEmpty() || !(new File(path).exists()))\r
+ path = Platform.getLocation().toOSString();\r
+ fd.setFilterPath(path);\r
String[] filterExt = {"*.mdl"};\r
fd.setFilterExtensions(filterExt);\r
String selected = fd.open();\r
File file = new File(selected);\r
if(!file.isFile()) return null;\r
\r
+ Activator.getDefault().getPreferenceStore().setValue(IMPORTMDLTPATH, (new File(selected)).getParent());\r
+ \r
final Model model = MdlParser.parse(file);\r
\r
SimanticsUI.getSession().asyncRequest(new WriteRequest() {\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.sysdyn.ui.utils.OldTransferableGraph1;\r
import org.simantics.ui.SimanticsUI;\r
\r
public class ImportModelHandler extends AbstractHandler {\r
+ \r
+ public static String IMPORTMODELTPATH = "IMPORT_MODEL_PATH";\r
\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
- fd.setText("Import...");\r
- fd.setFilterPath(Platform.getLocation().toOSString());\r
+ fd.setText("Import Model");\r
+ \r
+ String path = Activator.getDefault().getPreferenceStore().getString(IMPORTMODELTPATH);\r
+ if(path.isEmpty() || !(new File(path).exists()))\r
+ path = Platform.getLocation().toOSString();\r
+ fd.setFilterPath(path);\r
String[] filterExt = {"*.tg"};\r
fd.setFilterExtensions(filterExt);\r
String selected = fd.open();\r
if(selected == null) return null;\r
+ \r
+ Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(selected)).getParent());\r
+ \r
\r
TransferableGraph1 tg = null;\r
try {\r
import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;\r
import org.simantics.graph.db.MissingDependencyException;\r
import org.simantics.graph.representation.TransferableGraph1;\r
+import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.ui.utils.AdaptionUtils;\r
\r
public class ImportModuleHandler extends AbstractHandler {\r
\r
+ public static String IMPORTMODULETPATH = "IMPORT_MODULE_PATH";\r
+ \r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
ISelection sel = HandlerUtil.getCurrentSelection(event);\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
fd.setText("Import Module");\r
- fd.setFilterPath(Platform.getLocation().toOSString());\r
+ \r
+ String path = Activator.getDefault().getPreferenceStore().getString(IMPORTMODULETPATH);\r
+ if(path.isEmpty() || !(new File(path).exists()))\r
+ path = Platform.getLocation().toOSString();\r
+ fd.setFilterPath(path);\r
String[] filterExt = {"*.tg"};\r
fd.setFilterExtensions(filterExt);\r
String selected = fd.open();\r
if(selected == null) return null;\r
\r
+ Activator.getDefault().getPreferenceStore().setValue(IMPORTMODULETPATH, (new File(selected)).getParent());\r
+ \r
TransferableGraph1 tg = null;\r
try {\r
tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
import org.simantics.db.Resource;\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.common.utils.OrderedSetUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.layer0.Layer0;\r
}\r
}\r
\r
- Resource enumerationIndexes = OrderedSetUtils.create(g, sr.EnumerationIndexes);\r
- \r
- Resource enumeration = GraphUtils.create2(g, \r
- sr.Enumeration,\r
- l0.HasName, "Enumeration",\r
- sr.HasEnumerationIndexes, enumerationIndexes);\r
+ Resource enumerationIndexes = OrderedSetUtils.create(g, sr.EnumerationIndexes);\r
\r
- g.claim(configuration, l0.ConsistsOf, enumeration);\r
+ String name = NameUtils.findFreshName(g, "Enumeration", configuration, l0.ConsistsOf, "%s%d");\r
+ if("Enumeration".equals(name)) name = "Enumeration1";\r
\r
+ GraphUtils.create2(g, \r
+ sr.Enumeration,\r
+ l0.HasName, name,\r
+ sr.HasEnumerationIndexes, enumerationIndexes,\r
+ l0.PartOf, configuration);\r
}\r
});\r
return null;\r
import java.util.Collection;\r
import java.util.HashMap;\r
import java.util.HashSet;\r
+import java.util.LinkedHashMap;\r
import java.util.List;\r
import java.util.Set;\r
\r
if(activeDataSets != null && !activeDataSets.isEmpty())\r
datasets.addAll(activeDataSets);\r
}\r
+ \r
+ for(SysdynDataSet dataset : datasets)\r
+ System.out.println(dataset.name);\r
selectionChanged(datasets);\r
\r
}\r
\r
protected Collection<SysdynDataSet> loadAllActive(ReadGraph g, Variable variable) throws DatabaseException {\r
ArrayList<SysdynDataSet> dataSets = new ArrayList<SysdynDataSet>();\r
- HashMap<String, String> rvis = new HashMap<String, String>();\r
+ HashMap<String, String> rvis = new LinkedHashMap<String, String>();\r
\r
String rvi = Variables.getRVI(g, variable).replace("/", "."); \r
if(rvi.length() > 1)\r