]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Enumeration properties work also in the modules-folder. changes do not update model...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 18 Feb 2011 07:48:28 +0000 (07:48 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 18 Feb 2011 07:48:28 +0000 (07:48 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@19799 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java

index 0b210465ab542e7b684ee5332d1917d64636b81e..f4cbd5ff786e4074d3e9429ab76c5e86e5daac35 100644 (file)
@@ -98,15 +98,7 @@ public class EnumerationTab extends PropertyTabContributorImpl implements Widget
                     SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
                                                @Override\r
                                                public void run(ReadGraph graph) throws DatabaseException {\r
-                                                       Resource modelResource = Variables.getModel(graph, variable);\r
-                                                       if(modelResource != null) {\r
-                                                               Resource configuration = graph.getSingleObject(\r
-                                                                               modelResource, \r
-                                                                               SimulationResource.getInstance(graph).HasConfiguration);\r
-                                                               SysdynModel model = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
-                                                               // update results in graphs\r
-                                                               model.resultChanged();\r
-                                                       }\r
+                                                       updateModelResults(graph);\r
                                                }\r
                                        });\r
                 }\r
@@ -327,17 +319,7 @@ public class EnumerationTab extends PropertyTabContributorImpl implements Widget
                                                                }\r
                                                        }\r
                                                        \r
-                                                       \r
-                                                       Resource modelResource = Variables.getModel(graph, variable);\r
-                                                       if(modelResource != null) {\r
-                                                               Resource configuration = graph.getSingleObject(\r
-                                                                               modelResource, \r
-                                                                               SimulationResource.getInstance(graph).HasConfiguration);\r
-                                                               SysdynModel model = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
-                                                               // update results in graphs\r
-                                                               model.resultChanged();\r
-                                                       }\r
-\r
+                                                       updateModelResults(graph);\r
                                                }\r
                                        });\r
                                } catch (DatabaseException e1) {\r
@@ -353,6 +335,24 @@ public class EnumerationTab extends PropertyTabContributorImpl implements Widget
                        }\r
 \r
                }\r
+       \r
+       private void updateModelResults(ReadGraph graph) {\r
+               try {\r
+                       if(variable != null ) {\r
+                               Resource modelResource = Variables.getModel(graph, variable);\r
+                               if(modelResource != null) {\r
+                                       Resource configuration = graph.getSingleObject(\r
+                                                       modelResource, \r
+                                                       SimulationResource.getInstance(graph).HasConfiguration);\r
+                                       SysdynModel model = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
+                                       // update results in graphs\r
+                                       model.resultChanged();\r
+                               }\r
+                       }\r
+               } catch (DatabaseException e) {\r
+                       e.printStackTrace();\r
+               }\r
+       }\r
 \r
        @Override\r
        public void setInput(ISessionContext context, Object input) {\r
index b46e3d6393dbdab1b0852e536eb1787c84b4d250..8966861143578f94e74ff4caaa9b2920de2f554c 100644 (file)
@@ -146,10 +146,14 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                return tabs;\r
                        }\r
                        if (backend.isInstanceOf(r, sr.Enumeration)) {\r
+                               Object s = AdaptionUtils.adaptToSingle(selection, ISelection.class);\r
+                               if(s == null)\r
+                                       s = r;\r
+                               // give either variable or the actual resource\r
                                return Collections.singleton(new ComparableTabContributor(\r
                                                new EnumerationTab(),\r
                                                2,\r
-                                               AdaptionUtils.adaptToSingle(selection, ISelection.class),\r
+                                               s,\r
                                "Enumeration"));\r
                        }\r
                        if ( backend.isInstanceOf(r, sr.Configuration) || backend.isInstanceOf(r, sr.SysdynModel)) {\r