Class PromptActions

java.lang.Object
io.github.jbastgen.stemma.app.ui.dialog.PromptActions

public final class PromptActions extends Object
What can be done with the prompts of the library, shared by the favourites panel of the Cowork view and the dialog that manages all prompts: new, edit (a form), delete or hide (after a question), favourites, categories. Every change is written to the prompt file at once and then changed runs, so both places show the same library.
  • Constructor Details

    • PromptActions

      public PromptActions(CoworkView.Backend backend, Path file, Runnable changed)
      Parameters:
      backend - what the view offers: toasts, forms and questions
      file - the prompt file of the user
      changed - runs after every change, so the views show the new library
  • Method Details

    • change

      public void change(PromptActions.FileChange change, String done)
      Runs a change of the prompt file, tells the views and says done (already translated) when it is not empty.
    • newPrompt

      public void newPrompt(String title, String text)
      A form for a new prompt, prefilled with a title and text; it is a favourite unless the box is cleared.
    • editPrompt

      public void editPrompt(CoworkPrompts.Prompt p)
      A form to change a prompt. A ready-made prompt becomes one of the user's own (a copy) and the original is hidden.
    • removePrompt

      public void removePrompt(CoworkPrompts.Prompt p)
      Asks, then deletes one of the user's own prompts, or hides a ready-made one.
    • setFavorite

      public void setFavorite(CoworkPrompts.Prompt p, boolean favorite)
      Marks the prompt as a favourite or not.
    • restore

      public void restore()
      Brings back the built-in prompts that were hidden or edited.
    • renameCategory

      public void renameCategory(String category)
      A form with the name of a category.
    • removeCategory

      public void removeCategory(String category)
      Asks, then removes a category with its prompts: the user's own are deleted, the ready-made ones hidden.