Craig Raw
5 years ago
18 changed files with 417 additions and 9 deletions
@ -1 +1 @@ |
|||||
Subproject commit 0cebee3d22740d0ab38657b1deaba67fe282f920 |
Subproject commit 08e8df0807a01b2716ac80e9d6d9e2c113025848 |
@ -0,0 +1,14 @@ |
|||||
|
package com.sparrowwallet.sparrow.control; |
||||
|
|
||||
|
import javafx.beans.NamedArg; |
||||
|
import javafx.scene.control.ChoiceBox; |
||||
|
|
||||
|
public class EnumChoiceBox<E extends Enum<E>> extends ChoiceBox<E> { |
||||
|
|
||||
|
public EnumChoiceBox(@NamedArg("enumType") String enumType) throws Exception { |
||||
|
Class<E> enumClass = (Class<E>) Class.forName(enumType); |
||||
|
getItems().setAll(enumClass.getEnumConstants()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
@ -0,0 +1,5 @@ |
|||||
|
package com.sparrowwallet.sparrow.wallet; |
||||
|
|
||||
|
public enum Function { |
||||
|
TRANSACTIONS, SEND, RECEIVE, ADDRESSES, POLICIES, SETTINGS; |
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
package com.sparrowwallet.sparrow.wallet; |
||||
|
|
||||
|
import com.sparrowwallet.drongo.policy.PolicyType; |
||||
|
import com.sparrowwallet.drongo.protocol.ScriptType; |
||||
|
import com.sparrowwallet.sparrow.EventManager; |
||||
|
import com.sparrowwallet.sparrow.control.CopyableLabel; |
||||
|
import javafx.fxml.FXML; |
||||
|
import javafx.fxml.Initializable; |
||||
|
import javafx.scene.control.*; |
||||
|
import org.controlsfx.control.RangeSlider; |
||||
|
import tornadofx.control.Fieldset; |
||||
|
|
||||
|
import java.net.URL; |
||||
|
import java.util.ResourceBundle; |
||||
|
|
||||
|
public class SettingsController extends WalletFormController implements Initializable { |
||||
|
|
||||
|
@FXML |
||||
|
private ComboBox<PolicyType> policyType; |
||||
|
|
||||
|
@FXML |
||||
|
private TextField policy; |
||||
|
|
||||
|
@FXML |
||||
|
private ComboBox<ScriptType> scriptType; |
||||
|
|
||||
|
@FXML |
||||
|
private Fieldset multisigFieldset; |
||||
|
|
||||
|
@FXML |
||||
|
private RangeSlider multisigControl; |
||||
|
|
||||
|
@FXML |
||||
|
private CopyableLabel multisigLowLabel; |
||||
|
|
||||
|
@FXML |
||||
|
private CopyableLabel multisigHighLabel; |
||||
|
|
||||
|
@FXML |
||||
|
private TabPane keystoreTabs; |
||||
|
|
||||
|
@FXML ComboBox testType; |
||||
|
|
||||
|
@Override |
||||
|
public void initialize(URL location, ResourceBundle resources) { |
||||
|
EventManager.get().register(this); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void initializeView() { |
||||
|
policyType.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, policyType) -> { |
||||
|
scriptType.getSelectionModel().select(policyType.getDefaultScriptType()); |
||||
|
multisigFieldset.setVisible(policyType.equals(PolicyType.MULTI)); |
||||
|
}); |
||||
|
|
||||
|
multisigLowLabel.textProperty().bind(multisigControl.lowValueProperty().asString("%.0f") ); |
||||
|
multisigHighLabel.textProperty().bind(multisigControl.highValueProperty().asString("%.0f")); |
||||
|
|
||||
|
multisigFieldset.managedProperty().bind(multisigFieldset.visibleProperty()); |
||||
|
|
||||
|
if(walletForm.getWallet().getPolicyType() != null) { |
||||
|
policyType.getSelectionModel().select(walletForm.getWallet().getPolicyType()); |
||||
|
} else { |
||||
|
policyType.getSelectionModel().select(0); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,61 @@ |
|||||
|
package com.sparrowwallet.sparrow.wallet; |
||||
|
|
||||
|
import com.sparrowwallet.drongo.wallet.Wallet; |
||||
|
import com.sparrowwallet.sparrow.AppController; |
||||
|
import com.sparrowwallet.sparrow.EventManager; |
||||
|
import javafx.fxml.FXML; |
||||
|
import javafx.fxml.FXMLLoader; |
||||
|
import javafx.fxml.Initializable; |
||||
|
import javafx.scene.Node; |
||||
|
import javafx.scene.control.ToggleGroup; |
||||
|
import javafx.scene.layout.BorderPane; |
||||
|
import javafx.scene.layout.StackPane; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.net.URL; |
||||
|
import java.util.ResourceBundle; |
||||
|
|
||||
|
public class WalletController extends WalletFormController implements Initializable { |
||||
|
@FXML |
||||
|
private BorderPane tabContent; |
||||
|
|
||||
|
@FXML |
||||
|
private StackPane walletPane; |
||||
|
|
||||
|
@FXML |
||||
|
private ToggleGroup walletMenu; |
||||
|
|
||||
|
@Override |
||||
|
public void initialize(URL location, ResourceBundle resources) { |
||||
|
EventManager.get().register(this); |
||||
|
} |
||||
|
|
||||
|
public void initializeView() { |
||||
|
walletMenu.selectedToggleProperty().addListener((observable, oldValue, selectedToggle) -> { |
||||
|
Function function = (Function)selectedToggle.getUserData(); |
||||
|
|
||||
|
boolean existing = false; |
||||
|
for(Node walletFunction : walletPane.getChildren()) { |
||||
|
if(walletFunction.getUserData().equals(function)) { |
||||
|
existing = true; |
||||
|
walletFunction.setViewOrder(1); |
||||
|
} else { |
||||
|
walletFunction.setViewOrder(0); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
if(!existing) { |
||||
|
FXMLLoader functionLoader = new FXMLLoader(AppController.class.getResource("wallet/" + function.toString().toLowerCase() + ".fxml")); |
||||
|
Node walletFunction = functionLoader.load(); |
||||
|
WalletFormController controller = functionLoader.getController(); |
||||
|
controller.setWalletForm(getWalletForm()); |
||||
|
walletFunction.setViewOrder(1); |
||||
|
walletPane.getChildren().add(walletFunction); |
||||
|
} |
||||
|
} catch (IOException e) { |
||||
|
throw new IllegalStateException("Can't find pane", e); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.sparrowwallet.sparrow.wallet; |
||||
|
|
||||
|
import com.sparrowwallet.drongo.wallet.Wallet; |
||||
|
|
||||
|
public class WalletForm { |
||||
|
private Wallet wallet; |
||||
|
|
||||
|
public WalletForm(Wallet wallet) { |
||||
|
this.wallet = wallet; |
||||
|
} |
||||
|
|
||||
|
public Wallet getWallet() { |
||||
|
return wallet; |
||||
|
} |
||||
|
|
||||
|
public void setWallet(Wallet wallet) { |
||||
|
this.wallet = wallet; |
||||
|
} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.sparrowwallet.sparrow.wallet; |
||||
|
|
||||
|
public abstract class WalletFormController { |
||||
|
public WalletForm walletForm; |
||||
|
|
||||
|
public WalletForm getWalletForm() { |
||||
|
return walletForm; |
||||
|
} |
||||
|
|
||||
|
public void setWalletForm(WalletForm walletForm) { |
||||
|
this.walletForm = walletForm; |
||||
|
initializeView(); |
||||
|
} |
||||
|
|
||||
|
public abstract void initializeView(); |
||||
|
} |
After Width: | Height: | Size: 2.7 KiB |
@ -0,0 +1,11 @@ |
|||||
|
.form .fieldset:horizontal .field { |
||||
|
-fx-pref-height: 40px; |
||||
|
} |
||||
|
|
||||
|
.form .fieldset:horizontal .label-container { |
||||
|
-fx-alignment: center-left; |
||||
|
} |
||||
|
|
||||
|
.form .fieldset:horizontal .input-container { |
||||
|
-fx-alignment: center-left; |
||||
|
} |
@ -0,0 +1,82 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
|
||||
|
<?import javafx.collections.*?> |
||||
|
<?import javafx.geometry.*?> |
||||
|
<?import javafx.scene.control.*?> |
||||
|
<?import javafx.scene.layout.*?> |
||||
|
<?import tornadofx.control.*?> |
||||
|
<?import org.controlsfx.control.RangeSlider?> |
||||
|
<?import com.sparrowwallet.sparrow.control.CopyableLabel?> |
||||
|
<?import com.sparrowwallet.drongo.policy.PolicyType?> |
||||
|
<?import com.sparrowwallet.drongo.protocol.ScriptType?> |
||||
|
|
||||
|
<GridPane hgap="10.0" vgap="10.0" stylesheets="@settings.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.wallet.SettingsController"> |
||||
|
<padding> |
||||
|
<Insets left="25.0" right="25.0" top="25.0" /> |
||||
|
</padding> |
||||
|
<columnConstraints> |
||||
|
<ColumnConstraints percentWidth="50" /> |
||||
|
<ColumnConstraints percentWidth="50" /> |
||||
|
</columnConstraints> |
||||
|
<rowConstraints> |
||||
|
<RowConstraints /> |
||||
|
<RowConstraints /> |
||||
|
</rowConstraints> |
||||
|
|
||||
|
<Form GridPane.columnIndex="0" GridPane.rowIndex="0"> |
||||
|
<Fieldset inputGrow="SOMETIMES" text="Settings"> |
||||
|
<Field text="Policy Type:"> |
||||
|
<ComboBox fx:id="policyType"> |
||||
|
<items> |
||||
|
<FXCollections fx:factory="observableArrayList"> |
||||
|
<PolicyType fx:constant="SINGLE" /> |
||||
|
<PolicyType fx:constant="MULTI" /> |
||||
|
<PolicyType fx:constant="CUSTOM" /> |
||||
|
</FXCollections> |
||||
|
</items> |
||||
|
</ComboBox> |
||||
|
|
||||
|
</Field> |
||||
|
<Field text="Script Type:"> |
||||
|
<ComboBox fx:id="scriptType"> |
||||
|
<items> |
||||
|
<FXCollections fx:factory="observableArrayList"> |
||||
|
<ScriptType fx:constant="P2PK" /> |
||||
|
<ScriptType fx:constant="P2PKH" /> |
||||
|
<ScriptType fx:constant="P2SH" /> |
||||
|
<ScriptType fx:constant="P2SH_P2WPKH" /> |
||||
|
<ScriptType fx:constant="P2SH_P2WSH" /> |
||||
|
<ScriptType fx:constant="P2WPKH" /> |
||||
|
<ScriptType fx:constant="P2WSH" /> |
||||
|
</FXCollections> |
||||
|
</items> |
||||
|
</ComboBox> |
||||
|
</Field> |
||||
|
</Fieldset> |
||||
|
</Form> |
||||
|
|
||||
|
<Form GridPane.columnIndex="1" GridPane.rowIndex="0"> |
||||
|
<Fieldset inputGrow="SOMETIMES" text="" fx:id="multisigFieldset"> |
||||
|
<Field text="Cosigners:"> |
||||
|
<RangeSlider fx:id="multisigControl" showTickMarks="true" showTickLabels="true" blockIncrement="1" min="2" max="10" lowValue="2" highValue="3" snapToTicks="true" majorTickUnit="1" minorTickCount="0" /> |
||||
|
</Field> |
||||
|
<Field text="M of N:"> |
||||
|
<CopyableLabel fx:id="multisigLowLabel" /> |
||||
|
<CopyableLabel text="/"/> |
||||
|
<CopyableLabel fx:id="multisigHighLabel" /> |
||||
|
</Field> |
||||
|
</Fieldset> |
||||
|
</Form> |
||||
|
|
||||
|
<Form GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="1"> |
||||
|
<Fieldset inputGrow="SOMETIMES" text="Default Policy"> |
||||
|
<Field text="Policy:"> |
||||
|
<TextField fx:id="policy" /> |
||||
|
</Field> |
||||
|
</Fieldset> |
||||
|
</Form> |
||||
|
|
||||
|
<TabPane fx:id="keystoreTabs" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="2"> |
||||
|
|
||||
|
</TabPane> |
||||
|
</GridPane> |
@ -0,0 +1,21 @@ |
|||||
|
.list-menu { |
||||
|
-fx-pref-width: 180; |
||||
|
-fx-background-color: #3da0e3; |
||||
|
} |
||||
|
|
||||
|
.list-item { |
||||
|
-fx-pref-width: 180; |
||||
|
-fx-background-color: #3da0e3; |
||||
|
} |
||||
|
|
||||
|
.list-item * { |
||||
|
-fx-fill: #fff; |
||||
|
} |
||||
|
|
||||
|
.list-item:hover { |
||||
|
-fx-background-color: #4aa7e5; |
||||
|
} |
||||
|
|
||||
|
.list-item:selected { |
||||
|
-fx-background-color: #1e88cf; |
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
|
||||
|
<?import java.lang.*?> |
||||
|
<?import java.util.*?> |
||||
|
<?import javafx.scene.*?> |
||||
|
<?import javafx.scene.control.*?> |
||||
|
<?import javafx.scene.layout.*?> |
||||
|
<?import org.controlsfx.glyphfont.Glyph?> |
||||
|
<?import com.sparrowwallet.sparrow.wallet.Function?> |
||||
|
|
||||
|
<BorderPane fx:id="tabContent" stylesheets="@wallet.css, @../general.css" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.sparrowwallet.sparrow.wallet.WalletController"> |
||||
|
<left> |
||||
|
<VBox styleClass="list-menu"> |
||||
|
<ToggleButton VBox.vgrow="ALWAYS" text="Transactions" contentDisplay="TOP" styleClass="list-item" maxHeight="Infinity"> |
||||
|
<toggleGroup> |
||||
|
<ToggleGroup fx:id="walletMenu" /> |
||||
|
</toggleGroup> |
||||
|
<graphic> |
||||
|
<Glyph fontFamily="FontAwesome" icon="BTC" /> |
||||
|
</graphic> |
||||
|
<userData> |
||||
|
<Function fx:constant="TRANSACTIONS"/> |
||||
|
</userData> |
||||
|
</ToggleButton> |
||||
|
<ToggleButton VBox.vgrow="ALWAYS" text="Send" contentDisplay="TOP" styleClass="list-item" maxHeight="Infinity" toggleGroup="$walletMenu"> |
||||
|
<graphic> |
||||
|
<Glyph fontFamily="FontAwesome" icon="SEND" /> |
||||
|
</graphic> |
||||
|
<userData> |
||||
|
<Function fx:constant="SEND"/> |
||||
|
</userData> |
||||
|
</ToggleButton> |
||||
|
<ToggleButton VBox.vgrow="ALWAYS" text="Receive" contentDisplay="TOP" styleClass="list-item" maxHeight="Infinity" toggleGroup="$walletMenu"> |
||||
|
<graphic> |
||||
|
<Glyph fontFamily="FontAwesome" icon="ARROW_DOWN" /> |
||||
|
</graphic> |
||||
|
<userData> |
||||
|
<Function fx:constant="RECEIVE"/> |
||||
|
</userData> |
||||
|
</ToggleButton> |
||||
|
<ToggleButton VBox.vgrow="ALWAYS" text="Addresses" contentDisplay="TOP" styleClass="list-item" maxHeight="Infinity" toggleGroup="$walletMenu"> |
||||
|
<graphic> |
||||
|
<Glyph fontFamily="FontAwesome" icon="TH_LIST" /> |
||||
|
</graphic> |
||||
|
<userData> |
||||
|
<Function fx:constant="ADDRESSES"/> |
||||
|
</userData> |
||||
|
</ToggleButton> |
||||
|
<ToggleButton VBox.vgrow="ALWAYS" text="Policies" contentDisplay="TOP" styleClass="list-item" maxHeight="Infinity" toggleGroup="$walletMenu"> |
||||
|
<graphic> |
||||
|
<Glyph fontFamily="FontAwesome" icon="FILE_TEXT_ALT" /> |
||||
|
</graphic> |
||||
|
<userData> |
||||
|
<Function fx:constant="POLICIES"/> |
||||
|
</userData> |
||||
|
</ToggleButton> |
||||
|
<ToggleButton VBox.vgrow="ALWAYS" text="Settings" contentDisplay="TOP" styleClass="list-item" maxHeight="Infinity" toggleGroup="$walletMenu"> |
||||
|
<graphic> |
||||
|
<Glyph fontFamily="FontAwesome" icon="COG" /> |
||||
|
</graphic> |
||||
|
<userData> |
||||
|
<Function fx:constant="SETTINGS"/> |
||||
|
</userData> |
||||
|
</ToggleButton> |
||||
|
</VBox> |
||||
|
</left> |
||||
|
<center> |
||||
|
<StackPane fx:id="walletPane"> |
||||
|
|
||||
|
</StackPane> |
||||
|
</center> |
||||
|
</BorderPane> |
Loading…
Reference in new issue