void enqueue(Runnable r, boolean showdialog) { if (runlist == null) { runlist = new ArrayList<Runnable>(); } runlist.add(r); if (showdialog && dialog == null) { dialog = new LongRunningTask() { public float getProgress() { return 1 - (float) state.getBytesRemaining() / state.getBytes(); } public void run() { while (!isCancelled()) { synchronized (this) { try { wait(); } catch (InterruptedException e) { } } } } }; dialog.setCancellable(false); dialog.setModal(false); dialog.start(docpanel, UIManager.getString("PDFViewer.Loading")); } }
void close() { if (dialog != null) { dialog.cancel(); synchronized (dialog) { dialog.notifyAll(); } } if (runlist != null) { for (int i = 0; i < runlist.size(); i++) { runlist.get(i).run(); } } }