Add shortcut for displaying DAO menu item

This commit is contained in:
Manfred Karrer 2017-06-21 20:06:21 +02:00
parent 9166494d69
commit 68501364e9
10 changed files with 58 additions and 41 deletions

View File

@ -78,9 +78,13 @@ public class BisqEnvironment extends StandardEnvironment {
return BaseCurrencyNetwork.LTC_MAINNET;
}
public static boolean isBaseCurrencySupportingBsq() {
public static boolean isDAOActivatedAndBaseCurrencySupportingBsq() {
//noinspection ConstantConditions,PointlessBooleanExpression
return DevEnv.DAO_ACTIVATED && getBaseCurrencyNetwork().getCurrencyCode().equals("LTC");
return DevEnv.DAO_ACTIVATED && isBaseCurrencySupportingBsq();
}
public static boolean isBaseCurrencySupportingBsq() {
return getBaseCurrencyNetwork().getCurrencyCode().equals("LTC");
}
public static NetworkParameters getParameters() {

View File

@ -52,7 +52,7 @@ public class DaoManager {
}
public void onAllServicesInitialized(ErrorMessageHandler errorMessageHandler) {
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq()) {
daoPeriodService.onAllServicesInitialized();
bsqUtxoFeedService.onAllServicesInitialized();
voteManager.onAllServicesInitialized();

View File

@ -43,7 +43,7 @@ public class BsqBlockchainManager {
}
public void addBsqChainStateListener(BsqChainStateListener bsqChainStateListener) {
if (BisqEnvironment.isBaseCurrencySupportingBsq())
if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq())
bsqNode.addBsqChainStateListener(bsqChainStateListener);
}
@ -52,7 +52,7 @@ public class BsqBlockchainManager {
}
public void removeBsqChainStateListener(BsqChainStateListener bsqChainStateListener) {
if (BisqEnvironment.isBaseCurrencySupportingBsq())
if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq())
bsqNode.removeBsqChainStateListener(bsqChainStateListener);
}
}

View File

@ -82,7 +82,7 @@ public class CompensationRequestManager implements PersistedDataHost {
observableList = FXCollections.observableArrayList(model.getList());
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq()) {
p2PService.addHashSetChangedListener(new HashMapChangedListener() {
@Override
public void onAdded(ProtectedStorageEntry data) {
@ -108,7 +108,7 @@ public class CompensationRequestManager implements PersistedDataHost {
@Override
public void readPersisted() {
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq()) {
PersistableList<CompensationRequest> persisted = compensationRequestsStorage.initAndGetPersistedWithFileName("CompensationRequests");
if (persisted != null)
model.setPersistedCompensationRequest(persisted.getList());

View File

@ -93,7 +93,7 @@ public class VotingManager implements PersistedDataHost {
@Override
public void readPersisted() {
if (BisqEnvironment.isBaseCurrencySupportingBsq()) {
if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq()) {
PersistableList<VoteItemsList> persisted = voteItemCollectionsStorage.initAndGetPersistedWithFileName("VoteItemCollections");
if (persisted != null)
voteItemsLists.addAll(persisted.getList());

View File

@ -166,7 +166,7 @@ public class BisqApp extends Application {
Security.addProvider(new BouncyCastleProvider());
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
Res.setBaseCurrencyCode(baseCurrencyNetwork.getCurrencyCode());
Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName());
@ -261,33 +261,31 @@ public class BisqApp extends Application {
stop();
} else if (new KeyCodeCombination(KeyCode.E, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
showEmptyWalletPopup(injector.getInstance(BtcWalletService.class));
} else //noinspection ConstantConditions,ConstantConditions
if (DevEnv.DEV_MODE && new KeyCodeCombination(KeyCode.B, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
// BSQ empty wallet not public yet
showEmptyWalletPopup(injector.getInstance(BsqWalletService.class));
} else if (new KeyCodeCombination(KeyCode.M, KeyCombination.ALT_DOWN).match(keyEvent)) {
showSendAlertMessagePopup();
} else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) {
showFilterPopup();
} else if (new KeyCodeCombination(KeyCode.P, KeyCombination.ALT_DOWN).match(keyEvent)) {
showFPSWindow();
} else if (new KeyCodeCombination(KeyCode.J, KeyCombination.ALT_DOWN).match(keyEvent)) {
WalletsManager walletsManager = injector.getInstance(WalletsManager.class);
if (walletsManager.areWalletsAvailable())
new ShowWalletDataWindow(walletsManager).show();
else
new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show();
} else if (new KeyCodeCombination(KeyCode.G, KeyCombination.ALT_DOWN).match(keyEvent)) {
TradeWalletService tradeWalletService = injector.getInstance(TradeWalletService.class);
BtcWalletService walletService = injector.getInstance(BtcWalletService.class);
if (walletService.isWalletReady())
new SpendFromDepositTxWindow(tradeWalletService).show();
else
new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show();
} else //noinspection ConstantConditions,ConstantConditions
if (DevEnv.DEV_MODE && new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) {
showDebugWindow();
}
} else if (new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
// BSQ empty wallet not public yet
showEmptyWalletPopup(injector.getInstance(BsqWalletService.class));
} else if (new KeyCodeCombination(KeyCode.M, KeyCombination.ALT_DOWN).match(keyEvent)) {
showSendAlertMessagePopup();
} else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) {
showFilterPopup();
} else if (new KeyCodeCombination(KeyCode.J, KeyCombination.ALT_DOWN).match(keyEvent)) {
WalletsManager walletsManager = injector.getInstance(WalletsManager.class);
if (walletsManager.areWalletsAvailable())
new ShowWalletDataWindow(walletsManager).show();
else
new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show();
} else if (new KeyCodeCombination(KeyCode.G, KeyCombination.ALT_DOWN).match(keyEvent)) {
TradeWalletService tradeWalletService = injector.getInstance(TradeWalletService.class);
BtcWalletService walletService = injector.getInstance(BtcWalletService.class);
if (walletService.isWalletReady())
new SpendFromDepositTxWindow(tradeWalletService).show();
else
new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show();
} else if (DevEnv.DEV_MODE && new KeyCodeCombination(KeyCode.P, KeyCombination.ALT_DOWN).match(keyEvent)) {
showFPSWindow();
} else if (DevEnv.DEV_MODE && new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) {
showDebugWindow();
}
});
// configure the primary stage

View File

@ -46,6 +46,10 @@ import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.text.TextAlignment;
@ -126,7 +130,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
@Override
protected void initialize() {
MainView.rootContainer = this.root;
MainView.rootContainer = root;
ToggleButton marketButton = new NavButton(MarketView.class, Res.get("mainView.menu.market"));
ToggleButton buyButton = new NavButton(BuyOfferView.class, Res.get("mainView.menu.buyBtc"));
@ -140,10 +144,21 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
Pane portfolioButtonHolder = new Pane(portfolioButton);
Pane disputesButtonHolder = new Pane(disputesButton);
if (!BisqEnvironment.isBaseCurrencySupportingBsq()) {
if (!BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq()) {
daoButton.setVisible(false);
daoButton.setManaged(false);
}
// TODO can be removed once DAo is released
UserThread.runAfter(() -> {
root.getScene().addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> {
if (new KeyCodeCombination(KeyCode.D, KeyCombination.ALT_DOWN).match(keyEvent)) {
daoButton.setVisible(true);
daoButton.setManaged(true);
}
});
}, 1);
HBox leftNavPane = new HBox(marketButton, buyButton, sellButton, portfolioButtonHolder, fundsButton, disputesButtonHolder) {{
setLeftAnchor(this, 10d);
setTopAnchor(this, 0d);

View File

@ -123,7 +123,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
chainSyncIndicator = new ProgressBar();
chainSyncIndicator.setPrefWidth(120);
if (BisqEnvironment.isBaseCurrencySupportingBsq())
if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq())
chainSyncIndicator.setProgress(-1);
else
chainSyncIndicator.setProgress(0);

View File

@ -944,7 +944,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
makerFeeRowHBox.setSpacing(5);
makerFeeRowHBox.setAlignment(Pos.CENTER_LEFT);
if (BisqEnvironment.isBaseCurrencySupportingBsq())
if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq())
makerFeeRowHBox.getChildren().addAll(makerFeeValueCurrencyBox, payFeeInBtcToggleButtonsHBox);
else
makerFeeRowHBox.getChildren().addAll(makerFeeValueCurrencyBox);

View File

@ -837,7 +837,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
takerFeeRowHBox.setSpacing(5);
takerFeeRowHBox.setAlignment(Pos.CENTER_LEFT);
if (BisqEnvironment.isBaseCurrencySupportingBsq())
if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq())
takerFeeRowHBox.getChildren().addAll(makerFeeValueCurrencyBox, payFeeInBtcToggleButtonsHBox);
else
takerFeeRowHBox.getChildren().addAll(makerFeeValueCurrencyBox);