-
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.
Merge pull request #32 from rvanheest/Bugfixes
Bugfixes and small improvements
- Loading branch information
Showing
14 changed files
with
321 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is a testing text! | ||
Here you can put your name, adres, etc. |
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; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...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,61 @@ | ||
package org.rekeningsysteem.application.settings.offerte; | ||
|
||
import java.io.IOException; | ||
|
||
import javafx.event.ActionEvent; | ||
import javafx.scene.control.Alert; | ||
import javafx.scene.control.ButtonType; | ||
import javafx.scene.control.Alert.AlertType; | ||
import javafx.scene.control.ButtonBar.ButtonData; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.rekeningsysteem.exception.NoSuchFileException; | ||
import org.rekeningsysteem.logging.ApplicationLogger; | ||
import org.rekeningsysteem.logic.offerte.DefaultOfferteTextHandler; | ||
|
||
import rx.Observable; | ||
|
||
public class DefaultOfferteTextPaneController { | ||
|
||
private final DefaultOfferteTextPane ui; | ||
private final DefaultOfferteTextHandler handler = new DefaultOfferteTextHandler(); | ||
|
||
private final Logger logger = ApplicationLogger.getInstance(); | ||
|
||
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) { | ||
this.logger.error("Error while writing default offerte text to file.", e); | ||
} | ||
catch (NoSuchFileException e) { | ||
String alertText = "De tekst kon niet worden opgeslagen. Raadpleeg " | ||
+ "de programmeur om dit probleem op te lossen."; | ||
ButtonType close = new ButtonType("Sluit", ButtonData.CANCEL_CLOSE); | ||
Alert alert = new Alert(AlertType.NONE, alertText, close); | ||
alert.setHeaderText("Fout bij opslaan"); | ||
alert.show(); | ||
this.logger.error(e.getMessage() + "\n" + "De tekst was: \"" + s + "\"\n", e); | ||
} | ||
}); | ||
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
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
10 changes: 10 additions & 0 deletions
10
Rekeningsysteem/src/main/java/org/rekeningsysteem/exception/NoSuchFileException.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.exception; | ||
|
||
public class NoSuchFileException extends Exception { | ||
|
||
private static final long serialVersionUID = -5684032056630170886L; | ||
|
||
public NoSuchFileException(String error) { | ||
super(error); | ||
} | ||
} |
Oops, something went wrong.