Ignore:
Timestamp:
2013-04-15T19:12:01+02:00 (11 years ago)
Author:
stoecker
Message:

see #8606 - use JOSM agent also for WebStart, join help browser and WikiReader

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r5831 r5868  
    5151import org.openstreetmap.josm.tools.I18n;
    5252import org.openstreetmap.josm.tools.ImageProvider;
     53import org.openstreetmap.josm.tools.Utils;
    5354
    5455/**
     
    292293                System.out.println("Reading preferences from " + i);
    293294                try {
    294                     URL url = new URL(i);
    295                     config.openAndReadXML(url.openStream());
     295                    config.openAndReadXML(Utils.openURL(new URL(i)));
    296296                } catch (Exception ex) {
    297297                    throw new RuntimeException(ex);
  • trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java

    r5587 r5868  
    2121 * It also has to be <strong>transformed</strong> because the internal help browser required slightly
    2222 * different HTML than what is provided by the Wiki.
    23  *
    24  * @see WikiReader
    2523 */
    26 public class HelpContentReader {
    27 
    28     /** the base url */
    29     private String baseUrl;
     24public class HelpContentReader extends WikiReader {
    3025
    3126    /**
     
    3530     */
    3631    public HelpContentReader(String baseUrl) {
    37         this.baseUrl = baseUrl;
     32        super(baseUrl);
    3833    }
    3934
     
    9085     */
    9186    protected String prepareHelpContent(BufferedReader in, boolean dotest) throws HelpContentReaderException {
    92         boolean isInContent = false;
    93         boolean isInTranslationsSideBar = false;
    94         boolean isExistingHelpPage = false;
    95         StringBuffer sball = new StringBuffer();
    96         StringBuffer sb = new StringBuffer();
     87        String s = "";
    9788        try {
    98             for (String line = in.readLine(); line != null; line = in.readLine()) {
    99                 sball.append(line);
    100                 sball.append("\n");
    101                 if (line.contains("<div id=\"searchable\">")) {
    102                     isInContent = true;
    103                 } else if (line.contains("<div class=\"wiki-toc trac-nav\"")) {
    104                     isInTranslationsSideBar = true;
    105                 } else if (line.contains("<div class=\"wikipage searchable\">")) {
    106                     isInContent = true;
    107                 } else if (line.contains("<div class=\"buttons\">")) {
    108                     isInContent = false;
    109                 } else if (line.contains("<h3>Attachments</h3>")) {
    110                     isInContent = false;
    111                 } else if (line.contains("<div id=\"attachments\">")) {
    112                     isInContent = false;
    113                 } else if (line.contains("<div class=\"trac-modifiedby\">")) {
    114                     continue;
    115                 } else if (line.contains("<input type=\"submit\" name=\"attachfilebutton\"")) {
    116                     // heuristic: if we find a button for uploading images we are in an
    117                     // existing pages. Otherwise this is probably the stub page for a not yet
    118                     // existing help page
    119                     isExistingHelpPage = true;
    120                 }
    121                 if (isInContent && !isInTranslationsSideBar) {
    122                     // add a border="0" attribute to images, otherwise the internal help browser
    123                     // will render a thick  border around images inside an <a> element
    124                     //
    125                     // Also make sure image URLs are absolute
    126                     //
    127                     line = line.replaceAll("<img ([^>]*)src=\"/", "<img border=\"0\" \\1src=\"" + baseUrl + "/").replaceAll("href=\"/",
    128                             "href=\"" + baseUrl + "/").replaceAll(" />", ">");
    129                     sb.append(line);
    130                     sb.append("\n");
    131                 } else if (isInTranslationsSideBar && line.contains("</div>")) {
    132                     isInTranslationsSideBar = false;
    133                 }
    134             }
     89            s = readFromTrac(in);
    13590        } catch(IOException e) {
    13691            throw new HelpContentReaderException(e);
    13792        }
    138         if(!dotest && sb.length() == 0)
    139             sb = sball;
    140         else if (dotest && !isExistingHelpPage)
     93        if(dotest && s.isEmpty())
    14194            throw new MissingHelpContentException();
    142         sb.insert(0, "<html>");
    143         sb.append("<html>");
    144         return sb.toString();
     95        return s;
    14596    }
    14697}
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r5839 r5868  
    7777import org.openstreetmap.josm.io.OsmTransferException;
    7878import org.openstreetmap.josm.io.UTFInputStreamReader;
     79import org.openstreetmap.josm.tools.Utils;
    7980import org.xml.sax.InputSource;
    8081import org.xml.sax.SAXException;
     
    321322            protected byte[] updateData() throws IOException {
    322323                URL u = getAttributionUrl();
    323                 UTFInputStreamReader in = UTFInputStreamReader.create(u.openStream(), "utf-8");
     324                UTFInputStreamReader in = UTFInputStreamReader.create(Utils.openURL(u), "utf-8");
    324325                String r = new Scanner(in).useDelimiter("\\A").next();
    325326                in.close();
Note: See TracChangeset for help on using the changeset viewer.