Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructured ui #549

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
37290f5
prelim
damithc Jul 23, 2016
8af377e
Added MainWindowView
damithc Jul 23, 2016
a9a1273
tidied help
damithc Jul 23, 2016
fb12867
Added PersonListPanel
damithc Jul 23, 2016
b2b27a7
Added BaseView class
damithc Jul 23, 2016
6aa5ed3
Tidied BaseView class
damithc Jul 23, 2016
fb98b80
Added RootLayout
damithc Jul 23, 2016
6622c23
Added BaseUiPart
damithc Jul 23, 2016
85dec8a
Added MainWindow
damithc Jul 23, 2016
c14230e
Moved resizing to MainWindow
damithc Jul 23, 2016
b699854
merged RootLayoutView and MainWindow
damithc Jul 23, 2016
a7c7b1b
Added data files to .ignore
damithc Jul 23, 2016
844a4a4
Removed MainController
damithc Jul 23, 2016
ac5b33c
fixed failing test
damithc Jul 23, 2016
79f341b
Renamed RootLayout
damithc Jul 23, 2016
d4cb830
Moved PersonListPanel to MainWindow
damithc Jul 23, 2016
aaeccb3
Cosmetic changes
damithc Jul 23, 2016
0396ec7
Created PersonEditDialogUiPart
damithc Jul 24, 2016
68d826c
Moved the close() to PersonEditDialogView
damithc Jul 24, 2016
8d41289
Cosmetic changes to PersonEditDialogView
damithc Jul 24, 2016
82c4d9a
Moved tag related code together
damithc Jul 24, 2016
9bfffd5
Improved edit person dialog error handling
damithc Jul 24, 2016
7ed5a94
Cosmetic changes
damithc Jul 24, 2016
5723488
Renamed MainWindow -> MainWindowUiPart
damithc Jul 24, 2016
8eb2fb1
Relocated window resizing and saving window size
damithc Jul 24, 2016
860593b
Tweaked MainWindow*
damithc Jul 24, 2016
3dc610f
Tweaked HelpWindow*
damithc Jul 24, 2016
a73f030
Tidied PersonListPanel*
damithc Jul 24, 2016
1c2b68c
Unified Help Window UI
damithc Jul 24, 2016
2e99bdc
Unified PersonEditDialog
damithc Jul 24, 2016
463d759
Tidied PersonListPanel
damithc Jul 24, 2016
d4b39ab
Tidied Main window
damithc Jul 24, 2016
b7696c7
Removed Controller from class names
damithc Jul 24, 2016
491dc81
Minor refactorings
damithc Jul 24, 2016
d323b64
More cosmetic refactorings
damithc Jul 24, 2016
a379de7
Added TagSelectionEditDialog
damithc Jul 24, 2016
627a5fe
Added diagram
damithc Jul 24, 2016
b1b023b
renamed TagSelectionEditDialog
damithc Jul 24, 2016
ab3acbb
Added some comments
damithc Jul 24, 2016
221a139
Added load method to MainWindow
damithc Jul 25, 2016
e708ef2
Added load method to PersonListPanel
damithc Jul 25, 2016
9330386
Added load method to HelpWindow
damithc Jul 25, 2016
85ccd81
Add load method to PersonEditDialog
damithc Jul 25, 2016
8f7ba70
Added load method to TagSelectionEditDialog
damithc Jul 25, 2016
0af8f6f
Autodetected personListPanel placeholder
damithc Jul 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ config.json
src/main/resources/updater/updater*.jar
src/test/data/sandbox/
preferences.json
data/addressbook.xml
.$TEMP_ADDRESS_BOOK
Binary file added docs/images/UI structure.pptx
Binary file not shown.
105 changes: 105 additions & 0 deletions src/main/java/address/controller/BaseUiPart.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package address.controller;

import address.events.BaseEvent;
import address.events.EventManager;
import address.util.AppUtil;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;

/**
* Base class for UI parts.
* A 'UI part' represents a distinct par of the UI. e.g. Windows, dialogs, panels, status bars, etc.
*/
public abstract class BaseUiPart {

/**
* The primary stage for the UI Part.
*/
Stage primaryStage;

public BaseUiPart(){
EventManager.getInstance().registerHandler(this);
}

/**
* Raises the even via {@link EventManager#post(BaseEvent)}
* @param event
*/
protected void raise(BaseEvent event){
EventManager.getInstance().post(event);
}

/**
* Raises an event via {@link EventManager#postPotentialEvent(BaseEvent)}
* @param event
*/
protected void raisePotentialEvent(BaseEvent event) {
EventManager.getInstance().postPotentialEvent(event);
}

/**
* Override this method to receive the main Node generated while loading the view from the .fxml file.
* @param node
*/
public abstract void setNode(Node node);

/**
* Override this method to return the name of the fxml file. e.g. {@code "MainWindow.fxml"}
* @return
*/
public abstract String getFxmlPath();

public void setStage(Stage primaryStage) {
this.primaryStage = primaryStage;
}


/**
* Creates a modal dialog.
* @param title Title of the dialog.
* @param parentStage The owner stage of the dialog.
* @param scene The scene that will contain the dialog.
* @return the created dialog, not yet made visible.
*/
protected Stage createDialogStage(String title, Stage parentStage, Scene scene) {
Stage dialogStage = new Stage();
dialogStage.setTitle(title);
dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.initOwner(parentStage);
dialogStage.setScene(scene);
return dialogStage;
}

/**
* Sets the given image as the icon for the primary stage of this UI Part.
* @param iconSource e.g. {@code "/images/help_icon.png"}
*/
protected void setIcon(String iconSource) {
primaryStage.getIcons().add(AppUtil.getImage(iconSource));
}

/**
* Sets the given image as the icon for the given stage.
* @param stage
* @param iconSource e.g. {@code "/images/help_icon.png"}
*/
protected void setIcon(Stage stage, String iconSource) {
stage.getIcons().add(AppUtil.getImage(iconSource));
}

/**
* Sets the placeholder for UI parts that reside inside another UI part.
* This method will be called by the {@link UiPartLoader} during the loading process.
* @param placeholder
*/
public void setPlaceholder(AnchorPane placeholder) {
//Do nothing by default.
}

public Stage getPrimaryStage() {
return primaryStage;
}
}
30 changes: 0 additions & 30 deletions src/main/java/address/controller/HelpController.java

This file was deleted.

71 changes: 71 additions & 0 deletions src/main/java/address/controller/HelpWindow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package address.controller;

import address.util.AppLogger;
import address.util.AppUtil;
import address.util.LoggerManager;
import commons.FxViewUtil;
import hubturbo.EmbeddedBrowser;
import hubturbo.embeddedbrowser.fxbrowser.FxBrowserAdapter;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

/**
* The Help Window UI Part.
*/
public class HelpWindow extends BaseUiPart {
private static final AppLogger logger = LoggerManager.getLogger(HelpWindow.class);
private static final String ICON = "/images/help_icon.png";
public static final String FXML = "HelpWindow.fxml";
public static final String TITLE = "Help";

private AnchorPane pane;
private Stage dialogStage;

@FXML
private AnchorPane mainPane;

public HelpWindow() {
}

public static HelpWindow load(Stage primaryStage) {
logger.debug("Showing help page about the application.");
HelpWindow helpWindow = UiPartLoader.loadUiPart(primaryStage, new HelpWindow());
helpWindow.configure();
return helpWindow;
}

@FXML
public void initialize() {
EmbeddedBrowser browser = new FxBrowserAdapter(new WebView());
browser.loadUrl(AppUtil.getResourceUrl("/help_html/index.html").toExternalForm());
FxViewUtil.applyAnchorBoundaryParameters(browser.getBrowserView(), 0.0, 0.0, 0.0, 0.0);
mainPane.getChildren().add(browser.getBrowserView());
}

private void configure(){
Scene scene = new Scene(pane);
//Null passed as the parent stage to make it non-modal.
dialogStage = createDialogStage(TITLE, null, scene);
dialogStage.setMaximized(true); //TODO: set a more appropriate initial size
setIcon(dialogStage, ICON);
}

@Override
public void setNode(Node node) {
pane = (AnchorPane)node;
}

@Override
public String getFxmlPath() {
return FXML;
}

public void show() {
dialogStage.showAndWait();
}

}
Loading