Search in sources :

Example 1 with FileDisplayDialog

use of com.compomics.util.gui.file_handling.FileDisplayDialog in project peptide-shaker by compomics.

the class NewDialog method idFilesTxtMouseClicked.

// GEN-LAST:event_peptideShakerPublicationLabelMouseExited
/**
 * Display the list of selected identification files.
 *
 * @param evt
 */
private void idFilesTxtMouseClicked(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_idFilesTxtMouseClicked
    if (!idFiles.isEmpty()) {
        FileDisplayDialog fileDisplayDialog = new FileDisplayDialog(this, idFiles, true);
        if (!fileDisplayDialog.canceled()) {
            idFiles = fileDisplayDialog.getSelectedFiles();
            idFilesTxt.setText(idFiles.size() + " file(s) selected");
            validateInput();
        }
    }
}
Also used : FileDisplayDialog(com.compomics.util.gui.file_handling.FileDisplayDialog)

Example 2 with FileDisplayDialog

use of com.compomics.util.gui.file_handling.FileDisplayDialog in project peptide-shaker by compomics.

the class NewDialog method spectrumFilesTxtMouseClicked.

// GEN-LAST:event_idFilesTxtMouseClicked
/**
 * Display the list of selected spectrum files.
 *
 * @param evt
 */
private void spectrumFilesTxtMouseClicked(java.awt.event.MouseEvent evt) {
    if (!spectrumFiles.isEmpty()) {
        FileDisplayDialog fileDisplayDialog = new FileDisplayDialog(this, spectrumFiles, true);
        if (!fileDisplayDialog.canceled()) {
            ArrayList<File> selectedFiles = fileDisplayDialog.getSelectedFiles();
            // Load the files
            progressDialog = new ProgressDialogX(this, peptideShakerGUI, Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), true);
            progressDialog.setPrimaryProgressCounterIndeterminate(true);
            progressDialog.setTitle("Loading Files. Please Wait...");
            new Thread(new Runnable() {

                public void run() {
                    try {
                        progressDialog.setVisible(true);
                    } catch (IndexOutOfBoundsException e) {
                    // ignore
                    }
                }
            }, "ProgressDialog").start();
            new Thread("loadingThread") {

                public void run() {
                    boolean allLoaded = true;
                    for (File file : selectedFiles) {
                        try {
                            File folder = CmsFolder.getParentFolder() == null ? file.getParentFile() : new File(CmsFolder.getParentFolder());
                            msFileHandler.register(file, folder, progressDialog);
                        } catch (Exception e) {
                            progressDialog.setRunCanceled();
                            allLoaded = false;
                            JOptionPane.showMessageDialog(null, "An error occurred while reading the following file.\n" + file.getAbsolutePath() + "\n\nError:\n" + e.getLocalizedMessage(), "File error", JOptionPane.ERROR_MESSAGE);
                            e.printStackTrace();
                        }
                    }
                    progressDialog.setRunFinished();
                    if (allLoaded) {
                        spectrumFilesTxt.setText(spectrumFiles.size() + " file(s) selected");
                        validateInput();
                    }
                }
            }.start();
        }
    }
}
Also used : ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) FileDisplayDialog(com.compomics.util.gui.file_handling.FileDisplayDialog)

Aggregations

FileDisplayDialog (com.compomics.util.gui.file_handling.FileDisplayDialog)2 ProgressDialogX (com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX)1