File Source: DownloaderWindow.java
/*
P/P * Method: com.dmdirc.addons.addonbrowser.DownloaderWindow__static_init
*/
1 /*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6 package com.dmdirc.addons.addonbrowser;
7
8 import com.dmdirc.Main;
9 import com.dmdirc.util.DownloadListener;
10 import com.dmdirc.util.Downloader;
11
12 import java.awt.Component;
13 import java.io.File;
14 import java.io.IOException;
15
16 import javax.swing.JDialog;
17 import javax.swing.JProgressBar;
18
19 import net.miginfocom.swing.MigLayout;
20
21 /**
22 *
23 * @author chris
24 */
25 public class DownloaderWindow extends JDialog implements Runnable, DownloadListener {
26
27 /**
28 * A version number for this class. It should be changed whenever the class
29 * structure is changed (or anything else that would prevent serialized
30 * objects being unserialized with the new class).
31 */
32 private static final long serialVersionUID = 1;
33 /** Downloader progress bar. */
34 private final JProgressBar jpb = new JProgressBar(0, 100);
35
36 /** Instantiates a new downloader window. */
/*
P/P * Method: void com.dmdirc.addons.addonbrowser.DownloaderWindow()
*
* Preconditions:
* com/dmdirc/Main.controller != null
*
* Presumptions:
* com.dmdirc.ui.interfaces.MainWindow:getIcon(...)@44 != null
* com.dmdirc.ui.interfaces.UIController:getMainWindow(...)@44 != null
*
* Postconditions:
* this.jpb == &new JProgressBar(DownloaderWindow#1)
* new JProgressBar(DownloaderWindow#1) num objects == 1
*/
37 public DownloaderWindow() {
38 setTitle("Downloading addon information...");
39 setLayout(new MigLayout("fill"));
40 add(jpb, "grow");
41 pack();
42 setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
43 setLocationRelativeTo((Component) Main.getUI().getMainWindow());
44 setIconImage(Main.getUI().getMainWindow().getIcon().getImage());
45 setVisible(true);
46
47 new Thread(this, "Addon downloader thread").start();
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public void run() {
53 try {
/*
P/P * Method: void run()
*
* Preconditions:
* (soft) com/dmdirc/Main.controller != null
* (soft) init'ed(com/dmdirc/Main.configdir)
*
* Presumptions:
* init'ed(java.io.File.separator)
*
* Postconditions:
* com/dmdirc/Main.configdir == One-of{old com/dmdirc/Main.configdir, &java.lang.StringBuilder:toString(...)}
* init'ed(com/dmdirc/Main.configdir)
* java.lang.StringBuilder:toString(...)._tainted == 0
*/
54 Downloader.downloadPage("http://addons.dmdirc.com/feed",
55 Main.getConfigDir() + File.separator + "addons.feed", this);
56 new BrowserWindow();
57 } catch (IOException ex) {
58 // Do nothing
59 }
60
61 dispose();
62 }
63
64 /** {@inheritDoc} */
65 @Override
66 public void downloadProgress(float percent) {
/*
P/P * Method: void downloadProgress(float)
*
* Preconditions:
* (int) (percent) in {-231..232-1}
* this.jpb != null
*
* Presumptions:
* java.lang.System.out != null
*/
67 System.out.println("value: " + percent);
68 jpb.setValue((int) percent);
69 }
70
71 /** {@inheritDoc} */
72 @Override
73 public void setIndeterminate(final boolean indeterminate) {
/*
P/P * Method: void setIndeterminate(bool)
*
* Preconditions:
* this.jpb != null
*/
74 jpb.setIndeterminate(indeterminate);
75 }
76
77 }
SofCheck Inspector Build Version : 2.17854
| DownloaderWindow.java |
2009-Jun-25 01:54:24 |
| DownloaderWindow.class |
2009-Sep-02 17:04:14 |