Changeset 1733 in josm for trunk/src/org/openstreetmap/josm
- Timestamp:
- 2009-07-05T10:48:09+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/PreferencesAction.java
r1647 r1733 37 37 */ 38 38 public void actionPerformed(ActionEvent e) { 39 new Thread(this).start();39 run(); 40 40 } 41 41 … … 75 75 dlg.setBounds(targetX, targetY, targetWidth, targetHeight); 76 76 77 dlg.setModal(true); 77 78 dlg.setVisible(true); 78 79 if (pane.getValue() instanceof Integer && (Integer)pane.getValue() == JOptionPane.OK_OPTION) -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r1728 r1733 148 148 149 149 public LatLon interpolate(LatLon ll2, double proportion) { 150 return new LatLon(this. x + proportion * (ll2.x - this.x),151 this. y + proportion * (ll2.y - this.y));150 return new LatLon(this.lat() + proportion * (ll2.lat() - this.lat()), 151 this.lon() + proportion * (ll2.lon() - this.lon())); 152 152 } 153 153 154 154 public LatLon getCenter(LatLon ll2) { 155 return new LatLon((this. x + ll2.x)/2.0, (this.y + ll2.y)/2.0);155 return new LatLon((this.lat() + ll2.lat())/2.0, (this.lon() + ll2.lon())/2.0); 156 156 } 157 157 -
trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r1670 r1733 9 9 import java.awt.event.WindowAdapter; 10 10 import java.awt.event.WindowEvent; 11 import java.awt.event.WindowListener; 11 12 import java.io.FileNotFoundException; 12 13 import java.io.IOException; … … 36 37 private final String title; 37 38 39 private ActionListener cancelListener = new ActionListener(){ 40 public void actionPerformed(ActionEvent e) { 41 if (!cancelled) { 42 cancelled = true; 43 cancel(); 44 } 45 } 46 }; 47 48 private WindowListener windowListener = new WindowAdapter(){ 49 @Override public void windowClosing(WindowEvent e) { 50 if (!closeDialogCalled) { 51 if (!cancelled) { 52 cancelled = true; 53 cancel(); 54 } 55 closeDialog(); 56 } 57 } 58 }; 59 38 60 /** 39 61 * Create the runnable object with a given message for the user. … … 53 75 this.title = title; 54 76 this.ignoreException = ignoreException; 55 Main.pleaseWaitDlg.cancel.addActionListener(new ActionListener(){ 56 public void actionPerformed(ActionEvent e) { 57 if (!cancelled) { 58 cancelled = true; 59 cancel(); 60 } 61 } 62 }); 63 Main.pleaseWaitDlg.addWindowListener(new WindowAdapter(){ 64 @Override public void windowClosing(WindowEvent e) { 65 if (!closeDialogCalled) { 66 if (!cancelled) { 67 cancelled = true; 68 cancel(); 69 } 70 closeDialog(); 71 } 72 } 73 }); 74 } 75 76 public final void run() { 77 } 78 79 private void prepareDialog() { 80 // reset dialog state 81 errorMessage = null; 82 closeDialogCalled = false; 83 84 Main.pleaseWaitDlg.setTitle(title); 85 Main.pleaseWaitDlg.cancel.setEnabled(true); 86 Main.pleaseWaitDlg.setCustomText(""); 87 Main.pleaseWaitDlg.cancel.addActionListener(cancelListener); 88 Main.pleaseWaitDlg.addWindowListener(windowListener); 89 Main.pleaseWaitDlg.setVisible(true); 90 } 91 92 private void doRealRun() { 77 93 try { 78 94 try { 79 if (cancelled)80 return; // since realRun isn't executed, do not call to finish81 82 // reset dialog state83 Main.pleaseWaitDlg.setTitle(title);84 Main.pleaseWaitDlg.cancel.setEnabled(true);85 Main.pleaseWaitDlg.setCustomText("");86 errorMessage = null;87 closeDialogCalled = false;88 89 // show the dialog90 synchronized (this) {91 EventQueue.invokeLater(new Runnable() {92 public void run() {93 synchronized (PleaseWaitRunnable.this) {94 PleaseWaitRunnable.this.notifyAll();95 }96 Main.pleaseWaitDlg.setVisible(true);97 }98 });99 try {wait();} catch (InterruptedException e) {}100 }101 102 95 realRun(); 103 96 } catch (SAXException x) { … … 129 122 }); 130 123 } 124 } 125 } 126 127 public final void run() { 128 if (cancelled) 129 return; // since realRun isn't executed, do not call to finish 130 131 if (EventQueue.isDispatchThread()) { 132 new Thread(new Runnable() { 133 public void run() { 134 doRealRun(); 135 } 136 }).start(); 137 prepareDialog(); 138 } else { 139 EventQueue.invokeLater(new Runnable() { 140 public void run() { 141 prepareDialog(); 142 } 143 }); 144 doRealRun(); 131 145 } 132 146 } … … 165 179 Main.pleaseWaitDlg.setVisible(false); 166 180 Main.pleaseWaitDlg.dispose(); 181 Main.pleaseWaitDlg.removeWindowListener(windowListener); 182 Main.pleaseWaitDlg.cancel.removeActionListener(cancelListener); 167 183 } 168 184 if (errorMessage != null && !silent) { -
trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
r1732 r1733 11 11 import java.io.BufferedWriter; 12 12 import java.io.File; 13 import java.io.FileNotFoundException;14 13 import java.io.FileOutputStream; 15 import java.io.FileWriter;16 14 import java.io.FilenameFilter; 17 15 import java.io.IOException; … … 20 18 import java.io.OutputStream; 21 19 import java.io.OutputStreamWriter; 22 import java.net.MalformedURLException;23 20 import java.net.URL; 24 21 import java.util.Arrays; 25 import java.util.concurrent.Future;26 22 import java.util.Collection; 27 23 import java.util.LinkedList; … … 29 25 import javax.swing.JOptionPane; 30 26 27 import org.openstreetmap.josm.Main; 31 28 import org.openstreetmap.josm.actions.AboutAction; 32 import org.openstreetmap.josm.Main;33 29 import org.openstreetmap.josm.gui.ExtendedDialog; 34 30 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 66 62 if (!pluginDir.exists()) 67 63 pluginDir.mkdirs(); 64 Main.pleaseWaitDlg.progress.setMaximum(toUpdate.size()); 65 int progressValue = 0; 68 66 for (PluginInformation d : toUpdate) { 67 Main.pleaseWaitDlg.progress.setValue(progressValue++); 69 68 Main.pleaseWaitDlg.currentAction.setText(tr("Downloading Plugin {0}...", d.name)); 70 69 File pluginFile = new File(pluginDir, d.name + ".jar.new"); … … 145 144 146 145 public Collection<PluginInformation> download(Collection<PluginInformation> download) { 146 // Execute task in current thread instead of executing it in other thread and waiting for result 147 // Waiting for result is not a good idea because the waiting thread will probably be either EDT 148 // or worker thread. Blocking one of these threads will cause deadlock 147 149 UpdateTask t = new UpdateTask(download, false); 148 try { 149 Future<UpdateTask> ta = Main.worker.submit(t, t); 150 t = ta.get(); 151 return t.failed; 152 } 153 catch(java.lang.InterruptedException e) {e.printStackTrace();} 154 catch(java.util.concurrent.ExecutionException e) {e.printStackTrace();} 155 return download; 150 t.run(); 151 return t.failed; 156 152 } 157 153 -
trunk/src/org/openstreetmap/josm/plugins/PluginSelection.java
r1672 r1733 9 9 import java.awt.event.ActionEvent; 10 10 import java.awt.event.ActionListener; 11 12 11 import java.io.BufferedReader; 13 12 import java.io.ByteArrayInputStream; … … 15 14 import java.io.FileInputStream; 16 15 import java.io.InputStreamReader; 17 import java.io.IOException;18 16 import java.util.Arrays; 19 17 import java.util.Collection; … … 97 95 } 98 96 99 public Boolean finish() {97 public boolean finish() { 100 98 Collection<PluginInformation> toDownload = new LinkedList<PluginInformation>(); 101 99 String msg = "";
Note:
See TracChangeset
for help on using the changeset viewer.