Changeset 34733 in osm for applications
- Timestamp:
- 2018-11-22T00:18:36+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/src/org/openstreetmap/josm/plugins/indoorhelper/IndoorHelperPlugin.java
r34522 r34733 62 62 public IndoorHelperPlugin(PluginInformation info) throws IOException { 63 63 super(info); 64 exportValidator("/data/indoorhelper.validator.mapcss"); 65 exportStyleFile("sit.mapcss"); 66 exportStyleFile("entrance_door_icon.png"); 67 exportStyleFile("entrance_icon.png"); 68 exportStyleFile("elevator_icon.png"); 64 69 MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(this); 65 this.exportValidator("/data/indoorhelper.validator.mapcss");66 this.exportStyleFile("sit.mapcss");67 this.exportStyleFile("entrance_door_icon.png");68 this.exportStyleFile("entrance_icon.png");69 this.exportStyleFile("elevator_icon.png");70 70 } 71 71 … … 86 86 */ 87 87 private void exportValidator(String resourceName) throws IOException { 88 OutputStream resStreamOut = null;89 90 88 try (InputStream stream = IndoorHelperPlugin.class.getResourceAsStream(resourceName)) { 91 89 if (stream == null) { 92 System.out.println("Validator: stream is null");93 90 throw new IOException("Cannot get resource \"" + resourceName + "\" from Jar file."); 94 91 } 95 92 96 int readBytes; 97 byte[] buffer = new byte[4096]; 98 99 String valDirPath = Config.getDirs().getUserDataDirectory(true) + sep + "validator"; 100 File valDir = new File(valDirPath); 93 File valDir = new File(Config.getDirs().getUserDataDirectory(true), "validator"); 101 94 valDir.mkdirs(); 102 95 String outPath = valDir.getAbsolutePath() +sep+ "indoorhelper.validator.mapcss"; 103 96 104 resStreamOut = new FileOutputStream(outPath); 105 while ((readBytes = stream.read(buffer)) > 0) { 106 resStreamOut.write(buffer, 0, readBytes); 107 } 108 resStreamOut.close(); 97 try (OutputStream resStreamOut = new FileOutputStream(outPath)) { 98 int readBytes; 99 byte[] buffer = new byte[4096]; 100 while ((readBytes = stream.read(buffer)) > 0) { 101 resStreamOut.write(buffer, 0, readBytes); 102 } 103 } 109 104 } 110 105 } … … 150 145 public void paintableInvalidated(PaintableInvalidationEvent event) { 151 146 AutoFilter currentAutoFilter = AutoFilterManager.getInstance().getCurrentAutoFilter(); 152 String currentFilterValue = new String();153 147 154 148 if (currentAutoFilter != null) { 155 currentFilterValue = currentAutoFilter.getFilter().text.split("=")[1];156 157 this.controller.setIndoorLevel(currentFilterValue); 158 this.controller.getIndoorLevel(currentFilterValue);159 this.controller.unsetSpecificKeyFilter("repeat_on");160 161 } else {162 currentFilterValue = "";163 this.controller.setIndoorLevel(currentFilterValue);164 this.controller.getIndoorLevel(currentFilterValue);149 if (controller != null) { 150 String currentFilterValue = currentAutoFilter.getFilter().text.split("=")[1]; 151 152 controller.setIndoorLevel(currentFilterValue); 153 controller.getIndoorLevel(currentFilterValue); 154 controller.unsetSpecificKeyFilter("repeat_on"); 155 } 156 } else if (controller != null) { 157 controller.setIndoorLevel(""); 158 controller.getIndoorLevel(""); 165 159 } 166 160 }
Note:
See TracChangeset
for help on using the changeset viewer.