use of org.cytoscape.work.FinishStatus in project EnrichmentMapApp by BaderLab.
the class LoadSignatureSetsActionListener method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
// make sure that the minimum information is set in the current set of parameters
if (file.canRead()) {
// MKTODO warning LoadSignatureGMTFilesTask is side-effecting, it pulls the loaded genes into the EnrichmentMap object
LoadSignatureGMTFilesTask loadGMTs = new LoadSignatureGMTFilesTask(file, map, filterMetric);
TaskObserver taskObserver = new ResultTaskObserver() {
private SetOfGeneSets resultGeneSets;
private Set<String> filteredSignatureSets;
@Override
public void taskFinished(ObservableTask task) {
if (task instanceof FilterSignatureGSTask) {
resultGeneSets = task.getResults(SetOfGeneSets.class);
filteredSignatureSets = task.getResults(Set.class);
}
}
@Override
public void allFinished(FinishStatus finishStatus) {
geneSetCallback.accept(resultGeneSets);
filteredSignatureSetsCallback.accept(filteredSignatureSets);
}
};
taskManager.execute(loadGMTs.createTaskIterator(), taskObserver);
} else {
JOptionPane.showMessageDialog(application.getJFrame(), "Signature GMT file name not valid.\n", "Invalid File", JOptionPane.WARNING_MESSAGE);
}
}
use of org.cytoscape.work.FinishStatus in project EnrichmentMapApp by BaderLab.
the class SerialTestTaskManager method execute.
@Override
public void execute(TaskIterator iterator, TaskObserver observer) {
TaskMonitor monitor = mock(TaskMonitor.class);
FinishStatus finishStatus = null;
Task task = null;
try {
while (iterator.hasNext()) {
task = iterator.next();
if (tasksToIgnore.contains(task.getClass())) {
//System.out.println("Task Ignored: " + task.getClass());
continue;
}
task.run(monitor);
if (task instanceof ObservableTask && observer != null) {
observer.taskFinished((ObservableTask) task);
}
}
finishStatus = FinishStatus.getSucceeded();
} catch (Exception e) {
finishStatus = FinishStatus.newFailed(task, e);
throw new AssertionError("Task failed", e);
} finally {
if (observer != null) {
observer.allFinished(finishStatus);
}
}
}
use of org.cytoscape.work.FinishStatus in project EnrichmentMapApp by BaderLab.
the class BaseNetworkTest method buildEnrichmentMap.
protected void buildEnrichmentMap(EMCreationParameters params, DataSetFiles datasetFiles, Method method, String datasetName) {
List<DataSetParameters> dataSets = Arrays.asList(new DataSetParameters(datasetName, method, datasetFiles));
CreateEnrichmentMapTaskFactory taskFactory = masterMapTaskFactoryFactory.create(params, dataSets);
TaskIterator taskIterator = taskFactory.createTaskIterator();
// make sure the task iterator completes
TaskObserver observer = new TaskObserver() {
public void taskFinished(ObservableTask task) {
}
public void allFinished(FinishStatus finishStatus) {
if (finishStatus == null)
fail();
if (finishStatus.getType() != FinishStatus.Type.SUCCEEDED)
throw new AssertionError("TaskIterator Failed", finishStatus.getException());
}
};
SerialTestTaskManager testTaskManager = new SerialTestTaskManager();
testTaskManager.ignoreTask(CreateEMViewTask.class);
testTaskManager.execute(taskIterator, observer);
}
use of org.cytoscape.work.FinishStatus in project EnrichmentMapApp by BaderLab.
the class SerialTestTaskManager method execute.
@Override
public void execute(TaskIterator iterator, TaskObserver observer) {
TaskMonitor monitor = new NullTaskMonitor();
FinishStatus finishStatus = null;
Task task = null;
try {
while (iterator.hasNext()) {
task = iterator.next();
if (tasksToIgnore.contains(task.getClass())) {
//System.out.println("Task Ignored: " + task.getClass());
continue;
}
task.run(monitor);
if (task instanceof ObservableTask && observer != null) {
observer.taskFinished((ObservableTask) task);
}
}
finishStatus = FinishStatus.getSucceeded();
} catch (Exception e) {
finishStatus = FinishStatus.newFailed(task, e);
throw new AssertionError("Task failed", e);
} finally {
if (observer != null) {
observer.allFinished(finishStatus);
}
}
}
use of org.cytoscape.work.FinishStatus in project EnrichmentMapApp by BaderLab.
the class ControlPanelMediator method removeSignatureDataSets.
private void removeSignatureDataSets(EnrichmentMap map, EMViewControlPanel viewPanel) {
Set<EMSignatureDataSet> dataSets = viewPanel.getSelectedSignatureDataSets();
if (!dataSets.isEmpty()) {
if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(getControlPanel(), "Are you sure you want to remove the selected Signature Gene Sets\nand associated nodes?", "Remove Signature Gene Sets", JOptionPane.YES_NO_OPTION))
return;
RemoveSignatureDataSetsTask task = removeDataSetsTaskFactory.create(dataSets, map);
dialogTaskManager.execute(new TaskIterator(task), new TaskObserver() {
@Override
public void taskFinished(ObservableTask task) {
}
@Override
public void allFinished(FinishStatus finishStatus) {
viewPanel.updateDataSetSelector();
updateLegends(viewPanel);
viewPanel.getNetworkView().updateView();
}
});
}
}
Aggregations