Skip to content

Commit

Permalink
Make tag list view scalable horizontally
Browse files Browse the repository at this point in the history
Show tag info when a tag is clicked
  • Loading branch information
Ma-Yueran committed Oct 11, 2020
1 parent 4532b25 commit 73b62c6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class MainWindow extends UiPart<Stage> {

private static final String FXML = "MainWindow.fxml";
private static MainWindow instance = null;

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

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

// setAccelerators();

// Set instance
instance = this;
}

public static MainWindow getInstance() {
return instance;
}

public Stage getPrimaryStage() {
Expand Down Expand Up @@ -173,7 +181,7 @@ private void handleExit() {
*
* @see seedu.address.logic.Logic#execute(String)
*/
private CommandResult executeCommand(String commandText) throws CommandException, ParseException {
public CommandResult executeCommand(String commandText) throws CommandException, ParseException {
try {
CommandResult commandResult = logic.execute(commandText);
logger.info("Result: " + commandResult.getFeedbackToUser());
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/seedu/address/ui/TagCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.tag.Tag;

/**
Expand Down Expand Up @@ -43,6 +45,21 @@ public TagCard(Tag tag, int displayedIndex) {
fileAddress.setText(tag.getFileAddress().value);
}

/**
* Displays the information of the tag in the main window.
*
* @see seedu.address.logic.Logic#execute(String)
*/
public void showTagInfo() throws CommandException, ParseException {
MainWindow mainWindow = MainWindow.getInstance();
if (mainWindow == null) {
return;
}

String showInfoCommand = "show t/" + tag.getTagName();
mainWindow.executeCommand(showInfoCommand);
}

@Override
public boolean equals(Object other) {
// short circuit if same object
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/TagCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<HBox id="cardPane" fx:id="cardPane" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
<HBox id="cardPane" fx:id="cardPane" onMouseClicked="#showTagInfo" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
<GridPane HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />
Expand Down

0 comments on commit 73b62c6

Please sign in to comment.