protected JPanel buildContentPanel() {
      JPanel pnl = new JPanel(new GridBagLayout());
      GridBagConstraints gc = new GridBagConstraints();

      gc.anchor = GridBagConstraints.NORTHWEST;
      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.weightx = 1.0;
      gc.gridwidth = 2;
      HtmlPanel html = new HtmlPanel();
      html.setText(
          tr(
              "<html>"
                  + "JOSM successfully retrieved a Request Token. "
                  + "JOSM is now launching an authorization page in an external browser. "
                  + "Please login with your OSM username and password and follow the instructions "
                  + "to authorize the Request Token. Then switch back to this dialog and click on "
                  + "<strong>{0}</strong><br><br>"
                  + "If launching the external browser fails you can copy the following authorize URL "
                  + "and paste it into the address field of your browser.</html>",
              tr("Request Access Token")));
      pnl.add(html, gc);

      gc.gridx = 0;
      gc.gridy = 1;
      gc.weightx = 0.0;
      gc.gridwidth = 1;
      pnl.add(new JLabel(tr("Authorize URL:")), gc);

      gc.gridx = 1;
      gc.weightx = 1.0;
      pnl.add(tfAuthoriseUrl = new JosmTextField(), gc);
      tfAuthoriseUrl.setEditable(false);

      return pnl;
    }
    protected JPanel buildContentPanel() {
      JPanel pnl = new JPanel(new GridBagLayout());
      GridBagConstraints gc = new GridBagConstraints();

      gc.anchor = GridBagConstraints.NORTHWEST;
      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.weightx = 1.0;
      HtmlPanel html = new HtmlPanel();
      html.setText(
          tr(
              "<html>"
                  + "JOSM has successfully retrieved an Access Token. "
                  + "You can now accept this token. JOSM will use it in the future for authentication "
                  + "and authorization to the OSM server.<br><br>"
                  + "The access token is: </html>"));
      pnl.add(html, gc);

      gc.gridx = 0;
      gc.gridy = 1;
      gc.weightx = 1.0;
      gc.gridwidth = 1;
      pnl.add(pnlAccessTokenInfo = new AccessTokenInfoPanel(), gc);
      pnlAccessTokenInfo.setSaveToPreferences(
          OAuthAccessTokenHolder.getInstance().isSaveToPreferences());
      return pnl;
    }
    protected JPanel buildCommandPanel() {
      JPanel pnl = new JPanel(new GridBagLayout());
      GridBagConstraints gc = new GridBagConstraints();

      gc.anchor = GridBagConstraints.NORTHWEST;
      gc.fill = GridBagConstraints.BOTH;
      gc.weightx = 1.0;
      gc.weighty = 1.0;
      gc.insets = new Insets(0, 0, 0, 3);

      HtmlPanel h = new HtmlPanel();
      h.setText(
          tr(
              "<html>"
                  + "Please click on <strong>{0}</strong> to retrieve an OAuth Request Token from "
                  + "''{1}''.</html>",
              tr("Retrieve Request Token"),
              getAdvancedPropertiesPanel().getAdvancedParameters().getRequestTokenUrl()));
      pnl.add(h, gc);

      JPanel pnl1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
      pnl1.add(new SideButton(new RetrieveRequestTokenAction()));
      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.weightx = 1.0;
      gc.gridy = 1;
      pnl.add(pnl1, gc);
      return pnl;
    }
Example #4
0
  /** Displays a message when the plugin list is empty. */
  public void displayEmptyPluginListInformation() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(40, 0, 40, 0);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;

    HtmlPanel hint = new HtmlPanel();
    hint.setText(
        "<html>"
            + tr(
                "Please click on <strong>Download list</strong> to download and display a list of available plugins.")
            + "</html>");
    add(hint, gbc);
  }
 @Override
 public Component getPreferencesDecorationPanel() {
   HtmlPanel pnlMessage = new HtmlPanel();
   HTMLEditorKit kit = (HTMLEditorKit) pnlMessage.getEditorPane().getEditorKit();
   kit.getStyleSheet()
       .addRule(
           ".warning-body {background-color:rgb(253,255,221);padding: 10pt; border-color:rgb(128,128,128);border-style: solid;border-width: 1px;}");
   pnlMessage.setText(
       tr(
           "<html><body>"
               + "<p class=\"warning-body\">"
               + "<strong>Warning:</strong> The password is stored in plain text in the JOSM preferences file. "
               + "Furthermore, it is transferred <strong>unencrypted</strong> in every request sent to the OSM server. "
               + "<strong>Do not use a valuable password.</strong>"
               + "</p>"
               + "</body></html>"));
   return pnlMessage;
 }
  /**
   * Builds the panel with general information in the header
   *
   * @return panel woth information display
   */
  protected JPanel buildHeaderInfoPanel() {
    JPanel pnl = new JPanel(new GridBagLayout());
    pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    GridBagConstraints gc = new GridBagConstraints();

    // the oauth logo in the header
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1.0;
    gc.gridwidth = 2;
    JLabel lbl = new JLabel();
    lbl.setIcon(ImageProvider.get("oauth", "oauth-logo"));
    lbl.setOpaque(true);
    pnl.add(lbl, gc);

    // OAuth in a nutshell ...
    gc.gridy = 1;
    gc.insets = new Insets(5, 0, 0, 5);
    HtmlPanel pnlMessage = new HtmlPanel();
    pnlMessage.setText(
        "<html><body>"
            + tr(
                "With OAuth you grant JOSM the right to upload map data and GPS tracks "
                    + "on your behalf (<a href=\"{0}\">more info...</a>).",
                "http://oauth.net/")
            + "</body></html>");
    pnlMessage.getEditorPane().addHyperlinkListener(new ExternalBrowserLauncher());
    pnl.add(pnlMessage, gc);

    // the authorisation procedure
    gc.gridy = 2;
    gc.gridwidth = 1;
    gc.weightx = 0.0;
    lbl = new JLabel(tr("Please select an authorization procedure: "));
    lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
    pnl.add(lbl, gc);

    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.weightx = 1.0;
    pnl.add(cbAuthorisationProcedure = new AuthorizationProcedureComboBox(), gc);
    cbAuthorisationProcedure.addItemListener(new AuthorisationProcedureChangeListener());
    return pnl;
  }
Example #7
0
  /** Refreshes the list. */
  public void refreshView() {
    final Rectangle visibleRect = getVisibleRect();
    List<PluginInformation> displayedPlugins = model.getDisplayedPlugins();
    removeAll();

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;

    if (displayedPlugins.isEmpty()) {
      displayEmptyPluginListInformation();
      return;
    }

    int row = -1;
    for (final PluginInformation pi : displayedPlugins) {
      boolean selected = model.isSelectedPlugin(pi.getName());
      String remoteversion = formatPluginRemoteVersion(pi);
      String localversion = formatPluginLocalVersion(model.getPluginInformation(pi.getName()));

      final JPluginCheckBox cbPlugin = new JPluginCheckBox(pi, selected);
      String pluginText =
          tr("{0}: Version {1} (local: {2})", pi.getName(), remoteversion, localversion);
      if (pi.requires != null && !pi.requires.isEmpty()) {
        pluginText += tr(" (requires: {0})", pi.requires);
      }
      JLabel lblPlugin = new JLabel(pluginText, pi.getScaledIcon(), SwingConstants.LEFT);
      lblPlugin.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              cbPlugin.doClick();
            }
          });

      gbc.gridx = 0;
      gbc.gridy = ++row;
      gbc.insets = new Insets(5, 5, 0, 5);
      gbc.weighty = 0.0;
      gbc.weightx = 0.0;
      add(cbPlugin, gbc);

      gbc.gridx = 1;
      gbc.weightx = 1.0;
      add(lblPlugin, gbc);

      HtmlPanel description = new HtmlPanel();
      description.setText(pi.getDescriptionAsHtml());
      description
          .getEditorPane()
          .addHyperlinkListener(
              new HyperlinkListener() {
                @Override
                public void hyperlinkUpdate(HyperlinkEvent e) {
                  if (e.getEventType() == EventType.ACTIVATED) {
                    OpenBrowser.displayUrl(e.getURL().toString());
                  }
                }
              });

      gbc.gridx = 1;
      gbc.gridy = ++row;
      gbc.insets = new Insets(3, 25, 5, 5);
      gbc.weighty = 1.0;
      add(description, gbc);
    }
    revalidate();
    repaint();
    if (visibleRect != null && visibleRect.width > 0 && visibleRect.height > 0) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              scrollRectToVisible(visibleRect);
            }
          });
    }
  }