From: jsimomaa Date: Thu, 16 Oct 2014 08:13:49 +0000 (+0000) Subject: Merged trunk@30066-30400 to branches/sysdyn-1.8 on 2014-10-16 for 1.8.2 release. X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=9da7df4221f67fe1c83bca5082ec781b3967dcda;p=simantics%2Fsysdyn.git Merged trunk@30066-30400 to branches/sysdyn-1.8 on 2014-10-16 for 1.8.2 release. refs #5170 refs #5119 refs #4882 refs #5197 refs #5204 refs #5205 refs #5184 refs #5206 refs #5207 refs #5208 refs #5209 refs #5196 refs #5185 refs #5227 refs #5267 refs #5273 refs #5280 refs #5314 refs #5357 refs #5386 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/1.8@30425 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/Splash.xcf b/org.simantics.sysdyn.ui/Splash.xcf deleted file mode 100644 index 388267fc..00000000 Binary files a/org.simantics.sysdyn.ui/Splash.xcf and /dev/null differ diff --git a/org.simantics.sysdyn.ui/adapters.xml b/org.simantics.sysdyn.ui/adapters.xml index 517bc7e2..26ca56a7 100644 --- a/org.simantics.sysdyn.ui/adapters.xml +++ b/org.simantics.sysdyn.ui/adapters.xml @@ -10,5 +10,5 @@ VTT Technical Research Centre of Finland - initial API and implementation --> - none 0 fill 1 + none 0 fill 1 \ No newline at end of file diff --git a/org.simantics.sysdyn.ui/logo/Simantics_sysdyn_logo2.blend b/org.simantics.sysdyn.ui/logo/Simantics_sysdyn_logo2.blend new file mode 100644 index 00000000..8307229d Binary files /dev/null and b/org.simantics.sysdyn.ui/logo/Simantics_sysdyn_logo2.blend differ diff --git a/org.simantics.sysdyn.ui/logo/Simantics_sysdyn_text.png b/org.simantics.sysdyn.ui/logo/Simantics_sysdyn_text.png new file mode 100644 index 00000000..98035c26 Binary files /dev/null and b/org.simantics.sysdyn.ui/logo/Simantics_sysdyn_text.png differ diff --git a/org.simantics.sysdyn.ui/logo/Splash.xcf b/org.simantics.sysdyn.ui/logo/Splash.xcf new file mode 100644 index 00000000..110af1af Binary files /dev/null and b/org.simantics.sysdyn.ui/logo/Splash.xcf differ diff --git a/org.simantics.sysdyn.ui/logo/sysdyn.png b/org.simantics.sysdyn.ui/logo/sysdyn.png new file mode 100644 index 00000000..30e09cf0 Binary files /dev/null and b/org.simantics.sysdyn.ui/logo/sysdyn.png differ diff --git a/org.simantics.sysdyn.ui/logo/sysdyn_with_arrows.png b/org.simantics.sysdyn.ui/logo/sysdyn_with_arrows.png new file mode 100644 index 00000000..7a52a5a8 Binary files /dev/null and b/org.simantics.sysdyn.ui/logo/sysdyn_with_arrows.png differ diff --git a/org.simantics.sysdyn.ui/logo/sysdyn_with_arrows.xcf b/org.simantics.sysdyn.ui/logo/sysdyn_with_arrows.xcf new file mode 100644 index 00000000..d4d4cdb1 Binary files /dev/null and b/org.simantics.sysdyn.ui/logo/sysdyn_with_arrows.xcf differ diff --git a/org.simantics.sysdyn.ui/logo/sysdyn_with_arrows_and_orange_bg.xcf b/org.simantics.sysdyn.ui/logo/sysdyn_with_arrows_and_orange_bg.xcf new file mode 100644 index 00000000..dae6145d Binary files /dev/null and b/org.simantics.sysdyn.ui/logo/sysdyn_with_arrows_and_orange_bg.xcf differ diff --git a/org.simantics.sysdyn.ui/plugin.xml b/org.simantics.sysdyn.ui/plugin.xml index 7b06dd5b..3cac4f5e 100644 --- a/org.simantics.sysdyn.ui/plugin.xml +++ b/org.simantics.sysdyn.ui/plugin.xml @@ -811,6 +811,21 @@ tooltip="Exports the trend to SVG file"> + + + + + + + + + + + + + @@ -1696,6 +1718,10 @@ id="org.simantics.sysdyn.ui.renameNode" name="Rename Node"> + + + + + + + @@ -2005,6 +2038,11 @@ property="org.simantics.graph.resourceType" value="true"> + + diff --git a/org.simantics.sysdyn.ui/plugin_customization.ini b/org.simantics.sysdyn.ui/plugin_customization.ini index 92e8ed0c..2d6b595d 100644 --- a/org.simantics.sysdyn.ui/plugin_customization.ini +++ b/org.simantics.sysdyn.ui/plugin_customization.ini @@ -1,2 +1,4 @@ org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = false -org.eclipse.ui/DOCK_PERSPECTIVE_BAR=right \ No newline at end of file +org.eclipse.ui/DOCK_PERSPECTIVE_BAR=right + +org.simantics.sysdyn.solver.preferences/SOLVER_TYPE=OPENMODELICA \ No newline at end of file diff --git a/org.simantics.sysdyn.ui/splash.bmp b/org.simantics.sysdyn.ui/splash.bmp index faea2d91..3c372f64 100644 Binary files a/org.simantics.sysdyn.ui/splash.bmp and b/org.simantics.sysdyn.ui/splash.bmp differ diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java index 27c0272c..e5e308ac 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/ChartDropAction.java @@ -40,7 +40,7 @@ import org.simantics.utils.ui.AdaptionUtils; public class ChartDropAction implements DropActionFactory { @Override - public Runnable create(ReadGraph g, Object target, Object source) throws DatabaseException { + public Runnable create(ReadGraph g, Object target, Object source, int operation) throws DatabaseException { final Resource targetChart = AdaptionUtils.adaptToSingle(target, Resource.class); if(targetChart == null || source == null || !(source instanceof IStructuredSelection)) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/FunctionDropAction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/FunctionDropAction.java index 354f25b3..cb3e1626 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/FunctionDropAction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/drop/FunctionDropAction.java @@ -30,7 +30,7 @@ import org.simantics.utils.ui.AdaptionUtils; public class FunctionDropAction implements DropActionFactory { @Override - public Runnable create(ReadGraph g, Object target, Object source) throws DatabaseException { + public Runnable create(ReadGraph g, Object target, Object source, int operation) throws DatabaseException { Resource t = AdaptionUtils.adaptToSingle(target, Resource.class); Resource s = AdaptionUtils.adaptToSingle(source, Resource.class); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Project.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Project.java index 0d381be5..06105db3 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Project.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Project.java @@ -24,7 +24,7 @@ import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.Layer0; import org.simantics.project.ontology.ProjectResource; -import org.simantics.sysdyn.SysdynResource; +import org.simantics.simulation.ontology.SimulationResource; import org.simantics.sysdyn.ui.browser.nodes.SharedOntologyNode; public class Project extends ViewpointContributor { @@ -36,8 +36,8 @@ public class Project extends ViewpointContributor { ArrayList> result = new ArrayList>(); Layer0 l0 = Layer0.getInstance(graph); - SysdynResource sr = SysdynResource.getInstance(graph); - for(Resource r : graph.syncRequest(new ObjectsWithType(project, l0.ConsistsOf, sr.SysdynModel))) { + SimulationResource SIMU = SimulationResource.getInstance(graph); + for(Resource r : graph.syncRequest(new ObjectsWithType(project, l0.ConsistsOf, SIMU.Model))) { try { result.add(graph.adapt(r, AbstractNode.class)); } catch(DatabaseException e) { @@ -49,7 +49,7 @@ public class Project extends ViewpointContributor { if(!graph.isInstanceOf(project, PROJ.Project)) return Collections.emptyList(); Collection ontologies = Simantics.applySCL("Simantics/SharedOntologies", "traverseSharedOntologies", graph, graph.getRootLibrary()); for(Resource o : ontologies) { - if(!graph.isImmutable(o)) +// if(!graph.isImmutable(o)) result.add(new SharedOntologyNode(o)); } 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 index 91c46b6a..ce71ad29 100644 --- 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 @@ -9,8 +9,8 @@ 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.simulation.ontology.SimulationResource; import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode; -import org.simantics.sysdyn.SysdynResource; public class SysdynProject extends ViewpointContributor { @@ -20,7 +20,7 @@ public class SysdynProject extends ViewpointContributor { ArrayList result = new ArrayList(); Layer0 L0 = Layer0.getInstance(graph); - for(Resource r : graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModel))) { + for(Resource r : graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, SimulationResource.getInstance(graph).Model))) { try { result.add(graph.adapt(r, AbstractNode.class)); } catch(DatabaseException e) { 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 index 00a3dcb5..8813df95 100644 --- 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 @@ -11,6 +11,7 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.browser.nodes; +import org.simantics.Simantics; import org.simantics.browsing.ui.common.node.AbstractNode; import org.simantics.browsing.ui.common.node.DeleteException; import org.simantics.browsing.ui.common.node.IDeletableNode; @@ -21,7 +22,9 @@ 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.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; @@ -62,6 +65,8 @@ public class FunctionLibraryNode extends AbstractNode implements ID @Override public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); + Layer0Utils.addCommentMetadata(graph, "Removed " + NameUtils.getSafeName(graph, data)); RemoverUtil.remove(graph, data); } }); @@ -72,12 +77,18 @@ public class FunctionLibraryNode extends AbstractNode implements ID final Resource[] resources = ResourceAdaptionUtils.toResources(data); final Resource library = this.data; if(resources.length > 0) { - SimanticsUI.getSession().asyncRequest(new WriteRequest() { + Simantics.getSession().asyncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { SysdynResource sr = SysdynResource.getInstance(graph); Layer0 l0 = Layer0.getInstance(graph); + + // Fixing #5196 + // Prevent dropping functions to immutable function libraries such as Built-in Functions, Modelica Array Functions etc. + if (graph.isImmutable(library)) + return; + for(Resource tobeMoved : resources) { if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) || graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) { 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 21312513..df983ed1 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,6 +11,7 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.browser.nodes; +import org.simantics.Simantics; import org.simantics.browsing.ui.common.node.DeleteException; import org.simantics.browsing.ui.common.node.IDeletableNode; import org.simantics.browsing.ui.common.node.IDropTargetNode; @@ -20,12 +21,13 @@ 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.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.utils.FunctionNameValidator; -import org.simantics.ui.SimanticsUI; import org.simantics.ui.utils.ResourceAdaptionUtils; public class FunctionNode extends VariableNode implements IDeletableNode, IModifiableNode, IDropTargetNode { @@ -37,8 +39,8 @@ public class FunctionNode extends VariableNode implements IDeletableNo @Override public Modifier getModifier(String columnId) { try { - Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName; - LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) { + Resource hasName = Layer0.getInstance(Simantics.getSession()).HasName; + LabelModifier modifier = new LabelModifier(Simantics.getSession(), data, hasName) { @Override public String isValid(String label) { if (!new FunctionNameValidator().isValid(data, label)) @@ -56,10 +58,12 @@ public class FunctionNode extends VariableNode implements IDeletableNo @Override public void delete() throws DeleteException { - SimanticsUI.getSession().asyncRequest(new WriteRequest() { + Simantics.getSession().asyncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); + Layer0Utils.addCommentMetadata(graph, "Removed " + NameUtils.getSafeName(graph, data)); RemoverUtil.remove(graph, data); } }); @@ -71,7 +75,7 @@ public class FunctionNode extends VariableNode implements IDeletableNo final Resource thisFunction = this.data; if(resources.length > 0) { - SimanticsUI.getSession().asyncRequest(new WriteRequest() { + Simantics.getSession().asyncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { 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 5e4f8748..2bdb2e44 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 @@ -11,6 +11,7 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.browser.nodes; +import org.simantics.Simantics; import org.simantics.browsing.ui.common.node.AbstractNode; import org.simantics.browsing.ui.common.node.IDropTargetNode; import org.simantics.db.Resource; @@ -19,7 +20,6 @@ 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.ui.SimanticsUI; import org.simantics.ui.utils.ResourceAdaptionUtils; public class FunctionsFolder extends AbstractNode implements IDropTargetNode{ @@ -41,7 +41,7 @@ public class FunctionsFolder extends AbstractNode implements IDropTarg final Resource[] resources = ResourceAdaptionUtils.toResources(data); final Resource library = this.data; if(resources.length > 0) { - SimanticsUI.getSession().asyncRequest(new WriteRequest() { + Simantics.getSession().asyncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { 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 index b5082277..ec8d5f89 100644 --- 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 @@ -11,6 +11,7 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.browser.nodes; +import org.simantics.Simantics; import org.simantics.browsing.ui.common.node.DeleteException; import org.simantics.browsing.ui.common.node.IDropTargetNode; import org.simantics.browsing.ui.content.Labeler.Modifier; @@ -25,7 +26,6 @@ import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.utils.SharedFunctionLibraryNameValidator; -import org.simantics.ui.SimanticsUI; import org.simantics.ui.utils.ResourceAdaptionUtils; public class SharedFunctionLibraryNode extends FunctionLibraryNode implements IDropTargetNode { @@ -36,7 +36,7 @@ public class SharedFunctionLibraryNode extends FunctionLibraryNode imp @Override public void delete() throws DeleteException { - SimanticsUI.getSession().asyncRequest(new WriteRequest() { + Simantics.getSession().asyncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { @@ -50,8 +50,8 @@ public class SharedFunctionLibraryNode extends FunctionLibraryNode imp @Override public Modifier getModifier(String columnId) { try { - Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName; - LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) { + Resource hasName = Layer0.getInstance(Simantics.getSession()).HasName; + LabelModifier modifier = new LabelModifier(Simantics.getSession(), data, hasName) { @Override public String isValid(String label) { if (!new SharedFunctionLibraryNameValidator().isValid(data, label)) @@ -72,7 +72,7 @@ public class SharedFunctionLibraryNode extends FunctionLibraryNode imp final Resource[] resources = ResourceAdaptionUtils.toResources(data); final Resource library = this.data; if(resources.length > 0) { - SimanticsUI.getSession().asyncRequest(new WriteRequest() { + Simantics.getSession().asyncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java index fb89ccc3..5456e92a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java @@ -6,9 +6,11 @@ import java.util.Collections; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorPart; +import org.simantics.Simantics; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; -import org.simantics.db.common.request.ReadRequest; +import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; +import org.simantics.db.common.request.UnaryRead; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.request.PossibleModel; import org.simantics.db.layer0.variable.RVI; @@ -25,11 +27,9 @@ import org.simantics.modeling.ModelingResources; import org.simantics.modeling.actions.NavigateToTarget; import org.simantics.modeling.ui.Activator; import org.simantics.sysdyn.SysdynResource; -import org.simantics.ui.SimanticsUI; import org.simantics.ui.utils.ResourceAdaptionUtils; import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter; import org.simantics.utils.datastructures.Callback; -import org.simantics.utils.threads.SWTThread; import org.simantics.utils.threads.ThreadUtils; import org.simantics.utils.ui.AdaptionUtils; @@ -46,11 +46,7 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt @Override public boolean canHandle(ReadGraph graph, Object input) throws DatabaseException { - Resource r = tryGetResource(graph, input); - if (r == null) - return false; - Variable v = AdaptionUtils.adaptToSingle(input, Variable.class); - Collection rs = tryFindDiagram(graph, r, v); + Collection rs = graph.syncRequest(new DiagramFinderRequest(input), TransientCacheAsyncListener.>instance()); return !rs.isEmpty(); } @@ -78,30 +74,11 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt final Display d = Display.getCurrent(); if (d == null) return; - - SimanticsUI.getSession().syncRequest(new ReadRequest() { - @Override - public void run(ReadGraph graph) throws DatabaseException { - Resource r = tryGetResource(graph, input); - if (r == null) - return; - - Variable v = AdaptionUtils.adaptToSingle(input, Variable.class); - - final Collection rs = tryFindDiagram(graph, r, v); - if (rs.isEmpty()) - return; - - SWTThread.getThreadAccess(d).asyncExec(new Runnable() { - @Override - public void run() { - for (Runnable runnable : rs) { - runnable.run(); - } - } - }); - } - }); + + Collection rs = Simantics.getSession().syncRequest(new DiagramFinderRequest(input), TransientCacheAsyncListener.>instance()); + for (Runnable runnable : rs) { + runnable.run(); + } } private Collection tryFindDiagram(ReadGraph g, Resource module, Variable variable) throws DatabaseException { @@ -200,5 +177,21 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt } return selectedObjects; } + + private class DiagramFinderRequest extends UnaryRead> { + + public DiagramFinderRequest(Object parameter) { + super(parameter); + } + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + Resource r = tryGetResource(graph, parameter); + if (r == null) + return Collections.emptyList(); + Variable v = AdaptionUtils.adaptToSingle(parameter, Variable.class); + return tryFindDiagram(graph, r, v); + } + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynCreationInstruction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynCreationInstruction.java index 67721548..0e5de3ad 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynCreationInstruction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynCreationInstruction.java @@ -16,11 +16,11 @@ import gnu.trove.TIntIntHashMap; import java.util.Collection; import java.util.HashMap; +import org.simantics.databoard.util.URIStringUtils; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.common.utils.URIStringUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.Layer0; import org.simantics.layer0.utils.direct.GraphUtils; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectionBuilder.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectionBuilder.java index cd309499..4963437d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectionBuilder.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectionBuilder.java @@ -66,7 +66,7 @@ public class SysdynConnectionBuilder extends ConnectionBuilder{ */ public void create(WriteGraph graph, ConnectionJudgement judgment, Deque controlPoints, TerminalInfo startTerminal, TerminalInfo endTerminal) throws DatabaseException { - + if(startTerminal == null) return; if(endTerminal == null) return; @@ -81,11 +81,12 @@ public class SysdynConnectionBuilder extends ConnectionBuilder{ createConnection(graph, judgment, controlPoints, startTerminal, endTerminal, false); } - String startElementName = startTerminal.e.getHint(ElementHints.KEY_TEXT); - String endElementName = endTerminal.e.getHint(ElementHints.KEY_TEXT); - String startElementResource = startTerminal.e.getHint(ElementHints.KEY_OBJECT).toString(); - String endElementResource = endTerminal.e.getHint(ElementHints.KEY_OBJECT).toString(); + String startElementName = startTerminal != null ? startTerminal.e.getHint(ElementHints.KEY_TEXT).toString() : "null"; + String endElementName = endTerminal != null ? endTerminal.e.getHint(ElementHints.KEY_TEXT).toString() : "null"; + + String startElementResource = startTerminal != null ? startTerminal.e.getHint(ElementHints.KEY_OBJECT).toString() : "null"; + String endElementResource = endTerminal != null ? endTerminal.e.getHint(ElementHints.KEY_OBJECT).toString() : "null"; Layer0Utils.addCommentMetadata(graph, "Created dependency starting from " + startElementName + " " + startElementResource + " and ending to " + endElementName + " " + endElementResource); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java index 6515eb05..517a696e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java @@ -128,14 +128,8 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { // Do we need this? element.setHint(DiagramHints.ROUTE_ALGORITHM, new Router4(false)); - IModelingRules modelingRules = diagram.getHint(DiagramModelHints.KEY_MODELING_RULES); - IElement mappedElement = ElementUtils.getByData(diagram, connection); - if (mappedElement == null) - // FIXME: With undo this seems to happen, don't know why yet! - return; - Color color = null; DiagramResource DR = DiagramResource.getInstance(graph); G2DResource G2D = G2DResource.getInstance(graph); @@ -344,7 +338,7 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { // Initialize ConnectionEntity in element // NOTE: MUST use the mapped element with class CE, not the connection (element) were loading into. // GDS will synchronize element into mappedElement in a controlled manner. - element.setHint(ElementHints.KEY_CONNECTION_ENTITY, new CE(connection, mappedElement, backendonnections)); + element.setHint(ElementHints.KEY_CONNECTION_ENTITY, new CE(diagram, connection, element, backendonnections)); // Setup graph writeback support for route graph modifications final Session session = graph.getSession(); @@ -565,6 +559,11 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { */ static class CE implements ConnectionEntity { + + private IDiagram diagram; + + private transient DataElementMap dataMap; + /** * The connection instance resource in the graph backend. */ @@ -573,7 +572,7 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { /** * The connection entity element which is a part of the diagram. */ - final IElement connectionElement; + IElement connectionElement; /** * @see #getTerminalConnections(Collection) @@ -585,15 +584,31 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { */ Set terminalConnections; - CE(Resource connection, IElement connectionElement, Set backendConnections) { + + public CE(IDiagram diagram, Resource connection, IElement connectionElement, Set backendConnections) { + if (connectionElement == null) + throw new NullPointerException("null connection element"); + this.diagram = diagram; + this.dataMap = diagram.getDiagramClass().getSingleItem(DataElementMap.class); this.connection = connection; this.connectionElement = connectionElement; this.backendConnections = backendConnections; + IElement ce = getConnection0(); + if (ce != null) + this.connectionElement = ce; + } + + public IElement getConnection0() { + IElement connectionElement = dataMap.getElement(diagram, connection); + return connectionElement; } @Override public IElement getConnection() { - return connectionElement; + IElement c = getConnection0(); + if (c == null) + c = this.connectionElement; + return c; } public Object getConnectionObject() { @@ -626,7 +641,6 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { } private Set calculateTerminalConnections() { - IDiagram diagram = connectionElement.getDiagram(); DataElementMap dem = diagram.getDiagramClass().getSingleItem(DataElementMap.class); Set result = new HashSet(); ArrayList ts = new ArrayList(); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/profiles/ShadowStyle.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/profiles/ShadowStyle.java index 5e5f981c..ee0f442b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/profiles/ShadowStyle.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/profiles/ShadowStyle.java @@ -50,6 +50,9 @@ public class ShadowStyle extends StyleBase { AffineTransform transform = DiagramGraphUtil.getAffineTransform(graph, element); Resource component = graph.getPossibleObject(element, MOD.ElementToComponent); + + if (component == null) + return new ShadowResult(Style.NONE, transform); Resource original = graph.getPossibleObject(component, SR.Shadow_original); Collection shadows = graph.getObjects(component, SR.Shadow_original_Inverse); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/AssignIC.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/AssignIC.java index a84ec550..16bb242b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/AssignIC.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/AssignIC.java @@ -34,6 +34,7 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.request.PossibleModel; +import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.layer0.Layer0; import org.simantics.modeling.ui.Activator; import org.simantics.sysdyn.SysdynResource; @@ -99,22 +100,17 @@ public class AssignIC extends AbstractHandler { @Override public void perform(WriteGraph graph) throws DatabaseException { - + graph.markUndoPoint(); SysdynResource SYSDYN = SysdynResource.getInstance(graph); graph.deny(experiment, SYSDYN.Experiment_ic); graph.claim(experiment, SYSDYN.Experiment_ic, ic); - + Layer0Utils.addCommentMetadata(graph, "Assigned new IC " + NameUtils.getSafeName(graph, ic) + " to experiment " + NameUtils.getSafeLabel(graph, experiment)); } - }); - } catch (DatabaseException e) { - + e.printStackTrace(); } - return null; - } - } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/EnumerationIndexRenameNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/EnumerationIndexRenameNodeHandler.java new file mode 100644 index 00000000..11b5cc3b --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/EnumerationIndexRenameNodeHandler.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 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.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.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.part.IPage; +import org.eclipse.ui.part.IPageSite; +import org.simantics.browsing.ui.GraphExplorer; +import org.simantics.browsing.ui.NodeContext; +import org.simantics.browsing.ui.common.ColumnKeys; +import org.simantics.browsing.ui.platform.PropertyPageView; +import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite; +import org.simantics.sysdyn.ui.properties.SysdynPropertyPage; +import org.simantics.utils.ui.ISelectionUtils; + +public class EnumerationIndexRenameNodeHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + ISelection sel2 = HandlerUtil.getActiveMenuSelection(event); + NodeContext ctx = ISelectionUtils.filterSingleSelection(sel2, NodeContext.class); + if (ctx == null) + return null; + + IWorkbenchPart part = HandlerUtil.getActivePart(event); + if (part == null) + return null; + + PropertyPageView ppv = (PropertyPageView) part; + IPage p = ppv.getCurrentPage(); + Control control = p.getControl(); + + Control geComposite = findGEComposite(control); + GraphExplorerComposite ge = (GraphExplorerComposite) geComposite; + ge.getExplorer().startEditing(ctx, ColumnKeys.SINGLE); + + return null; + } + + private Control findGEComposite(Control control) { + Control[] comp = ((Composite) control).getChildren(); + Control ge = null; + for (Control cont : comp) { + if (cont instanceof GraphExplorerComposite) + return cont; + else if (cont instanceof Composite) { + ge = findGEComposite(cont); + return ge; + } + else + continue; + } + return ge; + } +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveHistoryHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveHistoryHandler.java index f4a103c0..dde222be 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveHistoryHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveHistoryHandler.java @@ -20,6 +20,9 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import org.simantics.Simantics; @@ -45,7 +48,6 @@ import org.simantics.sysdyn.manager.MemoryResult; import org.simantics.sysdyn.manager.SysdynGameExperimentBase; import org.simantics.sysdyn.manager.SysdynResult; import org.simantics.sysdyn.ui.utils.HandlerUtils; -import org.simantics.ui.SimanticsUI; import org.simantics.utils.datastructures.Pair; public class SaveHistoryHandler extends AbstractHandler { @@ -55,7 +57,7 @@ public class SaveHistoryHandler extends AbstractHandler { HandlerUtils.saveBeforeExperimentRun(event); IExperimentManager manager = - SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); + Simantics.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); IExperiment experiment = manager.getActiveExperiment(); if(experiment instanceof SysdynGameExperimentBase) { final SysdynGameExperimentBase exp = (SysdynGameExperimentBase)experiment; @@ -67,6 +69,15 @@ public class SaveHistoryHandler extends AbstractHandler { if(r instanceof MemoryResult) { MemoryResult gr = (MemoryResult)r; SimulationResult sr = gr.getSimulationResult(); + if (sr == null) { + + MessageBox messageDialog = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_WARNING | SWT.OK); + messageDialog.setText("No Simulation History"); + messageDialog.setMessage("There is no simulation history available, please simulate first!"); + + messageDialog.open(); + return null; + } for(DataSet ds : sr.getVariableDataSets()) { map.put(ds, new Pair(ds.name, null)); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveICHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveICHandler.java index de738344..b11fddff 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveICHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SaveICHandler.java @@ -25,7 +25,6 @@ import org.simantics.simulation.project.IExperimentManager; import org.simantics.sysdyn.manager.SysdynExperiment; import org.simantics.sysdyn.manager.SysdynExperiments; import org.simantics.sysdyn.ui.utils.HandlerUtils; -import org.simantics.ui.SimanticsUI; public class SaveICHandler extends AbstractHandler { @@ -34,7 +33,7 @@ public class SaveICHandler extends AbstractHandler { HandlerUtils.saveBeforeExperimentRun(event); IExperimentManager manager = - SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); + Simantics.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); IExperiment experiment = manager.getActiveExperiment(); if(experiment instanceof SysdynExperiment) { final SysdynExperiment exp = (SysdynExperiment)experiment; @@ -44,7 +43,7 @@ public class SaveICHandler extends AbstractHandler { @Override public void perform(WriteGraph graph) throws DatabaseException { Variable v = Variables.getVariable(graph, exp.getResource()); - SysdynExperiments.saveIC(graph, v, "IC"); + SysdynExperiments.saveIC(graph, v); } }); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportMdlHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportMdlHandler.java index 8d35a4ea..e1230b8a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportMdlHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/imports/ImportMdlHandler.java @@ -68,7 +68,7 @@ public class ImportMdlHandler extends AbstractHandler { // Convert Vensim model to Simantics SysDyn format using MdlParser final Model model; try { - model = MdlParser.parse(file); + model = new MdlParser().parse(file); } catch (Exception e) { e.printStackTrace(); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/ModelicaPreferencePage.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/ModelicaPreferencePage.java index 443c9014..af438d9a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/ModelicaPreferencePage.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/ModelicaPreferencePage.java @@ -84,7 +84,6 @@ public class ModelicaPreferencePage extends FieldEditorPreferencePage implements @Override public void doLoadDefault() { - System.err.println("LOAD DEFAULT"); IScopeContext context = ConfigurationScope.INSTANCE; Preferences node = context.getNode(Activator.PLUGIN_ID); node.put(OpenModelicaPreferences.OM_HOME, ModelicaManager.getDefaultOMHome().getAbsolutePath()); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java index 741cfcc2..0a2e68ec 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java @@ -408,9 +408,12 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg @Override public void run() { - up.getControl().setEnabled(finalEnabled); - down.getControl().setEnabled(finalEnabled); - remove.getControl().setEnabled(finalEnabled); + if (!up.getControl().isDisposed()) + up.getControl().setEnabled(finalEnabled); + if (!down.getControl().isDisposed()) + down.getControl().setEnabled(finalEnabled); + if (!remove.getControl().isDisposed()) + remove.getControl().setEnabled(finalEnabled); } }); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java index 36e3fa14..2c783b6e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java @@ -44,6 +44,7 @@ import org.simantics.issues.ontology.IssueResource; import org.simantics.jfreechart.chart.properties.AdjustableTab; import org.simantics.layer0.Layer0; import org.simantics.operation.Layer0X; +import org.simantics.simulation.ontology.SimulationResource; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.properties.widgets.EquivalentUnitsWidget; import org.simantics.sysdyn.ui.properties.widgets.factories.ComboStringPropertyModifier; @@ -69,7 +70,7 @@ public class ConfigurationTab extends AdjustableTab { outputIntervalLabel, methodLabel, toleranceLabel, variableFilterLabel; private TrackedText name, startTime, stopTime, stepLength, outputInterval, tolerance, variableFilter; private TrackedCombo method, timeUnit; - private Button validateUnits; + private Button validateUnits, useModelicaLibrary; private EquivalentUnitsWidget equivalentUnitsWidget; /** * Modifier for modifying model labels @@ -299,6 +300,35 @@ public class ConfigurationTab extends AdjustableTab { "NOTE: whitespace must be replaced with an underscore ('_') character" + "e.g. 'Growth Rate' -> 'Growth_Rate'"); + useModelicaLibrary = new Button(composite, support, SWT.CHECK); + useModelicaLibrary.setText("Use Modelica libraries"); + useModelicaLibrary.setSelectionFactory(new ReadFactoryImpl() { + + @Override + public Boolean perform(ReadGraph graph, Resource model) throws DatabaseException { + SysdynResource SR = SysdynResource.getInstance(graph); + SimulationResource SIM = SimulationResource.getInstance(graph); + Resource configuration = graph.getPossibleObject(model, SIM.HasConfiguration); + return graph.getPossibleObject(configuration, SR.SysdynModel_useModelicaLibraries) != null; + } + }); + + useModelicaLibrary.addSelectionListener(new SelectionListenerImpl(context){ + + @Override + public void apply(WriteGraph graph, Resource model) throws DatabaseException { + SysdynResource SR = SysdynResource.getInstance(graph); + SimulationResource SIM = SimulationResource.getInstance(graph); + Resource configuration = graph.getPossibleObject(model, SIM.HasConfiguration); + boolean useModelicaLibraries = graph.getPossibleObject(configuration, SR.SysdynModel_useModelicaLibraries) != null; + + if (!useModelicaLibraries) + graph.claim(configuration, SR.SysdynModel_useModelicaLibraries, configuration); + else + graph.deny(configuration, SR.SysdynModel_useModelicaLibraries); + } + }); + sc.setExpandHorizontal(true); sc.setExpandVertical(true); } @@ -330,6 +360,7 @@ public class ConfigurationTab extends AdjustableTab { GridDataFactory.fillDefaults().grab(true, false).hint(50, SWT.DEFAULT).applyTo(tolerance.getWidget()); GridDataFactory.fillDefaults().span(2, 1).align(SWT.BEGINNING, SWT.CENTER).applyTo(variableFilterLabel); GridDataFactory.fillDefaults().span(2, 1).grab(true, false).hint(100, SWT.DEFAULT).applyTo(variableFilter.getWidget()); + GridDataFactory.fillDefaults().span(2, 1).grab(true, false).hint(100, SWT.DEFAULT).applyTo(useModelicaLibrary.getWidget()); sc.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } @@ -362,7 +393,8 @@ public class ConfigurationTab extends AdjustableTab { GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(toleranceLabel); GridDataFactory.fillDefaults().grab(true, false).span(wideScreen ? 1 : 2, 1).hint(60, SWT.DEFAULT).applyTo(tolerance.getWidget()); GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(variableFilterLabel); - GridDataFactory.fillDefaults().grab(true, false).span(wideScreen ? 10 : 5, 1).hint(200, SWT.DEFAULT).applyTo(variableFilter.getWidget()); + GridDataFactory.fillDefaults().grab(true, false).span(wideScreen ? 9 : 4, 1).hint(200, SWT.DEFAULT).applyTo(variableFilter.getWidget()); + GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(useModelicaLibrary.getWidget()); sc.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java index 7514f47c..4252b6cd 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java @@ -15,6 +15,10 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.viewers.ISelectionProvider; @@ -29,7 +33,9 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.IWorkbenchSite; +import org.simantics.Simantics; import org.simantics.browsing.ui.NodeContext; +import org.simantics.browsing.ui.common.ColumnKeys; import org.simantics.browsing.ui.swt.SingleSelectionInputSource; import org.simantics.browsing.ui.swt.widgets.Button; import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite; @@ -47,6 +53,7 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.db.management.ISessionContext; @@ -62,8 +69,8 @@ import org.simantics.sysdyn.ui.properties.widgets.arrays.EnumerationIndexNode; import org.simantics.sysdyn.ui.properties.widgets.arrays.ReplaceableIndexesWidget; import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameInputValidator; import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier; -import org.simantics.ui.SimanticsUI; import org.simantics.utils.datastructures.ArrayMap; +import org.simantics.utils.threads.SWTThread; import org.simantics.utils.ui.AdaptionUtils; public class EnumerationTab extends LabelPropertyTabContributor implements Widget { @@ -78,6 +85,10 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge Variable variable; Table table; + + private Button add; + private Button remove; + @Override public void createControls(Composite body, IWorkbenchSite site, final ISessionContext context, WidgetSupport support) { @@ -97,6 +108,8 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge indexExplorer = new GraphExplorerComposite(ArrayMap.keys( "displaySelectors", "displayFilter").values(false, false), site, container, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | SWT.CHECK); + indexExplorer.setContextMenuId("#EnumerationTabPopup"); + indexExplorer .setBrowseContexts(SysdynResource.URIs.EnumerationIndexes); indexExplorer.setInputSource(new SingleSelectionInputSource( @@ -112,7 +125,7 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge final EnumerationIndexNode node = (EnumerationIndexNode) context.getAdapter(EnumerationIndexNode.class); node.setShowInChartsSelected(checked); - SimanticsUI.getSession().asyncRequest(new ReadRequest() { + Simantics.getSession().asyncRequest(new ReadRequest() { @Override public void run(ReadGraph graph) throws DatabaseException { updateModelResults(graph); @@ -122,7 +135,7 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge } }); - + indexExplorer.finish(); GridDataFactory.fillDefaults().grab(true, true).span(4, 1).applyTo( @@ -133,13 +146,13 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge ((Tree) c).setLinesVisible(true); - final Button add = new Button(container, support, SWT.None); + add = new Button(container, support, SWT.None); add.setText("Add"); - add.addSelectionListener(new addEnumerationIndexListener(support)); + add.addSelectionListener(new AddEnumerationIndexListener(support)); - final Button remove = new Button(container, support, SWT.None); + remove = new Button(container, support, SWT.None); remove.setText("Remove"); - remove.addSelectionListener(new removeEnumerationIndexListener(support)); + remove.addSelectionListener(new RemoveEnumerationIndexListener(support)); ReplaceableIndexesWidget externalIndexes = new ReplaceableIndexesWidget(container, support, SWT.NULL); GridDataFactory.fillDefaults().applyTo(externalIndexes.getWidget()); @@ -150,11 +163,11 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge } - private class addEnumerationIndexListener implements SelectionListener, Widget { + private class AddEnumerationIndexListener implements SelectionListener, Widget { Resource enumerationIndexes; - public addEnumerationIndexListener(WidgetSupport support) { + public AddEnumerationIndexListener(WidgetSupport support) { support.register(this); } @@ -177,10 +190,15 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge @Override public void widgetSelected(SelectionEvent e) { try { - SimanticsUI.getSession().syncRequest(new WriteRequest() { + + currentItemCount = getCurrentItemCount(); + lastItemCount = currentItemCount; + + Simantics.getSession().syncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); SysdynResource sr = SysdynResource.getInstance(graph); Layer0 l0 = Layer0.getInstance(graph); @@ -195,8 +213,17 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge ArrayList index = new ArrayList(); index.add(ei); ListUtils.insertBack(graph, enumerationIndexes, index); + + List list = ListUtils.toList(graph, enumerationIndexes); + if (!list.isEmpty()) + updateRemoveButton(true); + + Layer0Utils.addCommentMetadata(graph, "Added new Enumeration Index " + NameUtils.getSafeName(graph, ei) + " to " + enumerationIndexes); } }); + + enableItemForRename(); + } catch (DatabaseException e1) { e1.printStackTrace(); } @@ -205,16 +232,16 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge @Override public void widgetDefaultSelected(SelectionEvent e) { - + System.out.println("asd"); } } - private class removeEnumerationIndexListener implements SelectionListener, Widget { + private class RemoveEnumerationIndexListener implements SelectionListener, Widget { Resource enumerationIndexes; - public removeEnumerationIndexListener(WidgetSupport support) { + public RemoveEnumerationIndexListener(WidgetSupport support) { support.register(this); } @@ -227,6 +254,9 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge @Override public void run(ReadGraph graph) throws DatabaseException { enumerationIndexes = graph.getSingleObject(enumeration, SysdynResource.getInstance(graph).Enumeration_enumerationIndexList); + List list = ListUtils.toList(graph, enumerationIndexes); + if (list.isEmpty()) + updateRemoveButton(false); } }); } catch (DatabaseException e) { @@ -240,16 +270,21 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge final IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection(); try { - SimanticsUI.getSession().syncRequest(new WriteRequest() { + Simantics.getSession().syncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); for(Object o : selection.toList()) { Resource r = AdaptionUtils.adaptToSingle(o, Resource.class); if(r == null) continue; ListUtils.removeElement(graph, enumerationIndexes, r); } + List list = ListUtils.toList(graph, enumerationIndexes); + if (list.isEmpty()) + updateRemoveButton(false); + Layer0Utils.addCommentMetadata(graph, "Removed Enumeration Index " ); } }); } catch (DatabaseException e1) { @@ -331,10 +366,11 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge public void widgetSelected(SelectionEvent e) { final boolean selected = showAll.getWidget().getSelection(); try { - SimanticsUI.getSession().syncRequest(new WriteRequest() { + Simantics.getSession().syncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); SysdynResource sr = SysdynResource.getInstance(graph); List indexes = ListUtils.toList(graph, enumerationIndexes); for(Resource index : indexes) { @@ -345,7 +381,7 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge graph.claimLiteral(index, sr.EnumerationIndex_showEnumerationIndexInCharts, false, Bindings.BOOLEAN); } } - + Layer0Utils.addCommentMetadata(graph, "Modified Show all in charts"); updateModelResults(graph); } }); @@ -385,4 +421,87 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge public void setInput(ISessionContext context, Object input) { variable = AdaptionUtils.adaptToSingle(input, Variable.class); } + + private void updateRemoveButton(final boolean enable) { + SWTThread.getThreadAccess().asyncExec(new Runnable() { + + @Override + public void run() { + remove.getWidget().setEnabled(enable); + if (!enable) + add.getWidget().setFocus(); + } + }); + } + + private int currentItemCount = 0; + private int lastItemCount = 0; + + private void enableItemForRename() { + + + + Job j = new Job("") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + + while (lastItemCount == currentItemCount) { + SWTThread.getThreadAccess().syncExec(new Runnable() { + + @Override + public void run() { + lastItemCount = getCurrentItemCount(); + } + }); + try { + Thread.sleep(50); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + SWTThread.getThreadAccess().syncExec(new Runnable() { + + @Override + public void run() { + Control c = indexExplorer.getExplorer().getControl(); + if (c instanceof Tree) { + Tree tree = (Tree) c; + TreeItem[] items = tree.getItems(); + TreeItem lastItem = items[items.length - 1]; + tree.setSelection(lastItem); + } + } + }); + + SWTThread.getThreadAccess().syncExec(new Runnable() { + + @Override + public void run() { + Control c = indexExplorer.getExplorer().getControl(); + if (c instanceof Tree) { + Tree tree = (Tree) c; + TreeItem[] items = tree.getItems(); + TreeItem lastItem = items[items.length - 1]; + NodeContext context = (NodeContext)lastItem.getData(); + tree.setSelection(lastItem); + indexExplorer.getExplorer().startEditing(context, ColumnKeys.SINGLE); + tree.setSelection(lastItem); + } + } + }); + + return Status.OK_STATUS; + } + }; + j.schedule(); + } + + public int getCurrentItemCount() { + Control c = indexExplorer.getExplorer().getControl(); + Tree tree = (Tree) c; + return tree.getItemCount(); + } } + diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java index 4d45a5cb..4072c806 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java @@ -504,6 +504,7 @@ public class EquationTab extends AdjustableTab implements Widget { } else { // If there was no active expression, create a normal expression graph.claim(newExpression, l0.InstanceOf, sr.NormalExpression); + graph.claimLiteral(newExpression, sr.Expression_equation, ""); Layer0Utils.addCommentMetadata(graph, "Created new Normal Expression " + newExpression + " for " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING)); } ArrayList addition = new ArrayList(1); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/IsOutputWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/IsOutputWidget.java index db9a513f..40fe24cb 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/IsOutputWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/IsOutputWidget.java @@ -16,6 +16,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl; import org.simantics.browsing.ui.swt.widgets.impl.Widget; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; @@ -23,7 +24,6 @@ import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; -import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.management.ISessionContext; @@ -39,6 +39,14 @@ public class IsOutputWidget implements Widget{ public IsOutputWidget(Composite parent, WidgetSupport support, int style) { support.register(this); isOutputButton = new org.simantics.browsing.ui.swt.widgets.Button(parent, support, style |= SWT.CHECK); + isOutputButton.setSelectionFactory(new ReadFactoryImpl() { + + @Override + public Boolean perform(ReadGraph graph, Resource input) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + return graph.hasStatement(variable, sr.IsOutput); + } + }); isOutputButton.setText("Is Output"); } @@ -56,34 +64,8 @@ public class IsOutputWidget implements Widget{ if(variable == null) return; - try { - context.getSession().syncRequest(new ReadRequest() { - - @Override - public void run(ReadGraph graph) throws DatabaseException { - SysdynResource sr = SysdynResource.getInstance(graph); - final boolean isOutput = graph.hasStatement(variable, sr.IsOutput); - final Button button = getWidget(); - button.getDisplay().asyncExec(new Runnable() { - - @Override - public void run() { - if(button.isDisposed()) return; - - if(isOutput) - button.setSelection(true); - else - button.setSelection(false); - } - }); + isOutputButton.setInput(context, input); - - } - }); - } catch (DatabaseException e) { - e.printStackTrace(); - } - isOutputButton.addSelectionListener(new SelectionListenerImpl(context) { @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexNode.java index ff7b7021..b2ca447b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexNode.java @@ -1,5 +1,6 @@ package org.simantics.sysdyn.ui.properties.widgets.arrays; +import org.simantics.Simantics; import org.simantics.browsing.ui.common.node.AbstractNode; import org.simantics.browsing.ui.common.node.IDoubleClickableNode; import org.simantics.browsing.ui.common.node.IModifiableNode; @@ -8,12 +9,13 @@ import org.simantics.db.ReadGraph; 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.layer0.util.Layer0Utils; import org.simantics.db.request.Read; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.utils.VariableNameValidator; -import org.simantics.ui.SimanticsUI; public class EnumerationIndexNode extends AbstractNode implements IModifiableNode, IDoubleClickableNode { @@ -38,7 +40,7 @@ public class EnumerationIndexNode extends AbstractNode implements IMo }; try { - return SimanticsUI.getSession().syncRequest(request); + return Simantics.getSession().syncRequest(request); } catch (DatabaseException e) { e.printStackTrace(); return ""; @@ -54,7 +56,7 @@ public class EnumerationIndexNode extends AbstractNode implements IMo @Override public void modify(final String label) { - SimanticsUI.getSession().asyncRequest(new WriteRequest() { + Simantics.getSession().asyncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { graph.claimLiteral(data, Layer0.getInstance(graph).HasName, label); @@ -78,11 +80,13 @@ public class EnumerationIndexNode extends AbstractNode implements IMo public void setShowInChartsSelected(final boolean selected) { try { - SimanticsUI.getSession().syncRequest(new WriteRequest() { + Simantics.getSession().syncRequest(new WriteRequest() { @Override public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); SysdynResource sr = SysdynResource.getInstance(graph); graph.claimLiteral(data, sr.EnumerationIndex_showEnumerationIndexInCharts, selected); + Layer0Utils.addCommentMetadata(graph, "Modified show in chart of " + NameUtils.getSafeName(graph, data) + " to " + selected); } }); } catch (DatabaseException e) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/ReplaceableIndexesWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/ReplaceableIndexesWidget.java index 0dd0a49a..d5403ac9 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/ReplaceableIndexesWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/ReplaceableIndexesWidget.java @@ -17,14 +17,16 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl; import org.simantics.browsing.ui.swt.widgets.impl.Widget; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; -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.Layer0Utils; import org.simantics.db.management.ISessionContext; import org.simantics.sysdyn.SysdynResource; import org.simantics.utils.ui.ISelectionUtils; @@ -38,6 +40,14 @@ public class ReplaceableIndexesWidget implements Widget { public ReplaceableIndexesWidget(Composite parent, WidgetSupport support, int style) { support.register(this); isReplaceableButton = new org.simantics.browsing.ui.swt.widgets.Button(parent, support, style |= SWT.CHECK); + isReplaceableButton.setSelectionFactory(new ReadFactoryImpl() { + + @Override + public Boolean perform(ReadGraph graph, Resource input) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + return graph.getPossibleRelatedValue(variable, sr.Enumeration_isReplaceable); + } + }); isReplaceableButton.setText("Can be replaced by parent module"); } @@ -55,35 +65,7 @@ public class ReplaceableIndexesWidget implements Widget { if(variable == null) return; - try { - context.getSession().syncRequest(new ReadRequest() { - - @Override - public void run(ReadGraph graph) throws DatabaseException { - SysdynResource sr = SysdynResource.getInstance(graph); - final Boolean replaceable = graph.getPossibleRelatedValue(variable, sr.Enumeration_isReplaceable); - if(replaceable != null) - selected = replaceable; - final Button button = getWidget(); - button.getDisplay().asyncExec(new Runnable() { - - @Override - public void run() { - if(button.isDisposed()) return; - - if(replaceable) - button.setSelection(true); - else - button.setSelection(false); - } - }); - - - } - }); - } catch (DatabaseException e) { - e.printStackTrace(); - } + isReplaceableButton.setInput(context, input); isReplaceableButton.addSelectionListener(new SelectionListenerImpl(context) { @@ -98,6 +80,7 @@ public class ReplaceableIndexesWidget implements Widget { graph.claimLiteral(input, sr.Enumeration_isReplaceable, true); selected = true; } + Layer0Utils.addCommentMetadata(graph, "Modified " + NameUtils.getSafeName(graph, input) + " can be replaced to " + selected); } }); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/NameValidator.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/NameValidator.java index 25d7090b..ff352c72 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/NameValidator.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/NameValidator.java @@ -113,8 +113,8 @@ public abstract class NameValidator { // Function, FunctionLibrary, and SharedFunctionLibrary are not // allowed to have whitespace. if (graph.isInstanceOf(resource, sr.Variable) -// || graph.isInstanceOf(resource, sr.Module) -// || graph.isInstanceOf(resource, sr.ModuleType) + || graph.isInstanceOf(resource, sr.Module) + || graph.isInheritedFrom(resource, sr.ModuleSymbol) || graph.isInstanceOf(resource, sr.Enumeration) || graph.isInstanceOf(resource, sr.EnumerationIndex) || graph.isInstanceOf(resource, sheet.Spreadsheet) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/mdl/WizardMdlImportPage.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/mdl/WizardMdlImportPage.java index 93766ed4..d4679f7d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/mdl/WizardMdlImportPage.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/mdl/WizardMdlImportPage.java @@ -183,7 +183,7 @@ public class WizardMdlImportPage extends WizardPage{ final Model model; try { - model = MdlParser.parse(file); + model = new MdlParser().parse(file); } catch (Exception e) { e.printStackTrace();