pluginManager = new PluginManager(this, dir);  initGUI(); errorDialog = new ErrorDialog(display, shell);  if (playerList.getPlayers().length == 0) errorDialog.show(getResource("help/missingplayer.html"));  playThread.addUpdateListener(this); playThread.start();  downloadThread = new DownloadThread(trackDatabase) { public void process() throws IOException { super.process();  }  public void handleError(String code, String urlString) {  Reader r; try { if (urlString.indexOf(':') < 0) { r = getResource("help/" + urlString); if (r == null) throw new NullPointerException(); } else try { r = new InputStreamReader(new URL(urlString).openStream()); } catch (MalformedURLException e) { e.printStackTrace(); r = getResource("help/malformedurl.html"); } } catch (IOException e) { r = getResource("help/errorerror.txt"); } final Reader finalReader = r; display.asyncExec(new Runnable() { public void run() { errorDialog.show(finalReader); } }); } };  downloadThread.addUpdateListener(new UpdateListener() { boolean newState = false; public void actionPerformed() { String state = downloadThread.getState(); newState = false; if (!strState.equals(state)) { strState = state; newState = true; } display.asyncExec(new Runnable() { public void run() { int n = downloadThread.getPercentComplete(); boolean barVisible = progressBar.getVisible(); if (n > 0 && n < 100) { lblState.setText(strState + " " + n + "%"); progressBar.setSelection(n); if (!barVisible) progressBar.setVisible(true); } else { lblState.setText(strState); if (barVisible) progressBar.setVisible(false); } lblState.pack(); if (newState) synchronizePlaylist(playListManager, tblSongs); } }); } });
  public Client() {    File home = new File(System.getProperties().getProperty("user.home"));    // Check the current directory for an existing trackdatabase.xml for    // compatibility reasons only.    File dir = new File(".");    File file = new File(dir, "trackdatabase.xml");    if (!file.exists()) {      dir = new File("/irate");      file = new File(dir, "trackdatabase.xml");      if (!file.exists()) {        dir = new File(home, "irate");        if (!dir.exists())          dir.mkdir();        file = new File(dir, "trackdatabase.xml");      }    }    try {      trackDatabase = new TrackDatabase(file);    }    catch (IOException e) {      e.printStackTrace();    }    playerList = new PlayerList();    playListManager = new PlayListManager(trackDatabase);    playThread = new PlayThread(playListManager, playerList);    uiFactory = new SWTPluginUIFactory(display, (PluginApplication) this);    pluginManager = new PluginManager(this, dir);    initGUI();    errorDialog = new ErrorDialog(display, shell);    if (playerList.getPlayers().length == 0)      errorDialog.show(getResource("help/missingplayer.html"));    playThread.addUpdateListener(this);    playThread.start();    downloadThread = new DownloadThread(trackDatabase) {      public void process() throws IOException {        super.process();        // perhapsDisableAccount();      }      public void handleError(String code, String urlString) {        //actionSetContinuousDownload(false);        Reader r;        try {          if (urlString.indexOf(':') < 0) {            r = getResource("help/" + urlString);            if (r == null)              throw new NullPointerException();          }          else            try {              r = new InputStreamReader(new URL(urlString).openStream());            }            catch (MalformedURLException e) {              e.printStackTrace();              r = getResource("help/malformedurl.html");            }        }        catch (IOException e) {          r = getResource("help/errorerror.txt");        }        final Reader finalReader = r;        display.asyncExec(new Runnable() {          public void run() {            errorDialog.show(finalReader);          }        });      }    };    downloadThread.addUpdateListener(new UpdateListener() {      boolean newState = false;      public void actionPerformed() {        String state = downloadThread.getState();        newState = false;        if (!strState.equals(state)) {          strState = state;          newState = true;        }        display.asyncExec(new Runnable() {          public void run() {            int n = downloadThread.getPercentComplete();            boolean barVisible = progressBar.getVisible();            if (n > 0 && n < 100) {              lblState.setText(strState + " " + n + "%");              progressBar.setSelection(n);              if (!barVisible)                progressBar.setVisible(true);            }            else {              lblState.setText(strState);              if (barVisible)                progressBar.setVisible(false);            }            lblState.pack();            if (newState)              synchronizePlaylist(playListManager, tblSongs);          }        });      }    });    if (trackDatabase.getNoOfTracks() == 0)      showAccountDialog();              downloadThread.start();    shell.open();  }