Changeset 34309 in osm for applications/editors/josm/plugins
- Timestamp:
- 2018-06-17T17:51:18+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/indoorhelper
- Files:
-
- 2 added
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/src/controller/IndoorHelperController.java
r34179 r34309 57 57 58 58 import model.IndoorHelperModel; 59 import model.IndoorLevel; 59 60 import model.TagCatalog.IndoorObject; 60 61 import views.LevelSelectorView; … … 264 265 static class ToolHelpButtonListener implements ActionListener { 265 266 266 267 268 269 270 271 267 @Override 268 public void actionPerformed(ActionEvent e) { 269 String topic = "Plugin/IndoorHelper"; 270 //Open HelpBrowser for short description about the plugin 271 HelpBrowser.setUrlForHelpTopic(Optional.ofNullable(topic).orElse("/")); 272 } 272 273 } 273 274 … … 565 566 * specific tag (key). Just unsets the disabled state if object has a tag-value which is part of the 566 567 * current working level. 567 * 568 * 568 569 * @author rebsc 569 570 * @param key sepcific key to unset hidden objects which contains it … … 572 573 573 574 Collection<OsmPrimitive> p = Main.main.getEditDataSet().allPrimitives(); 574 Map<String, String> tags = new HashMap<>(); 575 Integer level = Integer.parseInt(levelValue); 576 Integer firstVal, secVal; 575 int level = Integer.parseInt(levelValue); 577 576 578 577 //Find all primitives with the specific tag and check if value is part of the current … … 580 579 for (OsmPrimitive osm: p) { 581 580 if ((osm.isDisabledAndHidden() || osm.isDisabled()) && osm.hasKey(key)) { 582 583 tags = osm.getInterestingTags(); 584 585 for (Map.Entry<String, String> e: tags.entrySet()) { 581 for (Map.Entry<String, String> e: osm.getInterestingTags().entrySet()) { 586 582 if (e.getKey().equals(key)) { 587 String val = e.getValue();588 589 //Extract values590 if (val.indexOf("-") == 0) {591 firstVal = (Integer.parseInt(val.split("-", 2)[1].split("-", 2)[0]))*-1;592 secVal = Integer.parseInt(val.split("-", 2)[1].split("-", 2)[1]);593 } else {594 firstVal = Integer.parseInt(val.split("-")[0]);595 secVal = Integer.parseInt(val.split("-")[1]);596 }597 598 583 //Compare values to current working level 599 if ( level >= ((firstVal)-1) && level <= secVal) {584 if (IndoorLevel.isPartOfWorkingLevel(e.getValue(), level)) { 600 585 osm.unsetDisabledState(); 601 586 } else { -
applications/editors/josm/plugins/indoorhelper/src/model/IndoorLevel.java
r32637 r34309 115 115 } 116 116 } 117 118 public static boolean isPartOfWorkingLevel(String vals, int level) { 119 for (String val : vals.split(";")) { 120 int firstVal, secVal; 121 122 //Extract values 123 if (val.indexOf("-") == 0) { 124 firstVal = (Integer.parseInt(val.split("-", 2)[1].split("-", 2)[0]))*-1; 125 secVal = Integer.parseInt(val.split("-", 2)[1].split("-", 2)[1]); 126 } else if (val.contains("-")) { 127 firstVal = Integer.parseInt(val.split("-")[0]); 128 secVal = Integer.parseInt(val.split("-")[1]); 129 } else { 130 firstVal = Integer.parseInt(val); 131 secVal = firstVal; 132 } 133 134 // Compare values to current working level 135 if (level >= firstVal && level <= secVal) { 136 return true; 137 } 138 } 139 140 return false; 141 } 117 142 } -
applications/editors/josm/plugins/indoorhelper/test/unit/model/PresetCounterTest.java
r34308 r34309 1 // License: GPL. For details, see LICENSE file. 2 package model; 3 1 4 import static org.junit.Assert.assertEquals; 2 5 … … 6 9 import org.junit.Test; 7 10 8 import model.PresetCounter;9 11 import model.TagCatalog.IndoorObject; 10 12 13 /** 14 * Unit tests of {@link PresetCounter} class. 15 */ 11 16 public class PresetCounterTest { 12 17 … … 36 41 expectedList.add(IndoorObject.STEPS); 37 42 38 39 43 //assertion 40 44 assertEquals(expectedList.get(0), actualList.get(0)); … … 42 46 assertEquals(expectedList.get(2), actualList.get(2)); 43 47 assertEquals(expectedList.get(3), actualList.get(3)); 44 45 46 48 } 47 49 }
Note:
See TracChangeset
for help on using the changeset viewer.