Package dk.gtz.graphedit.util
Class EditorActions
java.lang.Object
dk.gtz.graphedit.util.EditorActions
The central point of all scriptable editor actions. These actions can help you modify the editor to your hearts content
Plans are in the works to have scripting language bindings to these functions
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddSaveListener(Runnable runner) Register a callback function that will be called when the project is saved.static ModelProjectResourcecreateNewModel(String modelName) Create a new empty project resource model object with a specified namestatic voidPrompt the user to create a new file, that will become a newModelProjectResourceand save it If the file already exists, nothing will be savedstatic voidcreateNewModelFile(ModelProjectResource newModel) Prompt the user to create a new file and save the provided model If the file already exists, nothing will be savedstatic voidexecuteRunTarget(ViewModelRunTarget selectedRunTarget) Execute the provided runtarget Note.static voidexportFiles(IExporter exporter, Collection<File> files) Export the provided files using the provided exporter This will prompt the user to pick a folder to export tostatic voidexportFiles(IExporter exporter, Collection<File> files, Path exportFolder) Export the provided files using the provided exporter to the provided folderstatic StringGet the primary directory where Graphedit looks for configurationsstatic ViewModelEditorSettingsLoads the global editor settings file and returns a viewmodel version of it.newFile()Will open a "save as" file picker OS-native dialoguestatic voidCreate a new project with a picker dialogue and open itstatic voidOpens the about info pane modalstatic voidOpen the editor modal panePrompt the user to pick a file of some provided typeopenFile(javafx.stage.FileChooser.ExtensionFilter filter) Prompt the user to pick a filePrompt the user to pick one or more files of some provided typeopenFiles(javafx.stage.FileChooser.ExtensionFilter filter) Prompt the user to pick one or more filesPrompt the user to pick a folderPrompt the user to pick a json filePrompt the user to pick one or more json filesstatic voidOpen the viewer modal panestatic voidOpens an FXML based modalstatic voidOpens an injected modalstatic voidOpen a file as a model file.static voidOpen specified path as a model file.static voidOpen the project picker dialogue and load the selected projectstatic voidopenProject(File projectPath) Will attempt to open the project file provided Note.openProjectPicker(javafx.stage.Window window) Will open the project picker dialoguestatic voidOpen the editor modal panestatic voidOpen the editor modal panestatic voidOpen the modal panestatic voidOpen the tip of the day modal panestatic voidquit()Will immediately quit the application with no hesitation.static voidredo()Perform a redo actionstatic booleanremoveSaveListener(Runnable runner) Remove a registered save callback functionstatic voidrestart()Restart the application.static voidsave()Saves the currently opened project to disk.static voidsaveAs()Saves the currently opened project to disk.static voidsaveEditorSettings(ViewModelEditorSettings settings) Save the global editor settings to disk.static voidsaveModelToFile(Path newFilePath, ModelProjectResource newModel) Save a specified model to a specified file pathstatic voidSave the currently opened project to diskstatic voidsaveProject(ModelProject project, Path projectFilePath) Save a model project to a specific filestatic Optional<javafx.scene.control.ButtonBar.ButtonData>showConfirmAllDialog(String questionTitle, String question, javafx.stage.Window window) Will prompt the user for a Confirm / Confirm All / Cancel action.showConfirmDialog(String questionTitle, String question, javafx.stage.Window window) Will prompt the user for a Confirm / Cancel actionstatic voidToggle between light and dark theme for the editorstatic voidundo()Perform an undo action
-
Method Details
-
quit
public static void quit()Will immediately quit the application with no hesitation. -
addSaveListener
Register a callback function that will be called when the project is saved. This is useful to detect things such as "unsaved changes" and similar- Parameters:
runner- The callback function to call when projects are saved
-
removeSaveListener
Remove a registered save callback function- Parameters:
runner- The callback function to remove- Returns:
- true if the callback function was removed
-
saveAs
public static void saveAs()Saves the currently opened project to disk. Will prompt the user for a path to save to. -
save
public static void save()Saves the currently opened project to disk. Will not throw any exceptions, but errors may be logged if something went awry. -
loadEditorSettings
Loads the global editor settings file and returns a viewmodel version of it. Note. Will provide a default setttings object if the file could not be loaded. Note. Will use the injected to serialize.- Returns:
- the viewmodel representation of the editor settings
-
saveEditorSettings
Save the global editor settings to disk. The location of the file is determined by Note. Will use the injected to serialize.- Parameters:
settings- the settings object to save to disk
-
openProject
Will attempt to open the project file provided Note. Will not prompt to save unsaved changes.- Parameters:
projectPath- the project file to load
-
openProject
public static void openProject()Open the project picker dialogue and load the selected project -
newProject
public static void newProject()Create a new project with a picker dialogue and open it -
restart
public static void restart()Restart the application. Note. Will not prompt to save unsaved changes. -
saveProject
Save a model project to a specific file- Parameters:
project- The model project to saveprojectFilePath- The file to attempt to save to
-
saveProject
public static void saveProject()Save the currently opened project to disk -
openProjectPicker
Will open the project picker dialogue- Parameters:
window- the associated window- Returns:
- Optionally a file if one was chosen otherwise empty
-
newFile
Will open a "save as" file picker OS-native dialogue- Returns:
- Optionally a file if one was chosen otherwise empty
-
toggleTheme
public static void toggleTheme()Toggle between light and dark theme for the editor -
openEditorSettings
public static void openEditorSettings()Open the editor modal pane -
openKeybinds
public static void openKeybinds()Open the viewer modal pane -
openTipOfTheDay
public static void openTipOfTheDay()Open the tip of the day modal pane -
openProjectSettings
public static void openProjectSettings()Open the editor modal pane -
openRunTargetsEditor
public static void openRunTargetsEditor()Open the editor modal pane -
openSearchPane
public static void openSearchPane()Open the modal pane -
openAboutPane
public static void openAboutPane()Opens the about info pane modal -
openModal
Opens an injected modal- Parameters:
node- The modal to showtitle- The title displayed at the top of the modal
-
openModal
Opens an FXML based modal- Parameters:
fxmlFile- the .fxml file to open, must be from the perspective oftitle- The title displayed at the top of the modal
-
undo
public static void undo()Perform an undo action -
redo
public static void redo()Perform a redo action -
executeRunTarget
Execute the provided runtarget Note. Will provide the action with all the default environment variables: PROJECT_NAME - the name of the currently open project PROJECT_DIR - the directory path to the currently open project- Parameters:
selectedRunTarget- the runtarget to execute
-
showConfirmDialog
public static Optional<Boolean> showConfirmDialog(String questionTitle, String question, javafx.stage.Window window) Will prompt the user for a Confirm / Cancel action- Parameters:
questionTitle- prompt titlequestion- the question to ask the userwindow- the parent window- Returns:
trueif the user selected the affirmative action,falseif user selected the negative action orOptional.emptyif the prompt was closed with no action selected
-
showConfirmAllDialog
public static Optional<javafx.scene.control.ButtonBar.ButtonData> showConfirmAllDialog(String questionTitle, String question, javafx.stage.Window window) Will prompt the user for a Confirm / Confirm All / Cancel action.- Parameters:
questionTitle- prompt titlequestion- the question to ask the userwindow- the parent window- Returns:
ButtonData.YESif the user selected the Confirm action,ButtonData.NOif user selected cancel,ButtonData.OTHERif user selected confirm-all action or empty if the prompt was closed with no action selected
-
createNewModelFile
Prompt the user to create a new file and save the provided model If the file already exists, nothing will be saved- Parameters:
newModel- The model to serialize and save
-
openJsonFile
Prompt the user to pick a json file- Returns:
- Possibly a file reference. Will be empty if the user cancelled the action
-
openFile
Prompt the user to pick a file of some provided type- Parameters:
description- Description of the allowed typefilterTypes- The accepted filename extensions- Returns:
- Possibly a file reference. Will be empty if the user cancelled the action
-
openFile
Prompt the user to pick a file- Parameters:
filter- filter the types of files that can be picked- Returns:
- Possibly a file reference. Will be empty if the user cancelled the action
-
openJsonFiles
Prompt the user to pick one or more json files- Returns:
- Possibly a list of file references. Will be empty if the user cancelled the action or selected no files
-
openFiles
Prompt the user to pick one or more files of some provided type- Parameters:
description- Description of the allowed typefilterTypes- The accepted filename extensions- Returns:
- Possibly a list of file references. Will be empty if the user cancelled the action or selected no files
-
openFiles
Prompt the user to pick one or more files- Parameters:
filter- filter the types of files that can be picked- Returns:
- Possibly a list of file references. Will be empty if the user cancelled the action or selected no files
-
openFolder
Prompt the user to pick a folder- Returns:
- Possibly a folder reference. Will be empty if the user cancelled the action
-
exportFiles
Export the provided files using the provided exporter This will prompt the user to pick a folder to export to- Parameters:
exporter- The exporter to usefiles- The files to export
-
exportFiles
Export the provided files using the provided exporter to the provided folder- Parameters:
exporter- The exporter to usefiles- The files to exportexportFolder- The folder to export to
-
openModel
public static void openModel()Open a file as a model file. Will prompt the user to pick a file -
openModel
Open specified path as a model file.- Parameters:
path- Path to a file to try to open as a model
-
createNewModelFile
public static void createNewModelFile()Prompt the user to create a new file, that will become a newModelProjectResourceand save it If the file already exists, nothing will be saved -
saveModelToFile
public static void saveModelToFile(Path newFilePath, ModelProjectResource newModel) throws IOException Save a specified model to a specified file path- Parameters:
newFilePath- The path to write tonewModel- The model to serialize and save- Throws:
IOException- If an I/O error ocurs writing or creating the file
-
createNewModel
Create a new empty project resource model object with a specified name- Parameters:
modelName- The name of the model- Returns:
- A new empty model project resource with no syntactic elements
-
getConfigDir
Get the primary directory where Graphedit looks for configurations- Returns:
- Filepath as a string
-