public void actionPerformed()

in duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/GlobalFindDuplicates.java [51:112]


    public void actionPerformed(ActionEvent e) {
        final Iterator<? extends DuplicateDescription>[] dupes = new Iterator[1];
        final ProgressHandle handle = ProgressHandleFactory.createHandle("Compute Duplicates");
        JPanel panel = createPanel(handle);
        final AtomicBoolean cancel = new AtomicBoolean();
        DialogDescriptor w = new DialogDescriptor(panel, "Computing Duplicates", true, new Object[] {DialogDescriptor.CANCEL_OPTION}, DialogDescriptor.CANCEL_OPTION, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                cancel.set(true);
            }
        });

        w.setClosingOptions(null);

        final Dialog d = DialogDisplayer.getDefault().createDialog(w);
        final AtomicBoolean done = new AtomicBoolean();
        final Collection<String> sourceRoots = new LinkedList<String>();

        WORKER.post(new Runnable() {
            public void run() {
                try {
                    for (ClassPath cp : GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE)) {
                        for (ClassPath.Entry e : cp.entries()) {
                            FileObject root = e.getRoot();

                            if (root == null) continue;

                            sourceRoots.add(FileUtil.getFileDisplayName(root));
                        }
                    }

                    dupes[0] = new ComputeDuplicates().computeDuplicatesForAllOpenedProjects(handle, cancel);
                    done.set(true);
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                } finally {
                    handle.finish();

                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            d.setVisible(false);
                        }
                    });
                }
            }
        });

        handle.start();
        handle.progress(" ");

        d.setVisible(true);

        if (!done.get()) {
            cancel.set(true);
            return;
        }
        
        if (cancel.get()) return;

        NotifyDescriptor nd = new NotifyDescriptor.Message(new DuplicatesListPanel(sourceRoots, dupes[0]));

        DialogDisplayer.getDefault().notifyLater(nd);
    }