From a0b844a3303b3a6449b1b49915b5dc4184269913 Mon Sep 17 00:00:00 2001 From: pgondaliya Date: Thu, 24 Mar 2022 21:26:43 -0300 Subject: [PATCH 1/6] change the variable name (meaningful variable name) --- .config | 1 + src/main/java/core/task/creator/TodoCreator.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 .config 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/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(); } }; From b556571560d1e34a8c40ac781cf21aca1726fc6d Mon Sep 17 00:00:00 2001 From: pgondaliya Date: Thu, 24 Mar 2022 21:28:06 -0300 Subject: [PATCH 2/6] Add the Extract method for the predifined text --- src/main/java/core/Help.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; From 041487dd5adaee9dafd3ecc6e76b85043ac7e4f0 Mon Sep 17 00:00:00 2001 From: pgondaliya Date: Fri, 25 Mar 2022 18:49:05 -0300 Subject: [PATCH 3/6] pull up method becuase it shared the same code again --- src/main/java/core/module/Course.java | 12 +++--------- src/main/java/core/module/Module.java | 19 +++++++++---------- src/main/java/core/module/ModuleHandler.java | 2 ++ .../java/core/module/RegisteredCourse.java | 18 +++++++++--------- 4 files changed, 23 insertions(+), 28 deletions(-) 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() { From 51d9b98ab9636f7286a48a1a5e65435e6b000558 Mon Sep 17 00:00:00 2001 From: pgondaliya Date: Fri, 25 Mar 2022 19:58:08 -0300 Subject: [PATCH 4/6] Add another class forthe error message(abstartct class) --- src/main/java/core/utils/Internet.java | 3 ++- src/main/java/utg/Dashboard.java | 14 +++++++------- src/main/java/utg/ErrorMessage.java | 13 +++++++++++++ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 src/main/java/utg/ErrorMessage.java 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..5feebeb 100644 --- a/src/main/java/utg/Dashboard.java +++ b/src/main/java/utg/Dashboard.java @@ -75,7 +75,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); @@ -281,11 +281,11 @@ 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); - } +// 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); + } +} From b40ca36816b8aade324b4b387b5059959d130acc Mon Sep 17 00:00:00 2001 From: pgondaliya Date: Fri, 25 Mar 2022 20:42:51 -0300 Subject: [PATCH 5/6] move method --- src/main/java/core/first/Login.java | 11 +++++++++++ src/main/java/utg/Dashboard.java | 29 ++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-) 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/utg/Dashboard.java b/src/main/java/utg/Dashboard.java index 5feebeb..a1f7598 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.*; @@ -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,16 @@ 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(); - } +// 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 +282,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); -// } } From 0faa395ad203a7d4992dfd4f5a43852b046de17c Mon Sep 17 00:00:00 2001 From: pgondaliya Date: Fri, 25 Mar 2022 22:03:27 -0300 Subject: [PATCH 6/6] log removed --- src/main/java/utg/Dashboard.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/utg/Dashboard.java b/src/main/java/utg/Dashboard.java index a1f7598..807f883 100644 --- a/src/main/java/utg/Dashboard.java +++ b/src/main/java/utg/Dashboard.java @@ -228,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.