Changeset 7678 in josm
- Timestamp:
- 2014-10-30T16:49:19+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r7634 r7678 1562 1562 1563 1563 /** 1564 * Replies the base URL for browsing information about a primitive. 1565 * @return the base URL, i.e. https://www.openstreetmap.org 1566 * @since 7678 1567 */ 1568 public static String getBaseBrowseUrl() { 1569 if (Main.pref != null) 1570 return Main.pref.get("osm-browse.url", getOSMWebsite()); 1571 return getOSMWebsite(); 1572 } 1573 1574 /** 1575 * Replies the base URL for browsing information about a user. 1576 * @return the base URL, i.e. https://www.openstreetmap.org/user 1577 * @since 7678 1578 */ 1579 public static String getBaseUserUrl() { 1580 if (Main.pref != null) 1581 return Main.pref.get("osm-user.url", getOSMWebsite() + "/user"); 1582 return getOSMWebsite() + "/user"; 1583 } 1584 1585 /** 1564 1586 * Determines if we are currently running on OSX. 1565 1587 * @return {@code true} if we are currently running on OSX -
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 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
r7434 r7678 434 434 if (sel.size() > 10 && ! AbstractInfoAction.confirmLaunchMultiple(sel.size())) 435 435 return; 436 String baseUrl = AbstractInfoAction.getBaseBrowseUrl();436 String baseUrl = Main.getBaseBrowseUrl(); 437 437 for (Changeset cs: sel) { 438 438 String url = baseUrl + "/changeset/" + cs.getId(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r7005 r7678 222 222 User user = (User)infoObject; 223 223 try { 224 return getBaseUserUrl() + "/" + URLEncoder.encode(user.getName(), "UTF-8").replaceAll("\\+", "%20");224 return Main.getBaseUserUrl() + "/" + URLEncoder.encode(user.getName(), "UTF-8").replaceAll("\\+", "%20"); 225 225 } catch(UnsupportedEncodingException e) { 226 226 Main.error(e); -
trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r7299 r7678 20 20 21 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.actions.AbstractInfoAction;23 22 import org.openstreetmap.josm.data.osm.Changeset; 24 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 169 168 170 169 protected static String getUserUrl(String username) throws UnsupportedEncodingException { 171 return AbstractInfoAction.getBaseUserUrl() + "/" + URLEncoder.encode(username, "UTF-8").replaceAll("\\+", "%20");170 return Main.getBaseUserUrl() + "/" + URLEncoder.encode(username, "UTF-8").replaceAll("\\+", "%20"); 172 171 } 173 172 … … 181 180 if (!model.isLatest(primitive)) { 182 181 User user = primitive.getUser(); 183 String url = AbstractInfoAction.getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId();182 String url = Main.getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId(); 184 183 lblChangeset.setUrl(url); 185 184 lblChangeset.setDescription(Long.toString(primitive.getChangesetId())); -
trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java
r6915 r7678 156 156 protected String createInfoUrl(Object infoObject) { 157 157 HistoryOsmPrimitive primitive = (HistoryOsmPrimitive) infoObject; 158 return getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId();158 return Main.getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId(); 159 159 } 160 160 … … 186 186 protected String createInfoUrl(Object infoObject) { 187 187 HistoryOsmPrimitive hp = (HistoryOsmPrimitive) infoObject; 188 return hp.getUser() == null ? null : getBaseUserUrl() + "/" + hp.getUser().getName();188 return hp.getUser() == null ? null : Main.getBaseUserUrl() + "/" + hp.getUser().getName(); 189 189 } 190 190 -
trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
r7434 r7678 67 67 JPanel panel = new JPanel(new GridBagLayout()); 68 68 panel.add(new JLabel(trn("You have {0} unread message.", "You have {0} unread messages.", unread, unread)), GBC.eol()); 69 panel.add(new UrlLabel(Main.get OSMWebsite() + "/user/"+userInfo.getDisplayName()+"/inbox", tr("Click here to see your inbox.")), GBC.eol());69 panel.add(new UrlLabel(Main.getBaseUserUrl() + "/"+userInfo.getDisplayName()+"/inbox", tr("Click here to see your inbox.")), GBC.eol()); 70 70 panel.setOpaque(false); 71 71 new Notification().setContent(panel)
Note:
See TracChangeset
for help on using the changeset viewer.