Skip to content

Commit

Permalink
[#6] Updated example collated file
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianquek committed Jun 26, 2015
1 parent f66f180 commit fcf9e00
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 13 deletions.
58 changes: 47 additions & 11 deletions collated/Sebastian Quek.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Sebastian Quek
###### CommandBarController.java
###### main\java\gui\CommandBarController.java
```java
public class CommandBarController extends TextField {

private static final String COMMAND_BAR_LAYOUT_FXML = "/main/resources/layouts/CommandBar.fxml";
private Logic logic;

public CommandBarController() {
public CommandBarController(Logic logic) {
FXMLLoader loader = new FXMLLoader(getClass().getResource(COMMAND_BAR_LAYOUT_FXML));
loader.setController(this);
loader.setRoot(this);
Expand All @@ -14,21 +15,22 @@ public class CommandBarController extends TextField {
} catch (IOException e) {
e.printStackTrace();
}
this.logic = logic;
}

public CommandBarController(String text) {
this();
public CommandBarController(String text, Logic logic) {
this(logic);
this.setText(text);
this.selectAll();
}

@FXML
public void onKeyPress(KeyEvent event) {
Logic.handleKeyPress(this, event.getCode(), this.getText());
logic.handleKeyPress(this, event.getCode(), this.getText());
}
}
```
###### MainApp.java
###### main\java\gui\MainApp.java
```java
public class MainApp extends Application {

Expand All @@ -48,10 +50,12 @@ public class MainApp extends Application {
public void start(Stage primaryStage) {
initRootLayout();
initPrimaryStage(primaryStage);

Logic logic = initLogic();

// Add components to RootLayout
addCommandBar();
addOverview();
addCommandBar(logic);
addOverview();
}

/**
Expand All @@ -77,17 +81,21 @@ public class MainApp extends Application {
this.primaryStage.setScene(new Scene(rootLayout));
this.primaryStage.show();
}

private Logic initLogic() {
return new Logic();
}

private void addOverview() {
rootLayout.setCenter(new OverviewLayoutController());
}

private void addCommandBar() {
rootLayout.setBottom(new CommandBarController(COMMAND_BAR_DEFAULT_TEXT));
private void addCommandBar(Logic logic) {
rootLayout.setBottom(new CommandBarController(COMMAND_BAR_DEFAULT_TEXT, logic));
}
}
```
###### OverviewLayoutController.java
###### main\java\gui\OverviewLayoutController.java
```java
public class OverviewLayoutController extends StackPane {
@FXML
Expand Down Expand Up @@ -126,3 +134,31 @@ public class OverviewLayoutController extends StackPane {
}
}
```
###### main\resources\layouts\CommandBar.fxml
```fxml
<fx:root onKeyPressed="#onKeyPress" stylesheets="@../styles/stylesheet.css"
type="TextField" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" />
```
###### main\resources\layouts\Overview.fxml
```fxml
<fx:root type="StackPane" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ListView fx:id="overviewList">
<!-- TODO Add Nodes -->
</ListView>
</children>
</fx:root>
```
###### main\resources\layouts\RootLayout.fxml
```fxml
<BorderPane id="root" prefHeight="500.0" prefWidth="500.0"
stylesheets="@../styles/stylesheet.css" xmlns="http://javafx.com/javafx/8.0.40"
xmlns:fx="http://javafx.com/fxml/1" />
```
###### main\resources\styles\stylesheet.css
```css

#root {
-fx-padding: 10px;
}
```
2 changes: 1 addition & 1 deletion src/main/resources/layouts/CommandBar.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.control.TextField?>


<!-- @author Sebastian Quek -->
<fx:root onKeyPressed="#onKeyPress" stylesheets="@../styles/stylesheet.css"
type="TextField" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" />
1 change: 1 addition & 0 deletions src/main/resources/layouts/Overview.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.ListView?>

<!-- @author Sebastian Quek -->
<fx:root type="StackPane" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ListView fx:id="overviewList">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/layouts/RootLayout.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.BorderPane?>


<!-- @author Sebastian Quek -->
<BorderPane id="root" prefHeight="500.0" prefWidth="500.0"
stylesheets="@../styles/stylesheet.css" xmlns="http://javafx.com/javafx/8.0.40"
xmlns:fx="http://javafx.com/fxml/1" />
2 changes: 2 additions & 0 deletions src/main/resources/styles/stylesheet.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* @author Sebastian Quek */

#root {
-fx-padding: 10px;
}

0 comments on commit fcf9e00

Please sign in to comment.