Skip to content

Commit 73b62c6

Browse files
committed
Make tag list view scalable horizontally
Show tag info when a tag is clicked
1 parent 4532b25 commit 73b62c6

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
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/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)