</state>\r
</command>\r
<command\r
- defaultHandler="org.simantics.sysdyn.ui.handlers.NewModuleNodeHandler"\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewModuleNodeHandler"\r
id="org.simantics.sysdyn.ui.newModuleNode"\r
name="New Module">\r
</command>\r
name="Show in charts">\r
</command>\r
<command\r
- defaultHandler="org.simantics.sysdyn.ui.handlers.NewExperimentNodeHandler"\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewExperimentNodeHandler"\r
id="org.simantics.sysdyn.ui.newExperiment"\r
name="New Experiment">\r
</command>\r
name="Import .mdl">\r
</command>\r
<command\r
- defaultHandler="org.simantics.sysdyn.ui.handlers.NewFunctionHandler"\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewFunctionHandler"\r
id="org.simantics.sysdyn.ui.newFunction"\r
name="NewFunction">\r
</command>\r
</activeWhen>\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.ImportModelHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.imports.ImportModelHandler"\r
commandId="org.simantics.sysdyn.ui.importModel">\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.ExportModelHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.exports.ExportModelHandler"\r
commandId="org.simantics.sysdyn.ui.exportModel">\r
<activeWhen>\r
<with\r
</activeWhen>\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.ImportMdlHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.imports.ImportMdlHandler"\r
commandId="org.simantics.sysdyn.ui.importMdl">\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.NewEnumerationNodeHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.newComponents.NewEnumerationNodeHandler"\r
commandId="org.simantics.sysdyn.ui.newEnumeration">\r
<activeWhen>\r
<with\r
</activeWhen>\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.ImportExternalFunctionFilesHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.imports.ImportExternalFunctionFilesHandler"\r
commandId="org.simantics.sysdyn.ui.importExternalFunctionFile">\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.ExportExternalFunctionFilesHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.exports.ExportExternalFunctionFilesHandler"\r
commandId="org.simantics.sysdyn.ui.exportExternalFunctionFile">\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.NewFunctionLibraryHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.newComponents.NewFunctionLibraryHandler"\r
commandId="org.simantics.sysdyn.ui.newFunctionLibrary">\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.NewSharedFunctionLibraryHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.newComponents.NewSharedFunctionLibraryHandler"\r
commandId="org.simantics.sysdyn.ui.newSharedFunctionLibrary">\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.ExportFunctionLibrary"\r
+ class="org.simantics.sysdyn.ui.handlers.exports.ExportFunctionLibrary"\r
commandId="org.simantics.sysdyn.ui.exportFunctionLibrary">\r
<activeWhen>\r
<with\r
</activeWhen>\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.ImportFunctionLibrary"\r
+ class="org.simantics.sysdyn.ui.handlers.imports.ImportFunctionLibrary"\r
commandId="org.simantics.sysdyn.ui.importFunctionLibrary">\r
<activeWhen>\r
<with\r
</activeWhen>\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.ImportModuleHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.imports.ImportModuleHandler"\r
commandId="org.simantics.sysdyn.ui.importModule">\r
<activeWhen>\r
<with\r
</activeWhen>\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.ExportModuleHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.exports.ExportModuleHandler"\r
commandId="org.simantics.sysdyn.ui.exportModule">\r
<activeWhen>\r
<with\r
</activeWhen>\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.NewSpreadSheetHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.newComponents.NewSpreadSheetHandler"\r
commandId="org.simantics.sysdyn.ui.newSpreadSheet">\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.NewModelHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.newComponents.NewModelHandler"\r
commandId="org.simantics.sysdyn.ui.newModel">\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.NewPlaybackExperimentNodeHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.newComponents.NewPlaybackExperimentNodeHandler"\r
commandId="org.simantics.sysdyn.ui.newPlaybackExperiment">\r
</handler>\r
</extension>\r
+++ /dev/null
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 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
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-\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.jface.viewers.ISelection;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.FileDialog;\r
-import org.eclipse.swt.widgets.MessageBox;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-import org.simantics.browsing.ui.common.node.AbstractNode;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.Files;\r
-import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\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.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\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.layer0.Layer0;\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.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
- \r
- @SuppressWarnings("unchecked")\r
- AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
- if (node == null)\r
- return null;\r
-\r
- final Resource model = node.data;\r
- \r
- final 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(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
- } catch (RuntimeBindingConstructionException e) {\r
- e.printStackTrace();\r
- } catch (IOException e) {\r
- MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
- mb.setText("Error");\r
- mb.setMessage("The imported file is not of type: Module Type");\r
- mb.open();\r
- return null;\r
- }\r
- if(tg == null) return null;\r
-\r
- \r
- DefaultPasteImportAdvisor ia = new DefaultPasteImportAdvisor(model);\r
- try {\r
- DefaultPasteHandler.defaultExecute(tg, model, ia);\r
- } catch (MissingDependencyException e) {\r
- e.printStackTrace();\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- \r
- final Resource root = ia.getRoot();\r
- \r
- SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
- \r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- if(!graph.isInheritedFrom(root, SysdynResource.getInstance(graph).Module)) {\r
- Resource instanceOf = graph.getPossibleObject(root, Layer0.getInstance(graph).InstanceOf);\r
- String type = "...";\r
- if(instanceOf != null)\r
- type = NameUtils.getSafeName(graph, instanceOf);\r
- else {\r
- Resource inheritedFrom = graph.getPossibleObject(root, Layer0.getInstance(graph).Inherits);\r
- if(inheritedFrom != null)\r
- type = NameUtils.getSafeName(graph, inheritedFrom);\r
- }\r
- final String ft = type; \r
- graph.deny(root, Layer0.getInstance(graph).PartOf);\r
- \r
- shell.getDisplay().asyncExec(new Runnable() {\r
- \r
- @Override\r
- public void run() {\r
- MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
- mb.setText("Error");\r
- mb.setMessage("The imported file is not of type: System Dynamics Module (" + ft +")");\r
- mb.open(); \r
- }\r
- });\r
- } \r
- }\r
- });\r
- return null;\r
- }\r
-\r
-}\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.exports;\r
\r
import java.io.FileOutputStream;\r
import java.io.IOException;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
+/**\r
+ * Exports external function files from SysdynModelicaFunctions\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class ExportExternalFunctionFilesHandler extends AbstractHandler {\r
\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
-\r
- \r
+ // Find shell and resources to be exported\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
ISelection sel = HandlerUtil.getCurrentSelection(event);\r
final Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
return exportFiles(shell, resources);\r
}\r
\r
+ /**\r
+ * Exports selected file resources to files on disk. Assumes all resources are external files.\r
+ * \r
+ * @param shell SWT Shell\r
+ * @param resources External file resources\r
+ * @return null\r
+ */\r
public static Object exportFiles(Shell shell, final Resource[] resources) {\r
+ \r
+ // Select a path where to export the files\r
DirectoryDialog dd = new DirectoryDialog(shell);\r
dd.setFilterPath(Platform.getLocation().toOSString());\r
dd.setText("Export files to...");\r
@Override\r
public void run(ReadGraph graph) throws DatabaseException {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
+ // Get byte arrays from each resource and write them to disk\r
for(Resource r : resources) {\r
try {\r
String name = NameUtils.getSafeName(graph, r);\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.exports;\r
\r
import java.io.File;\r
import java.io.IOException;\r
import org.simantics.graph.representation.TransferableGraph1;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.handlers.imports.ImportFunctionLibrary;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.datastructures.Pair;\r
\r
+/**\r
+ * Exports a function library\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class ExportFunctionLibrary extends AbstractHandler {\r
\r
@Override\r
} catch (DatabaseException e1) {\r
e1.printStackTrace();\r
}\r
+ // Do not export if the resource has no name\r
if(name == null) return null;\r
\r
+ // Find a location (and name) for the exported library using FileDialog\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
fd.setText("Export Function Library");\r
final String selected = fd.open();\r
if(selected == null) return null;\r
\r
+ // Save location to preference store\r
Activator.getDefault().getPreferenceStore().setValue(ImportFunctionLibrary.IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
\r
+ // Asynchronously create the file using transferable graph\r
SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
\r
@Override\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.exports;\r
\r
import java.io.File;\r
import java.io.IOException;\r
import org.simantics.graph.representation.TransferableGraph1;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.handlers.imports.ImportModelHandler;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.datastructures.Pair;\r
\r
+/**\r
+ * Exports a selected model\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class ExportModelHandler extends AbstractHandler {\r
\r
@Override\r
} catch (DatabaseException e1) {\r
e1.printStackTrace();\r
}\r
+ // Do not export if the resource has no name\r
if(name == null) return null;\r
\r
+ // Find a location (and name) for the exported library using FileDialog\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
fd.setText("Export Model");\r
final String selected = fd.open();\r
if(selected == null) return null;\r
\r
+ // Save location to preference store\r
Activator.getDefault().getPreferenceStore().setValue(ImportModelHandler.IMPORTMODELTPATH, (new File(selected)).getParent());\r
\r
+ // Asynchronously create the file using transferable graph\r
SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
\r
@Override\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.exports;\r
\r
import java.io.File;\r
import java.io.IOException;\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.handlers.imports.ImportModuleHandler;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.datastructures.Pair;\r
\r
-public class ExportModuleHandler extends AbstractHandler {\r
+/**\r
+ * Exports a selected module\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class ExportModuleHandler extends AbstractHandler {\r
\r
/**\r
* Temporary exception. At this phase, the system will not support exporting modules\r
* that depend on other modules. \r
* \r
- * @author TLTEEMU\r
+ * @author Teemu Lempinen\r
*\r
*/\r
class ContainsDependenciesException extends DatabaseException {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
Layer0 l0 = Layer0.getInstance(graph);\r
\r
+ // Start checking for module dependencies\r
Resource component = graph.getPossibleObject(modulesymbol, mr.SymbolToComponentType);\r
if (component == null || !graph.hasStatement(component, Layer0.getInstance(graph).PartOf))\r
return null;\r
}\r
if(dependencies != null && !dependencies.isEmpty())\r
throw new ContainsDependenciesException(dependencies);\r
+ // End checking for module dependencies. If dependencies were found, an exception was thrown\r
\r
String name = graph.getPossibleRelatedValue(component, l0.HasName, Bindings.STRING);\r
return name;\r
} catch (DatabaseException e1) {\r
e1.printStackTrace();\r
}\r
+ \r
+ // Do not export if the resource has no name\r
if(name == null) return null;\r
\r
+ // Find a location (and name) for the exported library using FileDialog\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
fd.setText("Export Module");\r
final String selected = fd.open();\r
if(selected == null) return null;\r
\r
+ // Save location to preference store\r
Activator.getDefault().getPreferenceStore().setValue(ImportModuleHandler.IMPORTMODULETPATH, (new File(selected)).getParent());\r
\r
+ // Asynchronously create the file using transferable graph\r
SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
\r
@Override\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
\r
import java.io.File;\r
import java.io.FileInputStream;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.datastructures.Pair;\r
\r
+/**\r
+ * Imports external functions to SysdynModelicaFunctions using FileDialog.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class ImportExternalFunctionFilesHandler extends AbstractHandler {\r
\r
public static final String[] C_EXTENSIONS = {"*.c","*.h","*.a","*.o"};\r
}\r
\r
/**\r
- * Import \r
- * \r
- * @param shell\r
- * @return\r
+ * Opens a {@link FileDialog} to select the imported files.\r
+ * \r
+ * @param shell SWT Shell\r
+ * @param text Header text for the FileDialog\r
+ * @param filter Filters for the FileDialog\r
+ * @return File names and paths for the files to be imported\r
*/\r
public static Pair<String, String[]> importFiles(Shell shell, String text, String[] filter) {\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
return new Pair<String, String[]>(fd.getFilterPath(), fd.getFileNames());\r
}\r
\r
+ \r
+ /**\r
+ * Saves the given files as byte arrays to a function\r
+ * \r
+ * @param graph WriteGraph\r
+ * @param function Function where the files are to be added\r
+ * @param files Files to be added\r
+ * @throws DatabaseException\r
+ */\r
public static void addFilesToFunction(WriteGraph graph, Resource function, Pair<String, String[]> files) throws DatabaseException {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
Layer0 l0 = Layer0.getInstance(graph);\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
\r
import java.io.File;\r
import java.io.IOException;\r
import org.simantics.ui.utils.AdaptionUtils;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
+/**\r
+ * Imports an exported function library (or shared function library) transferable graph. \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class ImportFunctionLibrary extends AbstractHandler {\r
\r
public static String IMPORTFUNCTIONLIBRARYPATH = "IMPORT_FUNCTION_LIBRARY_PATH";\r
\r
+ /**\r
+ * Called from a functions folder node\r
+ */\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
ISelection sel = HandlerUtil.getCurrentSelection(event);\r
\r
final Resource functionLibrary = r;\r
\r
+ \r
+ // Get a transferable graph file\r
final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
fd.setText("Import Function Library");\r
\r
Activator.getDefault().getPreferenceStore().setValue(IMPORTFUNCTIONLIBRARYPATH, (new File(selected)).getParent());\r
\r
+ // Load the transferable graph\r
TransferableGraph1 tg = null;\r
try {\r
tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
} \r
if(tg == null) return null;\r
\r
- \r
+ // Make sure the "http://SharedOntologies resource exists\r
try {\r
Boolean hasSharedOntologies;\r
hasSharedOntologies = SimanticsUI.getSession().syncRequest(new Read<Boolean>() {\r
}\r
\r
\r
+ // Import a function library from the transferable graph\r
SysdynFunctionLibraryImportAdvisor ia = new SysdynFunctionLibraryImportAdvisor(functionLibrary);\r
try {\r
DefaultPasteHandler.defaultExecute(tg, functionLibrary, ia);\r
e.printStackTrace();\r
}\r
\r
- final Resource root = ia.getRoot();\r
+ final Resource root = ia.getRoot(); // Root of the library\r
\r
+ // Link the imported library to the selected resource (functionLibrary)\r
SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
\r
+ /**\r
+ * Link the imported library to the selected resource (functionLibrary)\r
+ * The imported library can be either SysdynModelicaFunctionLibrary or SysdynFunctionOntology\r
+ */\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
Layer0 l0 = Layer0.getInstance(graph);\r
+ // Case: SharedFunctionOntology. Link to SharedOntologies\r
if(graph.isInstanceOf(root, SysdynResource.getInstance(graph).SharedFunctionOntology)) {\r
Resource library = graph.getResource("http://SharedOntologies");\r
if(!graph.hasStatement(library, l0.ConsistsOf, root)) {\r
graph.claim(library, l0.ConsistsOf, root);\r
}\r
\r
+ // Link model to the shared library\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
Resource model = functionLibrary;\r
while(!graph.isInstanceOf(model, sr.SysdynModel) && graph.isInstanceOf(model, l0.Ontology))\r
graph.claim(model, l0.IsLinkedTo, l0.IsLinkedTo_Inverse, root);\r
}\r
\r
+ // Case: not SharedFunctionOntology or SysdynModelicaFunctionLibrary. \r
} else if(!graph.isInstanceOf(root, SysdynResource.getInstance(graph).SysdynModelicaFunctionLibrary)) {\r
Resource instanceOf = graph.getPossibleObject(root,l0.InstanceOf);\r
String type = "...";\r
type = NameUtils.getSafeName(graph, inheritedFrom);\r
}\r
final String ft = type; \r
+ \r
+ // Remove the functionLibrary ConsistsOf root relation\r
graph.deny(root, l0.PartOf);\r
\r
+ // Display error message\r
shell.getDisplay().asyncExec(new Runnable() {\r
\r
@Override\r
}\r
});\r
} else {\r
+ // imported library is already in the right place. Update function library files.\r
FunctionUtils.updateFunctionFileForLibrary(graph, functionLibrary);\r
}\r
\r
return null;\r
}\r
\r
+ /**\r
+ * Import advisor for importing function libraries to SysDyn\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
private class SysdynFunctionLibraryImportAdvisor extends DefaultPasteImportAdvisor {\r
\r
public SysdynFunctionLibraryImportAdvisor(Resource library) {\r
\r
@Override\r
public void analyzeType(ReadGraph graph, Root root) throws DatabaseException {\r
+ // Change the library to http://SharedOntologies, if the imported library is of type SharedFunctionOntology\r
if(root.type.equals(SysdynResource.URIs.SharedFunctionOntology)) {\r
try {\r
library = graph.getResource("http://SharedOntologies");\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
\r
import java.io.File;\r
\r
import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.ui.SimanticsUI;\r
\r
+/**\r
+ * Class for importing Vensim models (.mdl) to Simantics SysDyn using MdlParser \r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class ImportMdlHandler extends AbstractHandler {\r
\r
public static String IMPORTMDLTPATH = "IMPORT_MDL_PATH";\r
final Resource project = SimanticsUI.getProject().get();\r
if(project == null) return null;\r
\r
+ // Get the .mdl file\r
Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
fd.setText("Import .mdl");\r
\r
Activator.getDefault().getPreferenceStore().setValue(IMPORTMDLTPATH, (new File(selected)).getParent());\r
\r
+ // Convert Vensim model to Simantics SysDyn format using MdlParser\r
final Model model = MdlParser.parse(file);\r
\r
SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
\r
import java.io.File;\r
import java.io.IOException;\r
import org.simantics.sysdyn.ui.utils.SheetUtils;\r
import org.simantics.ui.SimanticsUI;\r
\r
+/**\r
+ * Imports models from exported transferable graph files.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class ImportModelHandler extends AbstractHandler {\r
\r
public static String IMPORTMODELTPATH = "IMPORT_MODEL_PATH";\r
Resource project = SimanticsUI.getProject().get();\r
if(project == null) return null;\r
\r
+ // Get imported transferable graph file using FileDialog\r
final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
fd.setText("Import Model");\r
\r
Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(selected)).getParent());\r
\r
-\r
+ // Get the transferable graph from file\r
TransferableGraph1 tg = null;\r
try {\r
tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
e.printStackTrace();\r
} catch (IOException e) { \r
try {\r
+ // "Version migration". Use OldTransferableGraph1 if the file was imported using old methods\r
OldTransferableGraph1 otg = (OldTransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(OldTransferableGraph1.class));\r
tg = new TransferableGraph1(otg.resourceCount, otg.identities, otg.statements, otg.values);\r
} catch (RuntimeBindingConstructionException e1) {\r
public void perform(WriteGraph graph) throws DatabaseException {\r
\r
if(!graph.isInstanceOf(root, SysdynResource.getInstance(graph).SysdynModel)) {\r
+ // Imported model was not a SysdynModel, display error message.\r
Resource instanceOf = graph.getPossibleObject(root, Layer0.getInstance(graph).InstanceOf);\r
String type = "...";\r
if(instanceOf != null)\r
Resource project = SimanticsUI.getProject().get();\r
graph.claim(root, Layer0X.getInstance(graph).IsActivatedBy, project);\r
\r
+ // Do all modifications that are necessary\r
updateOldConfigurationToBaseRealization(graph, root);\r
addDefaultOntologyLinks(graph, root);\r
addURIsToDiagrams(graph, root);\r
}\r
\r
\r
+ /**\r
+ * Add a container for providing URIs to diagrams. \r
+ * \r
+ * @param graph WriteGraph\r
+ * @param model Imported model\r
+ */\r
private static void addURIsToDiagrams(WriteGraph graph, Resource model) {\r
Layer0 l0 = Layer0.getInstance(graph);\r
SimulationResource simu = SimulationResource.getInstance(graph);\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.imports;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+\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.jface.viewers.ISelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.MessageBox;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.Files;\r
+import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\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.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\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.layer0.Layer0;\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.AdaptionUtils;\r
+\r
+/**\r
+ * Imports modules from exported transferable graph files.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\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
+\r
+ @SuppressWarnings("unchecked")\r
+ AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
+ if (node == null)\r
+ return null;\r
+\r
+ final Resource model = node.data;\r
+\r
+ // Get imported transferable graph file using FileDialog\r
+ final 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(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
+ // Get the transferable graph from file\r
+ TransferableGraph1 tg = null;\r
+ try {\r
+ tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
+ } catch (RuntimeBindingConstructionException e) {\r
+ e.printStackTrace();\r
+ } catch (IOException e) {\r
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
+ mb.setText("Error");\r
+ mb.setMessage("The imported file is not of type: Module Type");\r
+ mb.open();\r
+ return null;\r
+ }\r
+ if(tg == null) return null;\r
+\r
+\r
+ // Import the module to model\r
+ DefaultPasteImportAdvisor ia = new DefaultPasteImportAdvisor(model);\r
+ try {\r
+ DefaultPasteHandler.defaultExecute(tg, model, ia);\r
+ } catch (MissingDependencyException e) {\r
+ e.printStackTrace();\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ final Resource root = ia.getRoot();\r
+\r
+ // Check that the imported file actually was a module. Display error message otherwise.\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ if(!graph.isInheritedFrom(root, SysdynResource.getInstance(graph).Module)) {\r
+ Resource instanceOf = graph.getPossibleObject(root, Layer0.getInstance(graph).InstanceOf);\r
+ String type = "...";\r
+ if(instanceOf != null)\r
+ type = NameUtils.getSafeName(graph, instanceOf);\r
+ else {\r
+ Resource inheritedFrom = graph.getPossibleObject(root, Layer0.getInstance(graph).Inherits);\r
+ if(inheritedFrom != null)\r
+ type = NameUtils.getSafeName(graph, inheritedFrom);\r
+ }\r
+ final String ft = type; \r
+ graph.deny(root, Layer0.getInstance(graph).PartOf);\r
+\r
+ shell.getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
+ mb.setText("Error");\r
+ mb.setMessage("The imported file is not of type: System Dynamics Module (" + ft +")");\r
+ mb.open(); \r
+ }\r
+ });\r
+ } \r
+ }\r
+ });\r
+ return null;\r
+ }\r
+\r
+}\r
-package org.simantics.sysdyn.ui.handlers;\r
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.AdaptionUtils;\r
\r
+/**\r
+ * Creates a new Enumeration node to a configuration or module\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class NewEnumerationNodeHandler extends AbstractHandler {\r
\r
@Override\r
SysdynResource sr = SysdynResource.getInstance(g);\r
Layer0 l0 = Layer0.getInstance(g);\r
\r
+ // Find the actual configuration. Possible cases for resource are sr.Configuration, sr.ModuleSymbol or sr.Module.\r
Resource configuration = null;\r
if(g.isInstanceOf(resource, sr.Configuration)) {\r
configuration = resource;\r
}\r
}\r
\r
+ // Create the enumeartion\r
Resource enumerationIndexes = OrderedSetUtils.create(g, sr.EnumerationIndexes);\r
\r
String name = NameUtils.findFreshName(g, "Enum", configuration, l0.ConsistsOf, "%s%d");\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.AdaptionUtils;\r
\r
+/**\r
+ * Creates a new normal SysDyn experiment\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class NewExperimentNodeHandler extends AbstractHandler {\r
\r
+ /**\r
+ * Assumes that it is called from a node that has a SysDyn model as its resource.\r
+ */\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
ISelection sel = HandlerUtil.getCurrentSelection(event);\r
\r
}\r
\r
+ /**\r
+ * Get the type of this experiment.\r
+ * \r
+ * @param g ReadGraph\r
+ * @return The type resource of this experiment\r
+ */\r
protected Resource getExperimentType(ReadGraph g) {\r
return SysdynResource.getInstance(g).BasicExperiment;\r
}\r
\r
+ /**\r
+ * Returns the suggested name for this experiment.\r
+ * If the name has already been taken, appropriate prefix needs to be added. \r
+ * \r
+ * @return Suggested name for this experiment. \r
+ */\r
protected String getNameSuggestion() {\r
return "Experiment";\r
}\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.AdaptionUtils;\r
\r
+/**\r
+ * Creates a new function to a SysdynModel or Library.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class NewFunctionHandler extends AbstractHandler {\r
\r
+ /**\r
+ * Assumes to be called from a node with SysdynModel, Library or SysdynModelicaFunction as its resource\r
+ */\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
\r
Layer0 l0 = Layer0.getInstance(g);\r
SysdynResource sr = SysdynResource.getInstance(g);\r
\r
+ // Library can be either SysdynModel or L0.Library. \r
Resource library = null;\r
if(g.isInstanceOf(data, sr.SysdynModel) || g.isInstanceOf(data, l0.Library))\r
library = data;\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.AdaptionUtils;\r
\r
+/**\r
+ * Creates a new function library to a model or other library.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class NewFunctionLibraryHandler extends AbstractHandler {\r
\r
@Override\r
-package org.simantics.sysdyn.ui.handlers;\r
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.simantics.sysdyn.ui.utils.ModelUtils;\r
import org.simantics.ui.SimanticsUI;\r
\r
+/**\r
+ * Creates a new SysDyn model.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class NewModelHandler extends AbstractHandler {\r
\r
@Override\r
SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
+ // Use ModelUtils to keep all model creations up-to-date\r
ModelUtils.createModel(graph);\r
}\r
});\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.simantics.ui.utils.AdaptionUtils;\r
import org.simantics.utils.datastructures.ArrayMap;\r
\r
+/**\r
+ * Creates a new module node for a model.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class NewModuleNodeHandler extends AbstractHandler {\r
\r
+ /**\r
+ * Assumes to be called from a node that has a SysDyn model as its resource.\r
+ */\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
\r
\r
@Override\r
public void perform(WriteGraph g) throws DatabaseException {\r
- // Same as in SysdynProject.java. Should use the same code, not copy.\r
SysdynResource sr = SysdynResource.getInstance(g);\r
Layer0 l0 = Layer0.getInstance(g);\r
Layer0X L0X = Layer0X.getInstance(g);\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
\r
import java.awt.Color;\r
\r
import org.simantics.layer0.utils.direct.GraphUtils;\r
import org.simantics.sysdyn.SysdynResource;\r
\r
-\r
+/**\r
+ * Creates a new playback experiment.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class NewPlaybackExperimentNodeHandler extends NewExperimentNodeHandler {\r
\r
protected void configureExperiment(WriteGraph graph, Resource experiment) throws DatabaseException {\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.ui.handlers;\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.eclipse.core.commands.ExecutionException;\r
import org.simantics.db.Resource;\r
import org.simantics.ui.utils.AdaptionUtils;\r
\r
+/**\r
+ * Creates a new shared function library.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class NewSharedFunctionLibraryHandler extends NewFunctionLibraryHandler {\r
\r
@Override\r
-package org.simantics.sysdyn.ui.handlers;\r
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
+/**\r
+ * Creates a new spreadsheet sheet to a book.\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class NewSpreadSheetHandler extends AbstractHandler {\r
\r
+ /**\r
+ * Called from a node that has a book as its resource.\r
+ */\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
ISelection sel = HandlerUtil.getCurrentSelection(event);\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.handlers.ExportExternalFunctionFilesHandler;\r
-import org.simantics.sysdyn.ui.handlers.ImportExternalFunctionFilesHandler;\r
import org.simantics.sysdyn.ui.handlers.RemoveNodeHandler;\r
+import org.simantics.sysdyn.ui.handlers.exports.ExportExternalFunctionFilesHandler;\r
+import org.simantics.sysdyn.ui.handlers.imports.ImportExternalFunctionFilesHandler;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.datastructures.ArrayMap;\r
import org.simantics.utils.datastructures.Pair;\r
\r
+/**\r
+ * Tab for properties of a SysdynModelicaFunction containing all external files added to that function \r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class ExternalFilesTab extends LabelPropertyTabContributor implements Widget {\r
\r
GraphExplorerComposite externalFilesExplorer;\r
Composite composite = new Composite(body, SWT.NONE);\r
GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite);\r
- \r
+ \r
+ // Create the graph explorer displaying external files \r
externalFilesExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
"displaySelectors", "displayFilter").values(false, false), site, composite, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);\r
\r
((Tree) c).setLinesVisible(true);\r
\r
\r
+ // Create controls for importing, exporting and removing external files\r
Composite buttonRow = new Composite(composite, SWT.NONE);\r
GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonRow);\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonRow);\r
externalFilesExplorer.setInput(context, input);\r
}\r
\r
+ /**\r
+ * Method for retreiving selected resources from a GraphExplorerComposite\r
+ * @param explorer\r
+ * @return\r
+ */\r
private List<Resource> getSelectedResources(GraphExplorerComposite explorer) {\r
List<Resource> result = new ArrayList<Resource>();\r
\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.handlers.ImportModelHandler;\r
+import org.simantics.sysdyn.ui.handlers.imports.ImportModelHandler;\r
import org.simantics.sysdyn.ui.utils.OldTransferableGraph1;\r
import org.simantics.ui.SimanticsUI;\r
\r