示例#1
0
 /**
  * Loads a help topic given by a relative help topic name (i.e. "/Action/New")
  *
  * <p>First tries to load the language specific help topic. If it is missing, tries to load the
  * topic in english.
  *
  * @param relativeHelpTopic the relative help topic
  */
 protected void loadRelativeHelpTopic(String relativeHelpTopic) {
   String url = HelpUtil.getHelpTopicUrl(HelpUtil.buildAbsoluteHelpTopic(relativeHelpTopic));
   String content = null;
   try {
     content = reader.fetchHelpTopicContent(url, true);
   } catch (MissingHelpContentException e) {
     url =
         HelpUtil.getHelpTopicUrl(
             HelpUtil.buildAbsoluteHelpTopic(relativeHelpTopic, Locale.ENGLISH));
     try {
       logger.info("fetching url: " + url);
       content = reader.fetchHelpTopicContent(url, true);
     } catch (MissingHelpContentException e1) {
       this.url = url;
       handleMissingHelpContent(relativeHelpTopic);
       return;
     } catch (HelpContentReaderException e1) {
       e1.printStackTrace();
       handleHelpContentReaderException(relativeHelpTopic, e1);
       return;
     }
   } catch (HelpContentReaderException e) {
     e.printStackTrace();
     handleHelpContentReaderException(relativeHelpTopic, e);
     return;
   }
   help.setText(content);
   history.setCurrentUrl(url);
   this.url = url;
   scrollToTop();
 }
 protected void updateSummary() {
   StringBuffer sb = new StringBuffer();
   sb.append("<html>");
   sb.append(buildStrategySummary());
   sb.append("<br><br>");
   sb.append(buildChangesetSummary());
   sb.append("</html>");
   jepMessage.setText(sb.toString());
 }
示例#3
0
 /**
  * Displays a error page if a help topic couldn't be loaded because of network or IO error.
  *
  * @param relativeHelpTopic the help topic
  * @param e the exception
  */
 protected void handleHelpContentReaderException(
     String relativeHelpTopic, HelpContentReaderException e) {
   String message =
       tr(
           "<html><p class=\"error-header\">Error when retrieving help information</p>"
               + "<p class=\"error-body\">The content for the help topic <strong>{0}</strong> could "
               + "not be loaded. The error message is (untranslated):<br>"
               + "<tt>{1}</tt>"
               + "</p></html>",
           relativeHelpTopic, e.toString());
   help.setText(message);
 }
示例#4
0
 /**
  * Displays a warning page when a help topic doesn't exist yet.
  *
  * @param relativeHelpTopic the help topic
  */
 protected void handleMissingHelpContent(String relativeHelpTopic) {
   String message =
       tr(
           "<html><p class=\"warning-header\">Help content for help topic missing</p>"
               + "<p class=\"warning-body\">Help content for the help topic <strong>{0}</strong> is "
               + "not available yet. It is missing both in your local language ({1}) and in english.<br><br>"
               + "Please help to improve the JOSM help system and fill in the missing information. "
               + "You can both edit the <a href=\"{2}\">help topic in your local language ({1})</a> and "
               + "the <a href=\"{3}\">help topic in english</a>."
               + "</p></html>",
           relativeHelpTopic,
           Locale.getDefault().getDisplayName(),
           getHelpTopicEditUrl(buildAbsoluteHelpTopic(relativeHelpTopic)),
           getHelpTopicEditUrl(buildAbsoluteHelpTopic(relativeHelpTopic, Locale.ENGLISH)));
   help.setText(message);
 }
示例#5
0
 /**
  * Loads a help topic given by an absolute help topic name, i.e. "/De:Help/Action/New"
  *
  * @param absoluteHelpTopic the absolute help topic name
  */
 protected void loadAbsoluteHelpTopic(String absoluteHelpTopic) {
   String url = HelpUtil.getHelpTopicUrl(absoluteHelpTopic);
   String content = null;
   try {
     content = reader.fetchHelpTopicContent(url, true);
   } catch (MissingHelpContentException e) {
     this.url = url;
     handleMissingHelpContent(absoluteHelpTopic);
     return;
   } catch (HelpContentReaderException e) {
     e.printStackTrace();
     handleHelpContentReaderException(absoluteHelpTopic, e);
     return;
   }
   help.setText(content);
   history.setCurrentUrl(url);
   this.url = url;
   scrollToTop();
 }
示例#6
0
 /**
  * Opens an URL and displays the content.
  *
  * <p>If the URL is the locator of an absolute help topic, help content is loaded from the JOSM
  * wiki. Otherwise, the help browser loads the page from the given URL
  *
  * @param url the url
  */
 public void openUrl(String url) {
   if (!isVisible()) {
     setVisible(true);
     toFront();
   } else {
     toFront();
   }
   String helpTopic = HelpUtil.extractAbsoluteHelpTopic(url);
   if (helpTopic == null) {
     try {
       this.url = url;
       String content = reader.fetchHelpTopicContent(url, false);
       help.setText(content);
       history.setCurrentUrl(url);
       this.url = url;
       scrollToTop();
     } catch (Exception e) {
       HelpAwareOptionPane.showOptionDialog(
           Main.parent,
           tr(
               "<html>Failed to open help page for url {0}.<br>"
                   + "This is most likely due to a network problem, please check<br>"
                   + "your internet connection</html>",
               url.toString()),
           tr("Failed to open URL"),
           JOptionPane.ERROR_MESSAGE,
           null, /* no icon */
           null, /* standard options, just OK button */
           null, /* default is standard */
           null /* no help context */);
     }
     history.setCurrentUrl(url);
   } else {
     loadAbsoluteHelpTopic(helpTopic);
   }
 }