Search in sources :

Example 1 with MZmineProjectListener

use of net.sf.mzmine.datamodel.MZmineProjectListener in project mzmine2 by mzmine.

the class BatchTask method run.

@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Starting a batch of " + totalSteps + " steps");
    // Listen for new items in the project
    MZmineProjectListener listener = new MZmineProjectListener() {

        @Override
        public void peakListAdded(PeakList newPeakList) {
            createdPeakLists.add(newPeakList);
        }

        @Override
        public void dataFileAdded(RawDataFile newFile) {
            createdDataFiles.add(newFile);
        }
    };
    project.addProjectListener(listener);
    // Process individual batch steps
    for (int i = 0; i < totalSteps; i++) {
        processQueueStep(i);
        processedSteps++;
        // Update the project reference in case new project was loaded
        if (project != MZmineCore.getProjectManager().getCurrentProject()) {
            project.removeProjectListener(listener);
            project = MZmineCore.getProjectManager().getCurrentProject();
            project.addProjectListener(listener);
        }
        // If we are canceled or ran into error, stop here
        if (isCanceled() || (getStatus() == TaskStatus.ERROR)) {
            return;
        }
    }
    project.removeProjectListener(listener);
    logger.info("Finished a batch of " + totalSteps + " steps");
    setStatus(TaskStatus.FINISHED);
}
Also used : RawDataFile(net.sf.mzmine.datamodel.RawDataFile) PeakList(net.sf.mzmine.datamodel.PeakList) MZmineProjectListener(net.sf.mzmine.datamodel.MZmineProjectListener)

Aggregations

MZmineProjectListener (net.sf.mzmine.datamodel.MZmineProjectListener)1 PeakList (net.sf.mzmine.datamodel.PeakList)1 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)1