use of net.sf.mzmine.project.parameterssetup.ProjectParametersSetupDialog in project mzmine2 by mzmine.
the class MainMenu method actionPerformed.
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
MZmineRunnableModule module = moduleMenuItems.get(src);
if (module != null) {
ParameterSet moduleParameters = MZmineCore.getConfiguration().getModuleParameters(module.getClass());
RawDataFile[] selectedFiles = MZmineCore.getDesktop().getSelectedDataFiles();
if (selectedFiles.length > 0) {
for (Parameter<?> p : moduleParameters.getParameters()) {
if (p instanceof RawDataFilesParameter) {
RawDataFilesParameter rdp = (RawDataFilesParameter) p;
rdp.setValue(RawDataFilesSelectionType.GUI_SELECTED_FILES);
}
}
}
PeakList[] selectedPeakLists = MZmineCore.getDesktop().getSelectedPeakLists();
if (selectedPeakLists.length > 0) {
for (Parameter<?> p : moduleParameters.getParameters()) {
if (p instanceof PeakListsParameter) {
PeakListsParameter plp = (PeakListsParameter) p;
plp.setValue(PeakListsSelectionType.GUI_SELECTED_PEAKLISTS);
}
}
}
logger.finest("Setting parameters for module " + module.getName());
ExitCode exitCode = moduleParameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
if (exitCode == ExitCode.OK) {
ParameterSet parametersCopy = moduleParameters.cloneParameterSet();
logger.finest("Starting module " + module.getName() + " with parameters " + parametersCopy);
ArrayList<Task> tasks = new ArrayList<Task>();
MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
module.runModule(project, parametersCopy, tasks);
MZmineCore.getTaskController().addTasks(tasks.toArray(new Task[0]));
}
return;
}
if (src == projectExit) {
MZmineCore.getDesktop().exitMZmine();
}
if (src == projectSaveParameters) {
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showSaveDialog(MZmineCore.getDesktop().getMainWindow());
if (returnVal == JFileChooser.APPROVE_OPTION) {
File configFile = chooser.getSelectedFile();
try {
MZmineCore.getConfiguration().saveConfiguration(configFile);
} catch (Exception ex) {
MZmineCore.getDesktop().displayException(MZmineCore.getDesktop().getMainWindow(), ex);
}
}
}
if (src == projectLoadParameters) {
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showOpenDialog(MZmineCore.getDesktop().getMainWindow());
if (returnVal == JFileChooser.APPROVE_OPTION) {
File configFile = chooser.getSelectedFile();
try {
MZmineCore.getConfiguration().loadConfiguration(configFile);
} catch (Exception ex) {
MZmineCore.getDesktop().displayException(MZmineCore.getDesktop().getMainWindow(), ex);
}
}
}
if (src == projectSampleParameters) {
ProjectParametersSetupDialog dialog = new ProjectParametersSetupDialog();
dialog.setVisible(true);
}
if (src == projectPreferences) {
MZminePreferences preferences = MZmineCore.getConfiguration().getPreferences();
preferences.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
}
if (src == showAbout) {
MainWindow mainWindow = (MainWindow) MZmineCore.getDesktop();
mainWindow.showAboutDialog();
}
if (src == checkUpdate) {
// Check for updated version
NewVersionCheck NVC = new NewVersionCheck(CheckType.MENU);
new Thread(NVC).start();
}
}
Aggregations