Search in sources :

Example 1 with ScriptableWorkflowStep

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);
}
Also used : Button(javafx.scene.control.Button) ListCell(javafx.scene.control.ListCell) LoggerFactory(org.slf4j.LoggerFactory) KeyCombination(javafx.scene.input.KeyCombination) ParameterList(qupath.lib.plugins.parameters.ParameterList) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) TableView(javafx.scene.control.TableView) QuPathGUI(qupath.lib.gui.QuPathGUI) Pane(javafx.scene.layout.Pane) Orientation(javafx.geometry.Orientation) SplitPane(javafx.scene.control.SplitPane) MenuItem(javafx.scene.control.MenuItem) BufferedImage(java.awt.image.BufferedImage) WorkflowStep(qupath.lib.plugins.workflow.WorkflowStep) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Platform(javafx.application.Platform) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) Clipboard(javafx.scene.input.Clipboard) SimplePluginWorkflowStep(qupath.lib.plugins.workflow.SimplePluginWorkflowStep) Entry(java.util.Map.Entry) ObservableList(javafx.collections.ObservableList) ClipboardContent(javafx.scene.input.ClipboardContent) BorderPane(javafx.scene.layout.BorderPane) StringProperty(javafx.beans.property.StringProperty) Scene(javafx.scene.Scene) ListView(javafx.scene.control.ListView) WorkflowListener(qupath.lib.plugins.workflow.WorkflowListener) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ScriptEditor(qupath.lib.gui.scripting.ScriptEditor) PathPlugin(qupath.lib.plugins.PathPlugin) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) Dialogs(qupath.lib.gui.dialogs.Dialogs) TableCell(javafx.scene.control.TableCell) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) ImageData(qupath.lib.images.ImageData) KeyCode(javafx.scene.input.KeyCode) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) Workflow(qupath.lib.plugins.workflow.Workflow) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) ScriptableWorkflowStep(qupath.lib.plugins.workflow.ScriptableWorkflowStep) SelectionMode(javafx.scene.control.SelectionMode) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) Collections(java.util.Collections) PaneTools(qupath.lib.gui.tools.PaneTools) ScriptableWorkflowStep(qupath.lib.plugins.workflow.ScriptableWorkflowStep) ClipboardContent(javafx.scene.input.ClipboardContent)

Example 2 with ScriptableWorkflowStep

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
    }
}
Also used : PathPlugin(qupath.lib.plugins.PathPlugin) ScriptableWorkflowStep(qupath.lib.plugins.workflow.ScriptableWorkflowStep) SimplePluginWorkflowStep(qupath.lib.plugins.workflow.SimplePluginWorkflowStep) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BufferedImage (java.awt.image.BufferedImage)2 PathPlugin (qupath.lib.plugins.PathPlugin)2 ScriptableWorkflowStep (qupath.lib.plugins.workflow.ScriptableWorkflowStep)2 SimplePluginWorkflowStep (qupath.lib.plugins.workflow.SimplePluginWorkflowStep)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Platform (javafx.application.Platform)1 ObjectProperty (javafx.beans.property.ObjectProperty)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)1 StringProperty (javafx.beans.property.StringProperty)1 ChangeListener (javafx.beans.value.ChangeListener)1 ObservableValue (javafx.beans.value.ObservableValue)1 ObservableList (javafx.collections.ObservableList)1 Orientation (javafx.geometry.Orientation)1