diff --git a/.config b/.config new file mode 100644 index 0000000..59f785a --- /dev/null +++ b/.config @@ -0,0 +1 @@ +UID:f52f7d72-f67e-4eed-8218-8d8e2923ff02 diff --git a/src/main/java/core/Help.java b/src/main/java/core/Help.java index 6534ee5..6f69a88 100644 --- a/src/main/java/core/Help.java +++ b/src/main/java/core/Help.java @@ -62,7 +62,8 @@ public void answerActivity() { } } - private Component getTips(){ + + public String getTipText(){ final String tipText = heading("Running Courses") + "Dashboard provides a mechanism for you to effectively keep track of the courses you " + "register for every semester. Go to "+reference("Home", "This Semester")+". " + @@ -167,8 +168,11 @@ private Component getTips(){ subHeading("About UTG") + "You can visit the UTG official site to learn more about the University of the Gambia. " + "Click the About UTG Button appearing at the top-right of your Dashboard.
"; + return tipText; + } - final KTextPane textPane = KTextPane.htmlFormattedPane(tipText); + private Component getTips(){ + final KTextPane textPane = KTextPane.htmlFormattedPane(getTipText()); tipPane = new KScrollPane(textPane); tipPane.setBorder(null); return tipPane; diff --git a/src/main/java/core/first/Login.java b/src/main/java/core/first/Login.java index fb64b45..b4e6b3a 100644 --- a/src/main/java/core/first/Login.java +++ b/src/main/java/core/first/Login.java @@ -237,4 +237,15 @@ public static void notifyCompletion(){ statusHolder.stopAutoScrolling(); } + //Request password + public static String requestPassword(){ + final String studentName = Student.getFullNamePostOrder(); + final String input = App.requestInput(null, "Dashboard", + "This Dashboard belongs to '"+studentName+"'.\n" + + "Please enter your Matriculation Number to confirm:"); + if (input == null) { + System.exit(0); + } + return Globals.hasText(input) ? input : requestPassword(); + } } diff --git a/src/main/java/core/module/Course.java b/src/main/java/core/module/Course.java index da59180..1140b89 100644 --- a/src/main/java/core/module/Course.java +++ b/src/main/java/core/module/Course.java @@ -73,18 +73,12 @@ public double getQualityPoint() { * Merges this course with the outgoing, old course. * This ensures that the user's given details, * prior to editing or verification are not lost. - * By the time this method returns, it's safe to substitute old with this. + * By the time this method returns, it's safe to substitute old with this. (Only residence) */ - @Override - public void merge(Module old) { - this.day = old.day; - this.time = old.time; + + public void residence(Module old) { this.campus = old.campus; this.room = old.room; - this.requirement = old.requirement; - if (this.isLecturerEditable) { - this.lecturer = old.lecturer; - } } /** diff --git a/src/main/java/core/module/Module.java b/src/main/java/core/module/Module.java index 22dd4bf..e385073 100644 --- a/src/main/java/core/module/Module.java +++ b/src/main/java/core/module/Module.java @@ -533,16 +533,15 @@ public static String[] campuses(){ public abstract String export(); - /** - * Merges this module with the given module - old. - * By the time this method returns, the invoking-module must have - * the user-defined values of the its old counterpart. - *

The purpose of {@code merging} is to preserve the user-defined values - * as much as possible.

- * - * @param old - */ - public abstract void merge(Module old); + public void merge(Module old){ + this.day = old.day; + this.time = old.time; + this.requirement = old.requirement; + if (this.isLecturerEditable) { + this.lecturer = old.lecturer; + } + } + /** * Exhibits the contents of this Module on a dialog, diff --git a/src/main/java/core/module/ModuleHandler.java b/src/main/java/core/module/ModuleHandler.java index 882cb4a..b5e1612 100644 --- a/src/main/java/core/module/ModuleHandler.java +++ b/src/main/java/core/module/ModuleHandler.java @@ -380,6 +380,7 @@ public static void launchVerification(Course target) { modulesMonitor.add(foundOne); } else { // merge and replace (substitute) then foundOne.merge(existed); + foundOne.residence(existed); substitute(existed, foundOne); } @@ -550,6 +551,7 @@ public static void launchThoroughSync(boolean userRequested, KButton triggerButt modulesMonitor.add(found); } else {//merge and replace found.merge(existed); + found.residence(existed); substitute(existed, found); } } diff --git a/src/main/java/core/module/RegisteredCourse.java b/src/main/java/core/module/RegisteredCourse.java index 4d3ecb8..8eb901d 100644 --- a/src/main/java/core/module/RegisteredCourse.java +++ b/src/main/java/core/module/RegisteredCourse.java @@ -37,15 +37,15 @@ public RegisteredCourse(String code, String name, String lecturer, String campus super(code, name, "", "", lecturer, campus, room, day, time, "", -1, confirmed); } - @Override - public void merge(Module old) { - this.day = old.day; - this.time = old.time; - this.requirement = old.requirement; - if (this.isLecturerEditable) { - this.lecturer = old.lecturer; - } - } +// @Override +// public void merge(Module old) { +// this.day = old.day; +// this.time = old.time; +// this.requirement = old.requirement; +// if (this.isLecturerEditable) { +// this.lecturer = old.lecturer; +// } +// } @Override public String export() { diff --git a/src/main/java/core/task/creator/TodoCreator.java b/src/main/java/core/task/creator/TodoCreator.java index c08b394..301ca50 100644 --- a/src/main/java/core/task/creator/TodoCreator.java +++ b/src/main/java/core/task/creator/TodoCreator.java @@ -62,12 +62,12 @@ public TodoCreator(){ private ActionListener listener(){ return e -> { - final String name = descriptionField.getText(); + final String toDoFieldName = descriptionField.getText(); int givenDays = 0; - if (Globals.hasNoText(name)) { + if (Globals.hasNoText(toDoFieldName)) { App.reportError(getRootPane(), "No Name", "Please specify a name for the task."); descriptionField.requestFocusInWindow(); - } else if (name.length() > DESCRIPTION_LIMIT) { + } else if (toDoFieldName.length() > DESCRIPTION_LIMIT) { App.reportError("Error", "Sorry, description of a task must be at most "+ DESCRIPTION_LIMIT +" characters."); } else { @@ -83,7 +83,7 @@ private ActionListener listener(){ } else if (Objects.equals(span, "One Month")) { givenDays = 30; } - TodoHandler.newIncoming(new TodoSelf(name, givenDays)); + TodoHandler.newIncoming(new TodoSelf(toDoFieldName, givenDays)); dispose(); } }; diff --git a/src/main/java/core/utils/Internet.java b/src/main/java/core/utils/Internet.java index f17a45e..995cc90 100644 --- a/src/main/java/core/utils/Internet.java +++ b/src/main/java/core/utils/Internet.java @@ -6,6 +6,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import utg.Dashboard; +import utg.ErrorMessage; import utg.Version; import java.awt.*; @@ -61,7 +62,7 @@ public static void checkForUpdate(boolean requested){ verElement = document.selectFirst(".markdown-body > p:nth-child(2) > code:nth-child(1)"); } catch (HttpStatusException e) { Dashboard.setAuthentic(false); - Dashboard.reportAuthenticationError(); + ErrorMessage.reportAuthenticationError(); } catch (Exception e) { if (requested) { App.reportError(e); diff --git a/src/main/java/utg/Dashboard.java b/src/main/java/utg/Dashboard.java index 24a646d..807f883 100644 --- a/src/main/java/utg/Dashboard.java +++ b/src/main/java/utg/Dashboard.java @@ -23,6 +23,7 @@ import core.Board; import core.Preview; import core.alert.Notification; +import core.first.Login; import core.first.Welcome; import core.user.Student; import core.utils.*; @@ -75,7 +76,7 @@ public static void main(String[] args) { final boolean isAuthentic = Boolean.parseBoolean(lastConfigs.get("isAuthentic")); if (!isAuthentic) { PREVIEW.dispose(); - reportAuthenticationError(); + ErrorMessage.reportAuthenticationError(); } final Version recentVersion = Version.parse(lastConfigs.get("version")); final int comparison = VERSION.compare(recentVersion); @@ -215,7 +216,7 @@ private static void verifyUser(boolean initialize){ } PREVIEW.setVisible(false); - final String matNumber = requestPassword(); + final String matNumber = Login.requestPassword(); if (matNumber.equals(Student.getMatNumber())) { PREVIEW.setVisible(true); rebuildNow(false); @@ -227,16 +228,6 @@ private static void verifyUser(boolean initialize){ } } - private static String requestPassword(){ - final String studentName = Student.getFullNamePostOrder(); - final String input = App.requestInput(null, "Dashboard", - "This Dashboard belongs to '"+studentName+"'.\n" + - "Please enter your Matriculation Number to confirm:"); - if (input == null) { - System.exit(0); - } - return Globals.hasText(input) ? input : requestPassword(); - } /** * Builds the Dashboard from a serializable state. @@ -281,11 +272,5 @@ public static String getDefaultPath(){ return Globals.joinPaths(System.getProperty("user.home"), ".dashboard"); } - public static void reportAuthenticationError() { - App.reportWarning(null, "Authentication Error", - "This program is either not verified, or no longer supported.\n" + - "Contact the developers: '"+ Mailer.DEVELOPER_MAIL +"'."); - System.exit(0); - } } diff --git a/src/main/java/utg/ErrorMessage.java b/src/main/java/utg/ErrorMessage.java new file mode 100644 index 0000000..9b61d1f --- /dev/null +++ b/src/main/java/utg/ErrorMessage.java @@ -0,0 +1,13 @@ +package utg; + +import core.utils.App; +import core.utils.Mailer; + +public class ErrorMessage { + public static void reportAuthenticationError() { + App.reportWarning(null, "Authentication Error", + "This program is either not verified, or no longer supported.\n" + + "Contact the developers: '"+ Mailer.DEVELOPER_MAIL +"'."); + System.exit(0); + } +}