source: josm/trunk/test/functional/org/openstreetmap/josm/io/UploadStrategySelectionPanelTest.java@ 7081

Last change on this file since 7081 was 6643, checked in by Don-vip, 10 years ago

global replacement of e.printStackTrace() by Main.error(e)

File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import java.awt.BorderLayout;
5import java.awt.FlowLayout;
6import java.awt.event.ActionEvent;
7import java.awt.event.ActionListener;
8
9import javax.swing.JFrame;
10import javax.swing.JLabel;
11import javax.swing.JPanel;
12import javax.swing.JTextField;
13
14import org.openstreetmap.josm.Main;
15import org.openstreetmap.josm.gui.io.UploadStrategySelectionPanel;
16import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
17
18public class UploadStrategySelectionPanelTest extends JFrame {
19
20 private UploadStrategySelectionPanel uploadStrategySelectionPanel;
21
22 protected void build() {
23 getContentPane().setLayout(new BorderLayout());
24 uploadStrategySelectionPanel = new UploadStrategySelectionPanel();
25 getContentPane().add(uploadStrategySelectionPanel, BorderLayout.CENTER);
26 getContentPane().add(buildControlPanel(), BorderLayout.SOUTH);
27 setSize(400,400);
28 }
29
30
31 protected JPanel buildControlPanel() {
32 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
33 pnl.add(new JLabel("Num objects:"));
34 final JTextField tf;
35 pnl.add(tf = new JTextField(8));
36 tf.addActionListener(
37 new ActionListener() {
38 public void actionPerformed(ActionEvent arg0) {
39 int n = 0;
40 try {
41 n = Integer.parseInt(tf.getText());
42 } catch(NumberFormatException e) {
43 Main.error(e);
44 return;
45 }
46 uploadStrategySelectionPanel.setNumUploadedObjects(n);
47 }
48 }
49 );
50 return pnl;
51 }
52
53 /**
54 * Constructs a new {@code UploadStrategySelectionPanelTest}.
55 */
56 public UploadStrategySelectionPanelTest() {
57 build();
58 uploadStrategySelectionPanel.setNumUploadedObjects(51000);
59 }
60
61 public static void main(String args[]) throws OsmApiInitializationException, OsmTransferCanceledException{
62 OsmApi.getOsmApi().initialize(NullProgressMonitor.INSTANCE);
63 new UploadStrategySelectionPanelTest().setVisible(true);
64 }
65}
Note: See TracBrowser for help on using the repository browser.