]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Trend shows multiple variables
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 2 Aug 2010 06:05:26 +0000 (06:05 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 2 Aug 2010 06:05:26 +0000 (06:05 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16893 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java

index 7aca1505c68fe36bc53c57f0addec20824b62bee..b48574fd124492d058e6c69c30af9c22e600ca5e 100644 (file)
@@ -84,9 +84,8 @@ public class TrendView extends ViewPart {
             return sets[series].times.length;\r
         }\r
 \r
-        @SuppressWarnings("unchecked")\r
         @Override\r
-        public Comparable getSeriesKey(int series) {    \r
+        public Comparable<String> getSeriesKey(int series) {    \r
             SysdynDataSet sds = sets[series];\r
             if(sds.result == null)\r
                 return sds.name;\r
@@ -138,28 +137,12 @@ public class TrendView extends ViewPart {
                     return;\r
                 if(selection instanceof IStructuredSelection) {\r
                     Set<Resource> ress = ISelectionUtils.filterSetSelection(selection, Resource.class);\r
-                       Resource runtime = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_VARIABLE_RESOURCE, Resource.class);\r
-//                    Object[] els = ((IStructuredSelection) selection).toArray();\r
-//                    Resource[] resources = new Resource[els.length];\r
-//                    for(int i=0;i<els.length;++i) {\r
-//                        if(els[i] instanceof Resource)\r
-//                            resources[i] = (Resource)els[i];\r
-//                        else\r
-//                            return;\r
-//                    }\r
+                       Resource runtime = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_VARIABLE_RESOURCE, Resource.class).get(0);\r
                     setSelection(ress.toArray(Resource.NONE), runtime);\r
                 }                \r
             }\r
         });\r
 \r
-        /*composite.getDisplay().asyncExec(new Runnable() {\r
-\r
-                    @Override\r
-                    public void run() {\r
-                        // Do something\r
-                    }\r
-\r
-                });*/            \r
     }\r
 \r
     Resource[] resources;\r
@@ -184,7 +167,9 @@ public class TrendView extends ViewPart {
                 final ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
                 for(Resource resource : resources) {\r
                     SysdynDataSet set = load(g, resource, runtime);\r
-                    if(set == null) return;\r
+                    if(set == null) {\r
+                        return;\r
+                    }\r
                     datasets.add(set);\r
                 }
 \r
@@ -201,28 +186,6 @@ public class TrendView extends ViewPart {
         });\r
     }\r
 \r
-//    Runnable updater = new Runnable() {\r
-//        @Override\r
-//        public void run() {\r
-//            updateView();\r
-//        }        \r
-//    };\r
-//\r
-//    HashMap<Resource, SysdynModel> models = new HashMap<Resource, SysdynModel>(); \r
-//    protected SysdynModel getModel(ReadGraph g, Resource configuration) {\r
-//        synchronized(models) {\r
-//            SysdynModel model = models.get(configuration);\r
-//            if(model == null) {\r
-//                model = \r
-//                    SysdynModelManager.getInstance(g.getSession()).getModel(g, configuration);\r
-//                // SimulationScheduler.start(model); Don't want this to operate simulation\r
-//                model.addResultListener(updater);\r
-//                models.put(configuration, model);\r
-//            }\r
-//            return model;\r
-//        }\r
-//    }\r
-\r
     protected SysdynDataSet load(ReadGraph g, Resource element, Resource runtime) throws DatabaseException {\r
 \r
        Builtins b = g.getBuiltins();\r
@@ -255,50 +218,6 @@ public class TrendView extends ViewPart {
                }\r
                return null;\r
 \r
-//        graph.syncre\r
-//        \r
-//        \r
-//        String prefix = "";\r
-//        Resource model = g.getResource((String)g.getPossibleRelatedValue(runtime, dr.HasModelURI));\r
-//        Resource configuration = g.getPossibleObject(model, b.HasConfiguration);\r
-//        String rvi = g.getPossibleRelatedValue(runtime, dr.HasRVI);\r
-//        if(rvi.startsWith("/")) {\r
-//             rvi = rvi.substring(1);\r
-//            prefix = rvi.replace("/", ".") + ".";\r
-//        } \r
-////        System.out.println("load results rvi='" + rvi + "' prefix='" + prefix + "'");\r
-//        \r
-//        ModelingResources mr = ModelingResources.getInstance(g);\r
-//        Resource map = g.getPossibleObject(resource, mr.ElementToComponent);\r
-//        if(map != null) resource = map;\r
-//\r
-//        if(g.isInstanceOf(resource, sr.Variable)) {\r
-//            Resource module = g.getPossibleObject(resource, b.PartOf);\r
-////            while(!g.isInstanceOf(module, sr.Configuration)) {\r
-////                module = g.getPossibleObject(module, b.PartOf);\r
-////            }\r
-//            if(g.isInstanceOf(module, sr.Configuration)) {\r
-//             \r
-//                SysdynModel sm = getModel(g, configuration);\r
-//                if(model == null)\r
-//                    return null;\r
-//\r
-//                IElement element = sm.getElement(resource);\r
-//                if(element instanceof Variable) {\r
-//                    Variable var = (Variable)element;      \r
-//\r
-//                    Collection<SysdynResult> activeResults =  sm.getActiveResults(g);\r
-//                    ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
-//                    for(SysdynResult r : activeResults) {\r
-//                        SysdynDataSet sdds = r.getDataSet(prefix + var.getName());\r
-//                        if(sdds != null) datasets.add(sdds);\r
-//                    }\r
-//                    return datasets;\r
-//                }                       \r
-//\r
-//            }\r
-//        }\r
-//        return null;\r
     }\r
 \r
     @Override\r