Skip to content

Commit c5663d9

Browse files
authored
Merge pull request nus-cs2103-AY2223S2#68 from shaowi/help-window
Added navigation of user to user guide
2 parents e774676 + 8cc5ebb commit c5663d9

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package seedu.address.ui;
22

3+
import java.awt.Desktop;
4+
import java.io.IOException;
5+
import java.net.URISyntaxException;
6+
import java.net.URL;
37
import java.util.logging.Logger;
48

59
import javafx.fxml.FXML;
610
import javafx.scene.control.Button;
711
import javafx.scene.control.Label;
8-
import javafx.scene.input.Clipboard;
9-
import javafx.scene.input.ClipboardContent;
1012
import javafx.stage.Stage;
1113
import seedu.address.commons.core.LogsCenter;
1214

@@ -15,14 +17,15 @@
1517
*/
1618
public class HelpWindow extends UiPart<Stage> {
1719

18-
public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html";
19-
public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL;
20+
public static final String USERGUIDE_URL =
21+
"https://github.com/AY2223S2-CS2103-F10-2/tp/blob/master/docs/UserGuide.md";
22+
public static final String HELP_MESSAGE = "Click on the button to navigate to the user guide >>>";
2023

2124
private static final Logger logger = LogsCenter.getLogger(HelpWindow.class);
2225
private static final String FXML = "HelpWindow.fxml";
2326

2427
@FXML
25-
private Button copyButton;
28+
private Button openButton;
2629

2730
@FXML
2831
private Label helpMessage;
@@ -90,13 +93,16 @@ public void focus() {
9093
}
9194

9295
/**
93-
* Copies the URL to the user guide to the clipboard.
96+
* Navigates the user to the user guide URL.
9497
*/
9598
@FXML
96-
private void copyUrl() {
97-
final Clipboard clipboard = Clipboard.getSystemClipboard();
98-
final ClipboardContent url = new ClipboardContent();
99-
url.putString(USERGUIDE_URL);
100-
clipboard.setContent(url);
99+
private void openUrl() {
100+
try {
101+
Desktop.getDesktop().browse(new URL(USERGUIDE_URL).toURI());
102+
} catch (IOException e) {
103+
logger.warning("Cannot open user guide URL");
104+
} catch (URISyntaxException e) {
105+
logger.warning("Cannot open user guide URL");
106+
}
101107
}
102108
}

src/main/resources/view/HelpWindow.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<Insets right="5.0" />
2727
</HBox.margin>
2828
</Label>
29-
<Button fx:id="copyButton" mnemonicParsing="false" onAction="#copyUrl" text="Copy URL">
29+
<Button fx:id="openButton" mnemonicParsing="false" onAction="#openUrl" text="Open URL">
3030
<HBox.margin>
3131
<Insets left="5.0" />
3232
</HBox.margin>

0 commit comments

Comments
 (0)