More tweaking of PropertiesPane.
This commit is contained in:
parent
4c69cd1662
commit
8539ddec70
|
@ -12,9 +12,7 @@ import javafx.beans.property.BooleanProperty;
|
|||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
|
@ -87,15 +85,14 @@ public class AccountViewController implements RouteSelectionListener {
|
|||
|
||||
@FXML
|
||||
public void archiveAccount() {
|
||||
var confirmResult = new Alert(
|
||||
Alert.AlertType.CONFIRMATION,
|
||||
boolean confirmResult = Popups.confirm(
|
||||
"Are you sure you want to archive this account? It will no " +
|
||||
"longer show up in the app normally, and you won't be " +
|
||||
"able to add new transactions to it. You'll still be " +
|
||||
"able to view the account, and you can un-archive it " +
|
||||
"later if you need to."
|
||||
).showAndWait();
|
||||
if (confirmResult.isPresent() && confirmResult.get() == ButtonType.OK) {
|
||||
);
|
||||
if (confirmResult) {
|
||||
Profile.getCurrent().getDataSource().useAccountRepository(repo -> repo.archive(account.id));
|
||||
router.getHistory().clear();
|
||||
router.navigate("accounts");
|
||||
|
@ -103,20 +100,27 @@ public class AccountViewController implements RouteSelectionListener {
|
|||
}
|
||||
|
||||
@FXML public void unarchiveAccount() {
|
||||
System.out.println("Unarchiving");
|
||||
boolean confirm = Popups.confirm(
|
||||
"Are you sure you want to restore this account from its archived " +
|
||||
"status?"
|
||||
);
|
||||
if (confirm) {
|
||||
Profile.getCurrent().getDataSource().useAccountRepository(repo -> repo.unarchive(account.id));
|
||||
router.getHistory().clear();
|
||||
router.navigate("accounts");
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void deleteAccount() {
|
||||
var confirmResult = new Alert(
|
||||
Alert.AlertType.CONFIRMATION,
|
||||
boolean confirm = Popups.confirm(
|
||||
"Are you sure you want to permanently delete this account and " +
|
||||
"all data directly associated with it? This cannot be " +
|
||||
"undone; deleted accounts are not recoverable at all. " +
|
||||
"Consider archiving this account instead if you just " +
|
||||
"want to hide it."
|
||||
).showAndWait();
|
||||
if (confirmResult.isPresent() && confirmResult.get() == ButtonType.OK) {
|
||||
);
|
||||
if (confirm) {
|
||||
Profile.getCurrent().getDataSource().useAccountRepository(repo -> repo.delete(account));
|
||||
router.getHistory().clear();
|
||||
router.navigate("accounts");
|
||||
|
|
|
@ -13,19 +13,21 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* A specially-formatted {@link GridPane} that arranges its children into a
|
||||
* two-column grid representing key-value pairs.
|
||||
* two-column grid representing key-value pairs. It will use a default set of
|
||||
* {@link ColumnConstraints} unless they are already defined by the user.
|
||||
*/
|
||||
public class PropertiesPane extends GridPane {
|
||||
private final ColumnConstraints defaultKeyColumnConstraints;
|
||||
private final ColumnConstraints defaultValueColumnConstraints;
|
||||
private boolean columnConstraintsSet = false;
|
||||
|
||||
public PropertiesPane() {
|
||||
ColumnConstraints keyConstraints = new ColumnConstraints();
|
||||
keyConstraints.setHgrow(Priority.NEVER);
|
||||
keyConstraints.setHalignment(HPos.LEFT);
|
||||
keyConstraints.setMinWidth(10.0);
|
||||
ColumnConstraints valueConstraints = new ColumnConstraints();
|
||||
valueConstraints.setHgrow(Priority.ALWAYS);
|
||||
valueConstraints.setHalignment(HPos.LEFT);
|
||||
valueConstraints.setMinWidth(10.0);
|
||||
getColumnConstraints().setAll(keyConstraints, valueConstraints);
|
||||
defaultKeyColumnConstraints = new ColumnConstraints();
|
||||
defaultKeyColumnConstraints.setHgrow(Priority.NEVER);
|
||||
defaultKeyColumnConstraints.setHalignment(HPos.LEFT);
|
||||
defaultValueColumnConstraints = new ColumnConstraints();
|
||||
defaultValueColumnConstraints.setHgrow(Priority.ALWAYS);
|
||||
defaultValueColumnConstraints.setHalignment(HPos.LEFT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,6 +36,17 @@ public class PropertiesPane extends GridPane {
|
|||
// key 1 value 1
|
||||
// key 2 value 2
|
||||
// ... and so on.
|
||||
|
||||
// Set column restraints if they weren't set already.
|
||||
if (!columnConstraintsSet) {
|
||||
if (getColumnConstraints().isEmpty()) {
|
||||
// No preexisting constraints, so we set our defaults.
|
||||
getColumnConstraints().setAll(defaultKeyColumnConstraints, defaultValueColumnConstraints);
|
||||
}
|
||||
columnConstraintsSet = true;
|
||||
}
|
||||
|
||||
// Set row constraints for each row.
|
||||
int rowCount = getManagedChildren().size() / 2;
|
||||
List<RowConstraints> rows = new ArrayList<>(rowCount);
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
|
@ -43,6 +56,8 @@ public class PropertiesPane extends GridPane {
|
|||
rows.add(c);
|
||||
}
|
||||
getRowConstraints().setAll(rows);
|
||||
|
||||
// Set child row and column indices.
|
||||
for (int i = 0; i < getManagedChildren().size(); i++) {
|
||||
Node child = getManagedChildren().get(i);
|
||||
int column = i % 2;
|
||||
|
@ -50,6 +65,7 @@ public class PropertiesPane extends GridPane {
|
|||
GridPane.setRowIndex(child, row);
|
||||
GridPane.setColumnIndex(child, column);
|
||||
}
|
||||
|
||||
super.layoutChildren();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,9 +43,6 @@
|
|||
</VBox>
|
||||
<Label fx:id="accountBalanceLabel" styleClass="mono-font"/>
|
||||
</PropertiesPane>
|
||||
<VBox HBox.hgrow="SOMETIMES">
|
||||
<Label text="Panel 2"/>
|
||||
</VBox>
|
||||
</FlowPane>
|
||||
</VBox>
|
||||
</center>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.text.TextFlow?>
|
||||
<?import com.andrewlalis.perfin.view.component.PropertiesPane?>
|
||||
<BorderPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="com.andrewlalis.perfin.control.TransactionViewController"
|
||||
|
@ -16,19 +17,20 @@
|
|||
<center>
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true">
|
||||
<VBox styleClass="std-padding,std-spacing">
|
||||
<VBox>
|
||||
<Label text="Amount" styleClass="bold-text"/>
|
||||
<PropertiesPane vgap="5" hgap="5">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints minWidth="100" halignment="LEFT" hgrow="NEVER"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" halignment="LEFT"/>
|
||||
</columnConstraints>
|
||||
<Label text="Amount" styleClass="bold-text" style="-fx-min-width: 100px;"/>
|
||||
<Label fx:id="amountLabel" styleClass="mono-font"/>
|
||||
</VBox>
|
||||
<VBox>
|
||||
|
||||
<Label text="Timestamp" styleClass="bold-text"/>
|
||||
<Label fx:id="timestampLabel" styleClass="mono-font"/>
|
||||
</VBox>
|
||||
<VBox>
|
||||
|
||||
<Label text="Description" styleClass="bold-text"/>
|
||||
<Label fx:id="descriptionLabel" wrapText="true" style="-fx-min-height: 100px;" alignment="TOP_LEFT"/>
|
||||
</VBox>
|
||||
<Separator/>
|
||||
</PropertiesPane>
|
||||
<VBox>
|
||||
<TextFlow>
|
||||
<Text text="Debited to"/>
|
||||
|
@ -39,7 +41,6 @@
|
|||
<Hyperlink fx:id="creditAccountLink"/>
|
||||
</TextFlow>
|
||||
</VBox>
|
||||
<Separator/>
|
||||
<VBox fx:id="attachmentsContainer">
|
||||
<Label text="Attachments" styleClass="bold-text"/>
|
||||
<ScrollPane fitToWidth="true" fitToHeight="true">
|
||||
|
|
Loading…
Reference in New Issue