Class DefaultScriptEditor

java.lang.Object
qupath.lib.gui.scripting.DefaultScriptEditor
All Implemented Interfaces:
ScriptEditor
Direct Known Subclasses:
RichScriptEditor

public class DefaultScriptEditor extends Object implements ScriptEditor
Default multilingual script editor.

Lacks syntax highlighting and other pleasant features, unfortunately.

  • Property Details

  • Field Details

    • comboPasteEscape

      protected KeyCombination comboPasteEscape
    • completionCodeCombination

      protected final KeyCodeCombination completionCodeCombination
    • beautifySourceAction

      protected org.controlsfx.control.action.Action beautifySourceAction
    • compressSourceAction

      protected org.controlsfx.control.action.Action compressSourceAction
    • copyAction

      protected org.controlsfx.control.action.Action copyAction
    • cutAction

      protected org.controlsfx.control.action.Action cutAction
    • pasteAction

      protected org.controlsfx.control.action.Action pasteAction
    • pasteAndEscapeAction

      protected org.controlsfx.control.action.Action pasteAndEscapeAction
    • undoAction

      protected org.controlsfx.control.action.Action undoAction
    • redoAction

      protected org.controlsfx.control.action.Action redoAction
    • runScriptAction

      protected org.controlsfx.control.action.Action runScriptAction
    • runSelectedAction

      protected org.controlsfx.control.action.Action runSelectedAction
    • runProjectScriptAction

      protected org.controlsfx.control.action.Action runProjectScriptAction
    • runProjectScriptNoSaveAction

      protected org.controlsfx.control.action.Action runProjectScriptNoSaveAction
    • killRunningScriptAction

      protected org.controlsfx.control.action.Action killRunningScriptAction
    • insertMuAction

      protected org.controlsfx.control.action.Action insertMuAction
    • insertQPImportAction

      protected org.controlsfx.control.action.Action insertQPImportAction
    • insertQPExImportAction

      protected org.controlsfx.control.action.Action insertQPExImportAction
    • insertAllDefaultImportAction

      protected org.controlsfx.control.action.Action insertAllDefaultImportAction
    • insertPixelClassifiersAction

      protected org.controlsfx.control.action.Action insertPixelClassifiersAction
    • insertObjectClassifiersAction

      protected org.controlsfx.control.action.Action insertObjectClassifiersAction
    • insertDetectionMeasurementsAction

      protected org.controlsfx.control.action.Action insertDetectionMeasurementsAction
    • findAction

      protected org.controlsfx.control.action.Action findAction
    • smartEditingAction

      protected org.controlsfx.control.action.Action smartEditingAction
    • smartEditing

      protected BooleanProperty smartEditing
  • Constructor Details

    • DefaultScriptEditor

      public DefaultScriptEditor(QuPathGUI qupath)
      Constructor.
      Parameters:
      qupath - current QuPath instance.
  • Method Details

    • supportsFile

      public boolean supportsFile(File file)
      Query whether a file represents a supported script. Currently, this test looks at the file extension only.
      Specified by:
      supportsFile in interface ScriptEditor
      Parameters:
      file - the file to test
      Returns:
      true if the file is likely to contain a supported script, false otherwise
    • requestClose

      public boolean requestClose()
      Description copied from interface: ScriptEditor
      Attempt to close the editor, saving changes if requested.
      Specified by:
      requestClose in interface ScriptEditor
      Returns:
      True if the editor can be closed without losing changes, unless the user consents to losing changes.
    • getStage

      public Stage getStage()
      Get the stage for this script editor.
      Returns:
    • scriptRunning

      public ObservableValue<Boolean> scriptRunning()
      Observable value indicating whether a script is currently running or not. This can be used (for example) to determine whether a user action should be blocked until the script has completed.
      Returns:
    • promptToSetFontSize

      protected void promptToSetFontSize()
      Update the font size for the script editor and console.
    • addNewScript

      public void addNewScript(String script, ScriptLanguage language, boolean doSelect)
      Create a new script in the specified language.
      Parameters:
      script - text of the script to add
      language - language of the script
      doSelect - if true, select the script when it is added
    • selectedScriptProperty

      protected ReadOnlyObjectProperty<ScriptTab> selectedScriptProperty()
      Get a property representing the current selected ScriptTab.
      Returns:
    • getNewConsole

      protected ScriptEditorControl<?> getNewConsole()
    • createNewEditor

      public ScriptEditorControl<?> createNewEditor()
    • getNewEditor

      protected ScriptEditorControl<?> getNewEditor()
    • currentLanguageProperty

      protected ReadOnlyObjectProperty<ScriptLanguage> currentLanguageProperty()
      Returns:
      the currentLanguage property
      See Also:
    • currentSyntaxProperty

      protected ReadOnlyObjectProperty<ScriptSyntax> currentSyntaxProperty()
      Returns:
      the currentSyntax property
      See Also:
    • getCurrentLanguage

      protected ScriptLanguage getCurrentLanguage()
      Gets the value of the currentLanguage property.
      Property description:
      Returns:
      the value of the currentLanguage property
      See Also:
    • getCurrentSyntax

      protected ScriptSyntax getCurrentSyntax()
      Gets the value of the currentSyntax property.
      Property description:
      Returns:
      the value of the currentSyntax property
      See Also:
    • getCurrentScriptTab

      protected ScriptTab getCurrentScriptTab()
    • getCurrentEditorControl

      protected ScriptEditorControl<? extends Region> getCurrentEditorControl()
    • getCurrentConsoleControl

      protected ScriptEditorControl<? extends Region> getCurrentConsoleControl()
    • getSelectedText

      protected String getSelectedText()
    • getCurrentText

      protected String getCurrentText()
    • sendLogToConsoleProperty

      protected ObservableBooleanValue sendLogToConsoleProperty()
      Boolean property indicating whether the console should display the log, rather than directly-printed information.
      Returns:
    • getClipboardText

      public static String getClipboardText(boolean escapeCharacters)
      Get the text from the system clipboard, optionally escaping characters. This is useful when trying to avoid path trouble on Windows with unescaped characters.

      This command also queries the clipboard for files, using their paths where available.

      Parameters:
      escapeCharacters - if true, escape characters using Java language rules
      Returns:
      the clipboard text
    • pasteFromClipboard

      protected static boolean pasteFromClipboard(ScriptEditorControl<?> control, boolean escapeCharacters)
    • showEditor

      public void showEditor()
      Description copied from interface: ScriptEditor
      Show the script editor.
      Specified by:
      showEditor in interface ScriptEditor
    • showScript

      public void showScript(String name, String script)
      Description copied from interface: ScriptEditor
      Show the script editor, including a new script with the specified name.
      Specified by:
      showScript in interface ScriptEditor
      Parameters:
      name - name of the script to show
      script - content of the script
    • showScript

      public void showScript(File file)
      Description copied from interface: ScriptEditor
      Show the script editor, opening an existing script file.
      Specified by:
      showScript in interface ScriptEditor
      Parameters:
      file - the script file