Changeset 34005 in osm for applications/editors/josm/plugins/indoorhelper/src/org
- Timestamp:
- 2018-01-13T18:19:22+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/src/org/openstreetmap/josm/plugins/indoorhelper/IndoorHelperPlugin.java
r33997 r34005 40 40 import controller.IndoorHelperController; 41 41 42 43 42 /** 44 43 * This is the main class for the indoorhelper plug-in. … … 50 49 public class IndoorHelperPlugin extends Plugin implements PaintableInvalidationListener, ActiveLayerChangeListener { 51 50 52 53 @SuppressWarnings("unused") 51 @SuppressWarnings("unused") 54 52 private IndoorHelperController controller; 55 53 String sep = System.getProperty("file.separator"); … … 91 89 * Exports the mapcss validator file to the preferences directory. 92 90 */ 93 @SuppressWarnings("deprecation") 94 private void exportValidator(String resourceName) throws Exception { 91 private void exportValidator(String resourceName) throws Exception { 95 92 InputStream stream = null; 96 93 OutputStream resStreamOut = null; … … 107 104 byte[] buffer = new byte[4096]; 108 105 109 String valDirPath = Main.pref.getUserDataDirectory() + sep + "validator"; 106 String valDirPath = Main.pref.getDirs().getUserDataDirectory(true) + sep + "validator"; 110 107 File valDir = new File(valDirPath); 111 108 valDir.mkdirs(); … … 129 126 */ 130 127 private void exportStyleFile(String resourceName) throws Exception { 131 InputStream stream = null; 132 OutputStream resStreamOut = null; 133 134 try { 135 stream = IndoorHelperPlugin.class.getResourceAsStream("/data/" + resourceName); 128 try (InputStream stream = IndoorHelperPlugin.class.getResourceAsStream("/data/" + resourceName)) { 136 129 if (stream == null) { 137 130 System.out.println("MapPaint: stream is null"); … … 143 136 byte[] buffer = new byte[4096]; 144 137 145 @SuppressWarnings("deprecation") 146 String valDirPath = Main.pref.getUserDataDirectory() + sep + "styles"; 138 String valDirPath = Main.pref.getDirs().getUserDataDirectory(true) + sep + "styles"; 147 139 File valDir = new File(valDirPath); 148 140 valDir.mkdirs(); 149 141 outPath = valDir.getAbsolutePath() +sep+ resourceName; 150 System.out.println("MapPaint"+outPath); 151 152 resStreamOut = new FileOutputStream(outPath); 153 while ((readBytes = stream.read(buffer)) > 0) { 154 resStreamOut.write(buffer, 0, readBytes); 155 } 156 resStreamOut.close(); 142 143 try (OutputStream resStreamOut = new FileOutputStream(outPath)) { 144 while ((readBytes = stream.read(buffer)) > 0) { 145 resStreamOut.write(buffer, 0, readBytes); 146 } 147 } 157 148 } catch (Exception ex) { 158 149 throw ex; 159 } finally { 160 stream.close(); 161 } 162 } 163 164 @Override 165 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 166 OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 150 } 151 } 152 153 @Override 154 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 155 OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 167 156 if (editLayer != null) { 168 157 editLayer.addInvalidationListener(this); 169 158 } 170 } 171 172 @Override 173 public void paintableInvalidated(PaintableInvalidationEvent event){ 174 AutoFilter currentAutoFilter = AutoFilterManager.getInstance().getCurrentAutoFilter(); 175 String currentFilterValue = new String(); 176 177 if(currentAutoFilter != null) { 178 currentFilterValue = currentAutoFilter.getFilter().text.split("=")[1]; 179 180 this.controller.setIndoorLevel(currentFilterValue); 181 this.controller.getIndoorLevel(currentFilterValue); 182 this.controller.unsetSpecificKeyFilter("repeat_on"); 183 184 }else{ 185 currentFilterValue = ""; 186 this.controller.setIndoorLevel(currentFilterValue); 187 this.controller.getIndoorLevel(currentFilterValue); 188 }; 189 190 } 159 } 160 161 @Override 162 public void paintableInvalidated(PaintableInvalidationEvent event) { 163 AutoFilter currentAutoFilter = AutoFilterManager.getInstance().getCurrentAutoFilter(); 164 String currentFilterValue = new String(); 165 166 if (currentAutoFilter != null) { 167 currentFilterValue = currentAutoFilter.getFilter().text.split("=")[1]; 168 169 this.controller.setIndoorLevel(currentFilterValue); 170 this.controller.getIndoorLevel(currentFilterValue); 171 this.controller.unsetSpecificKeyFilter("repeat_on"); 172 173 } else { 174 currentFilterValue = ""; 175 this.controller.setIndoorLevel(currentFilterValue); 176 this.controller.getIndoorLevel(currentFilterValue); 177 } 178 } 191 179 192 180 /** … … 232 220 // } 233 221 // } 234 235 /**236 *237 *238 *239 *240 *241 *242 *243 *244 *245 */246 222 }
Note:
See TracChangeset
for help on using the changeset viewer.
