Changeset 7678 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2014-10-30T16:49:19+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r7005 r7678 32 32 public AbstractInfoAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean register, String toolbarId, boolean installAdapters) { 33 33 super(name, iconName, tooltip, shortcut, register, toolbarId, installAdapters); 34 }35 36 /**37 * Replies the base URL for browsing information about about a primitive.38 *39 * @return the base URL, i.e. https://www.openstreetmap.org40 */41 public static String getBaseBrowseUrl() {42 String baseUrl = Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL);43 Pattern pattern = Pattern.compile("/api/?$");44 String ret = pattern.matcher(baseUrl).replaceAll("");45 if (ret.equals(baseUrl)) {46 Main.warn(tr("Unexpected format of API base URL. Redirection to info or history page for OSM object will probably fail. API base URL is: ''{0}''",baseUrl));47 }48 for (String prefix : new String[]{"http://api.openstreetmap.org/", "https://api.openstreetmap.org/"}) {49 if (ret.startsWith(prefix)) {50 ret = Main.getOSMWebsite() + "/" + ret.substring(prefix.length());51 break;52 }53 }54 return ret;55 }56 57 /**58 * Replies the base URL for browsing information about a user.59 *60 * @return the base URL, i.e. https://www.openstreetmap.org/user61 */62 public static String getBaseUserUrl() {63 String baseUrl = Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL);64 Pattern pattern = Pattern.compile("/api/?$");65 String ret = pattern.matcher(baseUrl).replaceAll("/user");66 if (ret.equals(baseUrl)) {67 Main.warn(tr("Unexpected format of API base URL. Redirection to user page for OSM user will probably fail. API base URL is: ''{0}''",baseUrl));68 }69 for (String prefix : new String[]{"http://api.openstreetmap.org/", "https://api.openstreetmap.org/"}) {70 if (ret.startsWith(prefix)) {71 ret = Main.getOSMWebsite() + "/" + ret.substring(prefix.length());72 break;73 }74 }75 return ret;76 34 } 77 35 -
trunk/src/org/openstreetmap/josm/actions/HistoryInfoWebAction.java
r6380 r7678 7 7 import java.awt.event.KeyEvent; 8 8 9 import org.openstreetmap.josm.Main; 9 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 11 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 25 26 protected String createInfoUrl(Object infoObject) { 26 27 OsmPrimitive primitive = (OsmPrimitive) infoObject; 27 return getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId() + "/history";28 return Main.getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId() + "/history"; 28 29 } 29 30 } -
trunk/src/org/openstreetmap/josm/actions/InfoWebAction.java
r6380 r7678 7 7 import java.awt.event.KeyEvent; 8 8 9 import org.openstreetmap.josm.Main; 9 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 11 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 25 26 protected String createInfoUrl(Object infoObject) { 26 27 OsmPrimitive primitive = (OsmPrimitive)infoObject; 27 return getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId();28 return Main.getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId(); 28 29 } 29 30 }
Note:
See TracChangeset
for help on using the changeset viewer.