public void updateDownloadsTableModel() {
		if (MainDialog.isHeadless())
			return;
		
		if (!MainDialog.instance.isDownloadsPanelShown ())
			return;
		
		if (!checkUiInvalidated())
			return;
		
		//D.out("Doing Downloader UI update");
		

		// work on a copy of those lists so we do not get any
		// ConcurrentModificationExceptions
		final List<DownloadFile> dFs = (List<DownloadFile>) ((ArrayList) downloadFiles)
				.clone();
		final List<DownloadDirectory> dDs = (List<DownloadDirectory>) ((ArrayList) downloadDirectories)
				.clone();

		Runnable r = new Runnable() {

			public void run() {
				c++;
				//D.out("UI update" + (int) c);
				DownloadsTableModel dtm = DownloadsTableModel.instance();
				dtm.setRowCount(dFs.size() + dDs.size());

				int i = 0;
				for (DownloadFile df : dFs) {
					try {
						dtm.setValueAt(df.getUIRow().getDownloadIcon(), i, 0);
						dtm.setValueAt(df.getUIRow().getDisplayName(), i, 1);
						dtm.setValueAt(df.getUIRow().getStateString(), i, 2);

						i++;
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				ImageIcon dirIcon = IconChooser.getFolderImageIcon();
				for (DownloadDirectory dd : dDs) {

					dtm.setValueAt(dirIcon, i, 0);
					dtm.setValueAt(dd.getUIRow().getDisplayName(), i, 1);
					dtm.setValueAt(dd.getUIRow().getStateString(), i, 2);

					i++;
				}

			}
		};

		SwingUtilities.invokeLater(r);

	}