- Timestamp:
- 2013-04-20T02:24:00+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java
r5886 r5887 3 3 4 4 import java.io.IOException; 5 import java.io.InputStream; 5 6 import java.net.URL; 7 import java.net.URLConnection; 6 8 7 9 import javax.swing.JEditorPane; 8 10 11 import org.openstreetmap.josm.tools.Utils; 12 9 13 /** 10 * Subclass of {@link JEditorPane} that adds a "native" context menu (cut/copy/paste/select all). 11 * @since 5885 14 * Subclass of {@link JEditorPane} that adds a "native" context menu (cut/copy/paste/select all) 15 * and effectively uses JOSM user agent when performing HTTP request in {@link #setPage(URL)} method. 16 * @since 5886 12 17 */ 13 18 public class JosmEditorPane extends JEditorPane { … … 59 64 setText(text); 60 65 } 66 67 @Override 68 protected InputStream getStream(URL page) throws IOException { 69 URLConnection conn = Utils.setupURLConnection(page.openConnection()); 70 InputStream result = conn.getInputStream(); 71 String type = conn.getContentType(); 72 if (type != null) { 73 setContentType(type); 74 } 75 return result; 76 } 61 77 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextArea.java
r5886 r5887 7 7 /** 8 8 * Subclass of {@link JTextArea} that adds a "native" context menu (cut/copy/paste/select all). 9 * @since 588 59 * @since 5886 10 10 */ 11 11 public class JosmTextArea extends JTextArea { -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextField.java
r5886 r5887 7 7 /** 8 8 * Subclass of {@link JTextField} that adds a "native" context menu (cut/copy/paste/select all). 9 * @since 588 59 * @since 5886 10 10 */ 11 11 public class JosmTextField extends JTextField { -
trunk/src/org/openstreetmap/josm/gui/widgets/PopupMenuLauncher.java
r5886 r5887 39 39 * @param menu The popup menu to display 40 40 * @param checkEnabled if {@code true}, the popup menu will only be displayed if the component triggering the mouse event is enabled 41 * @since 588 541 * @since 5886 42 42 */ 43 43 public PopupMenuLauncher(JPopupMenu menu, boolean checkEnabled) { -
trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
r5886 r5887 34 34 * <li>Select All</li> 35 35 * </ul> 36 * @since 588 536 * @since 5886 37 37 */ 38 38 public class TextContextualPopupMenu extends JPopupMenu { -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r5881 r5887 586 586 */ 587 587 public static InputStream openURL(URL url) throws IOException { 588 URLConnection connection = url.openConnection(); 589 connection.setRequestProperty("User-Agent", Version.getInstance().getFullAgentString()); 590 connection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000); 591 connection.setReadTimeout(Main.pref.getInteger("socket.timeout.read",30)*1000); 592 return connection.getInputStream(); 588 return setupURLConnection(url.openConnection()).getInputStream(); 589 } 590 591 /*** 592 * Setups the given URL connection to match JOSM needs by setting its User-Agent and timeout properties. 593 * @param connection The connection to setup 594 * @return {@code connection}, with updated properties 595 * @since 5887 596 */ 597 public static URLConnection setupURLConnection(URLConnection connection) { 598 if (connection != null) { 599 connection.setRequestProperty("User-Agent", Version.getInstance().getFullAgentString()); 600 connection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000); 601 connection.setReadTimeout(Main.pref.getInteger("socket.timeout.read",30)*1000); 602 } 603 return connection; 593 604 } 594 605
Note:
See TracChangeset
for help on using the changeset viewer.