Skip to content

Commit

Permalink
Merge pull request #75 from HugeNoob/lingxi/help-command
Browse files Browse the repository at this point in the history
feat: Update help command
  • Loading branch information
jiakai-17 authored Oct 12, 2023
2 parents c0b7493 + 80deab9 commit a23a154
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
27 changes: 26 additions & 1 deletion src/main/java/seedu/address/ui/HelpWindow.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package seedu.address.ui;

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Logger;

import javafx.fxml.FXML;
Expand All @@ -9,13 +13,14 @@
import javafx.scene.input.ClipboardContent;
import javafx.stage.Stage;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.util.StringUtil;

/**
* Controller for a help page
*/
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-t10-2.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 All @@ -24,6 +29,9 @@ public class HelpWindow extends UiPart<Stage> {
@FXML
private Button copyButton;

@FXML
private Button openButton;

@FXML
private Label helpMessage;

Expand Down Expand Up @@ -99,4 +107,21 @@ private void copyUrl() {
url.putString(USERGUIDE_URL);
clipboard.setContent(url);
}

/**
* Opens the user guide URL in the default web browser.
*/
@FXML
private void openInBrowser() {
try {
Desktop.getDesktop().browse(new URI(USERGUIDE_URL));
} catch (IOException e) {
// Handle the IOException, which may occur when the system cannot open the
// default browser.
logger.warning("Failed to open URL in default browser: " + StringUtil.getDetails(e));
} catch (URISyntaxException e) {
// Handle the URISyntaxException, which may occur when the URL is not valid.
logger.warning("Invalid URL specified: " + StringUtil.getDetails(e));
}
}
}
8 changes: 4 additions & 4 deletions src/main/resources/view/HelpWindow.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#copyButton, #helpMessage {
#copyButton, #openButton, #helpMessage {
-fx-text-fill: white;
}

#copyButton {
#copyButton, #openButton {
-fx-background-color: dimgray;
}

#copyButton:hover {
#copyButton:hover, #openButton:hover {
-fx-background-color: gray;
}

#copyButton:armed {
#copyButton:armed, #openButton:armed {
-fx-background-color: darkgray;
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/view/HelpWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<Insets left="5.0" />
</HBox.margin>
</Button>
<Button fx:id="openButton" mnemonicParsing="false" onAction="#openInBrowser" text="Open in browser">
<HBox.margin>
<Insets left="5.0" />
</HBox.margin>
</Button>
</children>
<opaqueInsets>
<Insets bottom="10.0" left="5.0" right="10.0" top="5.0" />
Expand Down

0 comments on commit a23a154

Please sign in to comment.