Exemplo n.º 1
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);
       loadTopic(content);
       history.setCurrentUrl(url);
       this.url = url;
     } 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),
           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);
   }
 }
Exemplo n.º 2
0
 @Override
 public void hyperlinkUpdate(HyperlinkEvent e) {
   if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return;
   if (e.getURL() == null || e.getURL().toString().startsWith(url + "#")) {
     // Probably hyperlink event on a an A-element with a href consisting of
     // a fragment only, i.e. "#ALocalFragment".
     //
     String fragment = getUrlFragment(e);
     if (fragment != null) {
       // first try to scroll to an element with id==fragment. This is the way
       // table of contents are built in the JOSM wiki. If this fails, try to
       // scroll to a <A name="..."> element.
       //
       if (!scrollToElementWithId(fragment)) {
         help.scrollToReference(fragment);
       }
     } else {
       HelpAwareOptionPane.showOptionDialog(
           Main.parent,
           tr("Failed to open help page. The target URL is empty."),
           tr("Failed to open help page"),
           JOptionPane.ERROR_MESSAGE,
           null, /* no icon */
           null, /* standard options, just OK button */
           null, /* default is standard */
           null /* no help context */);
     }
   } else if (e.getURL().toString().endsWith("action=edit")) {
     OpenBrowser.displayUrl(e.getURL().toString());
   } else {
     url = e.getURL().toString();
     openUrl(e.getURL().toString());
   }
 }
Exemplo n.º 3
0
    protected void warn(Exception e) {
      String emsg = e.getMessage() != null ? e.getMessage() : e.toString();
      emsg = emsg.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
      String msg =
          tr(
              "<html>Failed to load the list of style sources from<br>"
                  + "''{0}''.<br>"
                  + "<br>"
                  + "Details (untranslated):<br>{1}</html>",
              url, emsg);

      HelpAwareOptionPane.showOptionDialog(
          Main.parent,
          msg,
          tr("Error"),
          JOptionPane.ERROR_MESSAGE,
          ht("Preferences/Styles#FailedToLoadStyleSources"));
    }
Exemplo n.º 4
0
 protected MaxChangesetSizeExceededPolicy askMaxChangesetSizeExceedsPolicy() {
   ButtonSpec[] specs =
       new ButtonSpec[] {
         new ButtonSpec(
             tr("Continue uploading"),
             ImageProvider.get("upload"),
             tr("Click to continue uploading to additional new changesets"),
             null /* no specific help text */),
         new ButtonSpec(
             tr("Go back to Upload Dialog"),
             ImageProvider.get("dialogs", "uploadproperties"),
             tr("Click to return to the Upload Dialog"),
             null /* no specific help text */),
         new ButtonSpec(
             tr("Abort"),
             ImageProvider.get("cancel"),
             tr("Click to abort uploading"),
             null /* no specific help text */)
       };
   int numObjectsToUploadLeft = toUpload.getSize() - processedPrimitives.size();
   String msg1 =
       tr(
           "The server reported that the current changeset was closed.<br>"
               + "This is most likely because the changesets size exceeded the max. size<br>"
               + "of {0} objects on the server ''{1}''.",
           OsmApi.getOsmApi().getCapabilities().getMaxChangesetSize(),
           OsmApi.getOsmApi().getBaseUrl());
   String msg2 =
       trn(
           "There is {0} object left to upload.",
           "There are {0} objects left to upload.",
           numObjectsToUploadLeft,
           numObjectsToUploadLeft);
   String msg3 =
       tr(
           "Click ''<strong>{0}</strong>'' to continue uploading to additional new changesets.<br>"
               + "Click ''<strong>{1}</strong>'' to return to the upload dialog.<br>"
               + "Click ''<strong>{2}</strong>'' to abort uploading and return to map editing.<br>",
           specs[0].text, specs[1].text, specs[2].text);
   String msg = "<html>" + msg1 + "<br><br>" + msg2 + "<br><br>" + msg3 + "</html>";
   int ret =
       HelpAwareOptionPane.showOptionDialog(
           Main.parent,
           msg,
           tr("Changeset is full"),
           JOptionPane.WARNING_MESSAGE,
           null, /* no special icon */
           specs,
           specs[0],
           ht("/Action/Upload#ChangesetFull"));
   switch (ret) {
     case 0:
       return MaxChangesetSizeExceededPolicy.AUTOMATICALLY_OPEN_NEW_CHANGESETS;
     case 1:
       return MaxChangesetSizeExceededPolicy.FILL_ONE_CHANGESET_AND_RETURN_TO_UPLOAD_DIALOG;
     case 2:
       return MaxChangesetSizeExceededPolicy.ABORT;
     case JOptionPane.CLOSED_OPTION:
       return MaxChangesetSizeExceededPolicy.ABORT;
   }
   // should not happen
   return null;
 }