package application.helpers; import application.UICoordinator; import application.enums.NavState; import application.helpers.wrappers.WrappedException; /** * Callback for the communication between the thread * {@link WorkWhileProgressThread} and the {@link UICoordinator} * * @author Bianca * */ public class ChangeViewCallback { /** * Coordinator for accessing */ private UICoordinator coord; public ChangeViewCallback(UICoordinator coord) { this.coord = coord; } /** * Calls the {@code fillDataList} method of the {@link UICoordinator}. Reads in * the health data. * * @throws WrappedException if there was an error reading the file */ public void callFillDataList() throws WrappedException { this.coord.fillDataList(); } /** * Calls the {@code createTempFiles} method of the {@link UICoordinator}. * Creates the temp files. * * @throws WrappedException If there was an error creating or writing to the * files */ public void callCreateTempFiles() throws WrappedException { this.coord.createTempFiles(); } /** * Changes to the overview view */ public void callOverview() { this.coord.changeView(this.coord.getOverviewView()); this.coord.updateNav(NavState.SELECT_DATA); } /** * In case an error occurred while the health data was read, the * {@link UICoordinator} will be informed. * * @param text The user readable information about the error. */ public void callErrorReadingFile(String text) { this.coord.setErrorReadingFile(text); } /** * In case an error occurred while the files were written, the * {@link UICoordinator} will be informed. * * @param text The user readable information about the error. */ public void callErrorWritingTemFiles(String text) { this.coord.setErrorWritingTempFiles(text); } /** * Changes to the inspect view */ public void callInspect() { this.coord.changeView(this.coord.getInspectView()); this.coord.updateNav(NavState.INSPECT); } /** * Changes to the inspect view after an error occurred. */ public void callInspectWithError() { this.coord.changeView(this.coord.getInspectView()); this.coord.updateNav(NavState.INSPECT_WITH_ERROR); } }