forked from nusCS2113-AY1819S1/addressbook-level4
-
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.
Merge pull request #137 from jomcruz93/master
Created a class to handle displaying of note prompt window when adding (and editing - v1.3) notes.
- Loading branch information
Showing
5 changed files
with
111 additions
and
65 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
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,73 @@ | ||
package seedu.address.ui; | ||
|
||
import java.io.IOException; | ||
|
||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Scene; | ||
import javafx.scene.layout.BorderPane; | ||
import javafx.stage.Modality; | ||
import javafx.stage.Stage; | ||
|
||
import seedu.address.model.note.Note; | ||
|
||
/** | ||
* Handles the displaying of a TextArea window for adding/editing a note. | ||
*/ | ||
public class NoteTextEditWindow { | ||
|
||
private static final String PATH = "/view/NoteEntryPromptWindow.fxml"; | ||
|
||
private BorderPane layout; | ||
private FXMLLoader loader; | ||
private Scene scene; | ||
private Stage notePromptStage; | ||
|
||
private NoteEntryPrompt controller; | ||
|
||
private Note note; | ||
|
||
public NoteTextEditWindow(Note note) { | ||
this.note = note; | ||
setUpWindow(); | ||
} | ||
|
||
/** | ||
* This method sets up the window to be loaded and | ||
* handles its configuration and behaviour. | ||
*/ | ||
private void setUpWindow() { | ||
try { | ||
controller = new NoteEntryPrompt(); | ||
|
||
loader = new FXMLLoader(getClass().getResource(PATH)); | ||
loader.setController(controller); | ||
layout = loader.load(); | ||
|
||
scene = new Scene(layout); | ||
|
||
notePromptStage = new Stage(); | ||
notePromptStage.setMinHeight(380); | ||
notePromptStage.setMinWidth(350); | ||
notePromptStage.setTitle("Add/Edit note"); | ||
notePromptStage.initModality(Modality.APPLICATION_MODAL); | ||
notePromptStage.setScene(scene); | ||
notePromptStage.setOnCloseRequest(e -> { | ||
e.consume(); | ||
controller.closeWindow(); | ||
}); | ||
|
||
controller.setDialogStage(notePromptStage); | ||
controller.setNote(note); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void showAndWait() { | ||
notePromptStage.showAndWait(); | ||
} | ||
|
||
public boolean isCancelled() { | ||
return controller.isCancelled(); | ||
} | ||
} |