use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class RawDataFilesComponent method actionPerformed.
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == detailsButton) {
RawDataFilesSelectionType type = (RawDataFilesSelectionType) typeCombo.getSelectedItem();
if (type == RawDataFilesSelectionType.SPECIFIC_FILES) {
final MultiChoiceParameter<RawDataFile> filesParameter = new MultiChoiceParameter<RawDataFile>("Select files", "Select files", MZmineCore.getProjectManager().getCurrentProject().getDataFiles(), currentValue.getSpecificFiles());
final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { filesParameter });
final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
if (exitCode == ExitCode.OK) {
RawDataFile[] files = paramSet.getParameter(filesParameter).getValue();
currentValue.setSpecificFiles(files);
}
}
if (type == RawDataFilesSelectionType.NAME_PATTERN) {
final StringParameter nameParameter = new StringParameter("Name pattern", "Set name pattern that may include wildcards (*), e.g. *mouse* matches any name that contains mouse", currentValue.getNamePattern());
final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { nameParameter });
final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
if (exitCode == ExitCode.OK) {
String namePattern = paramSet.getParameter(nameParameter).getValue();
currentValue.setNamePattern(namePattern);
}
}
}
if (src == typeCombo) {
RawDataFilesSelectionType type = (RawDataFilesSelectionType) typeCombo.getSelectedItem();
currentValue.setSelectionType(type);
detailsButton.setEnabled((type == RawDataFilesSelectionType.NAME_PATTERN) || (type == RawDataFilesSelectionType.SPECIFIC_FILES));
}
updateNumFiles();
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class RawDataFilesParameter method saveValueToXML.
@Override
public void saveValueToXML(Element xmlElement) {
if (value == null)
return;
Document parentDocument = xmlElement.getOwnerDocument();
xmlElement.setAttribute("type", value.getSelectionType().name());
if (value.getSpecificFiles() != null) {
for (RawDataFile item : value.getSpecificFiles()) {
Element newElement = parentDocument.createElement("specific_file");
newElement.setTextContent(item.getName());
xmlElement.appendChild(newElement);
}
}
if (value.getNamePattern() != null) {
Element newElement = parentDocument.createElement("name_pattern");
newElement.setTextContent(value.getNamePattern());
xmlElement.appendChild(newElement);
}
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class RawDataFilesParameter method loadValueFromXML.
@Override
public void loadValueFromXML(Element xmlElement) {
RawDataFile[] currentDataFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
RawDataFilesSelectionType selectionType;
final String attrValue = xmlElement.getAttribute("type");
if (Strings.isNullOrEmpty(attrValue))
selectionType = RawDataFilesSelectionType.GUI_SELECTED_FILES;
else
selectionType = RawDataFilesSelectionType.valueOf(xmlElement.getAttribute("type"));
ArrayList<Object> newValues = new ArrayList<Object>();
NodeList items = xmlElement.getElementsByTagName("specific_file");
for (int i = 0; i < items.getLength(); i++) {
String itemString = items.item(i).getTextContent();
for (RawDataFile df : currentDataFiles) {
if (df.getName().equals(itemString))
newValues.add(df);
}
}
RawDataFile[] specificFiles = newValues.toArray(new RawDataFile[0]);
String namePattern = null;
items = xmlElement.getElementsByTagName("name_pattern");
for (int i = 0; i < items.getLength(); i++) {
namePattern = items.item(i).getTextContent();
}
this.value = new RawDataFilesSelection();
this.value.setSelectionType(selectionType);
this.value.setSpecificFiles(specificFiles);
this.value.setNamePattern(namePattern);
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class FeaturesSelectionDialog method actionPerformed.
/*
*
*
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == btnOk) {
returnState = true;
this.dispose();
}
if (src == btnCancel) {
returnState = false;
this.dispose();
}
if (src == rawDataFileComboBox) {
panel12.removeAll();
RawDataFile dataFile = (RawDataFile) rawDataFileComboBox.getSelectedItem();
Feature[] features = allPeakLists[selectedIndex].getPeaks(dataFile);
featuresSelectionBox = new MultipleSelectionComponent<Feature>(features);
featuresSelectionBox.setToolTipText("Features Selection Box");
panel12.add(featuresSelectionBox, BorderLayout.CENTER);
panel12.revalidate();
}
if (src == peakListComboBox) {
PeakList peakList = (PeakList) peakListComboBox.getSelectedItem();
panel11.removeAll();
panel12.removeAll();
for (int j = 0; j < allPeakLists.length; j++) {
if (peakList.equals(allPeakLists[j])) {
RawDataFile[] rawDataFiles = allPeakLists[j].getRawDataFiles();
rawDataFileComboBox = new JComboBox<RawDataFile>(rawDataFiles);
rawDataFileComboBox.setToolTipText("Raw data files Selection Box");
rawDataFileComboBox.addActionListener(this);
panel11.add(rawDataFileComboBox, BorderLayout.CENTER);
this.setSize(670, 400);
LOG.finest("PeakListRowComboBox is Added");
selectedIndex = j;
RawDataFile datafile = allPeakLists[j].getRawDataFile(0);
Feature[] features = allPeakLists[j].getPeaks(datafile);
featuresSelectionBox = new MultipleSelectionComponent<Feature>(features);
featuresSelectionBox.setToolTipText("Features Selection Box");
panel12.add(featuresSelectionBox, BorderLayout.CENTER);
}
panel11.revalidate();
panel12.revalidate();
}
}
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class MZRangeComponent method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == setAutoButton) {
RawDataFile[] currentFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
ScanSelection scanSelection = new ScanSelection();
try {
ParameterSetupDialog setupDialog = (ParameterSetupDialog) SwingUtilities.getWindowAncestor(this);
RawDataFilesComponent rdc = (RawDataFilesComponent) setupDialog.getComponentForParameter(new RawDataFilesParameter());
if (rdc != null) {
RawDataFile[] matchingFiles = rdc.getValue().getMatchingRawDataFiles();
if (matchingFiles.length > 0)
currentFiles = matchingFiles;
}
ScanSelectionComponent ssc = (ScanSelectionComponent) setupDialog.getComponentForParameter(new ScanSelectionParameter());
if (ssc != null)
scanSelection = ssc.getValue();
} catch (Exception e) {
e.printStackTrace();
}
Range<Double> mzRange = null;
for (RawDataFile file : currentFiles) {
Scan[] scans = scanSelection.getMatchingScans(file);
for (Scan s : scans) {
Range<Double> scanRange = s.getDataPointMZRange();
if (scanRange == null)
continue;
if (mzRange == null)
mzRange = scanRange;
else
mzRange = mzRange.span(scanRange);
}
}
if (mzRange != null)
setValue(mzRange);
}
if (src == fromMassButton) {
Range<Double> mzRange = MzRangeMassCalculatorModule.showRangeCalculationDialog();
if (mzRange != null)
setValue(mzRange);
}
if (src == fromFormulaButton) {
Range<Double> mzRange = MzRangeFormulaCalculatorModule.showRangeCalculationDialog();
if (mzRange != null)
setValue(mzRange);
}
}
Aggregations