Changeset 7012 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2014-04-27T15:35:47+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/JosmUserIdentityManager.java
r7004 r7012 240 240 @Override 241 241 public void preferenceChanged(PreferenceChangeEvent evt) { 242 if ("osm-server.username".equals(evt.getKey())) { 242 switch (evt.getKey()) { 243 case "osm-server.username": 243 244 if (!(evt.getNewValue() instanceof StringSetting)) return; 244 String new Value = ((StringSetting) evt.getNewValue()).getValue();245 if (new Value == null || newValue.trim().length() == 0) {245 String newUserName = ((StringSetting) evt.getNewValue()).getValue(); 246 if (newUserName == null || newUserName.trim().isEmpty()) { 246 247 setAnonymous(); 247 248 } else { 248 if (! new Value.equals(userName)) {249 setPartiallyIdentified(new Value);249 if (! newUserName.equals(userName)) { 250 setPartiallyIdentified(newUserName); 250 251 } 251 252 } 252 253 return; 253 254 254 } else if ("osm-server.url".equals(evt.getKey())) {255 case "osm-server.url": 255 256 if (!(evt.getNewValue() instanceof StringSetting)) return; 256 String new Value= ((StringSetting) evt.getNewValue()).getValue();257 if (new Value == null || newValue.trim().isEmpty()) {257 String newUrl = ((StringSetting) evt.getNewValue()).getValue(); 258 if (newUrl == null || newUrl.trim().isEmpty()) { 258 259 setAnonymous(); 259 260 } else if (isFullyIdentified()) { 260 261 setPartiallyIdentified(getUserName()); 261 262 } 262 263 } else if ("oauth.access-token.key".equals(evt.getKey())) { 263 break; 264 265 case "oauth.access-token.key": 264 266 accessTokenKeyChanged = true; 265 266 } else if ("oauth.access-token.secret".equals(evt.getKey())) { 267 break; 268 269 case "oauth.access-token.secret": 267 270 accessTokenSecretChanged = true; 271 break; 268 272 } 269 273 -
trunk/src/org/openstreetmap/josm/gui/MapMover.java
r6990 r7012 51 51 EastNorth center = nc.getCenter(); 52 52 EastNorth newcenter = nc.getEastNorth(nc.getWidth()/2+nc.getWidth()/5, nc.getHeight()/2+nc.getHeight()/5); 53 if ("left".equals(action)) 53 switch(action) { 54 case "left": 54 55 nc.zoomTo(new EastNorth(2*center.east()-newcenter.east(), center.north())); 55 else if ("right".equals(action)) 56 break; 57 case "right": 56 58 nc.zoomTo(new EastNorth(newcenter.east(), center.north())); 57 else if ("up".equals(action)) 59 break; 60 case "up": 58 61 nc.zoomTo(new EastNorth(center.east(), 2*center.north()-newcenter.north())); 59 else if ("down".equals(action)) 62 break; 63 case "down": 60 64 nc.zoomTo(new EastNorth(center.east(), newcenter.north())); 65 break; 66 } 61 67 } 62 68 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
r6986 r7012 355 355 356 356 public boolean appliesImpl(Environment e) { 357 if ("closed".equals(id)) { 357 switch(id) { 358 case "closed": 358 359 if (e.osm instanceof Way && ((Way) e.osm).isClosed()) 359 360 return true; 360 361 if (e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon()) 361 362 return true; 362 return false;363 } else if ("modified".equals(id)) {363 break; 364 case "modified": 364 365 return e.osm.isModified() || e.osm.isNewOrUndeleted(); 365 } else if ("new".equals(id)) {366 case "new": 366 367 return e.osm.isNew(); 367 } else if ("connection".equals(id) && (e.osm instanceof Node)) {368 return ((Node) e.osm).isConnectionNode();369 } else if ("tagged".equals(id)) {368 case "connection": 369 return e.osm instanceof Node && ((Node) e.osm).isConnectionNode(); 370 case "tagged": 370 371 return e.osm.isTagged(); 371 } else if ("sameTags".equals(id)) {372 case "sameTags": 372 373 return e.osm.hasSameInterestingTags(Utils.firstNonNull(e.child, e.parent)); 373 } else if ("areaStyle".equals(id)) {374 case "areaStyle": 374 375 return ElemStyles.hasAreaElemStyle(e.osm, false); 375 } else if ("unconnected".equals(id) && (e.osm instanceof Node)) {376 return OsmPrimitive.getFilteredList(e.osm.getReferrers(), Way.class).isEmpty();376 case "unconnected": 377 return e.osm instanceof Node && OsmPrimitive.getFilteredList(e.osm.getReferrers(), Way.class).isEmpty(); 377 378 } 378 379 return false; -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSourceHandler.java
r7005 r7012 14 14 import org.xml.sax.helpers.DefaultHandler; 15 15 16 public class XmlStyleSourceHandler extends DefaultHandler 17 { 16 public class XmlStyleSourceHandler extends DefaultHandler { 18 17 private boolean inDoc, inRule, inCondition, inLine, inLineMod, inIcon, inArea, inScaleMax, inScaleMin; 19 18 private boolean hadLine, hadLineMod, hadIcon, hadArea; … … 79 78 private void startElementLine(String qName, Attributes atts, LinePrototype line) { 80 79 for (int count=0; count<atts.getLength(); count++) { 81 if(atts.getQName(count).equals("width")) { 80 switch (atts.getQName(count)) { 81 case "width": 82 82 String val = atts.getValue(count); 83 83 if (! (val.startsWith("+") || val.startsWith("-") || val.endsWith("%"))) { 84 84 line.setWidth(Integer.parseInt(val)); 85 85 } 86 } else if (atts.getQName(count).equals("colour")) { 87 line.color=convertColor(atts.getValue(count)); 88 } else if (atts.getQName(count).equals("realwidth")) { 89 line.realWidth=Integer.parseInt(atts.getValue(count)); 90 } else if (atts.getQName(count).equals("dashed")) { 86 break; 87 case "colour": 88 line.color = convertColor(atts.getValue(count)); 89 break; 90 case "realwidth": 91 line.realWidth = Integer.parseInt(atts.getValue(count)); 92 break; 93 case "dashed": 91 94 Float[] dashed; 92 95 try { … … 105 108 } 106 109 line.setDashed(dashed == null ? null : Arrays.asList(dashed)); 107 } else if (atts.getQName(count).equals("dashedcolour")) { 108 line.dashedColor=convertColor(atts.getValue(count)); 109 } else if(atts.getQName(count).equals("priority")) { 110 break; 111 case "dashedcolour": 112 line.dashedColor = convertColor(atts.getValue(count)); 113 break; 114 case "priority": 110 115 line.priority = Integer.parseInt(atts.getValue(count)); 111 } else if (!(atts.getQName(count).equals("mode") && line instanceof LinemodPrototype)){ 116 break; 117 case "mode": 118 if (line instanceof LinemodPrototype) 119 break; 120 default: 112 121 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 113 122 } … … 118 127 startElementLine(qName, atts, line); 119 128 for (int count=0; count<atts.getLength(); count++) { 120 if (atts.getQName(count).equals("width")) { 129 switch (atts.getQName(count)) { 130 case "width": 121 131 String val = atts.getValue(count); 122 132 if (val.startsWith("+")) { … … 132 142 line.setWidth(Integer.parseInt(val)); 133 143 } 134 } else if(atts.getQName(count).equals("mode")) { 135 line.over = !atts.getValue(count).equals("under"); 136 } 137 } 138 } 139 140 @Override public void startElement(String uri,String name, String qName, Attributes atts) { 144 break; 145 case "mode": 146 line.over = !"under".equals(atts.getValue(count)); 147 break; 148 } 149 } 150 } 151 152 @Override 153 public void startElement(String uri,String name, String qName, Attributes atts) { 141 154 if (inDoc) { 142 if (qName.equals("rule")) { 143 inRule=true; 144 } else if (qName.equals("rules")) { 155 switch(qName) { 156 case "rule": 157 inRule = true; 158 break; 159 case "rules": 145 160 if (style.name == null) { 146 161 style.name = atts.getValue("name"); … … 152 167 style.icon = atts.getValue("icon"); 153 168 } 154 } else if (qName.equals("scale_max")) { 169 break; 170 case "scale_max": 155 171 inScaleMax = true; 156 } else if (qName.equals("scale_min")) { 172 break; 173 case "scale_min": 157 174 inScaleMin = true; 158 } else if (qName.equals("condition") && inRule) { 159 inCondition=true; 160 XmlCondition c = rule.cond; 161 if (c.key != null) { 162 if(rule.conditions == null) { 163 rule.conditions = new LinkedList<>(); 164 } 165 rule.conditions.add(new XmlCondition(rule.cond)); 166 c = new XmlCondition(); 167 rule.conditions.add(c); 168 } 169 for (int count=0; count<atts.getLength(); count++) { 170 if (atts.getQName(count).equals("k")) { 171 c.key = atts.getValue(count); 172 } else if (atts.getQName(count).equals("v")) { 173 c.value = atts.getValue(count); 174 } else if(atts.getQName(count).equals("b")) { 175 c.boolValue = atts.getValue(count); 176 } else { 177 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 178 } 179 } 180 if(c.key == null) { 181 error("The condition has no key!"); 182 } 183 } else if (qName.equals("line")) { 175 break; 176 case "condition": 177 if (inRule) { 178 inCondition = true; 179 XmlCondition c = rule.cond; 180 if (c.key != null) { 181 if(rule.conditions == null) { 182 rule.conditions = new LinkedList<>(); 183 } 184 rule.conditions.add(new XmlCondition(rule.cond)); 185 c = new XmlCondition(); 186 rule.conditions.add(c); 187 } 188 for (int count=0; count<atts.getLength(); count++) { 189 switch (atts.getQName(count)) { 190 case "k": 191 c.key = atts.getValue(count); 192 break; 193 case "v": 194 c.value = atts.getValue(count); 195 break; 196 case "b": 197 c.boolValue = atts.getValue(count); 198 break; 199 default: 200 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 201 } 202 } 203 if(c.key == null) { 204 error("The condition has no key!"); 205 } 206 } 207 break; 208 case "line": 184 209 hadLine = inLine = true; 185 210 startElementLine(qName, atts, rule.line); 186 } else if (qName.equals("linemod")) { 211 break; 212 case "linemod": 187 213 hadLineMod = inLineMod = true; 188 214 startElementLinemod(qName, atts, rule.linemod); 189 } else if (qName.equals("icon")) { 215 break; 216 case "icon": 190 217 inIcon = true; 191 218 for (int count=0; count<atts.getLength(); count++) { 192 if (atts.getQName(count).equals("src")) { 219 switch (atts.getQName(count)) { 220 case "src": 193 221 IconReference icon = new IconReference(atts.getValue(count), style); 194 222 hadIcon = (icon != null); 195 223 rule.icon.icon = icon; 196 } else if (atts.getQName(count).equals("annotate")) { 224 break; 225 case "annotate": 197 226 rule.icon.annotate = Boolean.parseBoolean (atts.getValue(count)); 198 } else if(atts.getQName(count).equals("priority")) { 227 break; 228 case "priority": 199 229 rule.icon.priority = Integer.parseInt(atts.getValue(count)); 200 } else { 230 break; 231 default: 201 232 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 202 233 } 203 234 } 204 } else if (qName.equals("area")) { 235 break; 236 case "area": 205 237 hadArea = inArea = true; 206 for (int count=0; count<atts.getLength(); count++) 207 {208 if (atts.getQName(count).equals("colour")) {238 for (int count=0; count<atts.getLength(); count++) { 239 switch (atts.getQName(count)) { 240 case "colour": 209 241 rule.area.color=convertColor(atts.getValue(count)); 210 } else if (atts.getQName(count).equals("closed")) { 242 break; 243 case "closed": 211 244 rule.area.closed=Boolean.parseBoolean(atts.getValue(count)); 212 } else if(atts.getQName(count).equals("priority")) { 245 break; 246 case "priority": 213 247 rule.area.priority = Integer.parseInt(atts.getValue(count)); 214 } else { 248 break; 249 default: 215 250 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 216 251 } 217 252 } 218 } else { 253 break; 254 default: 219 255 error("The element \"" + qName + "\" is unknown!"); 220 256 } … … 222 258 } 223 259 224 @Override public void endElement(String uri,String name, String qName)225 {226 if (inRule && qName.equals("rule")) {260 @Override 261 public void endElement(String uri,String name, String qName) { 262 if (inRule && "rule".equals(qName)) { 227 263 if (hadLine) { 228 264 style.add(rule.cond, rule.conditions, 229 265 new LinePrototype(rule.line, new Range(rule.scaleMin, rule.scaleMax))); 230 266 } 231 if (hadLineMod) 232 { 267 if (hadLineMod) { 233 268 style.add(rule.cond, rule.conditions, 234 269 new LinemodPrototype(rule.linemod, new Range(rule.scaleMin, rule.scaleMax))); 235 270 } 236 if (hadIcon) 237 { 271 if (hadIcon) { 238 272 style.add(rule.cond, rule.conditions, 239 273 new IconPrototype(rule.icon, new Range(rule.scaleMin, rule.scaleMax))); 240 274 } 241 if (hadArea) 242 { 275 if (hadArea) { 243 276 style.add(rule.cond, rule.conditions, 244 277 new AreaPrototype(rule.area, new Range(rule.scaleMin, rule.scaleMax))); … … 247 280 hadLine = hadLineMod = hadIcon = hadArea = false; 248 281 rule.init(); 249 } else if (inCondition && qName.equals("condition")) {282 } else if (inCondition && "condition".equals(qName)) { 250 283 inCondition = false; 251 } else if (inLine && qName.equals("line")) {284 } else if (inLine && "line".equals(qName)) { 252 285 inLine = false; 253 } else if (inLineMod && qName.equals("linemod")) {286 } else if (inLineMod && "linemod".equals(qName)) { 254 287 inLineMod = false; 255 } else if (inIcon && qName.equals("icon")) {288 } else if (inIcon && "icon".equals(qName)) { 256 289 inIcon = false; 257 } else if (inArea && qName.equals("area")) {290 } else if (inArea && "area".equals(qName)) { 258 291 inArea = false; 259 } else if ( qName.equals("scale_max")) {292 } else if ("scale_max".equals(qName)) { 260 293 inScaleMax = false; 261 } else if ( qName.equals("scale_min")) {294 } else if ("scale_min".equals(qName)) { 262 295 inScaleMin = false; 263 296 } 264 297 } 265 298 266 @Override public void characters(char[] ch, int start, int length) { 299 @Override 300 public void characters(char[] ch, int start, int length) { 267 301 if (inScaleMax) { 268 302 rule.scaleMax = Long.parseLong(new String(ch, start, length)); -
trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java
r7005 r7012 1230 1230 } 1231 1231 String nodeType = st.sval.toUpperCase(); 1232 if ( nodeType.equals("LEAF")) {1232 if ("LEAF".equals(nodeType)) { 1233 1233 parseLeaf(st, parent); 1234 1234 } 1235 else if ( nodeType.equals("ROW") || nodeType.equals("COLUMN")) {1235 else if ("ROW".equals(nodeType) || "COLUMN".equals(nodeType)) { 1236 1236 Split split = new Split(); 1237 split.setRowLayout( nodeType.equals("ROW"));1237 split.setRowLayout("ROW".equals(nodeType)); 1238 1238 addSplitChild(parent, split); 1239 1239 parseSplit(st, split);
Note:
See TracChangeset
for help on using the changeset viewer.