use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class PeakListIdentificationTask method notifyRow.
/**
* Method notifies object about content update
*
* @param row to be notified
*/
private static void notifyRow(PeakListRow row) {
MZmineCore.getProjectManager().getCurrentProject().notifyObjectChanged(row, false);
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
}
use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class PrecursorDBSearchTask method run.
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
int count = 0;
try {
tasks = parseFile(dataBaseFile);
totalTasks = tasks.size();
if (!tasks.isEmpty()) {
// wait for the tasks to finish
while (!isCanceled() && !tasks.isEmpty()) {
for (int i = 0; i < tasks.size(); i++) {
if (tasks.get(i).isFinished() || tasks.get(i).isCanceled()) {
tasks.remove(i);
i--;
}
}
// wait for all sub tasks to finish
try {
Thread.sleep(100);
} catch (Exception e) {
cancel();
}
}
// cancelled
if (isCanceled()) {
tasks.stream().forEach(AbstractTask::cancel);
}
} else {
setStatus(TaskStatus.ERROR);
setErrorMessage("DB file was empty - or error while parsing " + dataBaseFile);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Could not read file " + dataBaseFile, e);
setStatus(TaskStatus.ERROR);
setErrorMessage(e.toString());
}
logger.info("Added " + matches.get() + " matches to possible precursors in library: " + dataBaseFile.getAbsolutePath());
// Add task description to peakList
peakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Possible precursor identification using MS/MS spectral database " + dataBaseFile, parameters));
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class SelectedRowsLocalSpectralDBSearchTask method run.
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
int count = 0;
if (peakListRows.length == 1) {
// add result frame
resultWindow = new SpectraIdentificationResultsWindow();
resultWindow.setVisible(true);
} else {
resultWindow = null;
}
try {
tasks = parseFile(dataBaseFile);
totalTasks = tasks.size();
if (!tasks.isEmpty()) {
// wait for the tasks to finish
while (!isCanceled() && !tasks.isEmpty()) {
for (int i = 0; i < tasks.size(); i++) {
if (tasks.get(i).isFinished() || tasks.get(i).isCanceled()) {
count += tasks.get(i).getCount();
tasks.remove(i);
i--;
}
}
// wait for all sub tasks to finish
try {
Thread.sleep(100);
} catch (Exception e) {
cancel();
}
}
// cancelled
if (isCanceled()) {
tasks.stream().forEach(AbstractTask::cancel);
}
} else {
setStatus(TaskStatus.ERROR);
setErrorMessage("DB file was empty - or error while parsing " + dataBaseFile);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Could not read file " + dataBaseFile, e);
setStatus(TaskStatus.ERROR);
setErrorMessage(e.toString());
}
logger.info("Added " + count + " spectral library matches");
if (resultWindow != null) {
resultWindow.setTitle("Matched " + count + " compounds for feature list row: " + peakListRows[0]);
resultWindow.setMatchingFinished();
resultWindow.revalidate();
resultWindow.repaint();
}
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
// work around to update feature list identities
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class StatusBarHandler method publish.
/**
* @see java.util.logging.Handler#publish(java.util.logging.LogRecord)
*/
public void publish(LogRecord record) {
// if the event level is below INFO, ignore it
if (record.getLevel().intValue() < infoLevel)
return;
// get Desktop instance
Desktop desktop = MZmineCore.getDesktop();
if (desktop == null)
return;
if (desktop.getMainWindow() == null)
return;
Date recordTime = new Date(record.getMillis());
// format the message
String formattedMessage = "[" + timeFormat.format(recordTime) + "]: " + record.getMessage();
// default color is black
Color messageColor = Color.black;
// display severe errors in red
if (record.getLevel().equals(Level.SEVERE))
messageColor = Color.red;
// set status bar text
desktop.setStatusBarText(formattedMessage, messageColor);
}
use of net.sf.mzmine.desktop.Desktop in project mzmine2 by mzmine.
the class LocalSpectralDBSearchTask method run.
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
int count = 0;
try {
tasks = parseFile(dataBaseFile);
totalTasks = tasks.size();
if (!tasks.isEmpty()) {
// wait for the tasks to finish
while (!isCanceled() && !tasks.isEmpty()) {
for (int i = 0; i < tasks.size(); i++) {
if (tasks.get(i).isFinished() || tasks.get(i).isCanceled()) {
count += tasks.get(i).getCount();
tasks.remove(i);
i--;
}
}
// wait for all sub tasks to finish
try {
Thread.sleep(100);
} catch (Exception e) {
cancel();
}
}
// cancelled
if (isCanceled()) {
tasks.stream().forEach(AbstractTask::cancel);
}
} else {
setStatus(TaskStatus.ERROR);
setErrorMessage("DB file was empty - or error while parsing " + dataBaseFile);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Could not read file " + dataBaseFile, e);
setStatus(TaskStatus.ERROR);
setErrorMessage(e.toString());
}
logger.info("Added " + count + " spectral library matches");
// Add task description to peakList
peakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Peak identification using MS/MS spectral database " + dataBaseFile, parameters));
// Repaint the window to reflect the change in the feature list
Desktop desktop = MZmineCore.getDesktop();
if (!(desktop instanceof HeadLessDesktop))
desktop.getMainWindow().repaint();
setStatus(TaskStatus.FINISHED);
}
Aggregations