Changeset 50 in josm for src/org/openstreetmap/josm/actions/JosmAction.java
- Timestamp:
- 2006-02-12T12:05:34+01:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/JosmAction.java
r44 r50 7 7 import javax.swing.JDialog; 8 8 import javax.swing.JLabel; 9 import javax.swing.SwingUtilities; 9 10 10 11 import org.openstreetmap.josm.Main; … … 17 18 abstract public class JosmAction extends AbstractAction { 18 19 20 /** 21 * Instanced of this thread will display a "Please Wait" message in middle of JOSM 22 * to indicate a progress beeing executed. 23 * 24 * @author Imi 25 */ 26 protected abstract class PleaseWaitRunnable implements Runnable { 27 private String msg; 28 private JDialog pleaseWaitDlg; 29 /** 30 * Create the runnable object with a given message for the user. 31 */ 32 PleaseWaitRunnable(String msg) { 33 this.msg = msg; 34 } 35 public final void run() { 36 pleaseWaitDlg = new JDialog(Main.main, true); 37 pleaseWaitDlg.setUndecorated(true); 38 JLabel l = new JLabel(msg+". Please Wait."); 39 l.setBorder(BorderFactory.createCompoundBorder( 40 BorderFactory.createEtchedBorder(), 41 BorderFactory.createEmptyBorder(20,20,20,20))); 42 pleaseWaitDlg.getContentPane().add(l); 43 pleaseWaitDlg.pack(); 44 pleaseWaitDlg.setLocation(Main.main.getX()+Main.main.getWidth()/2-pleaseWaitDlg.getWidth()/2, 45 Main.main.getY()+Main.main.getHeight()/2-pleaseWaitDlg.getHeight()/2); 46 pleaseWaitDlg.setResizable(false); 47 SwingUtilities.invokeLater(new Runnable(){ 48 public void run() { 49 pleaseWaitDlg.setVisible(true); 50 } 51 }); 52 try { 53 realRun(); 54 } finally { 55 closeDialog(); 56 } 57 } 58 public abstract void realRun(); 59 public void closeDialog() { 60 pleaseWaitDlg.setVisible(false); 61 pleaseWaitDlg.dispose(); 62 } 63 } 64 19 65 /** 20 66 * Construct the action. … … 34 80 putValue(ACCELERATOR_KEY, shortCut); 35 81 } 36 37 /**38 * @return A dialog labeled "... Please Wait." where ... is the message parameter.39 */40 protected JDialog createPleaseWaitDialog(String msg) {41 final JDialog pleaseWaitDlg = new JDialog(Main.main, true);42 pleaseWaitDlg.setUndecorated(true);43 JLabel l = new JLabel(msg+". Please Wait.");44 l.setBorder(BorderFactory.createCompoundBorder(45 BorderFactory.createEtchedBorder(),46 BorderFactory.createEmptyBorder(20,20,20,20)));47 pleaseWaitDlg.getContentPane().add(l);48 pleaseWaitDlg.pack();49 pleaseWaitDlg.setLocation(Main.main.getX()+Main.main.getWidth()/2-pleaseWaitDlg.getWidth()/2,50 Main.main.getY()+Main.main.getHeight()/2-pleaseWaitDlg.getHeight()/2);51 pleaseWaitDlg.setResizable(false);52 return pleaseWaitDlg;53 }54 82 }
Note:
See TracChangeset
for help on using the changeset viewer.