use of org.cytoscape.work.TaskObserver 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.TaskObserver 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.TaskObserver 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();
}
});
}
}
use of org.cytoscape.work.TaskObserver in project EnrichmentMapApp by BaderLab.
the class ControlPanelMediator method applyVisualStyle.
private void applyVisualStyle(EMStyleOptions options, CyCustomGraphics2<?> chart, boolean updateChartOnly) {
ApplyEMStyleTask task = applyStyleTaskFactory.create(options, chart, updateChartOnly);
dialogTaskManager.execute(new TaskIterator(task), new TaskObserver() {
@Override
public void taskFinished(ObservableTask task) {
}
@Override
public void allFinished(FinishStatus finishStatus) {
EMViewControlPanel viewPanel = getControlPanel().getViewControlPanel(options.getNetworkView());
updateLegends(viewPanel);
}
});
}
use of org.cytoscape.work.TaskObserver in project EnrichmentMapApp by BaderLab.
the class MasterDetailDialogPage method scan.
private void scan() {
Optional<File> rootFolder = fileBrowser.browseForRootFolder(jframeProvider.get());
if (rootFolder.isPresent()) {
scanButton.setEnabled(false);
ResolverTask task = new ResolverTask(rootFolder.get());
dialogTaskManager.execute(new TaskIterator(task), new TaskObserver() {
@Override
public void taskFinished(ObservableTask task) {
@SuppressWarnings("unchecked") List<DataSetParameters> datasets = task.getResults(List.class);
if (!datasets.isEmpty()) {
datasets.forEach(MasterDetailDialogPage.this::addDataSetToList);
dataSetList.setSelectedValue(datasets.get(0), true);
}
}
@Override
public void allFinished(FinishStatus finishStatus) {
scanButton.setEnabled(true);
updateButtonEnablement();
}
});
}
}
Aggregations