Search in sources :

Example 1 with MZmineProcessingStepImpl

use of net.sf.mzmine.modules.impl.MZmineProcessingStepImpl in project mzmine2 by mzmine.

the class BatchSetupComponent method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final Object src = e.getSource();
    if (btnAdd.equals(src)) {
        // Processing module selected?
        final Object selectedItem = methodsCombo.getSelectedItem();
        if (selectedItem instanceof BatchModuleWrapper) {
            // Show method's set-up dialog.
            final BatchModuleWrapper wrappedModule = (BatchModuleWrapper) selectedItem;
            final MZmineProcessingModule selectedMethod = (MZmineProcessingModule) wrappedModule.getModule();
            final ParameterSet methodParams = MZmineCore.getConfiguration().getModuleParameters(selectedMethod.getClass());
            // Clone the parameter set
            final ParameterSet stepParams = methodParams.cloneParameterSet();
            // data file and feature list selection
            if (!batchQueue.isEmpty()) {
                for (Parameter<?> param : stepParams.getParameters()) {
                    if (param instanceof RawDataFilesParameter) {
                        final RawDataFilesParameter rdfp = (RawDataFilesParameter) param;
                        final RawDataFilesSelection selection = new RawDataFilesSelection();
                        selection.setSelectionType(RawDataFilesSelectionType.BATCH_LAST_FILES);
                        rdfp.setValue(selection);
                    }
                    if (param instanceof PeakListsParameter) {
                        final PeakListsParameter plp = (PeakListsParameter) param;
                        final PeakListsSelection selection = new PeakListsSelection();
                        selection.setSelectionType(PeakListsSelectionType.BATCH_LAST_PEAKLISTS);
                        plp.setValue(selection);
                    }
                }
            }
            // Configure parameters
            if (stepParams.getParameters().length > 0) {
                Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
                ExitCode exitCode = stepParams.showSetupDialog(parent, false);
                if (exitCode != ExitCode.OK)
                    return;
            }
            // Make a new batch step
            final MZmineProcessingStep<MZmineProcessingModule> step = new MZmineProcessingStepImpl<MZmineProcessingModule>(selectedMethod, stepParams);
            // Add step to queue.
            batchQueue.add(step);
            currentStepsList.setListData(batchQueue);
            currentStepsList.setSelectedIndex(currentStepsList.getModel().getSize() - 1);
        }
    }
    if (btnRemove.equals(src)) {
        // Remove selected step.
        final MZmineProcessingStep<?> selected = (MZmineProcessingStep<?>) currentStepsList.getSelectedValue();
        if (selected != null) {
            final int index = currentStepsList.getSelectedIndex();
            batchQueue.remove(selected);
            currentStepsList.setListData(batchQueue);
            selectStep(index);
        }
    }
    if (btnClear.equals(src)) {
        // Clear the queue.
        batchQueue.clear();
        currentStepsList.setListData(batchQueue);
    }
    if (btnConfig.equals(src)) {
        // Configure the selected item.
        final MZmineProcessingStep<?> selected = (MZmineProcessingStep<?>) currentStepsList.getSelectedValue();
        final ParameterSet parameters = selected == null ? null : selected.getParameterSet();
        if (parameters != null) {
            Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
            parameters.showSetupDialog(parent, false);
        }
    }
    if (btnSave.equals(src)) {
        try {
            final File file = chooser.getSaveFile(this, XML_EXTENSION);
            if (file != null) {
                saveBatchSteps(file);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "A problem occurred saving the file.\n" + ex.getMessage(), "Saving Failed", JOptionPane.ERROR_MESSAGE);
        }
    }
    if (btnLoad.equals(src)) {
        try {
            // Load the steps.
            final File file = chooser.getLoadFile(this);
            if (file != null) {
                // Load the batch steps.
                loadBatchSteps(file);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "A problem occurred loading the file.\n" + ex.getMessage(), "Loading Failed", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) Window(java.awt.Window) ExitCode(net.sf.mzmine.util.ExitCode) MZmineProcessingStepImpl(net.sf.mzmine.modules.impl.MZmineProcessingStepImpl) MZmineProcessingModule(net.sf.mzmine.modules.MZmineProcessingModule) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) MZmineProcessingStep(net.sf.mzmine.modules.MZmineProcessingStep) RawDataFilesSelection(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelection) PeakListsSelection(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsSelection) PeakListsParameter(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter) File(java.io.File) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Example 2 with MZmineProcessingStepImpl

use of net.sf.mzmine.modules.impl.MZmineProcessingStepImpl in project mzmine2 by mzmine.

the class BatchQueue method clone.

@Override
public BatchQueue clone() {
    // Clone the parameters.
    final BatchQueue clonedQueue = new BatchQueue();
    for (final MZmineProcessingStep<MZmineProcessingModule> step : this) {
        final ParameterSet parameters = step.getParameterSet();
        final MZmineProcessingStepImpl<MZmineProcessingModule> stepCopy = new MZmineProcessingStepImpl<MZmineProcessingModule>(step.getModule(), parameters.cloneParameterSet());
        clonedQueue.add(stepCopy);
    }
    return clonedQueue;
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) MZmineProcessingStepImpl(net.sf.mzmine.modules.impl.MZmineProcessingStepImpl) MZmineProcessingModule(net.sf.mzmine.modules.MZmineProcessingModule)

Aggregations

MZmineProcessingModule (net.sf.mzmine.modules.MZmineProcessingModule)2 MZmineProcessingStepImpl (net.sf.mzmine.modules.impl.MZmineProcessingStepImpl)2 ParameterSet (net.sf.mzmine.parameters.ParameterSet)2 Window (java.awt.Window)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 MZmineProcessingStep (net.sf.mzmine.modules.MZmineProcessingStep)1 PeakListsParameter (net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter)1 PeakListsSelection (net.sf.mzmine.parameters.parametertypes.selectors.PeakListsSelection)1 RawDataFilesParameter (net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)1 RawDataFilesSelection (net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelection)1 ExitCode (net.sf.mzmine.util.ExitCode)1 SAXException (org.xml.sax.SAXException)1