use of net.sf.mzmine.modules.visualization.molstructure.MolStructureViewer in project mzmine2 by mzmine.
the class ResultWindow method actionPerformed.
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("ADD")) {
int index = IDList.getSelectedRow();
if (index < 0) {
MZmineCore.getDesktop().displayMessage(this, "Select one result to add as compound identity");
return;
}
index = IDList.convertRowIndexToModel(index);
peakListRow.addPeakIdentity(listElementModel.getCompoundAt(index), false);
// Notify the GUI about the change in the project
MZmineCore.getProjectManager().getCurrentProject().notifyObjectChanged(peakListRow, false);
// Repaint the window to reflect the change in the feature list
MZmineCore.getDesktop().getMainWindow().repaint();
dispose();
}
if (command.equals("VIEWER")) {
int index = IDList.getSelectedRow();
if (index < 0) {
MZmineCore.getDesktop().displayMessage(this, "Select one result to display molecule structure");
return;
}
index = IDList.convertRowIndexToModel(index);
DBCompound compound = listElementModel.getCompoundAt(index);
URL url2D = compound.get2DStructureURL();
URL url3D = compound.get3DStructureURL();
String name = compound.getName() + " (" + compound.getPropertyValue(PeakIdentity.PROPERTY_ID) + ")";
MolStructureViewer viewer = new MolStructureViewer(name, url2D, url3D);
viewer.setVisible(true);
}
if (command.equals("ISOTOPE_VIEWER")) {
int index = IDList.getSelectedRow();
if (index < 0) {
MZmineCore.getDesktop().displayMessage(this, "Select one result to display the isotope pattern");
return;
}
index = IDList.convertRowIndexToModel(index);
final IsotopePattern predictedPattern = listElementModel.getCompoundAt(index).getIsotopePattern();
if (predictedPattern == null)
return;
Feature peak = peakListRow.getBestPeak();
RawDataFile dataFile = peak.getDataFile();
int scanNumber = peak.getRepresentativeScanNumber();
SpectraVisualizerModule.showNewSpectrumWindow(dataFile, scanNumber, null, peak.getIsotopePattern(), predictedPattern);
}
if (command.equals("BROWSER")) {
int index = IDList.getSelectedRow();
if (index < 0) {
MZmineCore.getDesktop().displayMessage(this, "Select one compound to display in a web browser");
return;
}
index = IDList.convertRowIndexToModel(index);
logger.finest("Launching default browser to display compound details");
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
DBCompound compound = listElementModel.getCompoundAt(index);
String urlString = compound.getPropertyValue(PeakIdentity.PROPERTY_URL);
if ((urlString == null) || (urlString.length() == 0))
return;
try {
URL compoundURL = new URL(urlString);
desktop.browse(compoundURL.toURI());
} catch (Exception ex) {
logger.severe("Error trying to launch default browser: " + ex.getMessage());
}
}
}
Aggregations