Esempio n. 1
0
  protected JPanel buildSearchPanel() {
    JPanel lpanel = new JPanel(new GridLayout(2, 2));
    JPanel panel = new JPanel(new GridBagLayout());

    lpanel.add(new JLabel(tr("Choose the server for searching:")));
    lpanel.add(server);
    String s = Main.pref.get("namefinder.server", SERVERS[0].name);
    for (int i = 0; i < SERVERS.length; ++i) {
      if (SERVERS[i].name.equals(s)) {
        server.setSelectedIndex(i);
      }
    }
    lpanel.add(new JLabel(tr("Enter a place name to search for:")));

    cbSearchExpression = new HistoryComboBox();
    cbSearchExpression.setToolTipText(tr("Enter a place name to search for"));
    List<String> cmtHistory =
        new LinkedList<>(Main.pref.getCollection(HISTORY_KEY, new LinkedList<String>()));
    Collections.reverse(cmtHistory);
    cbSearchExpression.setPossibleItems(cmtHistory);
    lpanel.add(cbSearchExpression);

    panel.add(lpanel, GBC.std().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
    SearchAction searchAction = new SearchAction();
    JButton btnSearch = new JButton(searchAction);
    cbSearchExpression.getEditorComponent().getDocument().addDocumentListener(searchAction);
    cbSearchExpression.getEditorComponent().addActionListener(searchAction);

    panel.add(btnSearch, GBC.eol().insets(5, 5, 0, 5));

    return panel;
  }
Esempio n. 2
0
  protected Layer askTargetLayer(List<Layer> targetLayers) {
    JosmComboBox layerList = new JosmComboBox(targetLayers.toArray());
    layerList.setRenderer(new LayerListCellRenderer());
    layerList.setSelectedIndex(0);

    JPanel pnl = new JPanel(new GridBagLayout());
    pnl.add(new JLabel(tr("Please select the target layer.")), GBC.eol());
    pnl.add(layerList, GBC.eol());

    ExtendedDialog ed =
        new ExtendedDialog(
            Main.parent, tr("Select target layer"), new String[] {tr("Merge"), tr("Cancel")});
    ed.setButtonIcons(new String[] {"dialogs/mergedown", "cancel"});
    ed.setContent(pnl);
    ed.showDialog();
    if (ed.getValue() != 1) return null;

    Layer targetLayer = (Layer) layerList.getSelectedItem();
    return targetLayer;
  }