Skip to content

Commit bb3d81d

Browse files
authored
Merge pull request nus-cs2103-AY2021S1#90 from Ma-Yueran/branch-improve-task-list-view
Branch improve task list view
2 parents 40761f4 + 73b62c6 commit bb3d81d

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

src/main/java/seedu/address/ui/MainWindow.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
public class MainWindow extends UiPart<Stage> {
2525

2626
private static final String FXML = "MainWindow.fxml";
27+
private static MainWindow instance = null;
2728

2829
private final Logger logger = LogsCenter.getLogger(getClass());
2930

@@ -67,6 +68,13 @@ public MainWindow(Stage primaryStage, Logic logic) {
6768
setWindowDefaultSize(logic.getGuiSettings());
6869

6970
// setAccelerators();
71+
72+
// Set instance
73+
instance = this;
74+
}
75+
76+
public static MainWindow getInstance() {
77+
return instance;
7078
}
7179

7280
public Stage getPrimaryStage() {
@@ -173,7 +181,7 @@ private void handleExit() {
173181
*
174182
* @see seedu.address.logic.Logic#execute(String)
175183
*/
176-
private CommandResult executeCommand(String commandText) throws CommandException, ParseException {
184+
public CommandResult executeCommand(String commandText) throws CommandException, ParseException {
177185
try {
178186
CommandResult commandResult = logic.execute(commandText);
179187
logger.info("Result: " + commandResult.getFeedbackToUser());

src/main/java/seedu/address/ui/TagCard.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import javafx.scene.control.Label;
55
import javafx.scene.layout.HBox;
66
import javafx.scene.layout.Region;
7+
import seedu.address.logic.commands.exceptions.CommandException;
8+
import seedu.address.logic.parser.exceptions.ParseException;
79
import seedu.address.model.tag.Tag;
810

911
/**
@@ -43,6 +45,21 @@ public TagCard(Tag tag, int displayedIndex) {
4345
fileAddress.setText(tag.getFileAddress().value);
4446
}
4547

48+
/**
49+
* Displays the information of the tag in the main window.
50+
*
51+
* @see seedu.address.logic.Logic#execute(String)
52+
*/
53+
public void showTagInfo() throws CommandException, ParseException {
54+
MainWindow mainWindow = MainWindow.getInstance();
55+
if (mainWindow == null) {
56+
return;
57+
}
58+
59+
String showInfoCommand = "show t/" + tag.getTagName();
60+
mainWindow.executeCommand(showInfoCommand);
61+
}
62+
4663
@Override
4764
public boolean equals(Object other) {
4865
// short circuit if same object

src/main/resources/view/MainWindow.fxml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<?import javafx.scene.control.Menu?>
66
<?import javafx.scene.control.MenuBar?>
77
<?import javafx.scene.control.MenuItem?>
8-
<?import javafx.scene.layout.HBox?>
8+
<?import javafx.scene.control.SplitPane?>
99
<?import javafx.scene.layout.StackPane?>
1010
<?import javafx.scene.layout.VBox?>
1111
<?import javafx.stage.Stage?>
@@ -30,24 +30,21 @@
3030
</Menu>
3131
</menus>
3232
</MenuBar>
33-
<HBox prefHeight="100.0" prefWidth="200.0" spacing="10.0" VBox.vgrow="ALWAYS">
34-
<children>
35-
<VBox prefHeight="314.0" prefWidth="188.0" HBox.hgrow="NEVER">
33+
<SplitPane dividerPositions="0.3224299065420561" prefHeight="160.0" prefWidth="200.0" VBox.vgrow="ALWAYS">
34+
<items>
35+
<VBox prefHeight="200.0" prefWidth="100.0">
3636
<children>
37-
<StackPane fx:id="tagListPlaceholder" prefHeight="306.0" prefWidth="139.0" VBox.vgrow="ALWAYS" />
37+
<StackPane fx:id="tagListPlaceholder" prefHeight="294.0" prefWidth="143.0" VBox.vgrow="ALWAYS" />
3838
</children>
3939
</VBox>
40-
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0" HBox.hgrow="ALWAYS">
40+
<VBox prefHeight="200.0" prefWidth="100.0">
4141
<children>
4242
<StackPane fx:id="resultDisplayPlaceHolder" prefHeight="299.0" prefWidth="359.0" VBox.vgrow="ALWAYS" />
4343
<StackPane fx:id="lastInputPlaceHolder" prefHeight="15.0" prefWidth="301.0" VBox.vgrow="NEVER" />
4444
</children>
4545
</VBox>
46-
</children>
47-
<padding>
48-
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
49-
</padding>
50-
</HBox>
46+
</items>
47+
</SplitPane>
5148
<StackPane fx:id="commandBoxPlaceHolder" prefHeight="41.0" prefWidth="501.0">
5249
<padding>
5350
<Insets left="10.0" right="10.0" />

src/main/resources/view/TagCard.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<?import javafx.scene.layout.VBox?>
1111
<?import javafx.scene.text.Font?>
1212

13-
<HBox id="cardPane" fx:id="cardPane" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
13+
<HBox id="cardPane" fx:id="cardPane" onMouseClicked="#showTagInfo" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
1414
<GridPane HBox.hgrow="ALWAYS">
1515
<columnConstraints>
1616
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />

0 commit comments

Comments
 (0)