Example #1
0
  /**
   * Builds the panel for entering the server access preferences
   *
   * @return preferences panel for server settings
   */
  protected JPanel buildContentPanel() {
    JPanel pnl = new JPanel(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();

    // the checkbox for the default UL
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.weightx = 1.0;
    gc.insets = new Insets(0, 0, 0, 0);
    pnl.add(pnlApiUrlPreferences = new OsmApiUrlInputPanel(), gc);

    // the remaining access properties
    gc.gridy = 1;
    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 1.0;
    gc.weighty = 1.0;
    gc.insets = new Insets(10, 0, 3, 3);
    pnl.add(buildTabbedServerPreferences(), gc);

    // let the AuthPreferencesPanel know when the API URL changes
    //
    pnlApiUrlPreferences.addPropertyChangeListener(pnlAuthPreferences);

    HelpUtil.setHelpContext(pnl, HelpUtil.ht("/Preferences/Connection"));
    return pnl;
  }
Example #2
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();
 }
Example #3
0
    protected void alertFilesWithUnknownImporter(Collection<File> files) {
      final StringBuffer msg = new StringBuffer();
      msg.append("<html>");
      msg.append(
              trn(
                  "Cannot open {0} file because file does not exist or no suitable file importer is available.",
                  "Cannot open {0} files because files do not exist or no suitable file importer is available.",
                  files.size(),
                  files.size()))
          .append("<br>");
      msg.append("<ul>");
      for (File f : files) {
        msg.append("<li>");
        msg.append(f.getAbsolutePath());
        msg.append(" (<i>");
        msg.append(f.exists() ? tr("no importer") : tr("does not exist"));
        msg.append("</i>)</li>");
      }
      msg.append("</ul>");

      HelpAwareOptionPane.showMessageDialogInEDT(
          Main.parent,
          msg.toString(),
          tr("Warning"),
          JOptionPane.WARNING_MESSAGE,
          HelpUtil.ht("/Action/Open#MissingImporterForFiles"));
    }
Example #4
0
    protected void alertFilesNotMatchingWithImporter(
        Collection<File> files, FileImporter importer) {
      final StringBuffer msg = new StringBuffer();
      msg.append("<html>");
      msg.append(
              trn(
                  "Cannot open {0} file with the file importer ''{1}''.",
                  "Cannot open {0} files with the file importer ''{1}''.",
                  files.size(),
                  files.size(),
                  importer.filter.getDescription()))
          .append("<br>");
      msg.append("<ul>");
      for (File f : files) {
        msg.append("<li>").append(f.getAbsolutePath()).append("</li>");
      }
      msg.append("</ul>");

      HelpAwareOptionPane.showMessageDialogInEDT(
          Main.parent,
          msg.toString(),
          tr("Warning"),
          JOptionPane.WARNING_MESSAGE,
          HelpUtil.ht("/Action/Open#ImporterCantImportFiles"));
    }
Example #5
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);
   }
 }
Example #6
0
 protected JPanel createButtonPanel() {
   JPanel pnl = new JPanel(new FlowLayout());
   pnl.add(new SideButton(new OKAction()));
   pnl.add(new SideButton(new CancelAction()));
   pnl.add(new SideButton(new ContextSensitiveHelpAction(HelpUtil.ht("/Dialog/Password"))));
   return pnl;
 }
Example #7
0
  public DownloadDialog(Component parent) {
    super(JOptionPane.getFrameForComponent(parent), tr("Download"), ModalityType.DOCUMENT_MODAL);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(buildMainPanel(), BorderLayout.CENTER);
    getContentPane().add(buildButtonPanel(), BorderLayout.SOUTH);

    getRootPane()
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK), "checkClipboardContents");

    getRootPane()
        .getActionMap()
        .put(
            "checkClipboardContents",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                String clip = Utils.getClipboardContent();
                if (clip == null) {
                  return;
                }
                Bounds b = OsmUrlToBounds.parse(clip);
                if (b != null) {
                  boundingBoxChanged(new Bounds(b), null);
                }
              }
            });
    HelpUtil.setHelpContext(getRootPane(), ht("/Action/Download"));
    addWindowListener(new WindowEventHandler());
    restoreSettings();
  }
Example #8
0
 public void actionPerformed(ActionEvent e) {
   String url = getUrl();
   if (url == null) return;
   if (!url.startsWith(HelpUtil.getWikiBaseHelpUrl())) {
     String message =
         tr(
             "<html>The current URL <tt>{0}</tt><br>"
                 + "is an external URL. Editing is only possible for help topics<br>"
                 + "on the help server <tt>{1}</tt>.</html>",
             getUrl(), HelpUtil.getWikiBaseUrl());
     JOptionPane.showMessageDialog(
         Main.parent, message, tr("Warning"), JOptionPane.WARNING_MESSAGE);
     return;
   }
   url = url.replaceAll("#[^#]*$", "");
   OpenBrowser.displayUrl(url + "?action=edit");
 }
  /** builds the UI */
  protected void build() {
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(buildHeaderInfoPanel(), BorderLayout.NORTH);

    setTitle(tr("Get an Access Token for ''{0}''", apiUrl));

    pnlFullyAutomaticAuthorisationUI = new FullyAutomaticAuthorizationUI(apiUrl);
    pnlSemiAutomaticAuthorisationUI = new SemiAutomaticAuthorizationUI(apiUrl);
    pnlManualAuthorisationUI = new ManualAuthorizationUI(apiUrl);

    spAuthorisationProcedureUI = GuiHelper.embedInVerticalScrollPane(new JPanel());
    spAuthorisationProcedureUI
        .getVerticalScrollBar()
        .addComponentListener(
            new ComponentListener() {
              @Override
              public void componentShown(ComponentEvent e) {
                spAuthorisationProcedureUI.setBorder(UIManager.getBorder("ScrollPane.border"));
              }

              @Override
              public void componentHidden(ComponentEvent e) {
                spAuthorisationProcedureUI.setBorder(null);
              }

              @Override
              public void componentResized(ComponentEvent e) {}

              @Override
              public void componentMoved(ComponentEvent e) {}
            });
    getContentPane().add(spAuthorisationProcedureUI, BorderLayout.CENTER);
    getContentPane().add(buildButtonRow(), BorderLayout.SOUTH);

    addWindowListener(new WindowEventHandler());
    getRootPane()
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
    getRootPane().getActionMap().put("cancel", new CancelAction());

    refreshAuthorisationProcedurePanel();

    HelpUtil.setHelpContext(getRootPane(), HelpUtil.ht("/Dialog/OAuthAuthorisationWizard"));
  }
 protected final void build() {
   getContentPane().setLayout(new BorderLayout());
   updateTitle();
   spTagConflictTypes = new AutoAdjustingSplitPane(JSplitPane.VERTICAL_SPLIT);
   spTagConflictTypes.setTopComponent(buildTagConflictResolverPanel());
   spTagConflictTypes.setBottomComponent(buildRelationMemberConflictResolverPanel());
   getContentPane().add(pnlButtons = buildButtonPanel(), BorderLayout.SOUTH);
   addWindowListener(new AdjustDividerLocationAction());
   HelpUtil.setHelpContext(getRootPane(), ht("/"));
 }
Example #11
0
 public PurgeAction() {
   /* translator note: other expressions for "purge" might be "forget", "clean", "obliterate", "prune" */
   super(
       tr("Purge..."),
       "purge",
       tr("Forget objects but do not delete them on server when uploading."),
       Shortcut.registerShortcut(
           "system:purge", tr("Edit: {0}", tr("Purge")), KeyEvent.VK_P, Shortcut.CTRL_SHIFT),
       true);
   putValue("help", HelpUtil.ht("/Action/Purge"));
 }
Example #12
0
  /**
   * Builds the row with the action buttons
   *
   * @return panel with buttons
   */
  protected JPanel buildButtonRow() {
    JPanel pnl = new JPanel(new FlowLayout(FlowLayout.CENTER));

    AcceptAccessTokenAction actAcceptAccessToken = new AcceptAccessTokenAction();
    pnlFullyAutomaticAuthorisationUI.addPropertyChangeListener(actAcceptAccessToken);
    pnlSemiAutomaticAuthorisationUI.addPropertyChangeListener(actAcceptAccessToken);
    pnlManualAuthorisationUI.addPropertyChangeListener(actAcceptAccessToken);

    pnl.add(new SideButton(actAcceptAccessToken));
    pnl.add(new SideButton(new CancelAction()));
    pnl.add(
        new SideButton(
            new ContextSensitiveHelpAction(HelpUtil.ht("/Dialog/OAuthAuthorisationWizard"))));

    return pnl;
  }
Example #13
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;
   }
   loadTopic(content);
   history.setCurrentUrl(url);
   this.url = url;
 }
Example #14
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, LocaleType.DEFAULTNOTENGLISH));
   String content = null;
   try {
     content = reader.fetchHelpTopicContent(url, true);
   } catch (MissingHelpContentException e) {
     url =
         HelpUtil.getHelpTopicUrl(
             HelpUtil.buildAbsoluteHelpTopic(relativeHelpTopic, LocaleType.BASELANGUAGE));
     try {
       content = reader.fetchHelpTopicContent(url, true);
     } catch (MissingHelpContentException e1) {
       url =
           HelpUtil.getHelpTopicUrl(
               HelpUtil.buildAbsoluteHelpTopic(relativeHelpTopic, LocaleType.ENGLISH));
       try {
         content = reader.fetchHelpTopicContent(url, true);
       } catch (MissingHelpContentException e2) {
         this.url = url;
         handleMissingHelpContent(relativeHelpTopic);
         return;
       } catch (HelpContentReaderException e2) {
         e2.printStackTrace();
         handleHelpContentReaderException(relativeHelpTopic, e2);
         return;
       }
     } catch (HelpContentReaderException e1) {
       e1.printStackTrace();
       handleHelpContentReaderException(relativeHelpTopic, e1);
       return;
     }
   } catch (HelpContentReaderException e) {
     e.printStackTrace();
     handleHelpContentReaderException(relativeHelpTopic, e);
     return;
   }
   loadTopic(content);
   history.setCurrentUrl(url);
   this.url = url;
 }
Example #15
0
 /** Constructs a new {@code HelpBrowser}. */
 public HelpBrowser() {
   reader = new HelpContentReader(HelpUtil.getWikiBaseUrl());
   build();
 }
Example #16
0
 public OsmApiUrlInputPanel() {
   build();
   HelpUtil.setHelpContext(this, HelpUtil.ht("/Preferences/Connection#ApiUrl"));
 }