Skip to content

Commit

Permalink
Merge pull request #202
Browse files Browse the repository at this point in the history
Add color code of Tag names in the TagList of UI
  • Loading branch information
KrashKart authored Nov 4, 2024
2 parents d5d653b + e16b2d9 commit e38afa0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/tag/TagCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Provides categories to sort Tags into, as well as colour codes for display in the UI.
*/
public enum TagCategory {
GENERAL("#3E7B91"),
GENERAL("#ECECEC"), // Light Grey for default color
ACADEMICS("#FFD700"), // Gold
ACTIVITIES("#1E90FF"), // Dodger Blue
NETWORKING("#32CD32"), // Lime Green
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ void fillInnerParts() {
personListPanel = new PersonListPanel(logic.getFilteredPersonList());
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());

tagListPanel = new TagListPanel(logic.getListOfCurrentTags());
tagListPanel = new TagListPanel(logic.getListOfCurrentTags(), this);
tagsListPanelPlaceholder.getChildren().add(tagListPanel.getRoot());

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());
if (logic.getFilteredPersonList().isEmpty()) {
resultDisplay.setFeedbackToUser(LIST_EMPTY_MESSAGE);
updateResultDisplay(LIST_EMPTY_MESSAGE);
}

StatusBarFooter statusBarFooter = new StatusBarFooter(logic.getCampusConnectFilePath());
Expand Down Expand Up @@ -155,6 +155,14 @@ private void populateTagsList() {
tagListPanel.updateTagList(logic.getListOfCurrentTags());
}

/**
* Updates the ResultDisplay
* @param details the String to be displayed
*/
public void updateResultDisplay(String details) {
resultDisplay.setFeedbackToUser(details);
}

/**
* Opens the help window or focuses on it if it's already opened.
*/
Expand Down Expand Up @@ -197,7 +205,7 @@ private CommandResult executeCommand(String commandText) throws CommandException
CommandResult commandResult = logic.execute(commandText);
logger.info("Result: " + commandResult.getFeedbackToUser());
populateTagsList();
resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser());
updateResultDisplay(commandResult.getFeedbackToUser());
if (commandResult.isShowHelp()) {
handleHelp();
}
Expand All @@ -209,7 +217,7 @@ private CommandResult executeCommand(String commandText) throws CommandException
return commandResult;
} catch (CommandException | ParseException e) {
logger.info("An error occurred while executing command: " + commandText);
resultDisplay.setFeedbackToUser(e.getMessage());
updateResultDisplay(e.getMessage());
throw e;
}
}
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/seedu/address/ui/TagCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,28 @@ public class TagCard extends UiPart<Region> {
@FXML
private Label tagName;

private MainWindow mainWindow;

/**
* Creates a {@code TagCard} with the given {@code Tag} and index to display.
*/
public TagCard(Tag tag, int displayedIndex) {
public TagCard(Tag tag, int displayedIndex, MainWindow mainWindow) {
super(FXML);
this.mainWindow = mainWindow;
this.tag = tag;
// Tag category displayed for visual testing
// TODO: remove tag category text display after implementing colour code
tagName.setText((displayedIndex + 1) + ". " + tag.tagName + "(" + tag.getTagCategory() + ")");
tagName.setText((displayedIndex + 1) + ". " + tag.tagName);

String color = tag.getTagColour();
tagName.setStyle("-fx-text-fill: " + color + ";");

tagName.setOnMouseClicked(event -> showTagDetails());
}

/**
* Displays tag details in the ResultDisplay component of MainWindow.
*/
private void showTagDetails() {
String details = "Tag Name: " + tag.tagName + "\nCategory: " + tag.getTagCategory().toString();
mainWindow.updateResultDisplay(details);
}
}
7 changes: 5 additions & 2 deletions src/main/java/seedu/address/ui/TagListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ public class TagListPanel extends UiPart<Region> {
@FXML
private ListView<Tag> tagListView;

private MainWindow mainWindow;

/**
* Creates a {@code TagListPanel} with the given {@code ObservableList}.
*/
public TagListPanel(ObservableList<Tag> tagList) {
public TagListPanel(ObservableList<Tag> tagList, MainWindow mainWindow) {
super(FXML);
tagListView.setItems(FXCollections.observableArrayList(tagList));
tagListView.setCellFactory(listView -> new TagListViewCell());
this.mainWindow = mainWindow;
}

/**
Expand All @@ -52,7 +55,7 @@ protected void updateItem(Tag tag, boolean empty) {
setGraphic(null);
setText(null);
} else {
setGraphic(new TagCard(tag, getIndex()).getRoot());
setGraphic(new TagCard(tag, getIndex(), mainWindow).getRoot());
}
}
}
Expand Down

0 comments on commit e38afa0

Please sign in to comment.