Changeset 1670 in josm for trunk/src/org/openstreetmap/josm/io/ProgressInputStream.java
- Timestamp:
- 15.06.2009 20:22:46 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/ProgressInputStream.java
r1169 r1670 22 22 private PleaseWaitDialog pleaseWaitDlg; 23 23 24 public class OsmServerException extends IOException { 25 private OsmServerException(String e) { 26 super(e); 27 } 28 } 29 30 public ProgressInputStream(URLConnection con, PleaseWaitDialog pleaseWaitDlg) throws IOException, OsmServerException { 24 public ProgressInputStream(URLConnection con, PleaseWaitDialog pleaseWaitDlg) throws OsmTransferException { 31 25 this.connection = con; 32 26 … … 35 29 } catch (IOException e) { 36 30 if (con.getHeaderField("Error") != null) 37 throw new Osm ServerException(tr(con.getHeaderField("Error")));38 throw e;31 throw new OsmTransferException(tr(con.getHeaderField("Error"))); 32 throw new OsmTransferException(e); 39 33 } 40 34 … … 43 37 if (pleaseWaitDlg == null) 44 38 return; 45 if (contentLength > 0) 39 if (contentLength > 0) { 46 40 pleaseWaitDlg.progress.setMaximum(contentLength); 47 else41 } else { 48 42 pleaseWaitDlg.progress.setMaximum(0); 43 } 49 44 pleaseWaitDlg.progress.setValue(0); 50 45 } … … 56 51 @Override public int read(byte[] b, int off, int len) throws IOException { 57 52 int read = in.read(b, off, len); 58 if (read != -1) 53 if (read != -1) { 59 54 advanceTicker(read); 55 } 60 56 return read; 61 57 } … … 63 59 @Override public int read() throws IOException { 64 60 int read = in.read(); 65 if (read != -1) 61 if (read != -1) { 66 62 advanceTicker(1); 63 } 67 64 return read; 68 65 } … … 76 73 return; 77 74 78 if (pleaseWaitDlg.progress.getMaximum() == 0 && connection.getContentLength() != -1) 75 if (pleaseWaitDlg.progress.getMaximum() == 0 && connection.getContentLength() != -1) { 79 76 pleaseWaitDlg.progress.setMaximum(connection.getContentLength()); 77 } 80 78 81 79 readSoFar += amount; … … 89 87 String cur = pleaseWaitDlg.currentAction.getText(); 90 88 int i = cur.indexOf(' '); 91 if (i != -1) 89 if (i != -1) { 92 90 cur = cur.substring(0, i) + progStr; 93 else91 } else { 94 92 cur += progStr; 93 } 95 94 pleaseWaitDlg.currentAction.setText(cur); 96 95 }
Note: See TracChangeset
for help on using the changeset viewer.
