Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UID:f52f7d72-f67e-4eed-8218-8d8e2923ff02
8 changes: 6 additions & 2 deletions src/main/java/core/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <i>"+reference("Home", "This Semester")+"</i>. " +
Expand Down Expand Up @@ -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 <i>About UTG</i> Button appearing at the top-right of your Dashboard. <br/>";
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;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/core/first/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
12 changes: 3 additions & 9 deletions src/main/java/core/module/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/core/module/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p> The purpose of {@code merging} is to preserve the user-defined values
* as much as possible. </p>
*
* @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,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/core/module/ModuleHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/core/module/RegisteredCourse.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/core/task/creator/TodoCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/core/utils/Internet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 3 additions & 18 deletions src/main/java/utg/Dashboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand Down Expand Up @@ -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);
}

}
13 changes: 13 additions & 0 deletions src/main/java/utg/ErrorMessage.java
Original file line number Diff line number Diff line change
@@ -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);
}
}