forked from nus-cs2103-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
362 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package seedu.address.ui; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.input.Clipboard; | ||
import javafx.scene.input.ClipboardContent; | ||
import javafx.stage.Stage; | ||
import seedu.address.commons.core.LogsCenter; | ||
|
||
/** | ||
* 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 HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL; | ||
|
||
private static final Logger logger = LogsCenter.getLogger(HelpWindow.class); | ||
private static final String FXML = "HelpWindow.fxml"; | ||
|
||
@FXML | ||
private Button copyButton; | ||
|
||
@FXML | ||
private Label helpMessage; | ||
|
||
/** | ||
* Creates a new HelpWindow. | ||
* | ||
* @param root Stage to use as the root of the HelpWindow. | ||
*/ | ||
public HelpWindow(Stage root) { | ||
super(FXML, root); | ||
helpMessage.setText(HELP_MESSAGE); | ||
} | ||
|
||
/** | ||
* Creates a new HelpWindow. | ||
*/ | ||
public HelpWindow() { | ||
this(new Stage()); | ||
} | ||
|
||
/** | ||
* Shows the help window. | ||
* @throws IllegalStateException | ||
* <ul> | ||
* <li> | ||
* if this method is called on a thread other than the JavaFX Application Thread. | ||
* </li> | ||
* <li> | ||
* if this method is called during animation or layout processing. | ||
* </li> | ||
* <li> | ||
* if this method is called on the primary stage. | ||
* </li> | ||
* <li> | ||
* if {@code dialogStage} is already showing. | ||
* </li> | ||
* </ul> | ||
*/ | ||
public void show() { | ||
logger.fine("Showing help page about the application."); | ||
getRoot().show(); | ||
getRoot().centerOnScreen(); | ||
} | ||
|
||
/** | ||
* Returns true if the help window is currently being shown. | ||
*/ | ||
public boolean isShowing() { | ||
return getRoot().isShowing(); | ||
} | ||
|
||
/** | ||
* Hides the help window. | ||
*/ | ||
public void hide() { | ||
getRoot().hide(); | ||
} | ||
|
||
/** | ||
* Focuses on the help window. | ||
*/ | ||
public void focus() { | ||
getRoot().requestFocus(); | ||
} | ||
|
||
/** | ||
* Copies the URL to the user guide to the clipboard. | ||
*/ | ||
@FXML | ||
private void copyUrl() { | ||
final Clipboard clipboard = Clipboard.getSystemClipboard(); | ||
final ClipboardContent url = new ClipboardContent(); | ||
url.putString(USERGUIDE_URL); | ||
clipboard.setContent(url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#copyButton, #helpMessage { | ||
-fx-text-fill: white; | ||
} | ||
|
||
#copyButton { | ||
-fx-background-color: dimgray; | ||
} | ||
|
||
#copyButton:hover { | ||
-fx-background-color: gray; | ||
} | ||
|
||
#copyButton:armed { | ||
-fx-background-color: darkgray; | ||
} | ||
|
||
#helpMessageContainer { | ||
-fx-background-color: derive(#1d1d1d, 20%); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import java.net.URL?> | ||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.Scene?> | ||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.image.Image?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.stage.Stage?> | ||
|
||
<fx:root resizable="false" title="Help" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1"> | ||
<icons> | ||
<Image url="@/images/help_icon.png" /> | ||
</icons> | ||
<scene> | ||
<Scene> | ||
<stylesheets> | ||
<URL value="@HelpWindow.css" /> | ||
</stylesheets> | ||
|
||
<HBox alignment="CENTER" fx:id="helpMessageContainer"> | ||
<children> | ||
<Label fx:id="helpMessage" text="Label"> | ||
<HBox.margin> | ||
<Insets right="5.0" /> | ||
</HBox.margin> | ||
</Label> | ||
<Button fx:id="copyButton" mnemonicParsing="false" onAction="#copyUrl" text="Copy URL"> | ||
<HBox.margin> | ||
<Insets left="5.0" /> | ||
</HBox.margin> | ||
</Button> | ||
</children> | ||
<opaqueInsets> | ||
<Insets bottom="10.0" left="5.0" right="10.0" top="5.0" /> | ||
</opaqueInsets> | ||
<padding> | ||
<Insets bottom="10.0" left="5.0" right="10.0" top="5.0" /> | ||
</padding> | ||
</HBox> | ||
</Scene> | ||
</scene> | ||
</fx:root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package seedu.address.ui; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.testfx.api.FxToolkit; | ||
|
||
import javafx.application.Application; | ||
import javafx.stage.Stage; | ||
|
||
/** | ||
* Utility class for initializing the JavaFX toolkit before running tests. | ||
*/ | ||
public class JavaFxTestInitializer { | ||
|
||
/** | ||
* Initializes the JavaFX toolkit before running tests. | ||
* This method should be called before any JavaFX components are created or tested. | ||
* | ||
* @throws Exception If an error occurs during the initialization. | ||
*/ | ||
@BeforeAll | ||
public static void initToolkit() throws Exception { | ||
FxToolkit.registerPrimaryStage(); | ||
FxToolkit.setupApplication(() -> new ApplicationStub()); | ||
} | ||
|
||
private static class ApplicationStub extends Application { | ||
@Override | ||
public void start(Stage stage) { | ||
// No initialization code needed | ||
} | ||
} | ||
} |
Oops, something went wrong.