| Summary: | Multipopulation: Double entry in combobox | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Technology] STEM | Reporter: | Jan-Frederik Wigger <jan-frederik.wigger> | ||||
| Component: | UI | Assignee: | Stefan Edlund <sedlund> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | ||||||
| Version: | unspecified | ||||||
| Target Milestone: | 1.1.2 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Jan-Frederik Wigger
This bug is already mentioned in bug 317079. It seems that there is a special handling for multiple populations in a "multi-population disease model". See org.eclipse.stem.diseasemodels.multipopulation.provider(MultipopulationPopulationEnumeratorAdapter.java:23) public String[] getPopulationIdentifiers() { MultiPopulationSIDiseaseModel dm = (MultiPopulationSIDiseaseModel)getTarget(); StringValueList list = dm.getPopulationGroups(); EList<org.eclipse.stem.core.common.StringValue> vals = list.getValues(); String [] res = new String[vals.size()+1]; res[0] = dm.getPopulationIdentifier(); for(int i=1;i<vals.size()+1;++i) res[i] = vals.get(i-1).getValue(); return res; } The method getPopulationIdentifiers() manually adds the name of the "disease model population" to the array, afterwards adds all population groups of the disease model. This possibly creates double entries, as taken into account in org.eclipse.stem.util.loggers.views(NewCSVLogWriter.java:256 and :463) PopulationEnumeratorAdapter en = (PopulationEnumeratorAdapter)PopulationEnumeratorAdapterFactory.INSTANCE.adapt(dm, PopulationEnumerator.class); if(en != null) { en.setTarget(dm); String [] pops = en.getPopulationIdentifiers(); // Skip first one, it's already been added. if(pops.length > 1) for(int i=1;i<pops.length;++i) populationIdentifiers.add(pops[i]); } The first entry is skipped, "it's already been added" (text in comment). I cannot overlook whether it is still useful/necessary to add a disease model population that is possibly not part of the population groups (if that was the reason for this handling). Suggestions for possible solutions: --------------------------------------------------------- 1.) Avoid double entries in PopulationIdentifiers array: org.eclipse.stem.diseasemodels.multipopulation.provider(MultipopulationPopulationEnumeratorAdapter.java:23 ) public String[] getPopulationIdentifiers() { MultiPopulationSIDiseaseModel dm = (MultiPopulationSIDiseaseModel)getTarget(); StringValueList list = dm.getPopulationGroups(); EList<org.eclipse.stem.core.common.StringValue> vals = list.getValues(); java.util.List<String> popIDs = new java.util.ArrayList<String>(); popIDs.add(dm.getPopulationIdentifier()); for(int i=0;i<vals.size();++i) if (!popIDs.contains(vals.get(i).getValue())) popIDs.add(vals.get(i).getValue()); String [] res = new String[popIDs.size()]; for(int i=res.length-1;i>=0;i--) res[i] = popIDs.get(i); return res; } Because the LogWriter skips the first entry so far: Delete lines org.eclipse.stem.util.loggers.views(NewCSVLogWriter.java:260-263), change :466 to for(int j=1;j<subpops1.length;++j) (?not sure) ------------------------------------------------------ 2.)Abandon the special handling completely, replace: org.eclipse.stem.diseasemodels.multipopulation.provider(MultipopulationPopulationEnumeratorAdapter.java:29) String [] res = new String[vals.size()]; for(int i=0;i<vals.size();i++) res[i] = vals.get(i).getValue(); Delete lines org.eclipse.stem.util.loggers.views(NewCSVLogWriter.java:260-263), change :466 to for(int j=1;j<subpops1.length;++j) (?not sure) ------------------------------------------------------ 3.) Keep this special handling, but just do not show in the selection list: org.eclipse.stem.ui.widgets(GeoViewOptionsBar.java:384) might need the same check and handling as described above ("Skip first one, it's already been added"). if(pea != null) { pea.setTarget(decorator); String [] pis = pea.getPopulationIdentifiers(); for (int i=(pis.length > 1)?1:0;i<pis.length;++i) popIds.add(pis[i]); } ------------------------------------------------------ Problems with 1 and 2: Maybe I do not know all effects that a change of the return array of getPopulationIdentifiers() takes on STEM. Jan-Frederik Wigger Created attachment 184596 [details]
screenshot of the drop down menu with the populations
Stefan, Is this the bug you fixed yesterday? Jan-Frederik, I pretty much followed your first suggestion and that seems to work. Let me know if there's still any problems. Thanks! Complete |