Search in sources :

Example 1 with ProjectOpeningTask

use of net.sf.mzmine.modules.projectmethods.projectload.ProjectOpeningTask in project mzmine2 by mzmine.

the class MainMenu method setLastProjects.

public void setLastProjects(List<File> list) {
    lastProjects = list;
    SwingUtilities.invokeLater(() -> {
        lastProjectsSub.removeAll();
        if (list == null || list.isEmpty()) {
            lastProjectsSub.setEnabled(false);
            return;
        }
        lastProjectsSub.setEnabled(true);
        // add items to load last used projects directly
        lastProjects.stream().map(File::getAbsolutePath).forEach(name -> {
            JMenuItem item = new JMenuItem(name);
            item.addActionListener(e -> {
                JMenuItem c = (JMenuItem) e.getSource();
                if (c != null) {
                    File f = new File(c.getText());
                    if (f.exists()) {
                        // load file
                        ProjectOpeningTask newTask = new ProjectOpeningTask(f);
                        MZmineCore.getTaskController().addTask(newTask);
                    }
                }
            });
            lastProjectsSub.add(item);
        });
    });
}
Also used : JMenuItem(javax.swing.JMenuItem) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) File(java.io.File) ProjectOpeningTask(net.sf.mzmine.modules.projectmethods.projectload.ProjectOpeningTask)

Aggregations

File (java.io.File)1 JMenuItem (javax.swing.JMenuItem)1 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)1 ProjectOpeningTask (net.sf.mzmine.modules.projectmethods.projectload.ProjectOpeningTask)1