Class MainController
- java.lang.Object
-
- ui.main.MainController
-
public final class MainController extends java.lang.ObjectThe MainController class is used communicate with and control the main GUI.Communication is done through FXML, through the use of labels in the FXML file and annotations in this Java class.
- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description MainController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidexitProgram()Ends the JavaFX application and exits the program.(package private) voidinitialize()Runs when the main GUI is started up.(package private) voidlimitInputSize()Limits the amount of characters that can be placed within the tab size label.(package private) voidnewFile()Creates a new file.(package private) voidopenFileChooser()Opens a window for opening a file.(package private) voidopenHomePage()Opens the GitHub repository page in the browser.(package private) voidopenRepl()Opens the REPL window.(package private) voidopenWikiPage()Opens the GitHub wiki page in the browser.(package private) voidrunSource()Evaluates the users input and displays the output.(package private) voidsaveFile()Saves a file currently in progress.(package private) voidsaveFileAs()Opens a window for saving a file.(package private) voidupdateLineInfo()Updates the current position of the caret.(package private) voidupdateTabSize()Updates the amount of spaces generated by the tab key when pressed.
-
-
-
Method Detail
-
initialize
void initialize()
Runs when the main GUI is started up.Is used to initialise the AlertManager, FileManager, and CodeAreaManager so that they are ready for use.
-
runSource
void runSource()
Evaluates the users input and displays the output.The input given by the user is retrieved by the CodeAreaManager, and then compiled by the Compiler. The TextFlow is cleared, then result is then added to it.
-
openRepl
void openRepl() throws java.io.IOExceptionOpens the REPL window.- Throws:
java.io.IOException- If the path is not found
-
updateLineInfo
void updateLineInfo()
Updates the current position of the caret.This method executes every time the user moves the caret along the text in some way. The new position is retrieved by the CodeAreaManager, and then the Label displaying the line number is updated.
-
updateTabSize
void updateTabSize()
Updates the amount of spaces generated by the tab key when pressed.This method runs whenever the user updates the tab size field.
-
limitInputSize
void limitInputSize()
Limits the amount of characters that can be placed within the tab size label.To prevent the user overflowing the tab size field, its character limit is set to 2. This method is called whenever the user tries to update the field, and checks to ensure the input is valid.
-
newFile
void newFile()
Creates a new file.If the user currently has unsaved work, a confirmation alert will appear asking them if they wish to continue.
-
openFileChooser
void openFileChooser()
Opens a window for opening a file.If the user currently has unsaved work, a confirmation alert will appear asking them if they wish to continue.
If the user attempts to open a file they don't have permission to access, uses an invalid file extensions, or no longer exists since being selected, an error alert is shown.
-
saveFile
void saveFile()
Saves a file currently in progress.If the file has since been moved, renamed, deleted, or externally updated in any way since being opened, the 'save as' window will open instead.
-
saveFileAs
void saveFileAs()
Opens a window for saving a file.If the user attempts to save to a file they don't have permission to access, or no longer exists since being selected, an error alert is shown.
-
exitProgram
void exitProgram()
Ends the JavaFX application and exits the program.If the user has unsaved work, this method will show a confirmation alert asking them if they wish to continue.
-
openWikiPage
void openWikiPage() throws java.io.IOExceptionOpens the GitHub wiki page in the browser.This method opens the users default browser, and is designed to work with all major operating systems.
- Throws:
java.io.IOException- If the path is not valid
-
openHomePage
void openHomePage() throws java.io.IOExceptionOpens the GitHub repository page in the browser.This method opens the users default browser, and is designed to work with all major operating systems.
- Throws:
java.io.IOException- If the path is not valid
-
-