-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set default text for offerte via settings pane
- Loading branch information
Richard van Heest
authored and
Richard van Heest
committed
Jul 26, 2015
1 parent
adec6e8
commit 1a59662
Showing
7 changed files
with
160 additions
and
4 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
73 changes: 73 additions & 0 deletions
73
...rc/main/java/org/rekeningsysteem/application/settings/offerte/DefaultOfferteTextPane.java
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 org.rekeningsysteem.application.settings.offerte; | ||
|
||
import javafx.event.ActionEvent; | ||
import javafx.geometry.Insets; | ||
import javafx.geometry.Pos; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextArea; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.VBox; | ||
|
||
import org.rekeningsysteem.rxjavafx.Observables; | ||
|
||
import rx.Observable; | ||
|
||
public class DefaultOfferteTextPane extends VBox { | ||
|
||
private final TextArea textTA = new TextArea(); | ||
private final Button saveButton = new Button("Opslaan"); | ||
private final Button cancelButton = new Button("Cancel"); | ||
|
||
private final Observable<String> text = Observables.fromProperty(this.textTA.textProperty()); | ||
private final Observable<ActionEvent> save = Observables.fromNodeEvents(this.saveButton, ActionEvent.ACTION); | ||
private final Observable<ActionEvent> cancel = Observables.fromNodeEvents(this.cancelButton, ActionEvent.ACTION); | ||
|
||
public DefaultOfferteTextPane() { | ||
this.getStyleClass().addAll("working-pane", "page"); | ||
this.setAlignment(Pos.TOP_CENTER); | ||
this.setPadding(new Insets(15)); | ||
this.setSpacing(10); | ||
|
||
Label header = new Label("Standaard offerte tekst"); | ||
header.setId("title"); | ||
|
||
this.textTA.setPrefColumnCount(50); | ||
this.textTA.setPrefRowCount(20); | ||
this.textTA.setWrapText(true); | ||
|
||
this.cancelButton.setId("cancelButton"); | ||
this.cancelButton.setMinWidth(74); | ||
this.cancelButton.setPrefWidth(74); | ||
HBox.setMargin(this.cancelButton, new Insets(0, 8, 0, 0)); | ||
|
||
this.saveButton.setId("addButton"); | ||
this.saveButton.setMinWidth(74); | ||
this.saveButton.setPrefWidth(74); | ||
this.saveButton.setDefaultButton(true); | ||
|
||
HBox buttons = new HBox(0, this.cancelButton, this.saveButton); | ||
buttons.setAlignment(Pos.BASELINE_RIGHT); | ||
VBox.setMargin(buttons, new Insets(10, 5, 5, 5)); | ||
|
||
VBox content = new VBox(this.textTA, buttons); | ||
|
||
this.getChildren().addAll(header, content); | ||
} | ||
|
||
public Observable<String> getText() { | ||
return this.text; | ||
} | ||
|
||
public void setText(String text) { | ||
this.textTA.setText(text); | ||
} | ||
|
||
public Observable<ActionEvent> getSaveButtonEvent() { | ||
return this.save; | ||
} | ||
|
||
public Observable<ActionEvent> getCancelButtonEvent() { | ||
return this.cancel; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...va/org/rekeningsysteem/application/settings/offerte/DefaultOfferteTextPaneController.java
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,47 @@ | ||
package org.rekeningsysteem.application.settings.offerte; | ||
|
||
import java.io.IOException; | ||
|
||
import javafx.event.ActionEvent; | ||
|
||
import org.rekeningsysteem.exception.NoSuchFileException; | ||
import org.rekeningsysteem.logic.offerte.DefaultOfferteTextHandler; | ||
|
||
import rx.Observable; | ||
|
||
public class DefaultOfferteTextPaneController { | ||
|
||
private final DefaultOfferteTextPane ui; | ||
private final DefaultOfferteTextHandler handler = new DefaultOfferteTextHandler(); | ||
|
||
public DefaultOfferteTextPaneController() { | ||
this.ui = new DefaultOfferteTextPane(); | ||
|
||
Observable<String> text = this.ui.getText(); | ||
Observable<ActionEvent> save = this.ui.getSaveButtonEvent(); | ||
Observable<ActionEvent> cancel = this.ui.getCancelButtonEvent(); | ||
|
||
this.ui.setText(this.handler.getDefaultText()); | ||
|
||
text.sample(save) | ||
.subscribe(s -> { | ||
try { | ||
this.handler.setDefaultText(s); | ||
} | ||
catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
catch (NoSuchFileException e) { | ||
e.printStackTrace(); | ||
} | ||
}); | ||
cancel.subscribe(e -> { | ||
String s = this.handler.getDefaultText(); | ||
this.ui.setText(s); | ||
}); | ||
} | ||
|
||
public DefaultOfferteTextPane getUI() { | ||
return this.ui; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...src/main/java/org/rekeningsysteem/application/settings/offerte/DefaultOfferteTextTab.java
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,10 @@ | ||
package org.rekeningsysteem.application.settings.offerte; | ||
|
||
import javafx.scene.control.Tab; | ||
|
||
public class DefaultOfferteTextTab extends Tab { | ||
|
||
public DefaultOfferteTextTab(DefaultOfferteTextPane pane) { | ||
super("Offerte", pane); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ava/org/rekeningsysteem/application/settings/offerte/DefaultOfferteTextTabController.java
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,18 @@ | ||
package org.rekeningsysteem.application.settings.offerte; | ||
|
||
public class DefaultOfferteTextTabController { | ||
|
||
private final DefaultOfferteTextTab ui; | ||
|
||
public DefaultOfferteTextTabController() { | ||
this(new DefaultOfferteTextPaneController()); | ||
} | ||
|
||
public DefaultOfferteTextTabController(DefaultOfferteTextPaneController subController) { | ||
this.ui = new DefaultOfferteTextTab(subController.getUI()); | ||
} | ||
|
||
public DefaultOfferteTextTab getUI() { | ||
return this.ui; | ||
} | ||
} |
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