Improve Layout, add open data dir button

This commit is contained in:
Manfred Karrer 2016-03-31 18:32:55 +02:00
parent 75edc3e17e
commit 97ccd6ad99
6 changed files with 34 additions and 24 deletions

View File

@ -164,7 +164,7 @@ public class AltCoinAccountsView extends ActivatableViewAndModel<GridPane, AltCo
///////////////////////////////////////////////////////////////////////////////////////////
private void buildForm() {
addTitledGroupBg(root, gridRow, 2, "Manage accounts");
addTitledGroupBg(root, gridRow, 1, "Manage accounts");
Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, "Your cryptocurrency accounts:", Layout.FIRST_ROW_DISTANCE);
GridPane.setValignment(tuple.first, VPos.TOP);
@ -200,7 +200,7 @@ public class AltCoinAccountsView extends ActivatableViewAndModel<GridPane, AltCo
}
});
addAccountButton = addButton(root, ++gridRow, "Add new account");
addAccountButton = addButtonAfterGroup(root, ++gridRow, "Add new account");
addAccountButton.setOnAction(event -> addNewAccount());
}

View File

@ -128,7 +128,7 @@ public class ArbitratorSelectionView extends ActivatableViewAndModel<GridPane, A
///////////////////////////////////////////////////////////////////////////////////////////
private void addLanguageGroup() {
addTitledGroupBg(root, gridRow, 2, "Which languages do you speak?");
addTitledGroupBg(root, gridRow, 1, "Which languages do you speak?");
Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, "Your languages:", Layout.FIRST_ROW_DISTANCE);
GridPane.setValignment(tuple.first, VPos.TOP);
@ -165,7 +165,7 @@ public class ArbitratorSelectionView extends ActivatableViewAndModel<GridPane, A
}
});
languageComboBox = addLabelComboBox(root, ++gridRow).second;
languageComboBox = addLabelComboBox(root, ++gridRow, "", 15).second;
languageComboBox.setPromptText("Add language");
languageComboBox.setConverter(new StringConverter<String>() {
@Override

View File

@ -18,13 +18,15 @@
package io.bitsquare.gui.main.account.content.backup;
import io.bitsquare.app.BitsquareEnvironment;
import io.bitsquare.common.util.Tuple3;
import io.bitsquare.common.util.Utilities;
import io.bitsquare.gui.common.view.ActivatableView;
import io.bitsquare.gui.common.view.FxmlView;
import io.bitsquare.gui.main.overlays.popups.Popup;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.Layout;
import io.bitsquare.user.Preferences;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.DirectoryChooser;
@ -44,13 +46,13 @@ import static io.bitsquare.gui.util.FormBuilder.*;
public class BackupView extends ActivatableView<GridPane, Void> {
private final File dataDir;
private int gridRow = 0;
private final Stage stage;
private final Preferences preferences;
private final BitsquareEnvironment environment;
private final BSFormatter formatter;
private Button selectBackupDir, backupNow;
private TextField backUpLocationTextField;
private Button openDataDir;
///////////////////////////////////////////////////////////////////////////////////////////
@ -58,24 +60,25 @@ public class BackupView extends ActivatableView<GridPane, Void> {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private BackupView(Stage stage, Preferences preferences, BitsquareEnvironment environment, BSFormatter formatter) {
private BackupView(Stage stage, Preferences preferences, BitsquareEnvironment environment) {
super();
this.stage = stage;
this.preferences = preferences;
this.environment = environment;
this.formatter = formatter;
dataDir = new File(environment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY));
}
@Override
public void initialize() {
addTitledGroupBg(root, gridRow, 3, "Backup wallet and data");
backUpLocationTextField = addLabelTextField(root, gridRow, "Backup location:", "", Layout.FIRST_ROW_DISTANCE).second;
addTitledGroupBg(root, gridRow, 2, "Backup wallet and data directory");
Tuple3<Label, TextField, Button> tuple = addLabelTextFieldButton(root, gridRow, "Backup location:", "Select backup location", Layout.FIRST_ROW_DISTANCE);
backUpLocationTextField = tuple.second;
if (preferences.getBackupDirectory() != null)
backUpLocationTextField.setText(preferences.getBackupDirectory());
selectBackupDir = addButton(root, ++gridRow, "Select backup location");
selectBackupDir.setDefaultButton(preferences.getBackupDirectory() == null);
backupNow = addButton(root, ++gridRow, "Backup now (backup is not encrypted!)");
selectBackupDir = tuple.third;
openDataDir = addLabelButton(root, ++gridRow, "Application data directory:", "Open directory", 0).second;
openDataDir.setDefaultButton(false);
backupNow = addButtonAfterGroup(root, ++gridRow, "Backup now (backup is not encrypted!)");
backupNow.setDisable(preferences.getBackupDirectory() == null || preferences.getBackupDirectory().length() == 0);
backupNow.setDefaultButton(preferences.getBackupDirectory() != null);
}
@ -95,14 +98,21 @@ public class BackupView extends ActivatableView<GridPane, Void> {
selectBackupDir.setDefaultButton(false);
}
});
openDataDir.setOnAction(e -> {
try {
Utilities.openDirectory(dataDir);
} catch (IOException e1) {
log.error(e1.getMessage());
new Popup().warning("Cannot open directory.\nError =" + e1.getMessage()).show();
}
});
backupNow.setOnAction(e -> {
String backupDirectory = preferences.getBackupDirectory();
if (backupDirectory.length() > 0) {
try {
String dateString = new SimpleDateFormat("YYYY-MM-dd-HHmmss").format(new Date());
String destination = Paths.get(backupDirectory, "bitsquare_backup_" + dateString).toString();
FileUtils.copyDirectory(new File(environment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY)),
FileUtils.copyDirectory(dataDir,
new File(destination));
new Popup().feedback("Backup successfully saved at:\n" + destination).show();
} catch (IOException e1) {

View File

@ -167,7 +167,7 @@ public class FiatAccountsView extends ActivatableViewAndModel<GridPane, FiatAcco
///////////////////////////////////////////////////////////////////////////////////////////
private void buildForm() {
addTitledGroupBg(root, gridRow, 2, "Manage accounts");
addTitledGroupBg(root, gridRow, 1, "Manage accounts");
Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, "Your national currency\naccounts:", Layout.FIRST_ROW_DISTANCE);
GridPane.setValignment(tuple.first, VPos.TOP);
@ -204,7 +204,7 @@ public class FiatAccountsView extends ActivatableViewAndModel<GridPane, FiatAcco
}
});
addAccountButton = addButton(root, ++gridRow, "Add new account");
addAccountButton = addButtonAfterGroup(root, ++gridRow, "Add new account");
addAccountButton.setOnAction(event -> addNewAccount());
}

View File

@ -72,7 +72,7 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
@Override
public void initialize() {
headline = addTitledGroupBg(root, gridRow, 3, "");
headline = addTitledGroupBg(root, gridRow, 2, "");
passwordField = addLabelPasswordTextField(root, gridRow, "Enter password:", Layout.FIRST_ROW_DISTANCE).second;
passwordField.setValidator(passwordValidator);
passwordFieldChangeListener = (observable, oldValue, newValue) -> validatePasswords();
@ -83,7 +83,7 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
repeatedPasswordField.setValidator(passwordValidator);
repeatedPasswordFieldChangeListener = (observable, oldValue, newValue) -> validatePasswords();
Tuple3<Button, ProgressIndicator, Label> tuple = addButtonWithStatus(root, ++gridRow, "", 0);
Tuple3<Button, ProgressIndicator, Label> tuple = addButtonWithStatus(root, ++gridRow, "", 15);
pwButton = tuple.first;
ProgressIndicator progressIndicator = tuple.second;
progressIndicator.setVisible(false);

View File

@ -94,11 +94,11 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
datePicker = addLabelDatePicker(root, ++gridRow, "Creation Date:").second;
datePicker.setMouseTransparent(true);
addTitledGroupBg(root, ++gridRow, 3, "Restore your wallet seed words", Layout.GROUP_DISTANCE);
addTitledGroupBg(root, ++gridRow, 2, "Restore your wallet seed words", Layout.GROUP_DISTANCE);
restorSeedWordsTextArea = addLabelTextArea(root, gridRow, "Wallet seed words:", "", Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
restorSeedWordsTextArea.setPrefHeight(60);
restoreDatePicker = addLabelDatePicker(root, ++gridRow, "Creation Date:").second;
restoreButton = addButton(root, ++gridRow, "Restore wallet");
restoreButton = addButtonAfterGroup(root, ++gridRow, "Restore wallet");
addTitledGroupBg(root, ++gridRow, 1, "Information", Layout.GROUP_DISTANCE);
addMultilineLabel(root, gridRow, "Please write down you wallet seed words and the creation date.\n" +