use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.
the class PeakListTableWindow method actionPerformed.
/**
* Methods for ActionListener interface implementation
*/
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.equals("PROPERTIES")) {
ExitCode exitCode = parameters.showSetupDialog(this, true);
if (exitCode == ExitCode.OK) {
int rowHeight = parameters.getParameter(PeakListTableParameters.rowHeight).getValue();
table.setRowHeight(rowHeight);
PeakListTableColumnModel cm = (PeakListTableColumnModel) table.getColumnModel();
cm.createColumns();
}
}
if (command.equals("AUTOCOLUMNWIDTH")) {
// Auto size column width based on data
for (int column = 0; column < table.getColumnCount(); column++) {
TableColumn tableColumn = table.getColumnModel().getColumn(column);
if (tableColumn.getHeaderValue() != "Peak shape" && tableColumn.getHeaderValue() != "Status") {
TableCellRenderer renderer = tableColumn.getHeaderRenderer();
if (renderer == null) {
renderer = table.getTableHeader().getDefaultRenderer();
}
Component component = renderer.getTableCellRendererComponent(table, tableColumn.getHeaderValue(), false, false, -1, column);
int preferredWidth = component.getPreferredSize().width + 20;
tableColumn.setPreferredWidth(preferredWidth);
}
}
}
if (command.equals("PRINT")) {
try {
table.print(PrintMode.FIT_WIDTH);
} catch (PrinterException e) {
MZmineCore.getDesktop().displayException(this, e);
}
}
}
use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.
the class MSMSExportModule method exportMSMS.
public static void exportMSMS(PeakListRow row) {
ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(MSMSExportModule.class);
ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
if (exitCode != ExitCode.OK)
return;
File outputFile = parameters.getParameter(MSMSExportParameters.outputFile).getValue();
String massListName = parameters.getParameter(MSMSExportParameters.massList).getValue();
if ((outputFile == null) || (massListName == null))
return;
// Best peak always exists, because feature list row has at least one peak
Feature bestPeak = row.getBestPeak();
// Get the MS/MS scan number
int msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
if (msmsScanNumber < 1) {
MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no MS/MS scan for peak " + bestPeak);
return;
}
// MS/MS scan must exist, because msmsScanNumber was > 0
Scan msmsScan = bestPeak.getDataFile().getScan(msmsScanNumber);
MassList massList = msmsScan.getMassList(massListName);
if (massList == null) {
MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no mass list called " + massListName + " for MS/MS scan #" + msmsScanNumber + " (" + bestPeak.getDataFile() + ")");
return;
}
DataPoint[] peaks = massList.getDataPoints();
try {
FileWriter fileWriter = new FileWriter(outputFile);
BufferedWriter writer = new BufferedWriter(fileWriter);
for (DataPoint peak : peaks) {
writer.write(peak.getMZ() + " " + peak.getIntensity());
writer.newLine();
}
writer.close();
} catch (Exception e) {
e.printStackTrace();
MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Error writing to file " + outputFile + ": " + ExceptionUtils.exceptionToString(e));
}
}
use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.
the class IntensityPlotModule method showIntensityPlot.
public static void showIntensityPlot(@Nonnull MZmineProject project, PeakList peakList, PeakListRow[] rows) {
ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(IntensityPlotModule.class);
parameters.getParameter(IntensityPlotParameters.peakList).setValue(PeakListsSelectionType.SPECIFIC_PEAKLISTS, new PeakList[] { peakList });
parameters.getParameter(IntensityPlotParameters.dataFiles).setChoices(peakList.getRawDataFiles());
parameters.getParameter(IntensityPlotParameters.dataFiles).setValue(peakList.getRawDataFiles());
parameters.getParameter(IntensityPlotParameters.selectedRows).setValue(rows);
UserParameter<?, ?>[] projectParams = project.getParameters();
Object[] xAxisSources = new Object[projectParams.length + 1];
xAxisSources[0] = IntensityPlotParameters.rawDataFilesOption;
for (int i = 0; i < projectParams.length; i++) {
xAxisSources[i + 1] = new ParameterWrapper(projectParams[i]);
}
parameters.getParameter(IntensityPlotParameters.xAxisValueSource).setChoices(xAxisSources);
ExitCode exitCode = parameters.showSetupDialog(null, true);
if (exitCode == ExitCode.OK) {
PeakListRow[] selectedRows = parameters.getParameter(IntensityPlotParameters.selectedRows).getMatchingRows(peakList);
if (selectedRows.length == 0) {
MZmineCore.getDesktop().displayErrorMessage(null, "No rows selected");
return;
}
IntensityPlotWindow newFrame = new IntensityPlotWindow(parameters.cloneParameterSet());
newFrame.setVisible(true);
}
}
use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.
the class PeakListsComponent method actionPerformed.
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == detailsButton) {
PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
if (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS) {
final MultiChoiceParameter<PeakList> plsParameter = new MultiChoiceParameter<PeakList>("Select feature lists", "Select feature lists", MZmineCore.getProjectManager().getCurrentProject().getPeakLists(), currentValue.getSpecificPeakLists());
final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { plsParameter });
final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
if (exitCode == ExitCode.OK) {
PeakList[] pls = paramSet.getParameter(plsParameter).getValue();
currentValue.setSpecificPeakLists(pls);
}
}
if (type == PeakListsSelectionType.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) {
PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
currentValue.setSelectionType(type);
detailsButton.setEnabled((type == PeakListsSelectionType.NAME_PATTERN) || (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS));
}
updateNumPeakLists();
}
use of net.sf.mzmine.util.ExitCode 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();
}
Aggregations