Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2103T-T13-0#98 from xCOLOURx/branch-ui-…
Browse files Browse the repository at this point in the history
…javafx

Update JavaFx UI with ModulePlan
  • Loading branch information
ji-just-ji authored Oct 13, 2023
2 parents 4f114dc + 57e54e1 commit b00f1dc
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/HelpWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
public class HelpWindow extends UiPart<Stage> {

public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html";
public static final String USERGUIDE_URL = "https://ay2324s1-cs2103t-t13-0.github.io/tp/UserGuide.html";
public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL;

private static final Logger logger = LogsCenter.getLogger(HelpWindow.class);
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private MenuItem helpMenuItem;

@FXML
private StackPane personListPanelPlaceholder;

@FXML
private StackPane resultDisplayPlaceholder;

@FXML
private StackPane statusbarPlaceholder;

@FXML
private StackPane modulePlanPlaceholder;

/**
* Creates a {@code MainWindow} with the given {@code Stage} and {@code Logic}.
*/
Expand Down Expand Up @@ -110,9 +111,6 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) {
* Fills up all the placeholders of this window.
*/
void fillInnerParts() {
personListPanel = new PersonListPanel(logic.getFilteredPersonList());
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());

Expand All @@ -121,6 +119,10 @@ void fillInnerParts() {

CommandBox commandBox = new CommandBox(this::executeCommand);
commandBoxPlaceholder.getChildren().add(commandBox.getRoot());

//TODO
ModulePlanPanel modulePlanPanel = new ModulePlanPanel();
modulePlanPlaceholder.getChildren().add(modulePlanPanel.getRoot());
}

/**
Expand Down
59 changes: 59 additions & 0 deletions src/main/java/seedu/address/ui/ModulePlanCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package seedu.address.ui;

import java.util.Comparator;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;



public class ModulePlanCard extends UiPart<Region> {

private static final String FXML = "ModulePlanCard.fxml";


//TODO uncomment when ModulePlan is added.
//public final ModulePlan modulePlanSemester;

@FXML
private VBox modulePlanCardPane;
@FXML
private Label semester;
@FXML
private FlowPane modules;



/**
* Creates a {@code PersonCode} with the given {@code Person} and index to display.
*/
public ModulePlanCard(String semester) {
super(FXML);

//Placeholder text
this.semester.setText(semester);
modules.getChildren().add(new Label("CS2103"));
modules.getChildren().add(new Label("CS2103"));
modules.getChildren().add(new Label("CS2103"));
modules.getChildren().add(new Label("CS2103"));
modules.getChildren().add(new Label("CS2103"));
modules.getChildren().add(new Label("CS2103"));
modules.getChildren().add(new Label("CS2103"));
modules.getChildren().add(new Label("CS2103"));
modules.getChildren().add(new Label("CS2103"));
modules.getChildren().add(new Label("CS2103"));


//TODO
// this.modulePlanSemester = modulePlanSemester;
// modulePlanSemester.getTags().stream()
// .sorted(Comparator.comparing(tag -> tag.tagName))
// .forEach(tag -> modules.getChildren().add(new Label(tag.tagName)));
}
}
57 changes: 57 additions & 0 deletions src/main/java/seedu/address/ui/ModulePlanPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package seedu.address.ui;

import java.util.logging.Logger;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.layout.Region;
import seedu.address.commons.core.LogsCenter;
import seedu.address.model.person.Person;

/**
* Panel containing the list of persons.
*/
public class ModulePlanPanel extends UiPart<Region> {
private static final String FXML = "ModulePlanPanel.fxml";
private final Logger logger = LogsCenter.getLogger(ModulePlanPanel.class);

//TODO modify class.
@FXML
private ListView<String> modulePlanView;

/**
* Creates a {@code PersonListPanel} with the given {@code ObservableList}.
*/
public ModulePlanPanel(/*ObservableList<ModulePlan> modulePlan*/) {
super(FXML);

//Placeholder values
ObservableList<String> items = FXCollections.observableArrayList("Y1S1", "Y1S2", "Y2S1", "Y2S2", "Y3S1", "Y3S2", "Y4S1", "Y4S2");

modulePlanView.setItems(items);
modulePlanView.setCellFactory(listView -> new ModulePlanViewCell());
}

/**
* Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}.
*/
class ModulePlanViewCell extends ListCell<String> {
@Override
protected void updateItem(String string, boolean empty) {
super.updateItem(string, empty);

if (empty || string == null) {
setGraphic(null);
setText(null);
} else {
//Todo change constructor params
ModulePlanCard m = new ModulePlanCard(string);
setGraphic(m.getRoot());
}
}
}

}
14 changes: 14 additions & 0 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,17 @@
-fx-background-radius: 2;
-fx-font-size: 11;
}

#modules {
-fx-hgap: 1;
-fx-vgap: 5;
}

#modules .label {
-fx-text-fill: white;
-fx-background-color: #3e7b91;
-fx-padding: 1 3 1 3;
-fx-border-radius: 2;
-fx-background-radius: 2;
-fx-font-size: 14;
}
27 changes: 12 additions & 15 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.stage.Stage?>

<fx:root type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1"
title="Address App" minWidth="450" minHeight="600" onCloseRequest="#handleExit">
<fx:root minHeight="600" minWidth="450" onCloseRequest="#handleExit" title="Address App" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<icons>
<Image url="@/images/address_book_32.png" />
</icons>
Expand All @@ -32,27 +32,24 @@
<MenuItem fx:id="helpMenuItem" mnemonicParsing="false" onAction="#handleHelp" text="Help" />
</Menu>
</MenuBar>
<HBox fx:id="modulePlanList" minHeight="200.0" prefHeight="200.0" styleClass="pane-with-border" VBox.vgrow="ALWAYS">
<children>
<StackPane fx:id="modulePlanPlaceholder" HBox.hgrow="ALWAYS" />
</children>
</HBox>

<StackPane VBox.vgrow="NEVER" fx:id="commandBoxPlaceholder" styleClass="pane-with-border">
<StackPane fx:id="resultDisplayPlaceholder" maxHeight="200.0" minHeight="200.0" minWidth="340.0" prefHeight="200.0" prefWidth="340.0" styleClass="pane-with-border" VBox.vgrow="NEVER">
<padding>
<Insets top="5" right="10" bottom="5" left="10" />
<Insets bottom="5" left="10" right="10" top="5" />
</padding>
</StackPane>

<StackPane VBox.vgrow="NEVER" fx:id="resultDisplayPlaceholder" styleClass="pane-with-border"
minHeight="100" prefHeight="100" maxHeight="100">
<StackPane fx:id="commandBoxPlaceholder" styleClass="pane-with-border" VBox.vgrow="NEVER">
<padding>
<Insets top="5" right="10" bottom="5" left="10" />
<Insets bottom="5" left="10" right="10" top="5" />
</padding>
</StackPane>

<VBox fx:id="personList" styleClass="pane-with-border" minWidth="340" prefWidth="340" VBox.vgrow="ALWAYS">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="personListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>

<StackPane fx:id="statusbarPlaceholder" VBox.vgrow="NEVER" />
</VBox>
</Scene>
Expand Down
41 changes: 41 additions & 0 deletions src/main/resources/view/ModulePlanCard.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox id="cardPane" fx:id="modulePlanCardPane" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<GridPane VBox.vgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />
</columnConstraints>
<children>
<VBox alignment="TOP_CENTER" minHeight="105" GridPane.columnIndex="0" GridPane.hgrow="ALWAYS" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS">
<padding>
<Insets bottom="5" left="15" right="5" top="5" />
</padding>
<children>
<Label fx:id="semester" styleClass="cell_big_label" text="\$semester">
<font>
<Font size="14.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin>
</Label>
<FlowPane fx:id="modules" alignment="TOP_CENTER" columnHalignment="CENTER" orientation="VERTICAL" prefWrapLength="100.0" rowValignment="TOP" vgap="5.0" VBox.vgrow="ALWAYS" />
</children>
</VBox>
</children>
<rowConstraints>
<RowConstraints />
</rowConstraints>
</GridPane>
</children>
</VBox>
8 changes: 8 additions & 0 deletions src/main/resources/view/ModulePlanPanel.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.HBox?>

<HBox xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<ListView fx:id="modulePlanView" orientation="HORIZONTAL" HBox.hgrow="ALWAYS" />
</HBox>
2 changes: 1 addition & 1 deletion src/main/resources/view/PersonListPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.VBox?>

<VBox xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<VBox xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<ListView fx:id="personListView" VBox.vgrow="ALWAYS" />
</VBox>

0 comments on commit b00f1dc

Please sign in to comment.