Skip to content

Commit

Permalink
UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
qinxutan committed Mar 28, 2024
1 parent 089fc81 commit dd396cc
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 64 deletions.
55 changes: 3 additions & 52 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.logging.Logger;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.MenuItem;
Expand Down Expand Up @@ -125,11 +123,6 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) {
* Fills up all the placeholders of this window.
*/
void fillInnerParts() {
if (initiallyDisplayModuleListPanel()) {
switchToModuleListPanel();
} else {
switchToPersonListPanel();
}

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());
Expand All @@ -147,47 +140,18 @@ void fillInnerParts() {
moduleListPanelPlaceholder.getChildren().add(moduleListPanel.getRoot());

tutorialListPanel = new TutorialListPanel(logic.getAddressBook().getTutorialList(),
this::handleTutorialCardClicked);
this::handleTutorialCardClicked, personListPanel);
tutorialListPanelPlaceholder.getChildren().add(tutorialListPanel.getRoot());

focusedView = moduleListPanel;
}

/**
* Determines whether to initially display the module list panel.
*
* @return True if the module list panel should be initially displayed, false otherwise.
*/
private boolean initiallyDisplayModuleListPanel() {
return logic.isInitialModuleListPanelDisplayed();
}

/**
* Switches to the person list panel.
*/
void switchToPersonListPanel() {
personListPanel = new PersonListPanel(logic.getFilteredPersonList());
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());
focusedView = personListPanel;
}

/**
* Switches to the module list panel.
*/
void switchToModuleListPanel() {
ObservableList<ModuleCode> moduleObservableList = FXCollections
.observableList(logic.getAddressBook().getModuleList());
moduleListPanel = new ModuleListPanel(moduleObservableList, this::handleModuleCardClicked);
moduleListPanelPlaceholder.getChildren().add(moduleListPanel.getRoot());
focusedView = moduleListPanel;

}

private void switchToSortedPersonListPanel() {
personListPanel = new PersonListPanel(logic.getAddressBook().getSortedPersonList());
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());
}


/**
* Sets the default size based on {@code guiSettings}.
*/
Expand Down Expand Up @@ -274,15 +238,8 @@ private CommandResult executeCommand(String commandText) throws CommandException
if (commandResult.isExit()) {
handleExit();
}

clearPanels();

if (useModuleView(commandText)) {
switchToModuleListPanel();
} else if (useSortedView(commandText)) {
if (useSortedView(commandText)) {
switchToSortedPersonListPanel();
} else {
switchToPersonListPanel();
}
return commandResult;
} catch (CommandException | ParseException e) {
Expand All @@ -292,12 +249,6 @@ private CommandResult executeCommand(String commandText) throws CommandException
}
}

private void clearPanels() {
personListPanelPlaceholder.getChildren().clear();
moduleListPanelPlaceholder.getChildren().clear();
tutorialListPanelPlaceholder.getChildren().clear();
}

private void handleModuleCardClicked(ModuleCode moduleCode) {
tutorialListPanel.displayTutorialClassesForModule(moduleCode);
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/seedu/address/ui/PersonListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javafx.scene.layout.Region;
import seedu.address.commons.core.LogsCenter;
import seedu.address.model.module.TutorialClass;
import seedu.address.model.module.TutorialTeam;
import seedu.address.model.person.Person;

/**
Expand Down Expand Up @@ -64,6 +65,16 @@ protected void updateItem(Person person, boolean empty) {
}
}
}
/**
* Displays the list of persons associated with a specific tutorial team.
*
* @param team The tutorial team for which persons are to be displayed.
*/
public void displayPersonsForTeam(TutorialTeam team) {
ArrayList<Person> personList = team.getStudents();
ObservableList<Person> persons = FXCollections.observableArrayList(personList);
personListView.setItems(persons);
}
/**
* Displays the list of persons associated with a specific tutorial class.
*
Expand Down
46 changes: 45 additions & 1 deletion src/main/java/seedu/address/ui/TutorialClassCard.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package seedu.address.ui;

import java.util.ArrayList;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.Image;
Expand All @@ -10,6 +15,7 @@
import javafx.scene.paint.ImagePattern;
import javafx.scene.shape.Circle;
import seedu.address.model.module.TutorialClass;
import seedu.address.model.module.TutorialTeam;

/**
* An UI component that displays information of a {@code TutorialClass}.
Expand All @@ -19,6 +25,9 @@ public class TutorialClassCard extends UiPart<Region> {
private static final String FXML = "TutorialClassCard.fxml";

public final TutorialClass tutorialClass;
public final PersonListPanel personListPanel;
@FXML
protected ComboBox<TutorialTeam> teamComboBox;
@FXML
private Label tutorialClassLabel;
@FXML
Expand All @@ -29,11 +38,46 @@ public class TutorialClassCard extends UiPart<Region> {
/**
* Creates a {@code TutorialClassCard} with the given {@code TutorialClass}.
*/
public TutorialClassCard(TutorialClass tutorialClass) {
public TutorialClassCard(TutorialClass tutorialClass, PersonListPanel personListPanel) {
super(FXML);
this.tutorialClass = tutorialClass;
this.personListPanel = personListPanel;
tutorialClassLabel.setText(tutorialClass.toString());
updateImage();
updateTeamComboBox(tutorialClass.getTeams());
}

@FXML
private void initialize() {
// Initialize the teamComboBox
teamComboBox.setOnAction(event -> handleTeamSelection());
}

public void setTutorialTeams(ArrayList<TutorialTeam> teams) {
// Update the team ComboBox with the given list of teams
updateTeamComboBox(teams);
}
/**
* Handles team selection from the ComboBox.
*/
private void handleTeamSelection() {
TutorialTeam selectedTeam = teamComboBox.getSelectionModel().getSelectedItem();
if (selectedTeam != null) {
personListPanel.displayPersonsForTeam(selectedTeam); // Update PersonListPanel
}
}
/**
* Update the team ComboBox with the given list of teams.
* @param teams List of teams to be displayed in the ComboBox
*/
private void updateTeamComboBox(ArrayList<TutorialTeam> teams) {
if (teams != null) {
ObservableList<TutorialTeam> teamOptions = FXCollections.observableArrayList(teams);
teamComboBox.setItems(teamOptions);
} else {
// If the list of teams is null, clear the ComboBox
teamComboBox.setItems(FXCollections.emptyObservableList());
}
}
/**
* Updates the image displayed in a circle shape.
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/seedu/address/ui/TutorialListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public class TutorialListPanel extends UiPart<Region> implements SelectedArea {
* Creates a {@code TutorialListPanel} with the given {@code ObservableList}.
*/
public TutorialListPanel(ObservableList<TutorialClass> tutorialClassList,
Consumer<TutorialClass> tutorialCardClicker) {
Consumer<TutorialClass> tutorialCardClicker,
PersonListPanel personListPanel) {
super(FXML);
this.tutorialCardClickHandler = tutorialCardClicker;
this.personListPanel = personListPanel;
tutorialListView.setItems(tutorialClassList);
tutorialListView.setCellFactory(listView -> new TutorialListViewCell());
tutorialListView.focusedProperty().addListener((arg, oldVal, focused) -> {
Expand Down Expand Up @@ -68,7 +70,7 @@ protected void updateItem(TutorialClass tutorialClass, boolean empty) {
setGraphic(null);
setText(null);
} else {
setGraphic(new TutorialClassCard(tutorialClass).getRoot());
setGraphic(new TutorialClassCard(tutorialClass, personListPanel).getRoot());
setOnMouseClicked(event -> tutorialCardClickHandler.accept(tutorialClass));
}
}
Expand Down
Binary file added src/main/resources/images/damith1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/damith2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/damith3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/damith4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 30 additions & 6 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.effect.DropShadow?>

<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>
<fx:root type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1"
title="Address App" minWidth="500" minHeight="500" onCloseRequest="#handleExit">
<icons>
Expand All @@ -25,20 +27,37 @@
<URL value="@DarkTheme.css" />
<URL value="@Extensions.css" />
</stylesheets>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity"
xmlns="http://javafx.com/javafx/8.0.171"
xmlns:fx="http://javafx.com/fxml/1">
<top>
<MenuBar fx:id="menuBar" VBox.vgrow="ALWAYS">
<VBox minWidth="100.0" prefHeight="100.0" prefWidth="400.0"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<children>
<MenuBar fx:id="menuBar" prefWidth="400" prefHeight="50" >
<Menu mnemonicParsing="false" text="File">
<MenuItem mnemonicParsing="false" onAction="#handleExit" text="Exit"/>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<MenuItem fx:id="helpMenuItem" mnemonicParsing="false" onAction="#handleHelp" text="Help" />
</Menu>
</MenuBar>
<!-- Horizontal banner -->
<HBox prefHeight="50" prefWidth="400" style="-fx-background-color: derive(#d7cbc0, 20%);"
alignment="CENTER">
<!-- ImageView for the logo or image -->
<ImageView fitWidth="267" fitHeight="150" preserveRatio="true" HBox.hgrow="ALWAYS"
VBox.vgrow="ALWAYS">
<!-- Specify the path or URL for the image -->
<image>
<Image url="/images/logo.png"/>
</image>
</ImageView>
</HBox>
</children>
</VBox>
</top>
<center>
<center>
<SplitPane dividerPositions="0.33, 0.67">
<items>
<!-- Add a new VBox for the module list panel -->
Expand Down Expand Up @@ -69,12 +88,17 @@
</SplitPane>
</center>
<bottom>
<VBox prefHeight="111.0" prefWidth="604.0" BorderPane.alignment="CENTER">
<VBox prefHeight="111.0" prefWidth="604.0" BorderPane.alignment="CENTER"
style="-fx-background-color: derive(#d7cbc0, 20%);">
<children>
<StackPane fx:id="resultDisplayPlaceholder" minHeight="140" prefHeight="140.0"
prefWidth="200.0"/>
<StackPane fx:id="commandBoxPlaceholder" prefHeight="150.0" prefWidth="200.0"/>
prefWidth="200.0" style="-fx-background-color: #ececec"/>
<StackPane fx:id="commandBoxPlaceholder" prefHeight="150.0" prefWidth="200.0"
style="-fx-background-color: derive(#d7cbc0, 20%);"/>
</children>
<padding>
<Insets bottom="10" />
</padding>
</VBox>
</bottom>
<StackPane fx:id="statusbarPlaceholder" VBox.vgrow="NEVER" />
Expand Down
11 changes: 8 additions & 3 deletions src/main/resources/view/TutorialClassCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,31 @@
<?import javafx.scene.shape.Circle?>

<?import java.net.URL?>
<HBox id="tutorialCardPane" fx:id="tutorialCardPane" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<?import javafx.scene.control.ComboBox?>
<HBox id="tutorialCardPane" fx:id="tutorialCardPane" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<GridPane styleClass="roundedCard" HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />
</columnConstraints>
<VBox alignment="CENTER_LEFT" minHeight="105" GridPane.columnIndex="0">
<VBox alignment="CENTER_RIGHT" minHeight="105" GridPane.columnIndex="0">
<padding>
<Insets bottom="5" left="15" right="5" top="5" />
</padding>
<HBox alignment="CENTER_LEFT" spacing="5">
<children>
<HBox alignment="CENTER_LEFT">
<Circle fx:id="circle" radius="40.0" stroke="BLACK" strokeType="INSIDE" />
</children>
<Label fx:id="tutorialClassLabel" styleClass="cell_big_label">
<minWidth>
<!-- Ensures that the label text is never truncated -->
<Region fx:constant="USE_PREF_SIZE" />
</minWidth>
</Label>
</HBox>
</children>
</HBox>
<!-- Add ComboBox for selecting teams -->
<ComboBox fx:id="teamComboBox" minWidth="150" promptText="Select Team"/>
</VBox>
</GridPane>
</HBox>
1 change: 1 addition & 0 deletions src/main/resources/view/TutorialListPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.VBox?>

<?import javafx.scene.control.ComboBox?>
<VBox xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<ListView fx:id="tutorialListView" VBox.vgrow="ALWAYS" />
</VBox>

0 comments on commit dd396cc

Please sign in to comment.