use of qupath.lib.plugins.workflow.ScriptableWorkflowStep in project qupath by qupath.
the class WorkflowCommandLogView method copyScriptToClipboard.
private void copyScriptToClipboard(List<Integer> indices) {
var steps = getWorkflow().getSteps();
var script = indices.stream().map(index -> ((ScriptableWorkflowStep) steps.get(index)).getScript()).collect(Collectors.joining(System.lineSeparator()));
ClipboardContent content = new ClipboardContent();
content.putString(script);
Clipboard.getSystemClipboard().setContent(content);
}
use of qupath.lib.plugins.workflow.ScriptableWorkflowStep in project qupath by qupath.
the class WorkflowCommandLogView method runWorkflowStepInteractively.
/**
* Launch a plugin dialog for a specified WorkflowStep.
*
* TODO: Run any scriptable step
*
* @param qupath
* @param step
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void runWorkflowStepInteractively(final QuPathGUI qupath, final WorkflowStep step) {
ImageData<BufferedImage> imageData = qupath.getImageData();
if (imageData == null) {
Dialogs.showNoImageError("Run workflow step");
return;
}
if (step instanceof SimplePluginWorkflowStep) {
if (step instanceof SimplePluginWorkflowStep) {
SimplePluginWorkflowStep pluginStep = (SimplePluginWorkflowStep) step;
String pluginClassName = pluginStep.getPluginClass();
PathPlugin<BufferedImage> plugin = null;
try {
Class<? extends PathPlugin> cls = (Class<? extends PathPlugin>) Class.forName(pluginClassName);
plugin = qupath.createPlugin(cls);
Map<String, ?> parameterMap = pluginStep.getParameterMap();
String arg = null;
if (parameterMap != null && !parameterMap.isEmpty()) {
arg = ParameterList.getParameterListJSON(parameterMap, " ");
}
qupath.runPlugin(plugin, arg, true);
} catch (ClassNotFoundException e1) {
Dialogs.showErrorNotification("Plugin class not found", "No plugin class found with name " + pluginClassName);
} catch (Exception e1) {
Dialogs.showErrorNotification("Plugin error", "Error running plugin " + plugin.getName() + " - see log for details");
logger.error(e1.getLocalizedMessage(), e1);
}
}
} else if (step instanceof ScriptableWorkflowStep) {
// TODO: Run command script
}
}
Aggregations