Exemplo n.º 1
0
  /**
   * Adds a new tab to the download dialog in JOSM.
   *
   * <p>This method is, for all intents and purposes, the constructor for this class.
   */
  @Override
  public void addGui(final DownloadDialog gui) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(buildSearchPanel(), BorderLayout.NORTH);

    DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
    model = new NamedResultTableModel(selectionModel);
    columnmodel = new NamedResultTableColumnModel();
    tblSearchResults = new JTable(model, columnmodel);
    tblSearchResults.setSelectionModel(selectionModel);
    JScrollPane scrollPane = new JScrollPane(tblSearchResults);
    scrollPane.setPreferredSize(new Dimension(200, 200));
    panel.add(scrollPane, BorderLayout.CENTER);

    gui.addDownloadAreaSelector(panel, tr("Areas around places"));

    scrollPane.setPreferredSize(scrollPane.getPreferredSize());
    tblSearchResults.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tblSearchResults.getSelectionModel().addListSelectionListener(new ListSelectionHandler());
    tblSearchResults.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
              SearchResult sr = model.getSelectedSearchResult();
              if (sr == null) return;
              parent.startDownload(sr.getDownloadArea());
            }
          }
        });
    parent = gui;
  }
  public void addGui(final DownloadDialog gui) {
    buildDownloadAreaInputFields();
    final JPanel dlg = new JPanel(new GridBagLayout());

    tfOsmUrl.getDocument().addDocumentListener(new OsmUrlRefresher());

    // select content on receiving focus. this seems to be the default in the
    // windows look+feel but not for others. needs invokeLater to avoid strange
    // side effects that will cancel out the newly made selection otherwise.
    tfOsmUrl.addFocusListener(new SelectAllOnFocusHandler(tfOsmUrl));
    tfOsmUrl.setLineWrap(true);
    tfOsmUrl.setBorder(latlon[0].getBorder());

    dlg.add(new JLabel(tr("min lat")), GBC.std().insets(10, 20, 5, 0));
    dlg.add(latlon[0], GBC.std().insets(0, 20, 0, 0));
    dlg.add(new JLabel(tr("min lon")), GBC.std().insets(10, 20, 5, 0));
    dlg.add(latlon[1], GBC.eol().insets(0, 20, 0, 0));
    dlg.add(new JLabel(tr("max lat")), GBC.std().insets(10, 0, 5, 0));
    dlg.add(latlon[2], GBC.std());
    dlg.add(new JLabel(tr("max lon")), GBC.std().insets(10, 0, 5, 0));
    dlg.add(latlon[3], GBC.eol());

    dlg.add(
        new JLabel(
            tr("URL from www.openstreetmap.org (you can paste an URL here to download the area)")),
        GBC.eol().insets(10, 20, 5, 0));
    dlg.add(tfOsmUrl, GBC.eop().insets(10, 0, 5, 0).fill());
    tfOsmUrl.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            checkPopup(e);
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            checkPopup(e);
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            checkPopup(e);
          }

          private void checkPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
              OsmUrlPopup popup = new OsmUrlPopup();
              popup.show(tfOsmUrl, e.getX(), e.getY());
            }
          }
        });
    dlg.add(showUrl, GBC.eop().insets(10, 0, 5, 5));
    showUrl.setEditable(false);
    showUrl.setBackground(dlg.getBackground());
    showUrl.addFocusListener(new SelectAllOnFocusHandler(showUrl));

    gui.addDownloadAreaSelector(dlg, tr("Bounding Box"));
    this.parent = gui;
  }
Exemplo n.º 3
0
 private boolean parseURL(DownloadDialog gui) {
   Bounds b = OsmUrlToBounds.parse(tfOsmUrl.getText());
   if (b == null) return false;
   gui.boundingBoxChanged(b, BoundingBoxSelection.this);
   updateBboxFields(b);
   updateUrl(b);
   return true;
 }
Exemplo n.º 4
0
  @Override
  public boolean ok() {
    layerInfo.save();
    ImageryLayerInfo.instance.clear();
    ImageryLayerInfo.instance.load(false);
    Main.main.menu.imageryMenu.refreshOffsetMenu();
    OffsetBookmark.saveBookmarks();

    if (!GraphicsEnvironment.isHeadless()) {
      DownloadDialog.getInstance().refreshTileSources();
    }

    boolean commonRestartRequired = commonSettings.saveSettings();
    boolean wmsRestartRequired = wmsSettings.saveSettings();
    boolean tmsRestartRequired = tmsSettings.saveSettings();

    return commonRestartRequired || wmsRestartRequired || tmsRestartRequired;
  }