1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.gui;
|
---|
3 |
|
---|
4 | import java.awt.Component;
|
---|
5 | import java.awt.Dimension;
|
---|
6 | import java.awt.GridBagLayout;
|
---|
7 | import java.awt.event.ComponentEvent;
|
---|
8 | import java.awt.event.ComponentListener;
|
---|
9 |
|
---|
10 | import javax.swing.BorderFactory;
|
---|
11 | import javax.swing.BoundedRangeModel;
|
---|
12 | import javax.swing.JButton;
|
---|
13 | import javax.swing.JDialog;
|
---|
14 | import javax.swing.JLabel;
|
---|
15 | import javax.swing.JOptionPane;
|
---|
16 | import javax.swing.JPanel;
|
---|
17 | import javax.swing.JProgressBar;
|
---|
18 |
|
---|
19 | import org.openstreetmap.josm.Main;
|
---|
20 | import org.openstreetmap.josm.tools.GBC;
|
---|
21 | import org.openstreetmap.josm.tools.I18n;
|
---|
22 |
|
---|
23 | public class PleaseWaitDialog extends JDialog {
|
---|
24 |
|
---|
25 | private final JProgressBar progressBar = new JProgressBar();
|
---|
26 |
|
---|
27 | public final JLabel currentAction = new JLabel(I18n.tr("Contacting the OSM server..."));
|
---|
28 | public final BoundedRangeModel progress = progressBar.getModel();
|
---|
29 | public final JButton cancel = new JButton(I18n.tr("Cancel"));
|
---|
30 |
|
---|
31 | public PleaseWaitDialog(Component parent) {
|
---|
32 | super(JOptionPane.getFrameForComponent(parent), true);
|
---|
33 | setLayout(new GridBagLayout());
|
---|
34 | JPanel pane = new JPanel(new GridBagLayout());
|
---|
35 | pane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
|
---|
36 | pane.add(currentAction, GBC.eol().fill(GBC.HORIZONTAL));
|
---|
37 | pane.add(progressBar, GBC.eop().fill(GBC.HORIZONTAL));
|
---|
38 | pane.add(cancel, GBC.eol().anchor(GBC.CENTER));
|
---|
39 | setContentPane(pane);
|
---|
40 | setSize(Main.pref.getInteger("progressdialog.size",600),100);
|
---|
41 | setLocationRelativeTo(Main.parent);
|
---|
42 | addComponentListener(new ComponentListener() {
|
---|
43 | public void componentHidden(ComponentEvent e) {}
|
---|
44 | public void componentMoved(ComponentEvent e) {}
|
---|
45 | public void componentShown(ComponentEvent e) {}
|
---|
46 | public void componentResized(ComponentEvent ev) {
|
---|
47 | int w = getWidth();
|
---|
48 | if(w > 200)
|
---|
49 | Main.pref.putInteger("progressdialog.size",w);
|
---|
50 | }
|
---|
51 | });
|
---|
52 | }
|
---|
53 |
|
---|
54 | public void setIndeterminate(boolean newValue) {
|
---|
55 | progressBar.setIndeterminate(newValue);
|
---|
56 | }
|
---|
57 | }
|
---|